From 54f83079acb3ee9da8a06999ec444619f98f7cf3 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Mon, 11 Oct 2004 22:57:29 +0000 Subject: [PATCH] it is now possible to configure the roster style --- plugins/gtkgui/config.py | 149 ++++++----- plugins/gtkgui/gtkgui.glade | 507 +++++++++++++++++++++++++++++++----- plugins/gtkgui/gtkgui.py | 35 ++- 3 files changed, 545 insertions(+), 146 deletions(-) diff --git a/plugins/gtkgui/config.py b/plugins/gtkgui/config.py index c18911fa0..f4295bd1e 100644 --- a/plugins/gtkgui/config.py +++ b/plugins/gtkgui/config.py @@ -136,51 +136,53 @@ class preference_Window: """When Cancel button is clicked""" widget.get_toplevel().destroy() - def on_color_button_clicked(self, widget): - """Open a ColorSelectionDialog and change button's color""" - if widget.name == 'colorIn': - color = self.colorIn - da = self.da_in - elif widget.name == 'colorOut': - color = self.colorOut - da = self.da_out - elif widget.name == 'colorStatus': - color = self.colorStatus - da = self.da_status - colorseldlg = gtk.ColorSelectionDialog('Select Color') - colorsel = colorseldlg.colorsel - colorsel.set_previous_color(color) - colorsel.set_current_color(color) - colorsel.set_has_palette(gtk.TRUE) - response = colorseldlg.run() - if response == gtk.RESPONSE_OK: - color = colorsel.get_current_color() - da.modify_bg(gtk.STATE_NORMAL, color) - if widget.name == 'colorIn': - self.colorIn = color - elif widget.name == 'colorOut': - self.colorOut = color - elif widget.name == 'colorStatus': - self.colorStatus = color - colorseldlg.destroy() - def write_cfg(self): """Save preferences in config File and apply them""" #Color for incomming messages - colSt_in = '#'+(hex(self.colorIn.red)+'0')[2:4]\ - +(hex(self.colorIn.green)+'0')[2:4]\ - +(hex(self.colorIn.blue)+'0')[2:4] - self.plugin.config['inmsgcolor'] = colSt_in + color = self.xml.get_widget('colorbutton_in').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['inmsgcolor'] = colSt #Color for outgoing messages - colSt_out = '#'+(hex(self.colorOut.red)+'0')[2:4]\ - +(hex(self.colorOut.green)+'0')[2:4]\ - +(hex(self.colorOut.blue)+'0')[2:4] - self.plugin.config['outmsgcolor'] = colSt_out + color = self.xml.get_widget('colorbutton_out').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['outmsgcolor'] = colSt #Color for status messages - colSt_status = '#'+(hex(self.colorStatus.red)+'0')[2:4]\ - +(hex(self.colorStatus.green)+'0')[2:4]\ - +(hex(self.colorStatus.blue)+'0')[2:4] - self.plugin.config['statusmsgcolor'] = colSt_status + color = self.xml.get_widget('colorbutton_status').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['statusmsgcolor'] = colSt + #Color for account text + color = self.xml.get_widget('colorbutton_account_text').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['accounttextcolor'] = colSt + #Color for group text + color = self.xml.get_widget('colorbutton_group_text').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['grouptextcolor'] = colSt + #Color for user text + color = self.xml.get_widget('colorbutton_user_text').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['usertextcolor'] = colSt + #Color for background account + color = self.xml.get_widget('colorbutton_account_bg').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['accountbgcolor'] = colSt + #Color for background group + color = self.xml.get_widget('colorbutton_group_bg').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['groupbgcolor'] = colSt + #Color for background user + color = self.xml.get_widget('colorbutton_user_bg').get_color() + colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ + +(hex(color.blue)+'0')[2:4] + self.plugin.config['userbgcolor'] = colSt #update opened chat windows for a in self.plugin.accounts.keys(): for w in self.plugin.windows[a]['chats'].keys(): @@ -195,40 +197,35 @@ class preference_Window: self.plugin.config['iconstyle'] = ist self.plugin.roster.mkpixbufs() #autopopup - pp = self.chk_autopp.get_active() - if pp == True: + if self.chk_autopp.get_active(): self.plugin.config['autopopup'] = 1 else: self.plugin.config['autopopup'] = 0 #autopopupaway - ppaway = self.chk_autoppaway.get_active() - if ppaway == True: + if self.chk_autoppaway.get_active(): self.plugin.config['autopopupaway'] = 1 else: self.plugin.config['autopopupaway'] = 0 #autoaway - aw = self.chk_autoaway.get_active() - if aw == True: + if self.chk_autoaway.get_active(): self.plugin.config['autoaway'] = 1 else: self.plugin.config['autoaway'] = 0 aat = self.spin_autoawaytime.get_value_as_int() self.plugin.config['autoawaytime'] = aat #autoxa - xa = self.chk_autoxa.get_active() - if xa == True: + if self.chk_autoxa.get_active(): self.plugin.config['autoxa'] = 1 else: self.plugin.config['autoxa'] = 0 axt = self.spin_autoxatime.get_value_as_int() self.plugin.config['autoxatime'] = axt - if aw or xa: + if self.chk_autoaway.get_active() or self.chk_autoxa.get_active(): self.plugin.sleeper = common.sleepy.Sleepy(\ self.plugin.config['autoawaytime']*60, \ self.plugin.config['autoxatime']*60) #trayicon - trayicon = self.chk_trayicon.get_active() - if trayicon: + if self.chk_trayicon.get_active(): self.plugin.config['trayicon'] = 1 else: self.plugin.config['trayicon'] = 0 @@ -257,9 +254,6 @@ class preference_Window: self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Preferences', APP) self.window = self.xml.get_widget('Preferences') self.plugin = plugin - self.da_in = self.xml.get_widget('drawing_in') - self.da_out = self.xml.get_widget('drawing_out') - self.da_status = self.xml.get_widget('drawing_status') self.combo_iconstyle = self.xml.get_widget('combo_iconstyle') self.chk_autopp = self.xml.get_widget('chk_autopopup') self.chk_autoppaway = self.xml.get_widget('chk_autopopupaway') @@ -279,21 +273,18 @@ class preference_Window: #Color for incomming messages colSt = self.plugin.config['inmsgcolor'] - cmapIn = self.da_in.get_colormap() - self.colorIn = cmapIn.alloc_color(colSt) - self.da_in.window.set_background(self.colorIn) + self.xml.get_widget('colorbutton_in').set_color(\ + gtk.gdk.color_parse(colSt)) #Color for outgoing messages colSt = self.plugin.config['outmsgcolor'] - cmapOut = self.da_out.get_colormap() - self.colorOut = cmapOut.alloc_color(colSt) - self.da_out.window.set_background(self.colorOut) + self.xml.get_widget('colorbutton_out').set_color(\ + gtk.gdk.color_parse(colSt)) #Color for status messages colSt = self.plugin.config['statusmsgcolor'] - cmapStatus = self.da_status.get_colormap() - self.colorStatus = cmapStatus.alloc_color(colSt) - self.da_status.window.set_background(self.colorStatus) + self.xml.get_widget('colorbutton_status').set_color(\ + gtk.gdk.color_parse(colSt)) #iconStyle list_style = os.listdir('plugins/gtkgui/icons/') @@ -335,9 +326,37 @@ class preference_Window: st = self.plugin.config['trayicon'] self.chk_trayicon.set_active(st) + #Color for account text + colSt = self.plugin.config['accounttextcolor'] + self.xml.get_widget('colorbutton_account_text').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for group text + colSt = self.plugin.config['grouptextcolor'] + self.xml.get_widget('colorbutton_group_text').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for user text + colSt = self.plugin.config['usertextcolor'] + self.xml.get_widget('colorbutton_user_text').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for background account + colSt = self.plugin.config['accountbgcolor'] + self.xml.get_widget('colorbutton_account_bg').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for background group + colSt = self.plugin.config['groupbgcolor'] + self.xml.get_widget('colorbutton_group_bg').set_color(\ + gtk.gdk.color_parse(colSt)) + + #Color for background user + colSt = self.plugin.config['userbgcolor'] + self.xml.get_widget('colorbutton_user_bg').set_color(\ + gtk.gdk.color_parse(colSt)) + self.xml.signal_connect('gtk_widget_destroy', self.delete_event) - self.xml.signal_connect('on_but_col_clicked', \ - self.on_color_button_clicked) self.xml.signal_connect('on_ok_clicked', self.on_ok) self.xml.signal_connect('on_cancel_clicked', self.on_cancel) diff --git a/plugins/gtkgui/gtkgui.glade b/plugins/gtkgui/gtkgui.glade index 9b1809233..195334558 100644 --- a/plugins/gtkgui/gtkgui.glade +++ b/plugins/gtkgui/gtkgui.glade @@ -3653,71 +3653,6 @@ on the server. True - - - 144 - 112 - True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN - - - - True - False - 0 - - - - True - True - Icon in systray - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - - - - - - - True - Systray - False - True - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - label_item - - - - - 208 - 72 - - - 142 @@ -3762,9 +3697,9 @@ on the server. True - Icon Style + <b>Icon Style</b> False - False + True GTK_JUSTIFY_LEFT False False @@ -3784,10 +3719,75 @@ on the server. + + + 144 + 88 + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + False + 0 + + + + True + True + Icon in systray + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + + + + + + + True + <b>Systray</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 208 + 72 + + + - 200 - 200 + 192 + 160 True 0 0.5 @@ -3933,9 +3933,9 @@ on the server. True - Color + <b>Color</b> False - False + True GTK_JUSTIFY_LEFT False False @@ -3954,6 +3954,371 @@ on the server. 0 + + + + 352 + 171 + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 12 + 0 + + + + True + 4 + 4 + False + 5 + 5 + + + + True + Text color + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Account + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Group + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + User + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + Text font + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 0 + 1 + fill + + + + + + + True + Background color + False + False + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + + + 3 + 4 + 0 + 1 + fill + + + + + + + True + True + True + True + False + False + True + + + 2 + 3 + 1 + 2 + fill + + + + + + + True + True + False + True + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + True + False + True + + + 1 + 2 + 2 + 3 + fill + + + + + + + True + True + False + True + + + 1 + 2 + 3 + 4 + fill + + + + + + + True + True + True + True + False + False + True + + + 2 + 3 + 2 + 3 + fill + + + + + + + True + True + True + True + False + False + True + + + 2 + 3 + 3 + 4 + fill + + + + + + + True + True + False + True + + + 3 + 4 + 1 + 2 + fill + + + + + + + True + True + False + True + + + 3 + 4 + 2 + 3 + fill + + + + + + + True + True + False + True + + + 3 + 4 + 3 + 4 + fill + + + + + + + + + + + True + <b>Roster style</b> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + 168 + + False diff --git a/plugins/gtkgui/gtkgui.py b/plugins/gtkgui/gtkgui.py index 74473ff51..32fc09eb1 100644 --- a/plugins/gtkgui/gtkgui.py +++ b/plugins/gtkgui/gtkgui.py @@ -1666,33 +1666,42 @@ class roster_Window: def iconCellDataFunc(self, column, renderer, model, iter, data=None): """When a row is added, set properties for icon renderer""" if model.get_value(iter, 2) == 'account': - renderer.set_property('cell-background', '#9fdfff') + renderer.set_property('cell-background', \ + self.plugin.config['accountbgcolor']) renderer.set_property('xalign', 0) elif model.get_value(iter, 2) == 'group': - renderer.set_property('cell-background-set', False) + renderer.set_property('cell-background', \ + self.plugin.config['groupbgcolor']) renderer.set_property('xalign', 0.3) else: - renderer.set_property('cell-background-set', False) + renderer.set_property('cell-background', \ + self.plugin.config['userbgcolor']) renderer.set_property('xalign', 1) renderer.set_property('width', 30) def nameCellDataFunc(self, column, renderer, model, iter, data=None): """When a row is added, set properties for name renderer""" if model.get_value(iter, 2) == 'account': - renderer.set_property('foreground', 'red') - renderer.set_property('cell-background', '#9fdfff') + renderer.set_property('foreground', \ + self.plugin.config['accounttextcolor']) + renderer.set_property('cell-background', \ + self.plugin.config['accountbgcolor']) renderer.set_property('font', 'Normal') renderer.set_property('weight', 700) renderer.set_property('xpad', 0) elif model.get_value(iter, 2) == 'group': - renderer.set_property('foreground', 'blue') - renderer.set_property('cell-background-set', False) + renderer.set_property('foreground', \ + self.plugin.config['grouptextcolor']) + renderer.set_property('cell-background', \ + self.plugin.config['groupbgcolor']) renderer.set_property('font', 'Italic') renderer.set_property('weight-set', False) renderer.set_property('xpad', 8) else: - renderer.set_property('foreground-set', False) - renderer.set_property('cell-background-set', False) + renderer.set_property('foreground', \ + self.plugin.config['usertextcolor']) + renderer.set_property('cell-background', \ + self.plugin.config['userbgcolor']) renderer.set_property('font', 'Normal') renderer.set_property('weight-set', False) renderer.set_property('xpad', 16) @@ -2363,7 +2372,13 @@ class plugin: 'inmsgcolor':'#ff0000',\ 'outmsgcolor': '#0000ff',\ 'statusmsgcolor':'#1eaa1e',\ - 'hiddenlines':''})) + 'hiddenlines':'',\ + 'accounttextcolor': '#ff0000',\ + 'accountbgcolor': '#9fdfff',\ + 'grouptextcolor': '#0000ff',\ + 'groupbgcolor': '#ffffff',\ + 'usertextcolor': '#000000',\ + 'userbgcolor': '#ffffff'})) self.config = self.wait('CONFIG') self.send('ASK_CONFIG', None, ('GtkGui', 'accounts')) self.accounts = self.wait('CONFIG')