diff --git a/TODO b/TODO index 8a96b8c87..6ad82faf1 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ For 0.6 release: of deluge. * Update checking * Translations -* Implement 'Classic' mode * Add progress bars for downloading and importing lists instead of hanging (blocklist) After 0.6 release: diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index bd5101295..fdd4aec67 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtkui/connectionmanager.py @@ -117,6 +117,18 @@ class ConnectionManager(component.Component): self.hostlist.get_selection().connect("changed", self.on_selection_changed) + # If classic mode is set, we just start up a localhost daemon and connect to it + if self.gtkui_config["classic_mode"]: + uri = "http://localhost:58846" + os.popen("deluged -p 58846") + time.sleep(0.1) + # We need to wait for the host to start before connecting + while not self.test_online_status(uri): + time.sleep(0.01) + client.set_core_uri(uri) + self.hide() + return + self._update() # Auto connect to a host if applicable diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index e35aad31f..dc92dfaa1 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -96,7 +96,8 @@ DEFAULT_PREFS = { "autoadd_queued": False, "autoadd_enable": False, "autoadd_location": "", - "choose_directory_dialog_path": deluge.common.get_default_download_dir() + "choose_directory_dialog_path": deluge.common.get_default_download_dir(), + "classic_mode": False } class GtkUI: @@ -164,7 +165,7 @@ class GtkUI: # Show the connection manager self.connectionmanager = ConnectionManager() - if self.config["show_connection_manager_on_start"]: + if self.config["show_connection_manager_on_start"] and not self.config["classic_mode"]: self.connectionmanager.show() # Start the gtk main loop diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 491642e7e..85fbec4ee 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -57,6 +57,7 @@ class MainWindow(component.Component): self.window = self.main_glade.get_widget("main_window") self.window.set_icon(deluge.common.get_logo(32)) self.vpaned = self.main_glade.get_widget("vpaned") + # Load the window state self.load_window_state() @@ -88,10 +89,18 @@ class MainWindow(component.Component): def hide(self): component.pause("TorrentView") component.pause("StatusBar") + # Store the x, y positions for when we restore the window + self.window_x_pos = self.window.get_position()[0] + self.window_y_pos = self.window.get_position()[1] self.window.hide() - + def present(self): + # Restore the proper x,y coords for the window prior to showing it + self.config["window_x_pos"] = self.window_x_pos + self.config["window_y_pos"] = self.window_y_pos + self.window.present() + self.load_window_state() def active(self): """Returns True if the window is active, False if not.""" @@ -122,7 +131,7 @@ class MainWindow(component.Component): self.config["window_height"] - self.config["window_pane_position"]) def on_window_configure_event(self, widget, event): - if self.config["window_maximized"] == False: + if self.config["window_maximized"] == False and self.visible: self.config.set("window_x_pos", self.window.get_position()[0]) self.config.set("window_y_pos", self.window.get_position()[1]) self.config.set("window_width", event.width) @@ -131,6 +140,7 @@ class MainWindow(component.Component): def on_window_state_event(self, widget, event): if event.changed_mask & gtk.gdk.WINDOW_STATE_MAXIMIZED: if event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED: + log.debug("pos: %s", self.window.get_position()) self.config.set("window_maximized", True) else: self.config.set("window_maximized", False) diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 3ec3d1079..1a8937f6e 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -39,6 +39,7 @@ import pkg_resources import deluge.component as component from deluge.ui.client import aclient as client import deluge.common as common +from deluge.configmanager import ConfigManager from deluge.log import LOG as log @@ -47,6 +48,8 @@ class MenuBar(component.Component): log.debug("MenuBar init..") component.Component.__init__(self, "MenuBar") self.window = component.get("MainWindow") + self.config = ConfigManager("gtkui.conf") + # Get the torrent menu from the glade file self.torrentmenu_glade = gtk.glade.XML( pkg_resources.resource_filename("deluge.ui.gtkui", @@ -145,6 +148,12 @@ class MenuBar(component.Component): self.change_sensitivity = [ "menuitem_addtorrent" ] + + if self.config["classic_mode"]: + # We need to remove the 'quit and shutdown daemon' menu item + self.window.main_glade.get_widget("menuitem_quitdaemon").hide() + self.window.main_glade.get_widget("separatormenuitem").hide() + self.window.main_glade.get_widget("menuitem_connectionmanager").hide() def start(self): for widget in self.change_sensitivity: @@ -166,9 +175,10 @@ class MenuBar(component.Component): # Show the Torrent menu because we're connected to a host self.menu_torrent.show() - - self.window.main_glade.get_widget("separatormenuitem").show() - self.window.main_glade.get_widget("menuitem_quitdaemon").show() + + if not self.config["classic_mode"]: + self.window.main_glade.get_widget("separatormenuitem").show() + self.window.main_glade.get_widget("menuitem_quitdaemon").show() def stop(self): for widget in self.change_sensitivity: @@ -201,6 +211,8 @@ class MenuBar(component.Component): def on_menuitem_quit_activate(self, data=None): log.debug("on_menuitem_quit_activate") + if self.config["classic_mode"]: + client.shutdown() self.window.quit() ## Edit Menu ## diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py index 232772f1f..15a3ea72b 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtkui/preferences.py @@ -382,6 +382,8 @@ class Preferences(component.Component): self.gtkui_config["start_in_tray"]) self.glade.get_widget("chk_lock_tray").set_active( self.gtkui_config["lock_tray"]) + self.glade.get_widget("chk_classic_mode").set_active( + self.gtkui_config["classic_mode"]) ## Other tab ## self.glade.get_widget("chk_new_releases").set_active( @@ -514,6 +516,8 @@ class Preferences(component.Component): .hexdigest() if passhex != "c07eb5a8c0dc7bb81c217b67f11c3b7a5e95ffd7": new_gtkui_config["tray_password"] = passhex + new_gtkui_config["classic_mode"] = \ + self.glade.get_widget("chk_classic_mode").get_active() ## Other tab ## new_gtkui_config["check_new_releases"] = \ diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 434cc684f..4f1d733c1 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -77,6 +77,7 @@ class SystemTray(component.Component): self.tray_glade = gtk.glade.XML( pkg_resources.resource_filename("deluge.ui.gtkui", "glade/tray_menu.glade")) + try: self.tray = gtk.status_icon_new_from_icon_name("deluge") except: @@ -107,6 +108,12 @@ class SystemTray(component.Component): deluge.common.get_pixmap("downloading16.png")) self.tray_glade.get_widget("upload-limit-image").set_from_file( deluge.common.get_pixmap("seeding16.png")) + + if self.config["classic_mode"]: + self.hide_widget_list.remove("menuitem_quitdaemon") + self.hide_widget_list.remove("separatormenuitem4") + self.tray_glade.get_widget("menuitem_quitdaemon").hide() + self.tray_glade.get_widget("separatormenuitem4").hide() if client.get_core_uri() == None: # Hide menu widgets because we're not connected to a host. @@ -232,16 +239,14 @@ class SystemTray(component.Component): def on_tray_clicked(self, icon): """Called when the tray icon is left clicked.""" - if self.window.visible(): - if self.window.active(): - self.window.hide() - else: - self.window.present() + if self.config["lock_tray"]: + if not self.unlock_tray(): + return + + if self.window.active(): + self.window.hide() else: - if self.config["lock_tray"] == True: - self.unlock_tray("mainwinshow") - else: - self.window.show() + self.window.present() def on_tray_popup(self, status_icon, button, activate_time): """Called when the tray icon is right clicked.""" @@ -256,10 +261,10 @@ class SystemTray(component.Component): def on_menuitem_show_deluge_activate(self, menuitem): log.debug("on_menuitem_show_deluge_activate") if menuitem.get_active() and not self.window.visible(): - if self.config["lock_tray"] == True: - self.unlock_tray("mainwinshow") - else: - self.window.show() + if self.config["lock_tray"]: + if not self.unlock_tray(): + return + self.window.present() elif not menuitem.get_active() and self.window.visible(): self.window.hide() @@ -278,25 +283,23 @@ class SystemTray(component.Component): def on_menuitem_quit_activate(self, menuitem): log.debug("on_menuitem_quit_activate") - if self.window.visible(): - self.window.quit() - else: - if self.config["lock_tray"] == True: - self.unlock_tray("quitui") - else: - self.window.quit() + if self.config["lock_tray"]: + if not self.unlock_tray(): + return + if self.config["classic_mode"]: + client.shutdown() + + self.window.quit() + def on_menuitem_quitdaemon_activate(self, menuitem): log.debug("on_menuitem_quitdaemon_activate") - if self.window.visible(): - self.window.quit() - client.shutdown() - else: - if self.config["lock_tray"] == True: - self.unlock_tray("quitdaemon") - else: - self.window.quit() - client.shutdown() + if self.config["lock_tray"]: + if not self.unlock_tray(): + return + + client.shutdown() + self.window.quit() def tray_setbwdown(self, widget, data=None): self.setbwlimit(widget, _("Download"), "max_download_speed", @@ -328,6 +331,8 @@ class SystemTray(component.Component): def unlock_tray(self, comingnext, is_showing_dlg=[False]): import sha log.debug("Show tray lock dialog") + result = False + if is_showing_dlg[0]: return is_showing_dlg[0] = True @@ -353,18 +358,9 @@ window, please enter your password")) if tray_lock.run() == gtk.RESPONSE_ACCEPT: if self.config["tray_password"] == sha.new(entered_pass.get_text())\ .hexdigest(): - if comingnext == "mainwinshow": - log.debug("Showing main window via tray") - self.window.show() - elif comingnext == "quitdaemon": - client.shutdown() - self.window.hide() - self.window.quit() - elif comingnext == "quitui": - log.debug("Quiting UI via tray") - self.window.hide() - self.window.quit() + result = True tray_lock.destroy() is_showing_dlg[0] = False - return True + + return result diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index e86969241..88fea9b8c 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -40,6 +40,7 @@ import deluge.component as component from deluge.log import LOG as log from deluge.common import TORRENT_STATE from deluge.ui.client import aclient as client +from deluge.configmanager import ConfigManager class ToolBar(component.Component): def __init__(self): @@ -47,6 +48,7 @@ class ToolBar(component.Component): log.debug("ToolBar Init..") self.window = component.get("MainWindow") self.toolbar = self.window.main_glade.get_widget("toolbar") + self.config = ConfigManager("gtkui.conf") ### Connect Signals ### self.window.main_glade.signal_autoconnect({ "on_toolbutton_add_clicked": self.on_toolbutton_add_clicked, @@ -74,6 +76,9 @@ class ToolBar(component.Component): tb_remove.set_menu( component.get("MenuBar").torrentmenu_glade.get_widget("remove_torrent_menu")) + if self.config["classic_mode"]: + self.window.main_glade.get_widget("toolbutton_connectionmanager").hide() + def start(self): for widget in self.change_sensitivity: self.window.main_glade.get_widget(widget).set_sensitive(True)