Apply patch from #1581 to add an option to enable the app indicator

interface
This commit is contained in:
Andrew Resch 2011-03-22 17:16:03 -07:00
parent e81a279dc2
commit 67add964de
4 changed files with 50 additions and 9 deletions

View File

@ -2068,6 +2068,26 @@ Disabled</property>
<property name="position">2</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>
@ -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>

View File

@ -116,6 +116,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,

View File

@ -471,6 +471,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(
@ -637,6 +639,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(\
@ -782,6 +786,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},

View File

@ -70,6 +70,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
@ -103,7 +107,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)
@ -162,7 +166,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")
@ -200,7 +204,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)
@ -236,7 +240,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
@ -285,13 +289,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)
@ -323,6 +331,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)