diff options
Diffstat (limited to 'deluge/ui/gtkui/mainwindow.py')
-rw-r--r-- | deluge/ui/gtkui/mainwindow.py | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 4606726a6..aef8318cf 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -39,6 +39,7 @@ pygtk.require('2.0') import gtk, gtk.glade import gobject import pkg_resources +from hashlib import sha1 as sha try: import wnck @@ -49,6 +50,7 @@ from deluge.ui.client import client import deluge.component as component from deluge.configmanager import ConfigManager from deluge.ui.gtkui.ipcinterface import process_args +from deluge.ui.gtkui.dialogs import PasswordDialog from twisted.internet import reactor, defer from twisted.internet.error import ReactorNotRunning @@ -117,7 +119,6 @@ class MainWindow(component.Component): pass self.window.show() - def hide(self): component.pause("TorrentView") component.get("TorrentView").save_state() @@ -129,21 +130,32 @@ class MainWindow(component.Component): self.window.hide() def present(self): - # Restore the proper x,y coords for the window prior to showing it - try: - self.config["window_x_pos"] = self.window_x_pos - self.config["window_y_pos"] = self.window_y_pos - except: - pass - try: - component.resume("TorrentView") - component.resume("StatusBar") - component.resume("TorrentDetails") - except: - pass - - self.window.present() - self.load_window_state() + def restore(): + # Restore the proper x,y coords for the window prior to showing it + try: + self.config["window_x_pos"] = self.window_x_pos + self.config["window_y_pos"] = self.window_y_pos + except: + pass + try: + component.resume("TorrentView") + component.resume("StatusBar") + component.resume("TorrentDetails") + except: + pass + + self.window.present() + self.load_window_state() + + if self.config["tray_password"] and not self.visible(): + dialog = PasswordDialog("Enter your pasword to open Deluge.") + def on_dialog_response(response_id): + if response_id == gtk.RESPONSE_OK: + if self.config["tray_password"] == sha(dialog.get_password()).hexdigest(): + restore() + dialog.run().addCallback(on_dialog_response) + else: + restore() def active(self): """Returns True if the window is active, False if not.""" |