79
83
"""Enables the system tray icon."""
80
log.debug("Enabling the system tray icon..")
81
84
self.tray_glade = gtk.glade.XML(
82
85
pkg_resources.resource_filename("deluge.ui.gtkui",
83
86
"glade/tray_menu.glade"))
85
if deluge.common.windows_check() or deluge.common.osx_check():
86
self.tray = gtk.status_icon_new_from_pixbuf(
90
self.tray = gtk.status_icon_new_from_icon_name("deluge")
92
log.warning("Update PyGTK to 2.10 or greater for SystemTray..")
95
self.tray.connect("activate", self.on_tray_clicked)
96
self.tray.connect("popup-menu", self.on_tray_popup)
99
88
self.tray_glade.signal_autoconnect({
100
89
"on_menuitem_show_deluge_activate": \
101
90
self.on_menuitem_show_deluge_activate,
113
102
self.tray_menu = self.tray_glade.get_widget("tray_menu")
115
self.tray_glade.get_widget("download-limit-image").set_from_file(
116
deluge.common.get_pixmap("downloading16.png"))
117
self.tray_glade.get_widget("upload-limit-image").set_from_file(
118
deluge.common.get_pixmap("seeding16.png"))
105
log.debug("Enabling the Application Indicator..")
106
self.indicator = appindicator.Indicator (
107
"deluge", "deluge", appindicator.CATEGORY_APPLICATION_STATUS)
108
# Pass the menu to the Application Indicator
109
self.indicator.set_menu(self.tray_menu)
111
# Make sure the status of the Show Window MenuItem is correct
112
self._sig_win_hide = self.window.window.connect("hide", self._on_window_hide)
113
self._sig_win_show = self.window.window.connect("show", self._on_window_show)
114
if self.window.visible():
115
self.tray_glade.get_widget("menuitem_show_deluge").set_active(True)
117
self.tray_glade.get_widget("menuitem_show_deluge").set_active(False)
119
# Show the Application Indicator
120
self.indicator.set_status(appindicator.STATUS_ACTIVE)
123
log.debug("Enabling the system tray icon..")
124
if deluge.common.windows_check() or deluge.common.osx_check():
125
self.tray = gtk.status_icon_new_from_pixbuf(
129
self.tray = gtk.status_icon_new_from_icon_name("deluge")
131
log.warning("Update PyGTK to 2.10 or greater for SystemTray..")
134
self.tray.connect("activate", self.on_tray_clicked)
135
self.tray.connect("popup-menu", self.on_tray_popup)
137
# For some reason these icons do not display in appindicator
138
self.tray_glade.get_widget("download-limit-image").set_from_file(
139
deluge.common.get_pixmap("downloading16.png"))
140
self.tray_glade.get_widget("upload-limit-image").set_from_file(
141
deluge.common.get_pixmap("seeding16.png"))
120
143
client.register_event_handler("ConfigValueChangedEvent", self.config_value_changed)
121
if not client.connected():
122
# Hide menu widgets because we're not connected to a host.
123
for widget in self.hide_widget_list:
124
self.tray_glade.get_widget(widget).hide()
126
144
if client.connected():
127
145
# We're connected so we need to get some values from the core
148
# Hide menu widgets because we're not connected to a host.
149
for widget in self.hide_widget_list:
150
self.tray_glade.get_widget(widget).hide()
130
152
def __start(self):
131
153
if self.config["enable_system_tray"]:
136
158
self.tray_glade.get_widget("menuitem_quitdaemon").hide()
137
159
self.tray_glade.get_widget("separatormenuitem4").hide()
161
# These do not work with appindicator currently and can crash Deluge.
162
# Related to Launchpad bug #608219
164
self.hide_widget_list.remove("menuitem_download_limit")
165
self.hide_widget_list.remove("menuitem_upload_limit")
166
self.hide_widget_list.remove("separatormenuitem3")
167
self.tray_glade.get_widget("menuitem_download_limit").hide()
168
self.tray_glade.get_widget("menuitem_upload_limit").hide()
169
self.tray_glade.get_widget("separatormenuitem3").hide()
139
171
# Show widgets in the hide list because we've connected to a host
140
172
for widget in self.hide_widget_list:
141
173
self.tray_glade.get_widget(widget).show()
167
199
def shutdown(self):
168
200
if self.config["enable_system_tray"]:
169
self.tray.set_visible(False)
202
self.indicator.set_status(appindicator.STATUS_PASSIVE)
204
self.tray.set_visible(False)
171
206
def send_status_request(self):
172
207
client.core.get_session_status([
243
282
submenu_bwdownset.show_all()
244
283
submenu_bwupset.show_all()
285
# Re-set the menu to partly work around Launchpad bug #608219
287
self.indicator.set_menu(self.tray_menu)
246
289
def disable(self):
247
"""Disables the system tray icon."""
248
log.debug("Disabling the system tray icon..")
290
"""Disables the system tray icon or appindicator."""
250
self.tray.set_visible(False)
293
if hasattr(self, "_sig_win_hide"):
294
self.window.window.disconnect(self._sig_win_hide)
295
self.window.window.disconnect(self._sig_win_show)
296
log.debug("Disabling the application indicator..")
298
self.indicator.set_status(appindicator.STATUS_PASSIVE)
301
log.debug("Disabling the system tray icon..")
302
self.tray.set_visible(False)
252
304
del self.tray_glade
253
305
del self.tray_menu
254
306
except Exception, e:
336
388
self.setbwlimit(widget, _("Set Maximum Download Speed"), "max_download_speed",
337
389
"tray_download_speed_list", self.max_download_speed, "downloading.svg")
391
def _on_window_hide(self, widget, data=None):
392
"""_on_window_hide - update the menuitem's status"""
393
log.debug("_on_window_hide")
394
self.tray_glade.get_widget("menuitem_show_deluge").set_active(False)
396
def _on_window_show(self, widget, data=None):
397
"""_on_window_show - update the menuitem's status"""
398
log.debug("_on_window_show")
399
self.tray_glade.get_widget("menuitem_show_deluge").set_active(True)
339
401
def tray_setbwup(self, widget, data=None):
340
402
self.setbwlimit(widget, _("Set Maximum Upload Speed"), "max_upload_speed",
341
403
"tray_upload_speed_list", self.max_upload_speed, "seeding.svg")