| 1 | ## plugins/config.py |
|---|
| 2 | ## |
|---|
| 3 | ## Gajim Team: |
|---|
| 4 | ## - Yann Le Boulanger <asterix@crans.org> |
|---|
| 5 | ## - Vincent Hanquez <tab@snarc.org> |
|---|
| 6 | ## |
|---|
| 7 | ## Copyright (C) 2003 Gajim Team |
|---|
| 8 | ## |
|---|
| 9 | ## This program is free software; you can redistribute it and/or modify |
|---|
| 10 | ## it under the terms of the GNU General Public License as published |
|---|
| 11 | ## by the Free Software Foundation; version 2 only. |
|---|
| 12 | ## |
|---|
| 13 | ## This program is distributed in the hope that it will be useful, |
|---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | ## GNU General Public License for more details. |
|---|
| 17 | ## |
|---|
| 18 | |
|---|
| 19 | import pygtk |
|---|
| 20 | pygtk.require('2.0') |
|---|
| 21 | import gtk |
|---|
| 22 | from gtk import TRUE, FALSE |
|---|
| 23 | import gtk.glade,gobject |
|---|
| 24 | import os,string |
|---|
| 25 | import common.sleepy |
|---|
| 26 | from common import i18n |
|---|
| 27 | _ = i18n._ |
|---|
| 28 | APP = i18n.APP |
|---|
| 29 | gtk.glade.bindtextdomain (APP, i18n.DIR) |
|---|
| 30 | gtk.glade.textdomain (APP) |
|---|
| 31 | |
|---|
| 32 | from dialogs import * |
|---|
| 33 | import gtkgui |
|---|
| 34 | |
|---|
| 35 | GTKGUI_GLADE='plugins/gtkgui/gtkgui.glade' |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | class vCard_Window: |
|---|
| 39 | """Class for window that show vCard information""" |
|---|
| 40 | def delete_event(self, widget=None): |
|---|
| 41 | """close window""" |
|---|
| 42 | del self.plugin.windows[self.account]['infos'][self.jid] |
|---|
| 43 | |
|---|
| 44 | def on_close(self, widget): |
|---|
| 45 | """When Close button is clicked""" |
|---|
| 46 | widget.get_toplevel().destroy() |
|---|
| 47 | |
|---|
| 48 | def set_value(self, entry_name, value): |
|---|
| 49 | try: |
|---|
| 50 | self.xml.get_widget(entry_name).set_text(value) |
|---|
| 51 | except AttributeError, e: |
|---|
| 52 | pass |
|---|
| 53 | |
|---|
| 54 | def set_values(self, vcard): |
|---|
| 55 | for i in vcard.keys(): |
|---|
| 56 | if type(vcard[i]) == type({}): |
|---|
| 57 | for j in vcard[i].keys(): |
|---|
| 58 | self.set_value('entry_'+i+'_'+j, vcard[i][j]) |
|---|
| 59 | else: |
|---|
| 60 | if i == 'DESC': |
|---|
| 61 | self.xml.get_widget('textview_DESC').get_buffer().\ |
|---|
| 62 | set_text(vcard[i], 0) |
|---|
| 63 | else: |
|---|
| 64 | self.set_value('entry_'+i, vcard[i]) |
|---|
| 65 | |
|---|
| 66 | def add_to_vcard(self, vcard, entry, txt): |
|---|
| 67 | """Add an information to the vCard dictionary""" |
|---|
| 68 | entries = string.split(entry, '_') |
|---|
| 69 | loc = vcard |
|---|
| 70 | while len(entries) > 1: |
|---|
| 71 | if not loc.has_key(entries[0]): |
|---|
| 72 | loc[entries[0]] = {} |
|---|
| 73 | loc = loc[entries[0]] |
|---|
| 74 | del entries[0] |
|---|
| 75 | loc[entries[0]] = txt |
|---|
| 76 | return vcard |
|---|
| 77 | |
|---|
| 78 | def make_vcard(self): |
|---|
| 79 | """make the vCard dictionary""" |
|---|
| 80 | entries = ['FN', 'NICKNAME', 'BDAY', 'EMAIL_USERID', 'URL', 'TEL_NUMBER',\ |
|---|
| 81 | 'ADR_STREET', 'ADR_EXTADR', 'ADR_LOCALITY', 'ADR_REGION', 'ADR_PCODE',\ |
|---|
| 82 | 'ADR_CTRY', 'ORG_ORGNAME', 'ORG_ORGUNIT', 'TITLE', 'ROLE'] |
|---|
| 83 | vcard = {} |
|---|
| 84 | for e in entries: |
|---|
| 85 | txt = self.xml.get_widget('entry_'+e).get_text() |
|---|
| 86 | if txt != '': |
|---|
| 87 | vcard = self.add_to_vcard(vcard, e, txt) |
|---|
| 88 | buf = self.xml.get_widget('textview_DESC').get_buffer() |
|---|
| 89 | start_iter = buf.get_start_iter() |
|---|
| 90 | end_iter = buf.get_end_iter() |
|---|
| 91 | txt = buf.get_text(start_iter, end_iter, 0) |
|---|
| 92 | if txt != '': |
|---|
| 93 | vcard['DESC']= txt |
|---|
| 94 | return vcard |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | def on_retrieve(self, widget): |
|---|
| 98 | if self.plugin.connected[self.account]: |
|---|
| 99 | self.plugin.send('ASK_VCARD', self.account, self.jid) |
|---|
| 100 | else: |
|---|
| 101 | warning_Window(_("You must be connected to get your informations")) |
|---|
| 102 | |
|---|
| 103 | def on_publish(self, widget): |
|---|
| 104 | if not self.plugin.connected[self.account]: |
|---|
| 105 | warning_Window(_("You must be connected to publish your informations")) |
|---|
| 106 | return |
|---|
| 107 | vcard = self.make_vcard() |
|---|
| 108 | nick = '' |
|---|
| 109 | if vcard.has_key('NICKNAME'): |
|---|
| 110 | nick = vcard['NICKNAME'] |
|---|
| 111 | if nick == '': |
|---|
| 112 | nick = self.plugin.accounts[self.account]['name'] |
|---|
| 113 | self.plugin.nicks[self.account] = nick |
|---|
| 114 | self.plugin.send('VCARD', self.account, vcard) |
|---|
| 115 | |
|---|
| 116 | def __init__(self, jid, plugin, account): |
|---|
| 117 | self.xml = gtk.glade.XML(GTKGUI_GLADE, 'vcard', APP) |
|---|
| 118 | self.window = self.xml.get_widget('vcard') |
|---|
| 119 | self.jid = jid |
|---|
| 120 | self.plugin = plugin |
|---|
| 121 | self.account = account |
|---|
| 122 | |
|---|
| 123 | self.xml.signal_connect('gtk_widget_destroy', self.delete_event) |
|---|
| 124 | self.xml.signal_connect('on_close_clicked', self.on_close) |
|---|
| 125 | self.xml.signal_connect('on_retrieve_clicked', self.on_retrieve) |
|---|
| 126 | self.xml.signal_connect('on_publish_clicked', self.on_publish) |
|---|
| 127 | |
|---|
| 128 | class preference_Window: |
|---|
| 129 | """Class for Preferences window""" |
|---|
| 130 | def delete_event(self, widget): |
|---|
| 131 | """close window""" |
|---|
| 132 | del self.plugin.windows['preferences'] |
|---|
| 133 | |
|---|
| 134 | def on_cancel(self, widget): |
|---|
| 135 | """When Cancel button is clicked""" |
|---|
| 136 | widget.get_toplevel().destroy() |
|---|
| 137 | |
|---|
| 138 | def write_cfg(self): |
|---|
| 139 | """Save preferences in config File and apply them""" |
|---|
| 140 | #Color for incomming messages |
|---|
| 141 | color = self.xml.get_widget('colorbutton_in').get_color() |
|---|
| 142 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 143 | +(hex(color.blue)+'0')[2:4] |
|---|
| 144 | self.plugin.config['inmsgcolor'] = colSt |
|---|
| 145 | #Color for outgoing messages |
|---|
| 146 | color = self.xml.get_widget('colorbutton_out').get_color() |
|---|
| 147 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 148 | +(hex(color.blue)+'0')[2:4] |
|---|
| 149 | self.plugin.config['outmsgcolor'] = colSt |
|---|
| 150 | #Color for status messages |
|---|
| 151 | color = self.xml.get_widget('colorbutton_status').get_color() |
|---|
| 152 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 153 | +(hex(color.blue)+'0')[2:4] |
|---|
| 154 | self.plugin.config['statusmsgcolor'] = colSt |
|---|
| 155 | #Color for account text |
|---|
| 156 | color = self.xml.get_widget('colorbutton_account_text').get_color() |
|---|
| 157 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 158 | +(hex(color.blue)+'0')[2:4] |
|---|
| 159 | self.plugin.config['accounttextcolor'] = colSt |
|---|
| 160 | #Color for group text |
|---|
| 161 | color = self.xml.get_widget('colorbutton_group_text').get_color() |
|---|
| 162 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 163 | +(hex(color.blue)+'0')[2:4] |
|---|
| 164 | self.plugin.config['grouptextcolor'] = colSt |
|---|
| 165 | #Color for user text |
|---|
| 166 | color = self.xml.get_widget('colorbutton_user_text').get_color() |
|---|
| 167 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 168 | +(hex(color.blue)+'0')[2:4] |
|---|
| 169 | self.plugin.config['usertextcolor'] = colSt |
|---|
| 170 | #Color for background account |
|---|
| 171 | color = self.xml.get_widget('colorbutton_account_bg').get_color() |
|---|
| 172 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 173 | +(hex(color.blue)+'0')[2:4] |
|---|
| 174 | self.plugin.config['accountbgcolor'] = colSt |
|---|
| 175 | #Color for background group |
|---|
| 176 | color = self.xml.get_widget('colorbutton_group_bg').get_color() |
|---|
| 177 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 178 | +(hex(color.blue)+'0')[2:4] |
|---|
| 179 | self.plugin.config['groupbgcolor'] = colSt |
|---|
| 180 | #Color for background user |
|---|
| 181 | color = self.xml.get_widget('colorbutton_user_bg').get_color() |
|---|
| 182 | colSt = '#'+(hex(color.red)+'0')[2:4] + (hex(color.green)+'0')[2:4]\ |
|---|
| 183 | +(hex(color.blue)+'0')[2:4] |
|---|
| 184 | self.plugin.config['userbgcolor'] = colSt |
|---|
| 185 | #Font for account |
|---|
| 186 | fontStr = self.xml.get_widget('fontbutton_account_text').get_font_name() |
|---|
| 187 | self.plugin.config['accountfont'] = fontStr |
|---|
| 188 | #Font for group |
|---|
| 189 | fontStr = self.xml.get_widget('fontbutton_group_text').get_font_name() |
|---|
| 190 | self.plugin.config['groupfont'] = fontStr |
|---|
| 191 | #Font for user |
|---|
| 192 | fontStr = self.xml.get_widget('fontbutton_user_text').get_font_name() |
|---|
| 193 | self.plugin.config['userfont'] = fontStr |
|---|
| 194 | #update opened chat windows |
|---|
| 195 | for a in self.plugin.accounts.keys(): |
|---|
| 196 | for w in self.plugin.windows[a]['chats'].keys(): |
|---|
| 197 | self.plugin.windows[a]['chats'][w].tagIn.\ |
|---|
| 198 | set_property("foreground", self.plugin.config['inmsgcolor']) |
|---|
| 199 | self.plugin.windows[a]['chats'][w].tagOut.\ |
|---|
| 200 | set_property("foreground", self.plugin.config['outmsgcolor']) |
|---|
| 201 | self.plugin.windows[a]['chats'][w].tagStatus.\ |
|---|
| 202 | set_property("foreground", self.plugin.config['statusmsgcolor']) |
|---|
| 203 | #IconStyle |
|---|
| 204 | ist = self.combo_iconstyle.entry.get_text() |
|---|
| 205 | self.plugin.config['iconstyle'] = ist |
|---|
| 206 | self.plugin.roster.mkpixbufs() |
|---|
| 207 | #save position |
|---|
| 208 | chk = self.xml.get_widget('save_position_checkbutton') |
|---|
| 209 | if chk.get_active(): |
|---|
| 210 | self.plugin.config['saveposition'] = 1 |
|---|
| 211 | else: |
|---|
| 212 | self.plugin.config['saveposition'] = 0 |
|---|
| 213 | #autopopup |
|---|
| 214 | if self.chk_autopp.get_active(): |
|---|
| 215 | self.plugin.config['autopopup'] = 1 |
|---|
| 216 | else: |
|---|
| 217 | self.plugin.config['autopopup'] = 0 |
|---|
| 218 | #autopopupaway |
|---|
| 219 | if self.chk_autoppaway.get_active(): |
|---|
| 220 | self.plugin.config['autopopupaway'] = 1 |
|---|
| 221 | else: |
|---|
| 222 | self.plugin.config['autopopupaway'] = 0 |
|---|
| 223 | #autoaway |
|---|
| 224 | if self.chk_autoaway.get_active(): |
|---|
| 225 | self.plugin.config['autoaway'] = 1 |
|---|
| 226 | else: |
|---|
| 227 | self.plugin.config['autoaway'] = 0 |
|---|
| 228 | aat = self.spin_autoawaytime.get_value_as_int() |
|---|
| 229 | self.plugin.config['autoawaytime'] = aat |
|---|
| 230 | #autoxa |
|---|
| 231 | if self.chk_autoxa.get_active(): |
|---|
| 232 | self.plugin.config['autoxa'] = 1 |
|---|
| 233 | else: |
|---|
| 234 | self.plugin.config['autoxa'] = 0 |
|---|
| 235 | axt = self.spin_autoxatime.get_value_as_int() |
|---|
| 236 | self.plugin.config['autoxatime'] = axt |
|---|
| 237 | self.plugin.sleeper = common.sleepy.Sleepy(\ |
|---|
| 238 | self.plugin.config['autoawaytime']*60, \ |
|---|
| 239 | self.plugin.config['autoxatime']*60) |
|---|
| 240 | #Status messages |
|---|
| 241 | model = self.msg_tree.get_model() |
|---|
| 242 | iter = model.get_iter_first() |
|---|
| 243 | i = 0 |
|---|
| 244 | while iter: |
|---|
| 245 | self.plugin.config['msg%i_name' % i] = model.get_value(iter, 0) |
|---|
| 246 | self.plugin.config['msg%i' % i] = model.get_value(iter, 1) |
|---|
| 247 | iter = model.iter_next(iter) |
|---|
| 248 | i += 1 |
|---|
| 249 | while self.plugin.config.has_key('msg%s_name' % i): |
|---|
| 250 | del self.plugin.config['msg%i_name' % i] |
|---|
| 251 | del self.plugin.config['msg%i' % i] |
|---|
| 252 | i += 1 |
|---|
| 253 | #trayicon |
|---|
| 254 | if self.chk_trayicon.get_active(): |
|---|
| 255 | self.plugin.config['trayicon'] = 1 |
|---|
| 256 | self.plugin.show_systray() |
|---|
| 257 | else: |
|---|
| 258 | self.plugin.config['trayicon'] = 0 |
|---|
| 259 | self.plugin.hide_systray() |
|---|
| 260 | self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui')) |
|---|
| 261 | self.plugin.roster.draw_roster() |
|---|
| 262 | #log presences in user file |
|---|
| 263 | if self.xml.get_widget('chk_log_pres_usr').get_active(): |
|---|
| 264 | self.config_logger['lognotusr'] = 1 |
|---|
| 265 | else: |
|---|
| 266 | self.config_logger['lognotusr'] = 0 |
|---|
| 267 | #log presences in external file |
|---|
| 268 | if self.xml.get_widget('chk_log_pres_ext').get_active(): |
|---|
| 269 | self.config_logger['lognotsep'] = 1 |
|---|
| 270 | else: |
|---|
| 271 | self.config_logger['lognotsep'] = 0 |
|---|
| 272 | self.plugin.send('CONFIG', None, ('Logger', self.config_logger, 'GtkGui')) |
|---|
| 273 | |
|---|
| 274 | def on_ok(self, widget): |
|---|
| 275 | """When Ok button is clicked""" |
|---|
| 276 | self.write_cfg() |
|---|
| 277 | self.xml.get_widget('Preferences').destroy() |
|---|
| 278 | |
|---|
| 279 | def on_apply(self, widget): |
|---|
| 280 | """When Apply button is clicked""" |
|---|
| 281 | self.write_cfg() |
|---|
| 282 | |
|---|
| 283 | def change_notebook_page(self, number): |
|---|
| 284 | self.notebook.set_current_page(number) |
|---|
| 285 | |
|---|
| 286 | def on_lookfeel_button_clicked(self, widget, data=None): |
|---|
| 287 | self.change_notebook_page(0) |
|---|
| 288 | |
|---|
| 289 | def on_events_button_clicked(self, widget, data=None): |
|---|
| 290 | self.change_notebook_page(1) |
|---|
| 291 | |
|---|
| 292 | def on_presence_button_clicked(self, widget, data=None): |
|---|
| 293 | self.change_notebook_page(2) |
|---|
| 294 | |
|---|
| 295 | def on_log_button_clicked(self, widget, data=None): |
|---|
| 296 | self.change_notebook_page(3) |
|---|
| 297 | |
|---|
| 298 | def fill_msg_treeview(self): |
|---|
| 299 | i = 0 |
|---|
| 300 | self.xml.get_widget('delete_msg_button').set_sensitive(False) |
|---|
| 301 | model = self.msg_tree.get_model() |
|---|
| 302 | model.clear() |
|---|
| 303 | while self.plugin.config.has_key('msg%s_name' % i): |
|---|
| 304 | iter = model.append() |
|---|
| 305 | model.set(iter, 0, self.plugin.config['msg%s_name' % i], 1, self.plugin.config['msg%s' % i]) |
|---|
| 306 | i += 1 |
|---|
| 307 | |
|---|
| 308 | def on_msg_cell_edited(self, cell, row, new_text): |
|---|
| 309 | model = self.msg_tree.get_model() |
|---|
| 310 | iter = model.get_iter_from_string(row) |
|---|
| 311 | model.set_value(iter, 0, new_text) |
|---|
| 312 | |
|---|
| 313 | def on_msg_treeview_cursor_changed(self, widget, data=None): |
|---|
| 314 | self.xml.get_widget('delete_msg_button').set_sensitive(True) |
|---|
| 315 | buf = self.xml.get_widget('msg_textview').get_buffer() |
|---|
| 316 | (model, iter) = self.msg_tree.get_selection().get_selected() |
|---|
| 317 | name = model.get_value(iter, 0) |
|---|
| 318 | msg = model.get_value(iter, 1) |
|---|
| 319 | buf.set_text(msg) |
|---|
| 320 | |
|---|
| 321 | def on_new_msg_button_clicked(self, widget, data=None): |
|---|
| 322 | model = self.msg_tree.get_model() |
|---|
| 323 | iter = model.append() |
|---|
| 324 | model.set(iter, 0, 'msg', 1, 'message') |
|---|
| 325 | |
|---|
| 326 | def on_delete_msg_button_clicked(self, widget, data=None): |
|---|
| 327 | (model, iter) = self.msg_tree.get_selection().get_selected() |
|---|
| 328 | buf = self.xml.get_widget('msg_textview').get_buffer() |
|---|
| 329 | model.remove(iter) |
|---|
| 330 | buf.set_text('') |
|---|
| 331 | self.xml.get_widget('delete_msg_button').set_sensitive(False) |
|---|
| 332 | |
|---|
| 333 | def on_msg_textview_changed(self, widget, data=None): |
|---|
| 334 | (model, iter) = self.msg_tree.get_selection().get_selected() |
|---|
| 335 | if not iter: |
|---|
| 336 | return |
|---|
| 337 | buf = self.xml.get_widget('msg_textview').get_buffer() |
|---|
| 338 | first_iter, end_iter = buf.get_bounds() |
|---|
| 339 | name = model.get_value(iter, 0) |
|---|
| 340 | model.set_value(iter, 1, buf.get_text(first_iter, end_iter)) |
|---|
| 341 | |
|---|
| 342 | def on_chk_toggled(self, widget, widgets): |
|---|
| 343 | """set or unset sensitivity of widgets when widget is toggled""" |
|---|
| 344 | for w in widgets: |
|---|
| 345 | w.set_sensitive(widget.get_active()) |
|---|
| 346 | |
|---|
| 347 | def __init__(self, plugin): |
|---|
| 348 | """Initialize Preference window""" |
|---|
| 349 | self.xml = gtk.glade.XML(GTKGUI_GLADE, 'Preferences', APP) |
|---|
| 350 | self.window = self.xml.get_widget('Preferences') |
|---|
| 351 | self.plugin = plugin |
|---|
| 352 | self.combo_iconstyle = self.xml.get_widget('combo_iconstyle') |
|---|
| 353 | self.chk_autopp = self.xml.get_widget('chk_autopopup') |
|---|
| 354 | self.chk_autoppaway = self.xml.get_widget('chk_autopopupaway') |
|---|
| 355 | self.chk_autoaway = self.xml.get_widget('chk_autoaway') |
|---|
| 356 | self.spin_autoawaytime = self.xml.get_widget('spin_autoawaytime') |
|---|
| 357 | self.chk_autoxa = self.xml.get_widget('chk_autoxa') |
|---|
| 358 | self.spin_autoxatime = self.xml.get_widget('spin_autoxatime') |
|---|
| 359 | self.chk_trayicon = self.xml.get_widget('chk_trayicon') |
|---|
| 360 | self.notebook = self.xml.get_widget('preferences_notebook') |
|---|
| 361 | |
|---|
| 362 | #Color for incomming messages |
|---|
| 363 | colSt = self.plugin.config['inmsgcolor'] |
|---|
| 364 | self.xml.get_widget('colorbutton_in').set_color(\ |
|---|
| 365 | gtk.gdk.color_parse(colSt)) |
|---|
| 366 | |
|---|
| 367 | #Color for outgoing messages |
|---|
| 368 | colSt = self.plugin.config['outmsgcolor'] |
|---|
| 369 | self.xml.get_widget('colorbutton_out').set_color(\ |
|---|
| 370 | gtk.gdk.color_parse(colSt)) |
|---|
| 371 | |
|---|
| 372 | #Color for status messages |
|---|
| 373 | colSt = self.plugin.config['statusmsgcolor'] |
|---|
| 374 | self.xml.get_widget('colorbutton_status').set_color(\ |
|---|
| 375 | gtk.gdk.color_parse(colSt)) |
|---|
| 376 | |
|---|
| 377 | #iconStyle |
|---|
| 378 | list_style = os.listdir('plugins/gtkgui/icons/') |
|---|
| 379 | l = [] |
|---|
| 380 | for i in list_style: |
|---|
| 381 | if i != 'CVS' and i[0] != '.': |
|---|
| 382 | l.append(i) |
|---|
| 383 | if l.count == 0: |
|---|
| 384 | l.append(" ") |
|---|
| 385 | self.combo_iconstyle.set_popdown_strings(l) |
|---|
| 386 | if self.plugin.config['iconstyle'] in l: |
|---|
| 387 | self.combo_iconstyle.entry.set_text(self.plugin.config['iconstyle']) |
|---|
| 388 | |
|---|
| 389 | #Save position |
|---|
| 390 | st = self.plugin.config['saveposition'] |
|---|
| 391 | self.xml.get_widget('save_position_checkbutton').set_active(st) |
|---|
| 392 | |
|---|
| 393 | #Autopopup |
|---|
| 394 | st = self.plugin.config['autopopup'] |
|---|
| 395 | self.chk_autopp.set_active(st) |
|---|
| 396 | |
|---|
| 397 | #Autopopupaway |
|---|
| 398 | st = self.plugin.config['autopopupaway'] |
|---|
| 399 | self.chk_autoppaway.set_active(st) |
|---|
| 400 | self.chk_autoppaway.set_sensitive(self.plugin.config['autopopup']) |
|---|
| 401 | |
|---|
| 402 | #Autoaway |
|---|
| 403 | st = self.plugin.config['autoaway'] |
|---|
| 404 | self.chk_autoaway.set_active(st) |
|---|
| 405 | |
|---|
| 406 | #Autoawaytime |
|---|
| 407 | st = self.plugin.config['autoawaytime'] |
|---|
| 408 | self.spin_autoawaytime.set_value(st) |
|---|
| 409 | self.spin_autoawaytime.set_sensitive(self.plugin.config['autoaway']) |
|---|
| 410 | |
|---|
| 411 | #Autoxa |
|---|
| 412 | st = self.plugin.config['autoxa'] |
|---|
| 413 | self.chk_autoxa.set_active(st) |
|---|
| 414 | |
|---|
| 415 | #Autoxatime |
|---|
| 416 | st = self.plugin.config['autoxatime'] |
|---|
| 417 | self.spin_autoxatime.set_value(st) |
|---|
| 418 | self.spin_autoxatime.set_sensitive(self.plugin.config['autoxa']) |
|---|
| 419 | |
|---|
| 420 | #Status messages |
|---|
| 421 | self.msg_tree = self.xml.get_widget('msg_treeview') |
|---|
| 422 | model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) |
|---|
| 423 | self.msg_tree.set_model(model) |
|---|
| 424 | col = gtk.TreeViewColumn('name') |
|---|
| 425 | self.msg_tree.append_column(col) |
|---|
| 426 | renderer = gtk.CellRendererText() |
|---|
| 427 | col.pack_start(renderer, True) |
|---|
| 428 | col.set_attributes(renderer, text=0) |
|---|
| 429 | renderer.connect('edited', self.on_msg_cell_edited) |
|---|
| 430 | renderer.set_property('editable', True) |
|---|
| 431 | self.fill_msg_treeview() |
|---|
| 432 | buf = self.xml.get_widget('msg_textview').get_buffer() |
|---|
| 433 | buf.connect('changed', self.on_msg_textview_changed) |
|---|
| 434 | |
|---|
| 435 | #trayicon |
|---|
| 436 | st = self.plugin.config['trayicon'] |
|---|
| 437 | self.chk_trayicon.set_active(st) |
|---|
| 438 | if isinstance(self.plugin.systray, gtkgui.systrayDummy): |
|---|
| 439 | self.chk_trayicon.set_sensitive(False) |
|---|
| 440 | |
|---|
| 441 | #Color for account text |
|---|
| 442 | colSt = self.plugin.config['accounttextcolor'] |
|---|
| 443 | self.xml.get_widget('colorbutton_account_text').set_color(\ |
|---|
| 444 | gtk.gdk.color_parse(colSt)) |
|---|
| 445 | |
|---|
| 446 | #Color for group text |
|---|
| 447 | colSt = self.plugin.config['grouptextcolor'] |
|---|
| 448 | self.xml.get_widget('colorbutton_group_text').set_color(\ |
|---|
| 449 | gtk.gdk.color_parse(colSt)) |
|---|
| 450 | |
|---|
| 451 | #Color for user text |
|---|
| 452 | colSt = self.plugin.config['usertextcolor'] |
|---|
| 453 | self.xml.get_widget('colorbutton_user_text').set_color(\ |
|---|
| 454 | gtk.gdk.color_parse(colSt)) |
|---|
| 455 | |
|---|
| 456 | #Color for background account |
|---|
| 457 | colSt = self.plugin.config['accountbgcolor'] |
|---|
| 458 | self.xml.get_widget('colorbutton_account_bg').set_color(\ |
|---|
| 459 | gtk.gdk.color_parse(colSt)) |
|---|
| 460 | |
|---|
| 461 | #Color for background group |
|---|
| 462 | colSt = self.plugin.config['groupbgcolor'] |
|---|
| 463 | self.xml.get_widget('colorbutton_group_bg').set_color(\ |
|---|
| 464 | gtk.gdk.color_parse(colSt)) |
|---|
| 465 | |
|---|
| 466 | #Color for background user |
|---|
| 467 | colSt = self.plugin.config['userbgcolor'] |
|---|
| 468 | self.xml.get_widget('colorbutton_user_bg').set_color(\ |
|---|
| 469 | gtk.gdk.color_parse(colSt)) |
|---|
| 470 | |
|---|
| 471 | #font for account |
|---|
| 472 | fontStr = self.plugin.config['accountfont'] |
|---|
| 473 | self.xml.get_widget('fontbutton_account_text').set_font_name(fontStr) |
|---|
| 474 | |
|---|
| 475 | #font for group |
|---|
| 476 | fontStr = self.plugin.config['groupfont'] |
|---|
| 477 | self.xml.get_widget('fontbutton_group_text').set_font_name(fontStr) |
|---|
| 478 | |
|---|
| 479 | #font for account |
|---|
| 480 | fontStr = self.plugin.config['userfont'] |
|---|
| 481 | self.xml.get_widget('fontbutton_user_text').set_font_name(fontStr) |
|---|
| 482 | |
|---|
| 483 | self.xml.signal_connect('gtk_widget_destroy', self.delete_event) |
|---|
| 484 | self.xml.signal_connect('on_apply_clicked', self.on_apply) |
|---|
| 485 | self.xml.signal_connect('on_ok_clicked', self.on_ok) |
|---|
| 486 | self.xml.signal_connect('on_cancel_clicked', self.on_cancel) |
|---|
| 487 | self.xml.signal_connect('on_msg_treeview_cursor_changed', \ |
|---|
| 488 | self.on_msg_treeview_cursor_changed) |
|---|
| 489 | self.xml.signal_connect('on_new_msg_button_clicked', \ |
|---|
| 490 | self.on_new_msg_button_clicked) |
|---|
| 491 | self.xml.signal_connect('on_delete_msg_button_clicked', \ |
|---|
| 492 | self.on_delete_msg_button_clicked) |
|---|
| 493 | self.xml.signal_connect('on_chk_autopopup_toggled', \ |
|---|
| 494 | self.on_chk_toggled, [self.chk_autoppaway]) |
|---|
| 495 | self.xml.signal_connect('on_chk_autoaway_toggled', \ |
|---|
| 496 | self.on_chk_toggled, [self.spin_autoawaytime]) |
|---|
| 497 | self.xml.signal_connect('on_chk_autoxa_toggled', \ |
|---|
| 498 | self.on_chk_toggled, [self.spin_autoxatime]) |
|---|
| 499 | self.xml.signal_connect('on_lookfeel_button_clicked', \ |
|---|
| 500 | self.on_lookfeel_button_clicked) |
|---|
| 501 | self.xml.signal_connect('on_events_button_clicked', \ |
|---|
| 502 | self.on_events_button_clicked) |
|---|
| 503 | self.xml.signal_connect('on_presence_button_clicked', \ |
|---|
| 504 | self.on_presence_button_clicked) |
|---|
| 505 | self.xml.signal_connect('on_log_button_clicked', \ |
|---|
| 506 | self.on_log_button_clicked) |
|---|