From 48dfd4a3ea288fdaab431bdbf60fad8de836863e Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 4 Nov 2004 01:03:17 +0000 Subject: [PATCH] it is now possible to configure logger plugin from gtkgui plugin --- core/core.py | 4 +- plugins/gtkgui/config.py | 52 +++++++--- plugins/gtkgui/gtkgui.glade | 184 ++++++++++++++++++++++++++++++++++++ plugins/gtkgui/gtkgui.py | 8 +- plugins/logger/logger.py | 3 + 5 files changed, 235 insertions(+), 16 deletions(-) diff --git a/core/core.py b/core/core.py index 49a59e71b..aafb813a3 100644 --- a/core/core.py +++ b/core/core.py @@ -631,7 +631,7 @@ class GajimCore: self.cfgParser.writeCfgFile() config['usegpg'] = USE_GPG self.hub.sendPlugin('CONFIG', None, (ev[2][0], config)) - #('CONFIG', account, (section, config)) + #('CONFIG', account, (section, config, who_sent)) elif ev[0] == 'CONFIG': if ev[2][0] == 'accounts': #Remove all old accounts @@ -653,6 +653,8 @@ class GajimCore: self.gpg[a] = MyGnuPG() else: self.cfgParser.tab[ev[2][0]] = ev[2][1] + if ev[2][0] != ev[2][2]: + self.hub.sendPlugin('CONFIG', None, (ev[2][0], ev[2][1])) self.cfgParser.writeCfgFile() #TODO: tell the changes to other plugins #('STATUS', account, (status, msg)) diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index e1bfe49a1..015255b7f 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -256,8 +256,19 @@ class preference_Window: self.plugin.config['trayicon'] = 1 else: self.plugin.config['trayicon'] = 0 - self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config)) + self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) self.plugin.roster.draw_roster() + #log presences in user file + if self.xml.get_widget('chk_log_pres_usr').get_active(): + self.config_logger['lognotusr'] = 1 + else: + self.config_logger['lognotusr'] = 0 + #log presences in external file + if self.xml.get_widget('chk_log_pres_ext').get_active(): + self.config_logger['lognotsep'] = 1 + else: + self.config_logger['lognotsep'] = 0 + self.plugin.send('CONFIG', None, ('Logger', self.config_logger, 'GtkGui')) def on_ok(self, widget): """When Ok button is clicked""" @@ -280,6 +291,9 @@ class preference_Window: def on_presence_button_clicked(self, widget, data=None): self.change_notebook_page(2) + def on_log_button_clicked(self, widget, data=None): + self.change_notebook_page(3) + def fill_msg_treeview(self): i = 0 self.xml.get_widget('delete_msg_button').set_sensitive(False) @@ -344,13 +358,6 @@ class preference_Window: self.chk_trayicon = self.xml.get_widget('chk_trayicon') self.notebook = self.xml.get_widget('preferences_notebook') - button = self.xml.get_widget('lookfeel_button') - button.connect('clicked', self.on_lookfeel_button_clicked) - button = self.xml.get_widget('events_button') - button.connect('clicked', self.on_events_button_clicked) - button = self.xml.get_widget('presence_button') - button.connect('clicked', self.on_presence_button_clicked) - #Color for incomming messages colSt = self.plugin.config['inmsgcolor'] self.xml.get_widget('colorbutton_in').set_color(\ @@ -488,6 +495,26 @@ class preference_Window: self.on_chk_toggled, [self.spin_autoawaytime]) self.xml.signal_connect('on_chk_autoxa_toggled', \ self.on_chk_toggled, [self.spin_autoxatime]) + self.xml.signal_connect('on_lookfeel_button_clicked', \ + self.on_lookfeel_button_clicked) + self.xml.signal_connect('on_events_button_clicked', \ + self.on_events_button_clicked) + self.xml.signal_connect('on_presence_button_clicked', \ + self.on_presence_button_clicked) + self.xml.signal_connect('on_log_button_clicked', \ + self.on_log_button_clicked) + + self.plugin.send('ASK_CONFIG', None, ('GtkGui', 'Logger', {'lognotsep':1,\ + 'lognotusr':1})) + self.config_logger = self.plugin.wait('CONFIG') + + #log presences in user file + st = self.config_logger['lognotusr'] + self.xml.get_widget('chk_log_pres_usr').set_active(st) + + #log presences in external file + st = self.config_logger['lognotsep'] + self.xml.get_widget('chk_log_pres_ext').set_active(st) class accountPreference_Window: """Class for account informations""" @@ -637,7 +664,8 @@ class accountPreference_Window: entryProxyhost.get_text(), 'proxyport': proxyPort, 'keyid': keyID, \ 'keyname': keyName, 'savegpgpass': save_gpg_pass, \ 'gpgpass': gpg_pass} - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts)) + self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ + 'GtkGui')) #refresh accounts window if self.plugin.windows.has_key('accounts'): self.plugin.windows['accounts'].init_accounts() @@ -662,7 +690,8 @@ class accountPreference_Window: autoconnect, 'use_proxy': useProxy, 'proxyhost': \ entryProxyhost.get_text(), 'proxyport': proxyPort, 'keyid': keyID, \ 'keyname': keyName, 'savegpgpass': save_gpg_pass, 'gpgpass': gpg_pass} - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts)) + self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ + 'GtkGui')) #update variables self.plugin.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.plugin.queues[name] = {} @@ -792,7 +821,8 @@ class accounts_Window: if self.plugin.connected[account]: self.plugin.send('STATUS', account, ('offline', 'offline')) del self.plugin.accounts[account] - self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts)) + self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \ + 'GtkGui')) del self.plugin.windows[account] del self.plugin.queues[account] del self.plugin.connected[account] diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index d0231209f..1d0e37330 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -3626,6 +3626,63 @@ on the server. + + + + True + True + True + GTK_RELIEF_NONE + False + + + + + True + False + 0 + + + + True + gtk-justify-fill + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + Log + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 0 @@ -4882,6 +4939,133 @@ when NOT online tab + + + + True + + + + 344 + 122 + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + False + 0 + + + + True + True + Log presences in user's log file + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + True + Log presences in an external file + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + + + + + + + + True + <b>Log presences</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + 0 + + + + + False + True + + + + + + True + Log + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + 0 diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 51516f23d..06b796c8c 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -1535,7 +1535,7 @@ class roster_Window: """When we quit the gtk plugin : tell that to the core and exit gtk""" self.plugin.config['hiddenlines'] = string.join(self.hidden_lines, '\t') - self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config)) + self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) self.plugin.send('QUIT', None, ('gtkgui', 1)) print _("plugin gtkgui stopped") self.close_all(self.plugin.windows) @@ -1671,7 +1671,7 @@ class roster_Window: """when show offline option is changed : redraw the treeview""" self.plugin.config['showoffline'] = 1 - self.plugin.config['showoffline'] - self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config)) + self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) self.draw_roster() def iconCellDataFunc(self, column, renderer, model, iter, data=None): @@ -2243,7 +2243,7 @@ class plugin: 'use_proxy': array[6],\ 'proxyhost': array[7], \ 'proxyport': array[8]} - self.send('CONFIG', None, ('accounts', self.accounts)) + self.send('CONFIG', None, ('accounts', self.accounts, 'GtkGui')) self.windows[name] = {'infos': {}, 'chats': {}, 'gc': {}} self.queues[name] = {} self.connected[name] = 0 @@ -2478,7 +2478,7 @@ class plugin: import trayicon except: self.config['trayicon'] = 0 - self.send('CONFIG', None, ('GtkGui', self.config)) + self.send('CONFIG', None, ('GtkGui', self.config, 'GtkGui')) self.systray = systrayDummy() else: self.systray = systray(self) diff --git a/plugins/logger/logger.py b/plugins/logger/logger.py index e59ee9478..929420fdf 100644 --- a/plugins/logger/logger.py +++ b/plugins/logger/logger.py @@ -116,6 +116,9 @@ class plugin: t = time.mktime(ev[2][2]) fic.write("%s:recv:%s:%s\n" % (t, nick, msg)) fic.close() + elif ev[0] == 'CONFIG': + if ev[2][0] == 'Logger': + self.config = ev[2][1] time.sleep(0.1) def wait(self, what):