Module: deluge Branch: 1.3-stable Commit: 884bfd777edf49dbf15bfc8877547623af72e632
Author: Andrew Resch <[email protected]> Date: Tue Mar 22 17:16:03 2011 -0700 Apply patch from #1581 to add an option to enable the app indicator interface --- deluge/ui/gtkui/glade/preferences_dialog.glade | 24 ++++++++++++++++++- deluge/ui/gtkui/gtkui.py | 1 + deluge/ui/gtkui/preferences.py | 5 ++++ deluge/ui/gtkui/systemtray.py | 29 ++++++++++++++++++----- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade index d4cdc61..76c71ce 100644 --- a/deluge/ui/gtkui/glade/preferences_dialog.glade +++ b/deluge/ui/gtkui/glade/preferences_dialog.glade @@ -2069,6 +2069,26 @@ Disabled</property> </packing> </child> <child> + <widget class="GtkAlignment" id="alignment32"> + <property name="visible">True</property> + <property name="left_padding">10</property> + <child> + <widget class="GtkCheckButton" id="chk_enable_appindicator"> + <property name="label" translatable="yes">Enable Application Indicator</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="receives_default">False</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + </widget> + </child> + </widget> + <packing> + <property name="position">3</property> + </packing> + </child> + <child> <widget class="GtkAlignment" id="alignment17"> <property name="visible">True</property> <property name="bottom_padding">3</property> @@ -2088,7 +2108,7 @@ Disabled</property> </widget> <packing> <property name="expand">False</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> @@ -2131,7 +2151,7 @@ Disabled</property> </child> </widget> <packing> - <property name="position">4</property> + <property name="position">5</property> </packing> </child> </widget> diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 3ff0924..e9c4c54 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -113,6 +113,7 @@ DEFAULT_PREFS = { "enable_system_tray": True, "close_to_tray": True, "start_in_tray": False, + "enable_appindicator": False, "lock_tray": False, "tray_password": "", "check_new_releases": True, diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index edd888a..5525211 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -468,6 +468,8 @@ class Preferences(component.Component): self.gtkui_config["close_to_tray"]) self.glade.get_widget("chk_start_in_tray").set_active( self.gtkui_config["start_in_tray"]) + self.glade.get_widget("chk_enable_appindicator").set_active( + self.gtkui_config["enable_appindicator"]) self.glade.get_widget("chk_lock_tray").set_active( self.gtkui_config["lock_tray"]) self.glade.get_widget("chk_classic_mode").set_active( @@ -634,6 +636,8 @@ class Preferences(component.Component): self.glade.get_widget("chk_min_on_close").get_active() new_gtkui_config["start_in_tray"] = \ self.glade.get_widget("chk_start_in_tray").get_active() + new_gtkui_config["enable_appindicator"] = \ + self.glade.get_widget("chk_enable_appindicator").get_active() new_gtkui_config["lock_tray"] = \ self.glade.get_widget("chk_lock_tray").get_active() passhex = sha_hash(\ @@ -779,6 +783,7 @@ class Preferences(component.Component): "spin_outgoing_port_max": False}, "chk_use_tray": {"chk_min_on_close": True, "chk_start_in_tray": True, + "chk_enable_appindicator": True, "chk_lock_tray": True}, "chk_lock_tray": {"txt_tray_password": True, "password_label": True}, diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 212f643..cb10370 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -68,6 +68,10 @@ class SystemTray(component.Component): ] self.config.register_set_function("enable_system_tray", self.on_enable_system_tray_set) + # bit of a hack to prevent function from doing something on startup + self.__enabled_set_once = False + self.config.register_set_function("enable_appindicator", + self.on_enable_appindicator_set) self.max_download_speed = -1.0 self.download_rate = 0.0 @@ -101,7 +105,7 @@ class SystemTray(component.Component): self.tray_menu = self.tray_glade.get_widget("tray_menu") - if appindicator: + if appindicator and self.config["enable_appindicator"]: log.debug("Enabling the Application Indicator..") self.indicator = appindicator.Indicator ( "deluge", "deluge", appindicator.CATEGORY_APPLICATION_STATUS) @@ -160,7 +164,7 @@ class SystemTray(component.Component): # These do not work with appindicator currently and can crash Deluge. # Related to Launchpad bug #608219 - if appindicator: + if appindicator and self.config["enable_appindicator"]: self.hide_widget_list.remove("menuitem_download_limit") self.hide_widget_list.remove("menuitem_upload_limit") self.hide_widget_list.remove("separatormenuitem3") @@ -198,7 +202,7 @@ class SystemTray(component.Component): def shutdown(self): if self.config["enable_system_tray"]: - if appindicator: + if appindicator and self.config["enable_appindicator"]: self.indicator.set_status(appindicator.STATUS_PASSIVE) else: self.tray.set_visible(False) @@ -234,7 +238,7 @@ class SystemTray(component.Component): return # Tool tip text not available for appindicator - if appindicator: + if appindicator and self.config["enable_appindicator"]: return # Set the tool tip text @@ -283,13 +287,17 @@ class SystemTray(component.Component): submenu_bwupset.show_all() # Re-set the menu to partly work around Launchpad bug #608219 - if appindicator: + if appindicator and self.config["enable_appindicator"]: self.indicator.set_menu(self.tray_menu) - def disable(self): + def disable(self,invert_app_ind_conf=False): """Disables the system tray icon or appindicator.""" try: - if appindicator: + if invert_app_ind_conf: + app_ind_conf = not self.config["enable_appindicator"] + else: + app_ind_conf = self.config["enable_appindicator"] + if appindicator and app_ind_conf: if hasattr(self, "_sig_win_hide"): self.window.window.disconnect(self._sig_win_hide) self.window.window.disconnect(self._sig_win_show) @@ -321,6 +329,13 @@ class SystemTray(component.Component): else: self.disable() + def on_enable_appindicator_set(self, key, value): + """Called whenever the 'enable_appindicator' config key is modified""" + if self.__enabled_set_once: + self.disable(True) + self.enable() + self.__enabled_set_once = True + def on_tray_clicked(self, icon): """Called when the tray icon is left clicked.""" self.blink(False) -- You received this message because you are subscribed to the Google Groups "deluge-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/deluge-commit?hl=en.
