mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 06:58:42 +00:00
add tray locking
This commit is contained in:
parent
78f01e1397
commit
fd03c62ccb
2 changed files with 78 additions and 10 deletions
|
@ -112,12 +112,35 @@ class MenuBar:
|
||||||
def on_menuitem_quitdaemon_activate(self, data=None):
|
def on_menuitem_quitdaemon_activate(self, data=None):
|
||||||
log.debug("on_menuitem_quitdaemon_activate")
|
log.debug("on_menuitem_quitdaemon_activate")
|
||||||
# Tell the core to shutdown
|
# Tell the core to shutdown
|
||||||
functions.shutdown()
|
if self.window.visible():
|
||||||
self.window.quit()
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
functions.shutdown()
|
||||||
|
else:
|
||||||
|
from deluge.configmanager import ConfigManager
|
||||||
|
if self.config.get("lock_tray") == True:
|
||||||
|
from deluge.ui.gtk.systemtray import SystemTray
|
||||||
|
SystemTray.unlock_tray("quitdaemon")
|
||||||
|
else:
|
||||||
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
functions.shutdown()
|
||||||
|
|
||||||
def on_menuitem_quit_activate(self, data=None):
|
def on_menuitem_quit_activate(self, data=None):
|
||||||
log.debug("on_menuitem_quit_activate")
|
log.debug("on_menuitem_quit_activate")
|
||||||
self.window.quit()
|
if self.window.visible():
|
||||||
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
else:
|
||||||
|
from deluge.configmanager import ConfigManager
|
||||||
|
self.config = ConfigManager("gtkui.conf")
|
||||||
|
if self.config.get("lock_tray") == True:
|
||||||
|
log.debug("trying to import")
|
||||||
|
from deluge.ui.gtk.systemtray import SystemTray
|
||||||
|
SystemTray.unlock_tray("quitui")
|
||||||
|
else:
|
||||||
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
|
||||||
## Edit Menu ##
|
## Edit Menu ##
|
||||||
def on_menuitem_preferences_activate(self, data=None):
|
def on_menuitem_preferences_activate(self, data=None):
|
||||||
|
|
|
@ -132,7 +132,7 @@ class SystemTray:
|
||||||
self.window.update()
|
self.window.update()
|
||||||
else:
|
else:
|
||||||
if self.config["lock_tray"] == True:
|
if self.config["lock_tray"] == True:
|
||||||
log.debug("Implement tray locking please!")
|
self.unlock_tray("mainwinshow")
|
||||||
else:
|
else:
|
||||||
self.window.load_window_geometry()
|
self.window.load_window_geometry()
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
@ -153,7 +153,7 @@ class SystemTray:
|
||||||
log.debug("on_menuitem_show_deluge_activate")
|
log.debug("on_menuitem_show_deluge_activate")
|
||||||
if menuitem.get_active() and not self.window.visible():
|
if menuitem.get_active() and not self.window.visible():
|
||||||
if self.config["lock_tray"] == True:
|
if self.config["lock_tray"] == True:
|
||||||
self.unlock_tray()
|
self.unlock_tray("mainwinshow")
|
||||||
else:
|
else:
|
||||||
self.window.show()
|
self.window.show()
|
||||||
elif not menuitem.get_active() and self.window.visible():
|
elif not menuitem.get_active() and self.window.visible():
|
||||||
|
@ -174,12 +174,18 @@ class SystemTray:
|
||||||
|
|
||||||
def on_menuitem_quit_activate(self, menuitem):
|
def on_menuitem_quit_activate(self, menuitem):
|
||||||
log.debug("on_menuitem_quit_activate")
|
log.debug("on_menuitem_quit_activate")
|
||||||
self.window.quit()
|
if self.window.visible():
|
||||||
|
self.window.quit()
|
||||||
|
else:
|
||||||
|
self.unlock_tray("quitui")
|
||||||
|
|
||||||
def on_menuitem_quitdaemon_activate(self, menuitem):
|
def on_menuitem_quitdaemon_activate(self, menuitem):
|
||||||
log.debug("on_menuitem_quitdaemon_activate")
|
log.debug("on_menuitem_quitdaemon_activate")
|
||||||
functions.shutdown()
|
if self.window.visible():
|
||||||
self.window.quit()
|
self.window.quit()
|
||||||
|
functions.shutdown()
|
||||||
|
else:
|
||||||
|
self.unlock_tray("quitdaemon")
|
||||||
|
|
||||||
def build_menu_radio_list(self, value_list, callback, pref_value=None,
|
def build_menu_radio_list(self, value_list, callback, pref_value=None,
|
||||||
suffix=None, show_notset=False, notset_label=None, notset_lessthan=0,
|
suffix=None, show_notset=False, notset_label=None, notset_lessthan=0,
|
||||||
|
@ -295,5 +301,44 @@ class SystemTray:
|
||||||
# Update the UI
|
# Update the UI
|
||||||
self.window.update()
|
self.window.update()
|
||||||
|
|
||||||
def unlock_tray(self):
|
def unlock_tray(self, comingnext, is_showing_dlg=[False]):
|
||||||
log.debug("Tray locking needs implementation..!")
|
log.debug("Show tray lock dialog")
|
||||||
|
if is_showing_dlg[0]:
|
||||||
|
return
|
||||||
|
is_showing_dlg[0] = True
|
||||||
|
|
||||||
|
entered_pass = gtk.Entry(25)
|
||||||
|
entered_pass.set_activates_default(True)
|
||||||
|
entered_pass.set_width_chars(25)
|
||||||
|
entered_pass.set_visibility(False)
|
||||||
|
entered_pass.show()
|
||||||
|
tray_lock = gtk.Dialog(title=_("Deluge is locked"), parent=None,
|
||||||
|
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK,
|
||||||
|
gtk.RESPONSE_ACCEPT))
|
||||||
|
label = gtk.Label(_("Deluge is password protected.\nTo show the Deluge \
|
||||||
|
window, please enter your password"))
|
||||||
|
label.set_line_wrap(True)
|
||||||
|
label.set_justify(gtk.JUSTIFY_CENTER)
|
||||||
|
tray_lock.set_position(gtk.WIN_POS_CENTER_ALWAYS)
|
||||||
|
tray_lock.set_size_request(400, 200)
|
||||||
|
tray_lock.set_default_response(gtk.RESPONSE_ACCEPT)
|
||||||
|
tray_lock.vbox.pack_start(label)
|
||||||
|
tray_lock.vbox.pack_start(entered_pass)
|
||||||
|
tray_lock.show_all()
|
||||||
|
if tray_lock.run() == gtk.RESPONSE_ACCEPT:
|
||||||
|
if self.config["tray_password"] == entered_pass.get_text():
|
||||||
|
if comingnext == "mainwinshow":
|
||||||
|
log.debug("Showing main window via tray")
|
||||||
|
self.window.show()
|
||||||
|
elif comingnext == "quitdaemon":
|
||||||
|
functions.shutdown()
|
||||||
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
elif comingnext == "quitui":
|
||||||
|
log.debug("Quiting UI via tray")
|
||||||
|
self.window.hide()
|
||||||
|
self.window.quit()
|
||||||
|
tray_lock.destroy()
|
||||||
|
is_showing_dlg[0] = False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue