cleanup ichat mode code. No need of timeout. Fixes #1213
This commit is contained in:
parent
fcf31413dc
commit
111ea2c9b6
|
@ -164,7 +164,6 @@ class ChatControlBase(MessageControl):
|
||||||
'words feature will not be used')).get_response()
|
'words feature will not be used')).get_response()
|
||||||
gajim.config.set('use_speller', False)
|
gajim.config.set('use_speller', False)
|
||||||
|
|
||||||
self.print_time_timeout_id = None
|
|
||||||
self.style_event_id = 0
|
self.style_event_id = 0
|
||||||
|
|
||||||
def _on_send_button_clicked(self, widget):
|
def _on_send_button_clicked(self, widget):
|
||||||
|
@ -533,25 +532,6 @@ class ChatControlBase(MessageControl):
|
||||||
start, end = buffer.get_bounds()
|
start, end = buffer.get_bounds()
|
||||||
buffer.delete(start, end)
|
buffer.delete(start, end)
|
||||||
|
|
||||||
def print_time_timeout(self, arg):
|
|
||||||
if gajim.config.get('print_time') == 'sometimes':
|
|
||||||
conv_textview = self.conv_textview
|
|
||||||
buffer = conv_textview.get_buffer()
|
|
||||||
end_iter = buffer.get_end_iter()
|
|
||||||
tim = time.localtime()
|
|
||||||
tim_format = time.strftime('%H:%M', tim).decode(
|
|
||||||
locale.getpreferredencoding())
|
|
||||||
buffer.insert_with_tags_by_name(end_iter, '\n' + tim_format,
|
|
||||||
'time_sometimes')
|
|
||||||
# scroll to the end of the textview
|
|
||||||
if conv_textview.at_the_end():
|
|
||||||
# we are at the end
|
|
||||||
conv_textview.scroll_to_end()
|
|
||||||
return True # loop again
|
|
||||||
if self.print_time_timeout_id:
|
|
||||||
self.print_time_timeout_id = None
|
|
||||||
return False
|
|
||||||
|
|
||||||
def _on_history_menuitem_activate(self, widget = None, jid = None):
|
def _on_history_menuitem_activate(self, widget = None, jid = None):
|
||||||
'''When history menuitem is pressed: call history window'''
|
'''When history menuitem is pressed: call history window'''
|
||||||
if not jid:
|
if not jid:
|
||||||
|
@ -1304,9 +1284,6 @@ class ChatControl(ChatControlBase):
|
||||||
# Disconnect timer callbacks
|
# Disconnect timer callbacks
|
||||||
gobject.source_remove(self.possible_paused_timeout_id)
|
gobject.source_remove(self.possible_paused_timeout_id)
|
||||||
gobject.source_remove(self.possible_inactive_timeout_id)
|
gobject.source_remove(self.possible_inactive_timeout_id)
|
||||||
if self.print_time_timeout_id:
|
|
||||||
gobject.source_remove(self.print_time_timeout_id)
|
|
||||||
self.print_time_timeout_id = None
|
|
||||||
# Clean up systray
|
# Clean up systray
|
||||||
if gajim.interface.systray_enabled and self.nb_unread > 0:
|
if gajim.interface.systray_enabled and self.nb_unread > 0:
|
||||||
gajim.interface.systray.remove_jid(self.contact.jid, self.account,
|
gajim.interface.systray.remove_jid(self.contact.jid, self.account,
|
||||||
|
|
|
@ -591,11 +591,6 @@ class PreferencesWindow:
|
||||||
else:
|
else:
|
||||||
self.remove_speller()
|
self.remove_speller()
|
||||||
|
|
||||||
def update_print_time(self):
|
|
||||||
'''Update time in Opened Chat Windows'''
|
|
||||||
for msg_win in gajim.interface.msg_win_mgr.windows():
|
|
||||||
msg_win.update_print_time()
|
|
||||||
|
|
||||||
def _set_sensitivity_for_before_after_time_widgets(self, sensitive):
|
def _set_sensitivity_for_before_after_time_widgets(self, sensitive):
|
||||||
self.xml.get_widget('before_time_label').set_sensitive(sensitive)
|
self.xml.get_widget('before_time_label').set_sensitive(sensitive)
|
||||||
self.xml.get_widget('before_time_entry').set_sensitive(sensitive)
|
self.xml.get_widget('before_time_entry').set_sensitive(sensitive)
|
||||||
|
@ -606,21 +601,18 @@ class PreferencesWindow:
|
||||||
if widget.get_active():
|
if widget.get_active():
|
||||||
gajim.config.set('print_time', 'never')
|
gajim.config.set('print_time', 'never')
|
||||||
self._set_sensitivity_for_before_after_time_widgets(False)
|
self._set_sensitivity_for_before_after_time_widgets(False)
|
||||||
self.update_print_time()
|
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
|
|
||||||
def on_time_sometimes_radiobutton_toggled(self, widget):
|
def on_time_sometimes_radiobutton_toggled(self, widget):
|
||||||
if widget.get_active():
|
if widget.get_active():
|
||||||
gajim.config.set('print_time', 'sometimes')
|
gajim.config.set('print_time', 'sometimes')
|
||||||
self._set_sensitivity_for_before_after_time_widgets(False)
|
self._set_sensitivity_for_before_after_time_widgets(False)
|
||||||
self.update_print_time()
|
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
|
|
||||||
def on_time_always_radiobutton_toggled(self, widget):
|
def on_time_always_radiobutton_toggled(self, widget):
|
||||||
if widget.get_active():
|
if widget.get_active():
|
||||||
gajim.config.set('print_time', 'always')
|
gajim.config.set('print_time', 'always')
|
||||||
self._set_sensitivity_for_before_after_time_widgets(True)
|
self._set_sensitivity_for_before_after_time_widgets(True)
|
||||||
self.update_print_time()
|
|
||||||
gajim.interface.save_config()
|
gajim.interface.save_config()
|
||||||
|
|
||||||
def on_before_time_entry_focus_out_event(self, widget, event):
|
def on_before_time_entry_focus_out_event(self, widget, event):
|
||||||
|
|
|
@ -46,7 +46,6 @@ class MessageControl:
|
||||||
self.compact_view_always = False
|
self.compact_view_always = False
|
||||||
self.compact_view_current = False
|
self.compact_view_current = False
|
||||||
self.nb_unread = 0
|
self.nb_unread = 0
|
||||||
self.print_time_timeout_id = None
|
|
||||||
self.resource = resource
|
self.resource = resource
|
||||||
|
|
||||||
gajim.last_message_time[self.account][self.get_full_jid()] = 0
|
gajim.last_message_time[self.account][self.get_full_jid()] = 0
|
||||||
|
@ -97,13 +96,6 @@ class MessageControl:
|
||||||
def update_tags(self):
|
def update_tags(self):
|
||||||
pass # NOTE: Derived classes SHOULD implement this
|
pass # NOTE: Derived classes SHOULD implement this
|
||||||
|
|
||||||
def print_time_timeout(self, arg):
|
|
||||||
# NOTE: Derived classes SHOULD implement this
|
|
||||||
if self.print_time_timeout_id:
|
|
||||||
gobject.source_remove(self.print_time_timeout_id)
|
|
||||||
self.print_time_timeout_id = None
|
|
||||||
return False
|
|
||||||
|
|
||||||
def get_tab_label(self, chatstate):
|
def get_tab_label(self, chatstate):
|
||||||
'''Return a suitable the tab label string. Returns a tuple such as:
|
'''Return a suitable the tab label string. Returns a tuple such as:
|
||||||
(label_str, color) either of which can be None
|
(label_str, color) either of which can be None
|
||||||
|
|
|
@ -395,19 +395,6 @@ class MessageWindow:
|
||||||
for ctrl in ctrl_dict.values():
|
for ctrl in ctrl_dict.values():
|
||||||
yield ctrl
|
yield ctrl
|
||||||
|
|
||||||
def update_print_time(self):
|
|
||||||
if gajim.config.get('print_time') != 'sometimes':
|
|
||||||
for ctrl in self.controls():
|
|
||||||
if ctrl.print_time_timeout_id:
|
|
||||||
gobject.source_remove(ctrl.print_time_timeout_id)
|
|
||||||
ctrl.print_time_timeout_id = None
|
|
||||||
else:
|
|
||||||
for ctrl in self.controls():
|
|
||||||
if not ctrl.print_time_timeout_id:
|
|
||||||
ctrl.print_time_timeout(None)
|
|
||||||
ctrl.print_time_timeout_id = gobject.timeout_add(300000,
|
|
||||||
ctrl.print_time_timeout, None)
|
|
||||||
|
|
||||||
def move_to_next_unread_tab(self, forward):
|
def move_to_next_unread_tab(self, forward):
|
||||||
ind = self.notebook.get_current_page()
|
ind = self.notebook.get_current_page()
|
||||||
current = ind
|
current = ind
|
||||||
|
|
Loading…
Reference in New Issue