diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index 4bdc5960e..2b45dd873 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -41,75 +41,83 @@ class preferences_window: """close window""" del self.plugin.windows['preferences'] - def on_incoming_msg_colorbutton_color_set(self, widget): - """Take The Color For The Incoming Messages""" - color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] - self.plugin.config['inmsgcolor'] = color_string - self.update_text_tags() + def on_tray_icon_checkbutton_toggled(self, widget): + """On Tray Icon Checkbutton Toggled""" + if self.widget.get_active(): + self.plugin.config['trayicon'] = 1 + self.plugin.show_systray() + else: + self.plugin.config['trayicon'] = 0 + self.plugin.hide_systray() + self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) + self.plugin.roster.draw_roster() + + def on_save_position_checkbutton_toggled(self, widget): + """On Save Position Checkbutton Toggled""" + if widget.get_active(): + self.plugin.config['saveposition'] = 1 + else: + self.plugin.config['saveposition'] = 0 + + def on_merge_checkbutton_toggled(self, widget): + """On Merge Accounts Checkbutton Toggled""" + if widget.get_active(): + self.plugin.config['mergeaccounts'] = 1 + else: + self.plugin.config['mergeaccounts'] = 0 + self.plugin.roster.regroup = self.plugin.config['mergeaccounts'] + + def on_iconstyle_combobox_changed(self, widget, path): + model = widget.get_model() + icon_string = model[path][0] + self.plugin.config['iconstyle'] = icon_string + self.plugin.roster.mkpixbufs() - def on_outgoing_msg_colorbutton_color_set(self, widget): - """Take The Color For The Outgoing Messages""" - color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] - self.plugin.config['outmsgcolor'] = color_string - self.update_text_tags() - - def on_status_msg_colorbutton_color_set(self, widget): - """Take The Color For The Status Messages""" - color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] - self.plugin.config['statusmsgcolor'] = color_string - self.update_text_tags() - def on_account_text_colorbutton_color_set(self, widget): """Take The Color For The Account Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['accounttextcolor'] = color_string self.plugin.roster.draw_roster() def on_group_text_colorbutton_color_set(self, widget): """Take The Color For The Group Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['grouptextcolor'] = color_string self.plugin.roster.draw_roster() def on_user_text_colorbutton_color_set(self, widget): """Take The Color For The User Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['usertextcolor'] = color_string self.plugin.roster.draw_roster() def on_account_text_bg_colorbutton_color_set(self, widget): """Take The Color For The Background Of Account Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['accountbgcolor'] = color_string self.plugin.roster.draw_roster() def on_group_text_bg_colorbutton_color_set(self, widget): """Take The Color For The Background Of Group Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['groupbgcolor'] = color_string self.plugin.roster.draw_roster() def on_user_text_bg_colorbutton_color_set(self, widget): """Take The Color For The Background Of User Text""" color = widget.get_color() - color_string = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ - +(hex(color.blue)+'0')[2:4] + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] self.plugin.config['userbgcolor'] = color_string self.plugin.roster.draw_roster() @@ -131,69 +139,6 @@ class preferences_window: self.plugin.config['userfont'] = font_string self.plugin.roster.draw_roster() - def update_text_tags(self): - """Update Opened Chat Windows""" - for a in self.plugin.accounts.keys(): - if self.plugin.windows[a]['chats'].has_key('tabbed'): - self.plugin.windows[a]['chats']['tabbed'].update_tags() - else: - for jid in self.plugin.windows[a]['chats'].keys(): - self.plugin.windows[a]['chats'][jid].update_tags() - - def on_iconstyle_combobox_changed(self, widget, path): - model = widget.get_model() - icon_string = model[path][0] - self.plugin.config['iconstyle'] = icon_string - self.plugin.roster.mkpixbufs() - - def on_save_position_checkbutton_toggled(self, widget): - """On Save Position Checkbutton Toggled""" - if widget.get_active(): - self.plugin.config['saveposition'] = 1 - else: - self.plugin.config['saveposition'] = 0 - - def on_merge_checkbutton_toggled(self, widget): - """On Merge Accounts Checkbutton Toggled""" - if widget.get_active(): - self.plugin.config['mergeaccounts'] = 1 - else: - self.plugin.config['mergeaccounts'] = 0 - self.plugin.roster.regroup = self.plugin.config['mergeaccounts'] - - def on_use_tabbed_chat_window_checkbutton_toggled(self, widget): - """On Use Tabbed Chat Window Checkbutton Toggled""" - if widget.get_active(): - self.plugin.config['usetabbedchat'] = 1 - #TODO: merge opened chat windows - else: - self.plugin.config['usetabbedchat'] = 0 - #TODO: split the tabbed chat window - - def on_tray_icon_checkbutton_toggled(self, widget): - """On Tray Icon Checkbutton Toggled""" - if self.widget.get_active(): - self.plugin.config['trayicon'] = 1 - self.plugin.show_systray() - else: - self.plugin.config['trayicon'] = 0 - self.plugin.hide_systray() - self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) - self.plugin.roster.draw_roster() - - def on_reset_colors_button_clicked(self, widget): - defaults = self.plugin.default_config - self.plugin.config['inmsgcolor'] = defaults['inmsgcolor'] - self.plugin.config['outmsgcolor'] = defaults['outmsgcolor'] - self.plugin.config['statusmsgcolor'] = defaults['statusmsgcolor'] - self.xml.get_widget('incoming_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(defaults['inmsgcolor'])) - self.xml.get_widget('outgoing_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(defaults['outmsgcolor'])) - self.xml.get_widget('status_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(defaults['statusmsgcolor'])) - self.update_text_tags() - def on_reset_colors_and_fonts_button_clicked(self, widget): defaults = self.plugin.default_config self.plugin.config['accounttextcolor'] = defaults['accounttextcolor'] @@ -225,6 +170,85 @@ class preferences_window: defaults['userfont']) self.plugin.roster.draw_roster() + def on_use_tabbed_chat_window_checkbutton_toggled(self, widget): + """On Use Tabbed Chat Window Checkbutton Toggled""" + if widget.get_active(): + self.plugin.config['usetabbedchat'] = 1 + #TODO: merge opened chat windows + else: + self.plugin.config['usetabbedchat'] = 0 + #TODO: split the tabbed chat window + + def update_text_tags(self): + """Update Opened Chat Windows""" + for a in self.plugin.accounts.keys(): + if self.plugin.windows[a]['chats'].has_key('tabbed'): + self.plugin.windows[a]['chats']['tabbed'].update_tags() + else: + for jid in self.plugin.windows[a]['chats'].keys(): + self.plugin.windows[a]['chats'][jid].update_tags() + + def update_print_time(self): + """Update Opened Chat Windows""" + for a in self.plugin.accounts.keys(): + if self.plugin.windows[a]['chats'].has_key('tabbed'): + self.plugin.windows[a]['chats']['tabbed'].update_print_time() + else: + for jid in self.plugin.windows[a]['chats'].keys(): + self.plugin.windows[a]['chats'][jid].update_print_time() + + def on_incoming_msg_colorbutton_color_set(self, widget): + """Take The Color For The Incoming Messages""" + color = widget.get_color() + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] + self.plugin.config['inmsgcolor'] = color_string + self.update_text_tags() + + def on_outgoing_msg_colorbutton_color_set(self, widget): + """Take The Color For The Outgoing Messages""" + color = widget.get_color() + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] + self.plugin.config['outmsgcolor'] = color_string + self.update_text_tags() + + def on_status_msg_colorbutton_color_set(self, widget): + """Take The Color For The Status Messages""" + color = widget.get_color() + color_string = '#' + (hex(color.red) + '0')[2:4] + \ + (hex(color.green) + '0')[2:4] + (hex(color.blue) + '0')[2:4] + self.plugin.config['statusmsgcolor'] = color_string + self.update_text_tags() + + def on_reset_colors_button_clicked(self, widget): + defaults = self.plugin.default_config + self.plugin.config['inmsgcolor'] = defaults['inmsgcolor'] + self.plugin.config['outmsgcolor'] = defaults['outmsgcolor'] + self.plugin.config['statusmsgcolor'] = defaults['statusmsgcolor'] + self.xml.get_widget('incoming_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(defaults['inmsgcolor'])) + self.xml.get_widget('outgoing_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(defaults['outmsgcolor'])) + self.xml.get_widget('status_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(defaults['statusmsgcolor'])) + self.update_text_tags() + + def on_time_never_radiobutton_toggled(self, widget): + if widget.get_active(): + self.plugin.config['print_time'] = 'never' + self.update_print_time() + + def on_time_sometimes_radiobutton_toggled(self, widget): + if widget.get_active(): + self.plugin.config['print_time'] = 'sometimes' + self.update_print_time() + + def on_time_always_radiobutton_toggled(self, widget): + if widget.get_active(): + self.plugin.config['print_time'] = 'always' + self.update_print_time() + def on_use_emoticons_checkbutton_function(self): """ model = self.emot_tree.get_model() @@ -619,21 +643,20 @@ class preferences_window: self.tray_icon_checkbutton = self.xml.get_widget('tray_icon_checkbutton') self.notebook = self.xml.get_widget('preferences_notebook') - #Color for incomming messages - colSt = self.plugin.config['inmsgcolor'] - self.xml.get_widget('incoming_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(colSt)) - - #Color for outgoing messages - colSt = self.plugin.config['outmsgcolor'] - self.xml.get_widget('outgoing_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(colSt)) - - #Color for status messages - colSt = self.plugin.config['statusmsgcolor'] - self.xml.get_widget('status_msg_colorbutton').set_color(\ - gtk.gdk.color_parse(colSt)) + #trayicon + st = self.plugin.config['trayicon'] + self.tray_icon_checkbutton.set_active(st) + if isinstance(self.plugin.systray, gtkgui.systrayDummy): + self.tray_icon_checkbutton.set_sensitive(False) + + #Save position + st = self.plugin.config['saveposition'] + self.xml.get_widget('save_position_checkbutton').set_active(st) + #Merge accounts + st = self.plugin.config['mergeaccounts'] + self.xml.get_widget('merge_checkbutton').set_active(st) + #iconStyle list_style = os.listdir('plugins/gtkgui/icons/') model = gtk.ListStore(gobject.TYPE_STRING) @@ -649,131 +672,6 @@ class preferences_window: if self.plugin.config['iconstyle'] == l[i]: self.iconstyle_combobox.set_active(i) - #Save position - st = self.plugin.config['saveposition'] - self.xml.get_widget('save_position_checkbutton').set_active(st) - - #Merge accounts - st = self.plugin.config['mergeaccounts'] - self.xml.get_widget('merge_checkbutton').set_active(st) - - #use tabbed chat window - st = self.plugin.config['usetabbedchat'] - self.xml.get_widget('use_tabbed_chat_window_checkbutton').set_active(st) - - #Use emoticons - st = self.plugin.config['useemoticons'] - self.xml.get_widget('use_emoticons_checkbutton').set_active(st) - self.xml.get_widget('button_new_emoticon').set_sensitive(st) - self.xml.get_widget('button_remove_emoticon').set_sensitive(st) - self.xml.get_widget('treeview_emoticons').set_sensitive(st) - self.xml.get_widget('set_image_button').set_sensitive(st) - - #emoticons - self.emot_tree = self.xml.get_widget('treeview_emoticons') - model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.Image) - self.emot_tree.set_model(model) - col = gtk.TreeViewColumn('name') - self.emot_tree.append_column(col) - renderer = gtk.CellRendererText() - renderer.connect('edited', self.on_emot_cell_edited) - renderer.set_property('editable', True) - col.pack_start(renderer, True) - col.set_attributes(renderer, text=0) - - col = gtk.TreeViewColumn('Image') - self.emot_tree.append_column(col) - renderer = gtkgui.ImageCellRenderer() - col.pack_start(renderer, expand = False) - col.add_attribute(renderer, 'image', 2) - - self.fill_emot_treeview() - - #sound player - self.xml.get_widget('entry_soundplayer').set_text(\ - self.plugin.config['soundplayer']) - - #sounds - self.sound_tree = self.xml.get_widget('treeview_sounds') - model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \ - gobject.TYPE_STRING) - self.sound_tree.set_model(model) - - col = gtk.TreeViewColumn('Active') - self.sound_tree.append_column(col) - renderer = gtk.CellRendererToggle() - renderer.set_property('activatable', True) - renderer.connect("toggled", self.sound_toggled_cb) - col.pack_start(renderer) - col.set_attributes(renderer, active=1) - - col = gtk.TreeViewColumn('Event') - self.sound_tree.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) - col.set_attributes(renderer, text=0) - - col = gtk.TreeViewColumn('Sound') - self.sound_tree.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer) - col.set_attributes(renderer, text=2) - self.fill_sound_treeview() - - if not os.name == 'posix': - self.xml.get_widget('entry_soundplayer').set_sensitive(False) - self.sound_tree.set_sensitive(False) - self.xml.get_widget('entry_sounds').set_sensitive(False) - self.xml.get_widget('button_sounds').set_sensitive(False) - - #Autopopup - st = self.plugin.config['autopopup'] - self.auto_pp_checkbutton.set_active(st) - - #Autopopupaway - st = self.plugin.config['autopopupaway'] - self.auto_pp_away_checkbutton.set_active(st) - self.auto_pp_away_checkbutton.set_sensitive(self.plugin.config['autopopup']) - - #Autoaway - st = self.plugin.config['autoaway'] - self.auto_away_checkbutton.set_active(st) - - #Autoawaytime - st = self.plugin.config['autoawaytime'] - self.auto_away_time_spinbutton.set_value(st) - self.auto_away_time_spinbutton.set_sensitive(self.plugin.config['autoaway']) - - #Autoxa - st = self.plugin.config['autoxa'] - self.auto_xa_checkbutton.set_active(st) - - #Autoxatime - st = self.plugin.config['autoxatime'] - self.auto_xa_time_spinbutton.set_value(st) - self.auto_xa_time_spinbutton.set_sensitive(self.plugin.config['autoxa']) - - #Status messages - self.msg_tree = self.xml.get_widget('msg_treeview') - model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) - self.msg_tree.set_model(model) - col = gtk.TreeViewColumn('name') - self.msg_tree.append_column(col) - renderer = gtk.CellRendererText() - col.pack_start(renderer, True) - col.set_attributes(renderer, text=0) - renderer.connect('edited', self.on_msg_cell_edited) - renderer.set_property('editable', True) - self.fill_msg_treeview() - buf = self.xml.get_widget('msg_textview').get_buffer() - buf.connect('changed', self.on_msg_textview_changed) - - #trayicon - st = self.plugin.config['trayicon'] - self.tray_icon_checkbutton.set_active(st) - if isinstance(self.plugin.systray, gtkgui.systrayDummy): - self.tray_icon_checkbutton.set_sensitive(False) - #Color for account text colSt = self.plugin.config['accounttextcolor'] self.xml.get_widget('account_text_colorbutton').set_color(\ @@ -816,6 +714,148 @@ class preferences_window: fontStr = self.plugin.config['userfont'] self.xml.get_widget('user_text_fontbutton').set_font_name(fontStr) + #use tabbed chat window + st = self.plugin.config['usetabbedchat'] + self.xml.get_widget('use_tabbed_chat_window_checkbutton').set_active(st) + + #Color for incomming messages + colSt = self.plugin.config['inmsgcolor'] + self.xml.get_widget('incoming_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for outgoing messages + colSt = self.plugin.config['outmsgcolor'] + self.xml.get_widget('outgoing_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for status messages + colSt = self.plugin.config['statusmsgcolor'] + self.xml.get_widget('status_msg_colorbutton').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Print time + if self.plugin.config['print_time'] == 'never': + self.xml.get_widget('time_never_radiobutton').set_active(1) + elif self.plugin.config['print_time'] == 'sometimes': + self.xml.get_widget('time_sometimes_radiobutton').set_active(1) + else: + self.xml.get_widget('time_always_radiobutton').set_active(1) + + #Use emoticons + st = self.plugin.config['useemoticons'] + self.xml.get_widget('use_emoticons_checkbutton').set_active(st) + self.xml.get_widget('button_new_emoticon').set_sensitive(st) + self.xml.get_widget('button_remove_emoticon').set_sensitive(st) + self.xml.get_widget('treeview_emoticons').set_sensitive(st) + self.xml.get_widget('set_image_button').set_sensitive(st) + + #emoticons + self.emot_tree = self.xml.get_widget('treeview_emoticons') + model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gtk.Image) + self.emot_tree.set_model(model) + col = gtk.TreeViewColumn('name') + self.emot_tree.append_column(col) + renderer = gtk.CellRendererText() + renderer.connect('edited', self.on_emot_cell_edited) + renderer.set_property('editable', True) + col.pack_start(renderer, True) + col.set_attributes(renderer, text=0) + + col = gtk.TreeViewColumn('Image') + self.emot_tree.append_column(col) + renderer = gtkgui.ImageCellRenderer() + col.pack_start(renderer, expand = False) + col.add_attribute(renderer, 'image', 2) + + self.fill_emot_treeview() + + #Autopopup + st = self.plugin.config['autopopup'] + self.auto_pp_checkbutton.set_active(st) + + #Autopopupaway + st = self.plugin.config['autopopupaway'] + self.auto_pp_away_checkbutton.set_active(st) + self.auto_pp_away_checkbutton.set_sensitive(self.plugin.config['autopopup']) + + #sound player + self.xml.get_widget('entry_soundplayer').set_text(\ + self.plugin.config['soundplayer']) + + #sounds + self.sound_tree = self.xml.get_widget('treeview_sounds') + model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, \ + gobject.TYPE_STRING) + self.sound_tree.set_model(model) + + col = gtk.TreeViewColumn('Active') + self.sound_tree.append_column(col) + renderer = gtk.CellRendererToggle() + renderer.set_property('activatable', True) + renderer.connect("toggled", self.sound_toggled_cb) + col.pack_start(renderer) + col.set_attributes(renderer, active=1) + + col = gtk.TreeViewColumn('Event') + self.sound_tree.append_column(col) + renderer = gtk.CellRendererText() + col.pack_start(renderer) + col.set_attributes(renderer, text=0) + + col = gtk.TreeViewColumn('Sound') + self.sound_tree.append_column(col) + renderer = gtk.CellRendererText() + col.pack_start(renderer) + col.set_attributes(renderer, text=2) + self.fill_sound_treeview() + + if not os.name == 'posix': + self.xml.get_widget('entry_soundplayer').set_sensitive(False) + self.sound_tree.set_sensitive(False) + self.xml.get_widget('entry_sounds').set_sensitive(False) + self.xml.get_widget('button_sounds').set_sensitive(False) + + #Autoaway + st = self.plugin.config['autoaway'] + self.auto_away_checkbutton.set_active(st) + + #Autoawaytime + st = self.plugin.config['autoawaytime'] + self.auto_away_time_spinbutton.set_value(st) + self.auto_away_time_spinbutton.set_sensitive(self.plugin.config['autoaway']) + + #Autoxa + st = self.plugin.config['autoxa'] + self.auto_xa_checkbutton.set_active(st) + + #Autoxatime + st = self.plugin.config['autoxatime'] + self.auto_xa_time_spinbutton.set_value(st) + self.auto_xa_time_spinbutton.set_sensitive(self.plugin.config['autoxa']) + + #ask_status when online / offline + st = self.plugin.config['ask_online_status'] + self.xml.get_widget('prompt_online_status_message_checkbutton').\ + set_active(st) + st = self.plugin.config['ask_offline_status'] + self.xml.get_widget('prompt_offline_status_message_checkbutton').\ + set_active(st) + + #Status messages + self.msg_tree = self.xml.get_widget('msg_treeview') + model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) + self.msg_tree.set_model(model) + col = gtk.TreeViewColumn('name') + self.msg_tree.append_column(col) + renderer = gtk.CellRendererText() + col.pack_start(renderer, True) + col.set_attributes(renderer, text=0) + renderer.connect('edited', self.on_msg_cell_edited) + renderer.set_property('editable', True) + self.fill_msg_treeview() + buf = self.xml.get_widget('msg_textview').get_buffer() + buf.connect('changed', self.on_msg_textview_changed) + self.xml.signal_connect('on_auto_pop_up_checkbox_toggled', \ self.on_checkbutton_toggled, 'autopopup', None,\ [self.auto_pp_away_checkbutton]) diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index c6bab5548..599bc778b 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -4031,6 +4031,7 @@ on the server as a vCard False False True + 1 @@ -4042,29 +4043,6 @@ on the server as a vCard - - - True - True - On every lines - True - GTK_RELIEF_NORMAL - True - False - False - True - time_never_radiobutton - - - 1 - 2 - 1 - 2 - fill - - - - True @@ -4077,6 +4055,31 @@ on the server as a vCard False True time_never_radiobutton + + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + True + On every lines + True + GTK_RELIEF_NORMAL + True + False + False + True + time_never_radiobutton + 1 diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index dd8048f9a..f7d77ae65 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -55,6 +55,7 @@ import pygtk pygtk.require('2.0') import gtk import gtk.glade +import pango import gobject import os import time @@ -209,9 +210,11 @@ class tabbed_chat_window: self.tagIn = {} self.tagOut = {} self.tagStatus = {} + self.tagTimeSometimes = {} self.users = {} self.nb_unread = {} self.last_message_time = {} + self.print_time_timeout_id = {} self.window = self.xml.get_widget('tabbed_chat_window') self.new_user(user) self.show_title() @@ -236,6 +239,19 @@ class tabbed_chat_window: self.tagStatus[jid].set_property("foreground", \ self.plugin.config['statusmsgcolor']) + def update_print_time(self): + if self.plugin.config['print_time'] != 'sometimes': + list_jid = self.print_time_timeout_id.keys() + for jid in list_jid: + gobject.source_remove(self.print_time_timeout_id[jid]) + del self.print_time_timeout_id[jid] + else: + for jid in self.xmls: + if not self.print_time_timeout_id.has_key(jid): + self.print_time_timeout(jid) + self.print_time_timeout_id[jid] = gobject.timeout_add(300000, \ + self.print_time_timeout, jid) + def show_title(self): """redraw the window's title""" unread = 0 @@ -296,6 +312,7 @@ class tabbed_chat_window: #clean self.plugin.windows[self.account]['chats'] for jid in self.users: del self.plugin.windows[self.account]['chats'][jid] + #TODO: stop all print time timout if self.plugin.windows[self.account]['chats'].has_key('tabbed'): del self.plugin.windows[self.account]['chats']['tabbed'] @@ -384,6 +401,9 @@ class tabbed_chat_window: if len(self.xmls) == 1: self.window.destroy() else: + if self.print_time_timeout_id.has_key(jid): + gobject.source_remove(self.print_time_timeout_id[jid]) + del self.print_time_timeout_id[jid] self.chat_notebook.remove_page(\ self.chat_notebook.get_current_page()) del self.plugin.windows[self.account]['chats'][jid] @@ -394,6 +414,7 @@ class tabbed_chat_window: del self.tagIn[jid] del self.tagOut[jid] del self.tagStatus[jid] + del self.tagTimeSometimes[jid] if len(self.xmls) == 1: self.chat_notebook.set_show_tabs(False) self.show_title() @@ -418,6 +439,11 @@ class tabbed_chat_window: self.tagStatus[user.jid] = conversation_buffer.create_tag('status') color = self.plugin.config['statusmsgcolor'] self.tagStatus[user.jid].set_property('foreground', color) + self.tagTimeSometimes[user.jid] = conversation_buffer.\ + create_tag('time_sometimes') + self.tagTimeSometimes[user.jid].set_property('foreground', '#9e9e9e') + self.tagTimeSometimes[user.jid].set_property('scale', pango.SCALE_SMALL) + self.tagTimeSometimes[user.jid].set_property('justification', gtk.JUSTIFY_CENTER) self.link_tag = conversation_buffer.create_tag('hyperlink', foreground='blue') self.xmls[user.jid].signal_autoconnect(self) @@ -442,6 +468,11 @@ class tabbed_chat_window: self.print_conversation(_("%s is now %s (%s)") % (user.name, \ user.show, user.status), user.jid, 'status') + if self.plugin.config['print_time'] == 'sometimes': + self.print_time_timeout(user.jid) + self.print_time_timeout_id[user.jid] = gobject.timeout_add(3000, \ + self.print_time_timeout, user.jid) + def on_message_textview_key_press_event(self, widget, event): """When a key is pressed : if enter is pressed without the shit key, message (if not empty) is sent @@ -552,6 +583,30 @@ class tabbed_chat_window: self.redraw_tab(jid) self.show_title() self.plugin.systray.remove_jid(jid, self.account) + + def print_time_timeout(self, jid): + if not jid in self.xmls.keys(): + return 0 + if self.plugin.config['print_time'] == 'sometimes': + conversation_textview = self.xmls[jid].\ + get_widget('conversation_textview') + conversation_buffer = conversation_textview.get_buffer() + end_iter = conversation_buffer.get_end_iter() + tim = time.localtime() + tim_format = time.strftime('%H:%M', tim) + conversation_buffer.insert_with_tags_by_name(end_iter, tim_format + \ + '\n', 'time_sometimes') + #scroll to the end of the textview + end_rect = conversation_textview.get_iter_location(end_iter) + visible_rect = conversation_textview.get_visible_rect() + if end_rect.y <= (visible_rect.y + visible_rect.height): + #we are at the end + conversation_textview.scroll_to_mark(conversation_buffer.\ + get_mark('end'), 0.1, 0, 0, 0) + return 1 + if self.print_time_timeout_id.has_key(jid): + del self.print_time_timeout_id[jid] + return 0 def print_conversation(self, text, jid, contact = '', tim = None): """Print a line in the conversation : @@ -564,10 +619,11 @@ class tabbed_chat_window: if not text: text = '' end_iter = conversation_buffer.get_end_iter() - if not tim: - tim = time.localtime() - tim_format = time.strftime("[%H:%M:%S]", tim) - conversation_buffer.insert(end_iter, tim_format + ' ') + if self.plugin.config['print_time'] == 'always': + if not tim: + tim = time.localtime() + tim_format = time.strftime("[%H:%M:%S]", tim) + conversation_buffer.insert(end_iter, tim_format + ' ') otext = '' ttext = '' @@ -918,10 +974,11 @@ class Groupchat_window: if not text: text = '' end_iter = conversation_buffer.get_end_iter() - if not tim: - tim = time.localtime() - tim_format = time.strftime('[%H:%M:%S]', tim) - conversation_buffer.insert(end_iter, tim_format + ' ') + if self.plugin.config['print_time'] == 'always': + if not tim: + tim = time.localtime() + tim_format = time.strftime('[%H:%M:%S]', tim) + conversation_buffer.insert(end_iter, tim_format + ' ') otext = '' ttext = '' @@ -3343,6 +3400,7 @@ class plugin: 'saveposition': 1,\ 'mergeaccounts': 0,\ 'usetabbedchat': 1,\ + 'print_time': 'always',\ 'useemoticons': 1,\ 'emoticons':':-)\tplugins/gtkgui/emoticons/smile.png\t(@)\tplugins/gtkgui/emoticons/pussy.png\t8)\tplugins/gtkgui/emoticons/coolglasses.png\t:(\tplugins/gtkgui/emoticons/unhappy.png\t:)\tplugins/gtkgui/emoticons/smile.png\t(})\tplugins/gtkgui/emoticons/hugleft.png\t:$\tplugins/gtkgui/emoticons/blush.png\t(Y)\tplugins/gtkgui/emoticons/yes.png\t:-@\tplugins/gtkgui/emoticons/angry.png\t:-D\tplugins/gtkgui/emoticons/biggrin.png\t(U)\tplugins/gtkgui/emoticons/brheart.png\t(F)\tplugins/gtkgui/emoticons/flower.png\t:-[\tplugins/gtkgui/emoticons/bat.png\t:>\tplugins/gtkgui/emoticons/biggrin.png\t(T)\tplugins/gtkgui/emoticons/phone.png\t(l)\tplugins/gtkgui/emoticons/heart.png\t:-S\tplugins/gtkgui/emoticons/frowing.png\t:-P\tplugins/gtkgui/emoticons/tongue.png\t(h)\tplugins/gtkgui/emoticons/coolglasses.png\t(D)\tplugins/gtkgui/emoticons/drink.png\t:-O\tplugins/gtkgui/emoticons/oh.png\t(f)\tplugins/gtkgui/emoticons/flower.png\t(C)\tplugins/gtkgui/emoticons/coffee.png\t:-o\tplugins/gtkgui/emoticons/oh.png\t({)\tplugins/gtkgui/emoticons/hugright.png\t(*)\tplugins/gtkgui/emoticons/star.png\tB-)\tplugins/gtkgui/emoticons/coolglasses.png\t(z)\tplugins/gtkgui/emoticons/boy.png\t:-d\tplugins/gtkgui/emoticons/biggrin.png\t(E)\tplugins/gtkgui/emoticons/mail.png\t(N)\tplugins/gtkgui/emoticons/no.png\t(p)\tplugins/gtkgui/emoticons/photo.png\t(K)\tplugins/gtkgui/emoticons/kiss.png\t(r)\tplugins/gtkgui/emoticons/rainbow.png\t:-|\tplugins/gtkgui/emoticons/stare.png\t:-s\tplugins/gtkgui/emoticons/frowing.png\t:-p\tplugins/gtkgui/emoticons/tongue.png\t(c)\tplugins/gtkgui/emoticons/coffee.png\t(e)\tplugins/gtkgui/emoticons/mail.png\t;-)\tplugins/gtkgui/emoticons/wink.png\t;-(\tplugins/gtkgui/emoticons/cry.png\t(6)\tplugins/gtkgui/emoticons/devil.png\t:o\tplugins/gtkgui/emoticons/oh.png\t(L)\tplugins/gtkgui/emoticons/heart.png\t(w)\tplugins/gtkgui/emoticons/brflower.png\t:d\tplugins/gtkgui/emoticons/biggrin.png\t(Z)\tplugins/gtkgui/emoticons/boy.png\t(u)\tplugins/gtkgui/emoticons/brheart.png\t:|\tplugins/gtkgui/emoticons/stare.png\t(P)\tplugins/gtkgui/emoticons/photo.png\t:O\tplugins/gtkgui/emoticons/oh.png\t(R)\tplugins/gtkgui/emoticons/rainbow.png\t(t)\tplugins/gtkgui/emoticons/phone.png\t(i)\tplugins/gtkgui/emoticons/lamp.png\t;)\tplugins/gtkgui/emoticons/wink.png\t;(\tplugins/gtkgui/emoticons/cry.png\t:p\tplugins/gtkgui/emoticons/tongue.png\t(H)\tplugins/gtkgui/emoticons/coolglasses.png\t:s\tplugins/gtkgui/emoticons/frowing.png\t;\'-(\tplugins/gtkgui/emoticons/cry.png\t:-(\tplugins/gtkgui/emoticons/unhappy.png\t:-)\tplugins/gtkgui/emoticons/smile.png\t(b)\tplugins/gtkgui/emoticons/beer.png\t8-)\tplugins/gtkgui/emoticons/coolglasses.png\t(B)\tplugins/gtkgui/emoticons/beer.png\t(W)\tplugins/gtkgui/emoticons/brflower.png\t:D\tplugins/gtkgui/emoticons/biggrin.png\t(y)\tplugins/gtkgui/emoticons/yes.png\t(8)\tplugins/gtkgui/emoticons/music.png\t:@\tplugins/gtkgui/emoticons/angry.png\tB)\tplugins/gtkgui/emoticons/coolglasses.png\t:-$\tplugins/gtkgui/emoticons/blush.png\t:\'(\tplugins/gtkgui/emoticons/cry.png\t(n)\tplugins/gtkgui/emoticons/no.png\t(k)\tplugins/gtkgui/emoticons/kiss.png\t:->\tplugins/gtkgui/emoticons/biggrin.png\t:[\tplugins/gtkgui/emoticons/bat.png\t(I)\tplugins/gtkgui/emoticons/lamp.png\t:P\tplugins/gtkgui/emoticons/tongue.png\t(%)\tplugins/gtkgui/emoticons/cuffs.png\t(d)\tplugins/gtkgui/emoticons/drink.png\t:S\tplugins/gtkgui/emoticons/frowing.png\t:(S)\tplugins/gtkgui/emoticons/moon.png',\ 'soundplayer': 'play',\