summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2012-11-26 01:59:22 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2012-11-26 02:03:20 +0000
commit8ffa80c2a2c295682856ba6605c1712a77d98c52 (patch)
treee2ba4a7dba5caf8cb96212de71aae7042d6e6081
parent0f16faabcb5153c55a8a45997e89b267e9d973fd (diff)
downloaddeluge-8ffa80c2a2c295682856ba6605c1712a77d98c52.zip
deluge-8ffa80c2a2c295682856ba6605c1712a77d98c52.tar.gz
deluge-8ffa80c2a2c295682856ba6605c1712a77d98c52.tar.bz2
Fix #2086 : Enable submenus for appindicator
-rw-r--r--deluge/ui/gtkui/glade/tray_menu.glade3
-rw-r--r--deluge/ui/gtkui/systemtray.py55
2 files changed, 26 insertions, 32 deletions
diff --git a/deluge/ui/gtkui/glade/tray_menu.glade b/deluge/ui/gtkui/glade/tray_menu.glade
index 504e2e7..b8668a7 100644
--- a/deluge/ui/gtkui/glade/tray_menu.glade
+++ b/deluge/ui/gtkui/glade/tray_menu.glade
@@ -25,6 +25,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Add Torrent</property>
<property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
<signal name="activate" handler="on_menuitem_add_torrent_activate"/>
<child internal-child="image">
<widget class="GtkImage" id="menu-item-image1">
@@ -86,6 +87,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Download Speed Limit</property>
<property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
<child internal-child="image">
<widget class="GtkImage" id="download-limit-image">
<property name="visible">True</property>
@@ -102,6 +104,7 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Upload Speed Limit</property>
<property name="use_underline">True</property>
+ <property name="always_show_image">True</property>
<child internal-child="image">
<widget class="GtkImage" id="upload-limit-image">
<property name="visible">True</property>
diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py
index 43318f1..1db5ec1 100644
--- a/deluge/ui/gtkui/systemtray.py
+++ b/deluge/ui/gtkui/systemtray.py
@@ -143,10 +143,9 @@ class SystemTray(component.Component):
self.tray.connect("activate", self.on_tray_clicked)
self.tray.connect("popup-menu", self.on_tray_popup)
- # For some reason these icons do not display in appindicator
- self.tray_glade.get_widget("download-limit-image").set_from_file(
+ self.tray_glade.get_widget("download-limit-image").set_from_file(
deluge.common.get_pixmap("downloading16.png"))
- self.tray_glade.get_widget("upload-limit-image").set_from_file(
+ self.tray_glade.get_widget("upload-limit-image").set_from_file(
deluge.common.get_pixmap("seeding16.png"))
client.register_event_handler("ConfigValueChangedEvent", self.config_value_changed)
@@ -167,16 +166,6 @@ class SystemTray(component.Component):
self.tray_glade.get_widget("menuitem_quitdaemon").hide()
self.tray_glade.get_widget("separatormenuitem4").hide()
- # These do not work with appindicator currently and can crash Deluge.
- # Related to Launchpad bug #608219
- 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")
- self.tray_glade.get_widget("menuitem_download_limit").hide()
- self.tray_glade.get_widget("menuitem_upload_limit").hide()
- self.tray_glade.get_widget("separatormenuitem3").hide()
-
# Show widgets in the hide list because we've connected to a host
for widget in self.hide_widget_list:
self.tray_glade.get_widget(widget).show()
@@ -271,16 +260,15 @@ class SystemTray(component.Component):
def build_tray_bwsetsubmenu(self):
# Create the Download speed list sub-menu
submenu_bwdownset = common.build_menu_radio_list(
- self.config["tray_download_speed_list"], self.tray_setbwdown,
+ self.config["tray_download_speed_list"], self.on_tray_setbwdown,
self.max_download_speed,
_("KiB/s"), show_notset=True, show_other=True)
# Create the Upload speed list sub-menu
submenu_bwupset = common.build_menu_radio_list(
- self.config["tray_upload_speed_list"], self.tray_setbwup,
+ self.config["tray_upload_speed_list"], self.on_tray_setbwup,
self.max_upload_speed,
_("KiB/s"), show_notset=True, show_other=True)
-
# Add the sub-menus to the tray menu
self.tray_glade.get_widget("menuitem_download_limit").set_submenu(
submenu_bwdownset)
@@ -291,10 +279,6 @@ class SystemTray(component.Component):
submenu_bwdownset.show_all()
submenu_bwupset.show_all()
- # Re-set the menu to partly work around Launchpad bug #608219
- if appindicator and self.config["enable_appindicator"]:
- self.indicator.set_menu(self.tray_menu)
-
def disable(self,invert_app_ind_conf=False):
"""Disables the system tray icon or appindicator."""
try:
@@ -404,10 +388,22 @@ class SystemTray(component.Component):
self.window.quit(shutdown=True)
- def tray_setbwdown(self, widget, data=None):
+ def on_tray_setbwdown(self, widget, data=None):
+ if isinstance(widget, gtk.RadioMenuItem):
+ #ignore previous radiomenuitem value
+ if not widget.get_active():
+ return
self.setbwlimit(widget, _("Set Maximum Download Speed"), "max_download_speed",
"tray_download_speed_list", self.max_download_speed, "downloading.svg")
+ def on_tray_setbwup(self, widget, data=None):
+ if isinstance(widget, gtk.RadioMenuItem):
+ #ignore previous radiomenuitem value
+ if not widget.get_active():
+ return
+ self.setbwlimit(widget, _("Set Maximum Upload Speed"), "max_upload_speed",
+ "tray_upload_speed_list", self.max_upload_speed, "seeding.svg")
+
def _on_window_hide(self, widget, data=None):
"""_on_window_hide - update the menuitem's status"""
log.debug("_on_window_hide")
@@ -418,26 +414,21 @@ class SystemTray(component.Component):
log.debug("_on_window_show")
self.tray_glade.get_widget("menuitem_show_deluge").set_active(True)
- def tray_setbwup(self, widget, data=None):
- self.setbwlimit(widget, _("Set Maximum Upload Speed"), "max_upload_speed",
- "tray_upload_speed_list", self.max_upload_speed, "seeding.svg")
-
def setbwlimit(self, widget, string, core_key, ui_key, default, image):
"""Sets the bandwidth limit based on the user selection."""
- value = widget.get_children()[0].get_text().rstrip(" " + _("KiB/s"))
- if value == _("Unlimited"):
+ value = widget.get_children()[0].get_text().split(" ")[0]
+ log.debug('setbwlimit: %s', value)
+ if widget.get_name() == "unlimited":
value = -1
-
- if value == _("Other..."):
+ if widget.get_name() == "other":
value = common.show_other_dialog(string, _("KiB/s"), None, image, default)
if value == None:
return
-
+ elif value == 0:
+ value = -1
# Set the config in the core
client.core.set_config({core_key: value})
- self.build_tray_bwsetsubmenu()
-
def unlock_tray(self, is_showing_dlg=[False]):
try:
from hashlib import sha1 as sha_hash