From 11d9f5398d52629ecc380d270a329d954375ebf6 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sun, 5 Mar 2006 12:18:47 +0000 Subject: [PATCH] preferences window is created on the fly like every other window (well apart from FT [TODO for that]); this is good as we do not want such window to sit in memory; also fix some border width and spacing in prefs window --- src/advanced.py | 2 -- src/config.py | 66 +++++++++++++++++++------------------------- src/gajim.py | 1 - src/gtkgui.glade | 7 ++--- src/roster_window.py | 4 +-- 5 files changed, 33 insertions(+), 47 deletions(-) diff --git a/src/advanced.py b/src/advanced.py index 6ccbe30f2..78db60f8f 100644 --- a/src/advanced.py +++ b/src/advanced.py @@ -205,8 +205,6 @@ class AdvancedConfigurationWindow: self.check_for_restart() def on_advanced_configuration_window_destroy(self, widget): - # update ui of preferences window to get possible changes we did - gajim.interface.instances['preferences'].update_preferences_window() del gajim.interface.instances['advanced_config'] def on_advanced_close_button_clicked(self, widget): diff --git a/src/config.py b/src/config.py index 39ce8a0cc..0e8eaeb7f 100644 --- a/src/config.py +++ b/src/config.py @@ -52,12 +52,12 @@ GTKGUI_GLADE = 'gtkgui.glade' class PreferencesWindow: '''Class for Preferences window''' - def on_preferences_window_delete_event(self, widget, event): - self.window.hide() - return True # do NOT destroy the window + def on_preferences_window_destroy(self, widget): + '''close window''' + del gajim.interface.instances['preferences'] def on_close_button_clicked(self, widget): - self.window.hide() + self.window.destroy() def __init__(self): '''Initialize Preferences window''' @@ -168,6 +168,15 @@ class PreferencesWindow: theme_combobox.add_attribute(cell, 'text', 0) model = gtk.ListStore(str) theme_combobox.set_model(model) + + i = 0 + for config_theme in gajim.config.get_per('themes'): + theme = config_theme.replace('_', ' ') + model.append([theme]) + if gajim.config.get('roster_theme') == config_theme: + theme_combobox.set_active(i) + i += 1 + self.on_theme_combobox_changed(theme_combobox) #use speller if os.name == 'nt': @@ -409,6 +418,20 @@ class PreferencesWindow: st = gajim.config.get('send_os_info') self.xml.get_widget('send_os_info_checkbutton').set_active(st) + # Notify user of new gmail e-mail messages, + # only show checkbox if user has a gtalk account + notify_gmail_checkbutton = self.xml.get_widget('notify_gmail_checkbutton') + notify_gmail_checkbutton.set_no_show_all(True) + for account in gajim.config.get_per('accounts'): + jid = gajim.get_jid_from_account(account) + if gajim.get_server_from_jid(jid) == 'gmail.com': + st = gajim.config.get('notify_on_new_gmail_email') + notify_gmail_checkbutton.set_active(st) + notify_gmail_checkbutton.show() + break + else: + notify_gmail_checkbutton.hide() + self.xml.signal_autoconnect(self) self.sound_tree.get_model().connect('row-changed', @@ -419,40 +442,9 @@ class PreferencesWindow: self.on_msg_treemodel_row_deleted) self.theme_preferences = None - - def on_preferences_window_show(self, widget): - self.update_preferences_window() - self.notebook.set_current_page(0) - - def update_preferences_window(self): - st = gajim.config.get('print_ichat_every_foo_minutes') - text = _('Every %s _minutes') % st - self.xml.get_widget('time_sometimes_radiobutton').set_label(text) - - #Themes - theme_combobox = self.xml.get_widget('theme_combobox') - model = theme_combobox.get_model() - model.clear() - i = 0 - for config_theme in gajim.config.get_per('themes'): - theme = config_theme.replace('_', ' ') - model.append([theme]) - if gajim.config.get('roster_theme') == config_theme: - theme_combobox.set_active(i) - i += 1 - self.on_theme_combobox_changed(theme_combobox) - # Notify user of new gmail e-mail messages, - # only show checkbox if user has a gtalk account - self.xml.get_widget('notify_gmail_checkbutton').hide() - for account in gajim.config.get_per('accounts'): - jid = gajim.get_jid_from_account(account) - if gajim.get_server_from_jid(jid) == 'gmail.com': - st = gajim.config.get('notify_on_new_gmail_email') - self.xml.get_widget('notify_gmail_checkbutton').set_active(st) - self.xml.get_widget('notify_gmail_checkbutton').show() - - #FIXME: move code from __init__ here + self.notebook.set_current_page(0) + self.window.show_all() def on_preferences_window_key_press_event(self, widget, event): if event.keyval == gtk.keysyms.Escape: diff --git a/src/gajim.py b/src/gajim.py index 76eb88808..3f3af4d12 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1675,7 +1675,6 @@ class Interface: # get instances for windows/dialogs that will show_all()/hide() self.instances['file_transfers'] = dialogs.FileTransfersWindow() - self.instances['preferences'] = config.PreferencesWindow() for account in gajim.connections: self.instances[account]['xml_console'] = dialogs.XMLConsoleWindow( diff --git a/src/gtkgui.glade b/src/gtkgui.glade index 285a48106..2ac733506 100644 --- a/src/gtkgui.glade +++ b/src/gtkgui.glade @@ -3282,19 +3282,17 @@ Agent JID - node GDK_WINDOW_TYPE_HINT_NORMAL GDK_GRAVITY_NORTH_WEST True - - + True False - 0 + 6 - 5 True True True @@ -6515,7 +6513,6 @@ Custom - 4 True GTK_BUTTONBOX_END 15 diff --git a/src/roster_window.py b/src/roster_window.py index 5fa7d2728..adea5e0a5 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1957,10 +1957,10 @@ _('If "%s" accepts this request you will know his or her status.') % jid) self.tree.set_cursor(path) def on_preferences_menuitem_activate(self, widget): - if gajim.interface.instances['preferences'].window.get_property('visible'): + if gajim.interface.instances.has_key('preferences'): gajim.interface.instances['preferences'].window.present() else: - gajim.interface.instances['preferences'].window.show_all() + gajim.interface.instances['preferences'] = config.PreferencesWindow() def on_add_new_contact(self, widget, account): dialogs.AddNewContactWindow(account)