def present(self): def restore(): # Restore the proper x,y coords for the window prior to showing it try: if self.window_x_pos == -32000 or self.window_y_pos == -32000: self.config["window_x_pos"] = 0 self.config["window_y_pos"] = 0 else: 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["lock_tray"] and not self.visible(): dialog = PasswordDialog(_("Enter your password to show 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 quit(self, shutdown=False, restart=False): """Quits the GtkUI application. Args: shutdown (bool): Whether or not to shutdown the daemon as well. restart (bool): Whether or not to restart the application after closing. """ def quit_gtkui(): def stop_gtk_reactor(result=None): self.restart = restart try: reactor.callLater(0, reactor.fireSystemEvent, 'gtkui_close') except ReactorNotRunning: log.debug('Attempted to stop the reactor but it is not running...') if shutdown: client.daemon.shutdown().addCallback(stop_gtk_reactor) elif not client.is_standalone() and client.connected(): client.disconnect().addCallback(stop_gtk_reactor) else: stop_gtk_reactor() if self.config['lock_tray'] and not self.visible(): dialog = PasswordDialog(_('Enter your password to Quit Deluge...')) def on_dialog_response(response_id): if response_id == gtk.RESPONSE_OK: if self.config['tray_password'] == sha(dialog.get_password()).hexdigest(): quit_gtkui() dialog.run().addCallback(on_dialog_response) else: quit_gtkui()
def quit(self, shutdown=False): """ Quits the GtkUI :param shutdown: whether or not to shutdown the daemon as well :type shutdown: boolean """ def quit_gtkui(): def shutdown_daemon(result): return client.daemon.shutdown() def disconnect_client(result): return client.disconnect() def stop_reactor(result): try: reactor.stop() except ReactorNotRunning: log.debug( "Attempted to stop the reactor but it is not running..." ) def log_failure(failure, action): log.error("Encountered error attempting to %s: %s" % \ (action, failure.getErrorMessage())) d = defer.succeed(None) if shutdown: d.addCallback(shutdown_daemon) d.addErrback(log_failure, "shutdown daemon") if not client.is_classicmode() and client.connected(): d.addCallback(disconnect_client) d.addErrback(log_failure, "disconnect client") d.addBoth(stop_reactor) if self.config["lock_tray"] and not self.visible(): dialog = PasswordDialog(_("Enter your password to Quit Deluge...")) def on_dialog_response(response_id): if response_id == gtk.RESPONSE_OK: if self.config["tray_password"] == sha( dialog.get_password()).hexdigest(): quit_gtkui() dialog.run().addCallback(on_dialog_response) else: quit_gtkui()
def present(self): def restore(): # Restore the proper x,y coords for the window prior to showing it component.resume(self.child_components) self.window.present() self.load_window_state() if self.config['lock_tray'] and not self.visible(): dialog = PasswordDialog(_('Enter your password to show 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()