From be130c1e92b5341971b7bb1999943a93d2a09bae Mon Sep 17 00:00:00 2001 From: Zach Tibbitts Date: Mon, 26 Mar 2007 01:19:08 +0000 Subject: [PATCH] - --- glade/delugegtk.glade | 1455 +++++++++++++++++++++-------------------- src/delugegtk.py | 34 +- src/pref.py | 9 +- 3 files changed, 784 insertions(+), 714 deletions(-) diff --git a/glade/delugegtk.glade b/glade/delugegtk.glade index 4225beaf8..ec6bcb4b2 100644 --- a/glade/delugegtk.glade +++ b/glade/delugegtk.glade @@ -14,636 +14,130 @@ 4 3 - + True + False - + True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - True - True - True - False - - - + Add Torrent + Add Torrent + True + gtk-add + - False - False + False - + True - True - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - - - True - 10 - 12 - 4 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 2 - 2 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - 1 - 2 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Progress:</b> - True - - - 1 - 2 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - <b>Name:</b> - True - - - GTK_FILL - - - - - True - - - 1 - 2 - 1 - 2 - - - - - - 4 - 2 - - - - - True - - - 3 - 4 - 11 - 12 - - - - - True - 0 - <b>Estimated Time Remaining:</b> - True - - - 2 - 3 - 11 - 12 - - - - - True - 0 - - - 3 - 4 - 5 - 6 - - - - - True - 0 - - - 1 - 2 - 5 - 6 - - - - - True - 0 - <b>Peers:</b> - True - - - 2 - 3 - 5 - 6 - - - - - True - 0 - <b>Seeders:</b> - True - - - 5 - 6 - - - - - True - 0 - <b>Total Size:</b> - True - - - 2 - 3 - - - - - True - 0 - <b>Total Downloaded:</b> - True - - - 3 - 4 - - - - - True - 0 - <b>Downloaded this session:</b> - True - - - 7 - 8 - - - - - True - 0 - - - 1 - 2 - 2 - 3 - - - - - True - 0 - - - 1 - 2 - 3 - 4 - - - - - True - 0 - - - 1 - 2 - 7 - 8 - - - - - True - 0 - <b>Tracker:</b> - True - - - 8 - 9 - - - - - True - 0 - <b>Tracker Response:</b> - True - - - 9 - 10 - - - - - True - 0 - <b>Tracker Status:</b> - True - - - 10 - 11 - - - - - True - 0 - - - 1 - 2 - 10 - 11 - - - - - True - 0 - <b>Next Announce:</b> - True - - - 2 - 3 - 10 - 11 - - - - - True - 0 - - - 3 - 4 - 10 - 11 - - - - - True - 0 - <b>Pieces:</b> - True - - - 2 - 3 - 2 - 3 - - - - - True - 0 - <b>Total Uploaded:</b> - True - - - 2 - 3 - 3 - 4 - - - - - True - 0 - - - 3 - 4 - 2 - 3 - - - - - True - 0 - - - 3 - 4 - 3 - 4 - - - - - True - 0 - <b>Share Ratio:</b> - True - - - 2 - 3 - 6 - 7 - - - - - True - 0 - <b>Uploaded This Session:</b> - True - - - 2 - 3 - 7 - 8 - - - - - True - 0 - - - 3 - 4 - 6 - 7 - - - - - True - 0 - - - 3 - 4 - 7 - 8 - - - - - True - 0 - - - 1 - 4 - 8 - 9 - - - - - True - 0 - - - 1 - 4 - 9 - 10 - - - - - True - 0 - <b>Use compact storage allocation:</b> - True - - - 11 - 12 - - - - - True - 0 - - - 1 - 2 - 11 - 12 - - - - - True - 0 - <b>Download Rate:</b> - True - - - 4 - 5 - - - - - True - 0 - - - 1 - 2 - 4 - 5 - - - - - True - 0 - <b>Upload Rate:</b> - True - - - 2 - 3 - 4 - 5 - - - - - True - 0 - - - 3 - 4 - 4 - 5 - - - - - - - - - False - - - - - True - Details - - - tab - False - False - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - - - - - 1 - False - - - - - True - Peers - - - tab - 1 - False - False - - - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - True - - - - - 2 - False - - - - - True - Files - - - tab - 2 - False - False - - + Remove Torrent + Remove Torrent + True + gtk-remove + - False - False + False + + + + + True + Clear Finished Torrents + Clear Finished + True + gtk-clear + + + + False + + + + + True + + + False + False + + + + + True + Start / Pause + Start / Pause + True + gtk-media-play + + + + False + + + + + True + Queue Torrent Up + Move Up + True + gtk-go-up + + + + False + + + + + True + Queue Torrent Down + Move Down + True + gtk-go-down + + + + False - 3 - 2 - 3 + 1 + 2 + + GTK_FILL - + True + GTK_TOOLBAR_BOTH_HORIZ + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + GTK_TOOLBAR_BOTH_HORIZ + False + + + 2 3 - 3 - 4 - + 1 + 2 + + GTK_FILL @@ -906,130 +400,671 @@ - + True - GTK_TOOLBAR_BOTH_HORIZ - False - 2 3 - 1 - 2 - - GTK_FILL + 3 + 4 + - + True - GTK_TOOLBAR_BOTH_HORIZ - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - False - + True - Add Torrent - Add Torrent - True - gtk-add - + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + True + True + False + + + - False + False + False - + True - Remove Torrent - Remove Torrent - True - gtk-remove - + True + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + + + True + 10 + 12 + 4 + + + + + + + + + True + 0 + + + 3 + 4 + 4 + 5 + + + + + True + 0 + <b>Upload Rate:</b> + True + + + 2 + 3 + 4 + 5 + + + + + True + 0 + + + 1 + 2 + 4 + 5 + + + + + True + 0 + <b>Download Rate:</b> + True + + + 4 + 5 + + + + + True + 0 + + + 1 + 2 + 11 + 12 + + + + + True + 0 + <b>Use compact storage allocation:</b> + True + + + 11 + 12 + + + + + True + 0 + + + 1 + 4 + 9 + 10 + + + + + True + 0 + + + 1 + 4 + 8 + 9 + + + + + True + 0 + + + 3 + 4 + 7 + 8 + + + + + True + 0 + + + 3 + 4 + 6 + 7 + + + + + True + 0 + <b>Uploaded This Session:</b> + True + + + 2 + 3 + 7 + 8 + + + + + True + 0 + <b>Share Ratio:</b> + True + + + 2 + 3 + 6 + 7 + + + + + True + 0 + + + 3 + 4 + 3 + 4 + + + + + True + 0 + + + 3 + 4 + 2 + 3 + + + + + True + 0 + <b>Total Uploaded:</b> + True + + + 2 + 3 + 3 + 4 + + + + + True + 0 + <b>Pieces:</b> + True + + + 2 + 3 + 2 + 3 + + + + + True + 0 + + + 3 + 4 + 10 + 11 + + + + + True + 0 + <b>Next Announce:</b> + True + + + 2 + 3 + 10 + 11 + + + + + True + 0 + + + 1 + 2 + 10 + 11 + + + + + True + 0 + <b>Tracker Status:</b> + True + + + 10 + 11 + + + + + True + 0 + <b>Tracker Response:</b> + True + + + 9 + 10 + + + + + True + 0 + <b>Tracker:</b> + True + + + 8 + 9 + + + + + True + 0 + + + 1 + 2 + 7 + 8 + + + + + True + 0 + + + 1 + 2 + 3 + 4 + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + 0 + <b>Downloaded this session:</b> + True + + + 7 + 8 + + + + + True + 0 + <b>Total Downloaded:</b> + True + + + 3 + 4 + + + + + True + 0 + <b>Total Size:</b> + True + + + 2 + 3 + + + + + True + 0 + <b>Seeders:</b> + True + + + 5 + 6 + + + + + True + 0 + <b>Peers:</b> + True + + + 2 + 3 + 5 + 6 + + + + + True + 0 + + + 1 + 2 + 5 + 6 + + + + + True + 0 + + + 3 + 4 + 5 + 6 + + + + + True + 0 + <b>Estimated Time Remaining:</b> + True + + + 2 + 3 + 11 + 12 + + + + + True + + + 3 + 4 + 11 + 12 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + 2 + + + True + + + 1 + 2 + 1 + 2 + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Name:</b> + True + + + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + <b>Progress:</b> + True + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + 1 + 2 + + + + + 4 + 2 + + + + + + + + + False + + + + + True + Details + + + tab + False + False + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + + + + + 1 + False + + + + + True + Peers + + + tab + 1 + False + False + + + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + + + + + 2 + False + + + + + True + Files + + + tab + 2 + False + False + + + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + False + False + + + + + 3 + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Log + + + tab + 3 + False + False + + - False - - - - - True - Clear Finished Torrents - Clear Finished - True - gtk-clear - - - - False - - - - - True - - - False - False - - - - - True - Start / Pause - Start / Pause - True - gtk-media-play - - - - False - - - - - True - Queue Torrent Up - Move Up - True - gtk-go-up - - - - False - - - - - True - Queue Torrent Down - Move Down - True - gtk-go-down - - - - False + False + False - 1 - 2 - - GTK_FILL + 3 + 2 + 3 diff --git a/src/delugegtk.py b/src/delugegtk.py index 6b9f5cf04..4f9688add 100644 --- a/src/delugegtk.py +++ b/src/delugegtk.py @@ -29,6 +29,37 @@ import gtk, gtk.glade, gobject import xdg, xdg.BaseDirectory import gettext, locale +DEFAULT_PREFS = { + "auto_end_seeding" : False, + "close_to_tray" : False, + "default_download_path" : "", + "enable_system_tray" : True, + "enabled_plugins" : "", + "end_seed_ratio" : 0.0, + "max_download_rate" : -1.0, + "max_number_downloads" : -1.0, + "max_number_uploads" : -1.0, + "max_upload_rate" : -1.0, + "show_dl" : True, + "show_eta" : True, + "show_infopane" : True, + "show_peers" : True, + "show_seeders" : True, + "show_share" : True, + "show_size" : True, + "show_status" : True, + "show_toolbar" : True, + "show_ul" : True, + "tcp_port_range_lower" : 6881, + "tcp_port_range_upper" : 6889, + "use_compact_storage" : False, + "use_default_dir" : False, + "window_height" : 480, + "window_width" : 640, + "window_x_pos" : 0, + "window_y_pos" : 0, + } + class DelugeGTK: def __init__(self): APP = 'deluge' @@ -71,8 +102,7 @@ class DelugeGTK: if os.path.isdir(os.path.join(dcommon.CONFIG_DIR , 'plugins')): self.plugins.add_plugin_dir(os.path.join(dcommon.CONFIG_DIR, 'plugins')) self.plugins.scan_for_plugins() - self.config = pref.Preferences() - self.config.load_from_file(self.conf_file) + self.config = pref.Preferences(self.conf_file, DEFAULT_PREFS) #Set up the interface: self.wtree = gtk.glade.XML(dcommon.get_glade_file("delugegtk.glade"), domain=APP) self.window = self.wtree.get_widget("main_window") diff --git a/src/pref.py b/src/pref.py index 52e399cf1..7366f8fa5 100644 --- a/src/pref.py +++ b/src/pref.py @@ -23,11 +23,14 @@ # object. However, this class provides a few extra features on top of # the built in class that Deluge can take advantage of. class Preferences: - def __init__(self, filename=None): + def __init__(self, filename=None, defaults=None): self.mapping = {} self.config_file = filename if self.config_file is not None: self.load_from_file(self.config_file) + if defaults is not None: + for key in defaults.keys(): + self.mapping.setdefault(key, defaults[key]) # Allows you to access an item in a Preferences objecy by calling # instance[key] rather than instance.get(key). However, this will @@ -54,7 +57,9 @@ class Preferences: if filename is None: filename = self.config_file f = open(filename, mode='w') - for key in self.mapping.keys(): + keys = self.mapping.keys() + keys.sort() + for key in keys: f.write(key) f.write(' = ') f.write(str(self.mapping[key]))