From 8bd900d189d7d14d682874efa8c889ffa23fefbf Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 8 Aug 2007 21:45:18 +0000 Subject: [PATCH] add "open containing folder" by me and lifetime totals in tray tooltip by micah --- glade/preferences_dialog.glade | 80 ++++++++++++++++++++++++++++++++-- glade/torrent_menu.glade | 14 ++++++ src/common.py | 10 ++++- src/dialogs.py | 2 + src/interface.py | 54 +++++++++++++++++++++-- src/pref.py | 1 + 6 files changed, 154 insertions(+), 7 deletions(-) diff --git a/glade/preferences_dialog.glade b/glade/preferences_dialog.glade index 170600202..c7b041b4d 100644 --- a/glade/preferences_dialog.glade +++ b/glade/preferences_dialog.glade @@ -2245,6 +2245,80 @@ HTTP W/ Auth 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + GTK_SHADOW_NONE + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + 15 + + + True + 0 + Open folders with: + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Konqueror +Nautilus +Thunar + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + + + False + 1 + + + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Desktop File Manager</b> + True + + + label_item + + + + + False + False + 2 + 1 + + 0 @@ -2303,7 +2377,7 @@ HTTP W/ Auth False False 2 - 1 + 2 @@ -2355,7 +2429,7 @@ HTTP W/ Auth False False - 2 + 3 @@ -2398,7 +2472,7 @@ information is sent. False False - 3 + 4 diff --git a/glade/torrent_menu.glade b/glade/torrent_menu.glade index 95ccd3711..1d0251921 100644 --- a/glade/torrent_menu.glade +++ b/glade/torrent_menu.glade @@ -191,5 +191,19 @@ + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + _Open Containing Folder + True + + + + gtk-open + + + + diff --git a/src/common.py b/src/common.py index 3b13dcb71..b0065f781 100644 --- a/src/common.py +++ b/src/common.py @@ -69,7 +69,13 @@ def fsize(fsize_b): if fsize_mb < 1000: return "%.1f %s" % (fsize_mb, _("MiB")) fsize_gb = float (fsize_mb / 1024.0) - return "%.1f %s" % (fsize_gb, _("GiB")) + if fsize_gb < 1000: + return "%.1f %s" % (fsize_gb, _("GiB")) + fsize_tb = float (fsize_gb / 1024.0) + if fsize_tb < 1000: + return "%.1f %s" % (fsize_tb, _("TiB")) + fsize_pb = float (fsize_tb / 1024.0) + return "%.1f %s" % (fsize_pb, _("PiB")) # Returns a formatted string representing a percentage def fpcnt(dec): @@ -159,3 +165,5 @@ class EncLevel: class ProxyType: none, socks4, socks5, socks5_pw, http, http_pw = range(6) +class FileManager: + konqueror, nautilus, thunar = range(3) diff --git a/src/dialogs.py b/src/dialogs.py index d5756dd62..b311024d2 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -56,6 +56,7 @@ class PreferencesDlg: def show(self, interface, window): # Load settings into dialog try: + self.glade.get_widget("combo_file_manager").set_active(self.preferences.get("file_manager")) self.glade.get_widget("combo_encin").set_active(self.preferences.get("encin_state")) self.glade.get_widget("combo_encout").set_active(self.preferences.get("encout_state")) self.glade.get_widget("combo_enclevel").set_active(self.preferences.get("enclevel_type")) @@ -156,6 +157,7 @@ class PreferencesDlg: def ok_clicked(self, source, interface): self.dialog.hide() + self.preferences.set("file_manager", self.glade.get_widget("combo_file_manager").get_active()) self.preferences.set("encin_state", self.glade.get_widget("combo_encin").get_active()) self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active()) self.preferences.set("enclevel_type", self.glade.get_widget("combo_enclevel").get_active()) diff --git a/src/interface.py b/src/interface.py index 599dc6eea..ece1e7489 100644 --- a/src/interface.py +++ b/src/interface.py @@ -52,6 +52,9 @@ class DelugeGTK: #Start the Deluge Manager: self.manager = core.Manager(common.CLIENT_CODE, common.CLIENT_VERSION, '%s %s'%(common.PROGRAM_NAME, common.PROGRAM_VERSION), common.CONFIG_DIR) + self.logdir = os.path.join(common.CONFIG_DIR, 'logs') + self.alltime_download = None + self.alltime_upload = None self.plugins = plugins.PluginManager(self.manager, self) self.plugins.add_plugin_dir(common.PLUGIN_DIR) if os.path.isdir(os.path.join(common.CONFIG_DIR , 'plugins')): @@ -499,6 +502,7 @@ class DelugeGTK: "tor_pause": self.tor_pause, "update_tracker": self.update_tracker, "clear_finished": self.clear_finished, + "open_folder_clicked": self.open_folder, "queue_up": self.q_torrent_up, "queue_down": self.q_torrent_down, "queue_bottom": self.q_to_bottom, @@ -633,7 +637,23 @@ class DelugeGTK: return is_selected else: return False - + + def open_folder(self, widget): + unique_ids = self.get_selected_torrent_rows() +# try: + for uid in unique_ids: + if self.config.get("file_manager") == 0: + command = "/usr/bin/konqueror" + if self.config.get("file_manager") == 1: + command = "/usr/bin/nautilus" + if self.config.get("file_manager") == 2: + command = "/usr/bin/thunar" +# print "command %s uid %i dir %s\n" %(command, uid, self.manager.unique_IDs[uid].save_dir) + os.system('%s %s' %(command, self.manager.unique_IDs[uid].save_dir)) + self.update() +# except KeyError: + # pass + def tor_start(self, widget): unique_ids = self.get_selected_torrent_rows() try: @@ -800,6 +820,20 @@ class DelugeGTK: ## Start the timer that updates the interface def start(self, start_in_tray=False, cmd_line_torrents=None): + if not os.path.isdir(self.logdir): + os.mkdir(self.logdir) + log = os.path.join(self.logdir, "stats.log") + try: + logfile = open(log, "r") + except: + self.alltime_download = 0 + self.alltime_upload = 0 + else: + readlines = logfile.readlines() + self.alltime_download = long(readlines[0]) + self.alltime_upload = long(readlines[1]) + logfile.close() + if cmd_line_torrents is None: cmd_line_torrents = [] @@ -947,10 +981,14 @@ class DelugeGTK: max_connections = _("Unlimited") else: max_connections = int(self.config.get("max_connections_global")) + + dlall = long(core_state['total_downloaded']) + self.alltime_download + ulall = long(core_state['total_uploaded']) + self.alltime_upload + dlspeed = common.fspeed(core_state['download_rate']) ulspeed = common.fspeed(core_state['upload_rate']) - dltotal = common.fsize(core_state['total_downloaded']) - ultotal = common.fsize(core_state['total_uploaded']) + dltotal = common.fsize(dlall) + ultotal = common.fsize(ulall) if self.config.get("max_download_speed") < 0: dlspeed_max = _("Unlimited") @@ -1325,6 +1363,16 @@ class DelugeGTK: self.shutdown() def shutdown(self): + core_state = self.manager.get_state() + + dlall = long(core_state['total_downloaded']) + self.alltime_download + ulall = long(core_state['total_uploaded']) + self.alltime_upload + + log = os.path.join(self.logdir, "stats.log") + logfile = open(log, "w") + logfile.writelines([str(dlall)+'\n', str(ulall)+'\n']) + logfile.close() + enabled_plugins = ':'.join(self.plugins.get_enabled_plugins()) self.config.set('enabled_plugins', enabled_plugins) self.save_window_settings() diff --git a/src/pref.py b/src/pref.py index 4706f94b7..7d5311fba 100644 --- a/src/pref.py +++ b/src/pref.py @@ -40,6 +40,7 @@ import common import os.path DEFAULT_PREFS = { + "file_manager" : common.FileManager.nautilus, "send_info" : True, "auto_end_seeding" : False, "auto_seed_ratio" : 0,