From 5116cb02050769bfc7ebc2fcb13021783c2155db Mon Sep 17 00:00:00 2001 From: Stefan Bethge <stefan@lanpartei.de> Date: Sun, 17 Sep 2006 15:49:47 +0000 Subject: [PATCH] add checkbutton to preferences window to toggle zeroconf --- data/glade/preferences_window.glade | 21 ++++++++++++++++++++- src/common/config.py | 2 +- src/common/zeroconf/connection_zeroconf.py | 1 + src/config.py | 10 +++++++++- src/gajim.py | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade index f5aceb5ffe..62e7c260a9 100644 --- a/data/glade/preferences_window.glade +++ b/data/glade/preferences_window.glade @@ -18,7 +18,6 @@ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> - <property name="urgency_hint">False</property> <signal name="key_press_event" handler="on_preferences_window_key_press_event" last_modification_time="Fri, 08 Apr 2005 01:08:08 GMT"/> <signal name="destroy" handler="on_preferences_window_destroy" last_modification_time="Sun, 05 Mar 2006 11:50:52 GMT"/> @@ -147,6 +146,26 @@ </packing> </child> + <child> + <widget class="GtkCheckButton" id="enable_zeroconf_checkbutton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Enable link-local messaging (Zeroconf)</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">False</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_enable_zeroconf_checkbutton_toggled" last_modification_time="Sun, 17 Sep 2006 15:13:22 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + <child> <widget class="GtkFrame" id="frame35"> <property name="visible">True</property> diff --git a/src/common/config.py b/src/common/config.py index 43f717404b..f9f0dacac3 100644 --- a/src/common/config.py +++ b/src/common/config.py @@ -79,6 +79,7 @@ class Config: 'saveposition': [ opt_bool, True ], 'mergeaccounts': [ opt_bool, False, '', True ], 'sort_by_show': [ opt_bool, True, '', True ], + 'enable_zeroconf': [opt_bool, False, _('Enable link-local/zeroconf messaging')], 'use_speller': [ opt_bool, False, ], 'speller_language': [ opt_str, '', _('Language used by speller')], 'print_time': [ opt_str, 'always', _('\'always\' - print time for every message.\n\'sometimes\' - print time every print_ichat_every_foo_minutes minute.\n\'never\' - never print time.')], @@ -205,7 +206,6 @@ class Config: 'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickame.')], 'gc_nicknames_colors': [ opt_str, '#a34526:#c000ff:#0012ff:#388a99:#38995d:#519938:#ff8a00:#94452d:#244b5a:#32645a', _('List of colors that will be used to color nicknames in group chats.'), True ], 'ctrl_tab_go_to_next_composing': [opt_bool, True, _('Ctrl-Tab go to next composing tab when none is unread.')], - 'zeroconf_enabled': [opt_bool, True, _('Enable zeroconf network')], } __options_per_key = { diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 726f7f0d09..c811db9391 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -262,6 +262,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): txt['msg'] = msg check = check and self.zeroconf.update_txt(txt) + #stay offline when zeroconf does something wrong if check: self.dispatch('STATUS', show) else: diff --git a/src/config.py b/src/config.py index dd8e7bce38..5397d397fe 100644 --- a/src/config.py +++ b/src/config.py @@ -94,6 +94,10 @@ class PreferencesWindow: st = gajim.config.get('sort_by_show') self.xml.get_widget('sort_by_show_checkbutton').set_active(st) + # enable zeroconf + st = gajim.config.get('enable_zeroconf') + self.xml.get_widget('enable_zeroconf_checkbutton').set_active(st) + # Display avatars in roster st = gajim.config.get('show_avatars_in_roster') self.xml.get_widget('show_avatars_in_roster_checkbutton').set_active(st) @@ -522,6 +526,10 @@ class PreferencesWindow: def on_sort_by_show_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'sort_by_show') gajim.interface.roster.draw_roster() + + def on_enable_zeroconf_checkbutton_toggled(self, widget): + self.on_checkbutton_toggled(widget, 'enable_zeroconf') + #TODO: add calls to close/restart zeroconf things and temporarily hide/show the account def on_show_status_msgs_in_roster_checkbutton_toggled(self, widget): self.on_checkbutton_toggled(widget, 'show_status_msgs_in_roster') @@ -1096,7 +1104,7 @@ class AccountModificationWindow: '''set or unset sensitivity of widgets when widget is toggled''' for w in widgets: w.set_sensitive(widget.get_active()) - + def init_account_gpg(self): keyid = gajim.config.get_per('accounts', self.account, 'keyid') keyname = gajim.config.get_per('accounts', self.account, 'keyname') diff --git a/src/gajim.py b/src/gajim.py index a15c769cd4..a925c96284 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -1852,7 +1852,7 @@ class Interface: self.handle_event_file_progress) gajim.proxy65_manager = proxy65_manager.Proxy65Manager(gajim.idlequeue) self.register_handlers() - if gajim.config.get('zeroconf_enabled'): + if gajim.config.get('enable_zeroconf'): gajim.connections['zeroconf'] = common.zeroconf.connection_zeroconf.ConnectionZeroconf('zeroconf') for account in gajim.config.get_per('accounts'): if account != 'zeroconf': -- GitLab