diff --git a/src/dcommon.py b/src/dcommon.py
index 0884ae9ef..3a1e81860 100644
--- a/src/dcommon.py
+++ b/src/dcommon.py
@@ -18,7 +18,7 @@
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
-import sys, os, webbrowser
+import sys, os, os.path, webbrowser
PROGRAM_NAME = "Deluge"
PROGRAM_VERSION = "0.4.9.0"
@@ -36,6 +36,9 @@ class DelugePreferences:
def get(self, key):
return self.pref[key]
+ def keys(self):
+ return self.pref.keys()
+
def load_from_file(self, filename):
f = open(filename, mode='r')
for line in f:
diff --git a/src/delugegtk.py b/src/delugegtk.py
index 3057ecd6b..9443480ee 100755
--- a/src/delugegtk.py
+++ b/src/delugegtk.py
@@ -37,10 +37,20 @@ class DelugeGTK(dbus.service.Object):
dbus.service.Object.__init__(self, bus_name, object_path)
self.is_running = False
self.torrent_file_queue = []
+ #Load up a config file:
+ self.conf_file = xdg.BaseDirectory.save_config_path("deluge-svn") + '/deluge.conf'
+ if os.path.isdir(self.conf_file):
+ print 'Weird, the file I was trying to write to, %s, is an existing directory'%(self.conf_file)
+ sys.exit(0)
+ if not os.path.isfile(self.conf_file):
+ f = open(self.conf_file, mode='w')
+ f.flush()
+ f.close()
+ self.pref = dcommon.DelugePreferences()
+ self.pref.load_from_file(self.conf_file)
#Start the Deluge Manager:
- self.manager = deluge.Manager("DE", "0500", "Deluge 0.5.0",
- os.path.expanduser("~") + "/Temp")
- #xdg.BaseDirectory.save_config_path("deluge-svn"))
+ self.manager = deluge.Manager("DE", "0490", "Deluge 0.4.9",
+ xdg.BaseDirectory.save_config_path("deluge-svn"))
#Set up the interface:
self.gladefile = dcommon.get_glade_file("delugegtk.glade")
self.wtree = gtk.glade.XML(self.gladefile)
@@ -68,8 +78,8 @@ class DelugeGTK(dbus.service.Object):
"remove_torrent" : self.remove_torrent_clicked,
"menu_quit": self.quit,
## Edit Menu
- "pref_clicked": self.prf.show_pref,
- "plugins_clicked": self.prf.show_plugins,
+ "pref_clicked": self.show_pref,
+ "plugins_clicked": self.show_plugins,
## View Menu
"infopane_toggle": self.infopane_toggle,
"size_toggle": self.size_toggle,
@@ -83,7 +93,11 @@ class DelugeGTK(dbus.service.Object):
## Help Menu
"show_about_dialog": self.abt.show,
## Toolbar
+ "recheck_files": self.recheck_files,
"update_tracker": self.update_tracker,
+ "clear_finished": self.clear_finished,
+ "queue_up": self.q_torrent_up,
+ "queue_down": self.q_torrent_down,
## Other events
"torrentrow_click": self.torrentview_clicked,
})
@@ -91,7 +105,7 @@ class DelugeGTK(dbus.service.Object):
## Create the torrent listview
self.view = self.wtree.get_widget("torrent_view")
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
- self.store = gtk.ListStore(int, int, str, str, int, str, str, str, str, str, str, str)
+ self.store = gtk.ListStore(int, int, str, str, float, str, str, str, str, str, str, str)
self.view.set_model(self.store)
self.view.set_rules_hint(True)
@@ -157,6 +171,7 @@ class DelugeGTK(dbus.service.Object):
self.text_summary_eta = self.wtree.get_widget("summary_eta")
## Interface created
+ self.apply_prefs()
## external_add_torrent should only be called from outside the class
@dbus.service.method('org.deluge_torrent.DelugeInterface')
@@ -196,8 +211,34 @@ class DelugeGTK(dbus.service.Object):
gtk.main()
except KeyboardInterrupt:
self.manager.quit()
+
+ def show_pref(self, o=None):
+ self.pref = self.prf.show_dlg(self.pref)
+
+ def show_plugins(self, o=None):
+ pass
+
+ def apply_prefs(self):
+ for k in self.pref.keys():
+ print k, self.pref.get(k)
+ # UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
+ def get_list_from_unique_id(self, unique_id):
+ state = self.manager.get_torrent_state(unique_id)
+ queue = int(state['queue_pos']) + 1
+ name = state['name']
+ size = dcommon.fsize(state['total_size'])
+ progress = float(state['progress'] * 100)
+ message = deluge.STATE_MESSAGES[state['state']]
+ seeds = dcommon.fseed(state)
+ peers = dcommon.fpeer(state)
+ dlrate = dcommon.frate(state['download_rate'])
+ ulrate = dcommon.frate(state['upload_rate'])
+ eta = "NULL"
+ share = self.calc_share_ratio(unique_id, state)
+ return [unique_id, queue, name, size, progress, message,
+ seeds, peers, dlrate, ulrate, eta, share]
## Call via a timer to update the interface
def update(self):
@@ -239,7 +280,7 @@ class DelugeGTK(dbus.service.Object):
self.text_summary_seeders.set_text(dcommon.fseed(state))
self.text_summary_peers.set_text(dcommon.fpeer(state))
self.text_summary_percentage_done.set_text(dcommon.fpcnt(state["progress"]))
- self.text_summary_share_ratio.set_text(self.calc_share_ratio(state))
+ self.text_summary_share_ratio.set_text(self.calc_share_ratio(self.get_selected_torrent(), state))
#self.text_summary_downloaded_this_session.set_text(str(state[""]))
#self.text_summary_uplodaded_this_session.set_text(str(state[""]))
self.text_summary_tracker.set_text(str(state["tracker"]))
@@ -263,34 +304,16 @@ class DelugeGTK(dbus.service.Object):
return True
- def calc_share_ratio(self, torrent_state):
- if torrent_state["total_upload"] == 0:
- return "0"
- elif torrent_state["total_download"] == 0:
- return "Undefined"
- else:
- ratio = float(torrent_state["total_upload"]) / float(torrent_state["total_download"])
- return dcommon.fpcnt(ratio)
+ def calc_share_ratio(self, unique_id, torrent_state):
+ r = self.manager.calc_ratio(unique_id, torrent_state)
+ return '%.2f'%(r)
def get_selected_torrent(self):
- return self.store.get_value(self.view.get_selection().get_selected()[1], 0)
-
- # UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
- def get_list_from_unique_id(self, unique_id):
- state = self.manager.get_torrent_state(unique_id)
- queue = int(state['queue_pos']) + 1
- name = state['name']
- size = dcommon.fsize(state['total_size'])
- progress =state['progress']
- message = deluge.STATE_MESSAGES[state['state']]
- seeds = dcommon.fseed(state)
- peers = dcommon.fpeer(state)
- dlrate = dcommon.frate(state['download_rate'])
- ulrate = dcommon.frate(state['upload_rate'])
- eta = "NULL"
- share = self.calc_share_ratio(state)
- return [unique_id, queue, name, size, progress, message,
- seeds, peers, dlrate, ulrate, eta, share]
+ try:
+ return self.store.get_value(self.view.get_selection().get_selected()[1], 0)
+ except TypeError:
+ return None
+
def new_torrent_clicked(self, obj=None):
pass
@@ -302,11 +325,31 @@ class DelugeGTK(dbus.service.Object):
self.store.append(self.get_list_from_unique_id(uid))
def remove_torrent_clicked(self, obj=None):
- self.manager.remove_torrent(self.get_selected_torrent(), False)
+ torrent = self.get_selected_torrent()
+ if torrent is not None:
+ self.manager.remove_torrent(torrent, False)
+ def recheck_files(self, obj=None):
+ pass
+
def update_tracker(self, obj=None):
- self.manager.update_tracker(get_selected_torrent())
-
+ torrent = self.get_selected_torrent()
+ if torrent is not None:
+ self.manager.update_tracker(torrent)
+
+ def clear_finished(self, obj=None):
+ self.manager.clear_completed()
+
+ def q_torrent_up(self, obj=None):
+ torrent = self.get_selected_torrent()
+ if torrent is not None:
+ self.manager.queue_up(torrent)
+
+ def q_torrent_down(self, obj=None):
+ torrent = self.get_selected_torrent()
+ if torrent is not None:
+ self.manager.queue_up(torrent)
+
def torrentview_clicked(self, widget, event):
pass
diff --git a/src/dgtk.py b/src/dgtk.py
index fb1f622a0..370e00083 100644
--- a/src/dgtk.py
+++ b/src/dgtk.py
@@ -63,33 +63,51 @@ class AboutDialog:
self.abt.show_all()
self.abt.run()
self.abt.hide_all()
-
+
+
+## TODO: Merge this class (and possibly others) into the main interface class
class PreferencesDialog:
def __init__(self):
self.gladefile = dcommon.get_glade_file("dgtkpref.glade")
self.wtree = gtk.glade.XML(self.gladefile)
- self.prf = self.wtree.get_widget("pref_dialog")
+ self.dlg = self.wtree.get_widget("pref_dialog")
self.notebook = self.wtree.get_widget("pref_notebook")
- self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
+ self.dlg.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
- self.plugin_view = self.wtree.get_widget("plugin_view")
- self.plugin_store = gtk.ListStore(str, 'gboolean')
- self.plugin_view.set_model(self.plugin_store)
- self.plugin_name_column = add_text_column(self.plugin_view, "Plugin", 0)
- self.plugin_name_column.set_expand(True)
- self.plugin_toggle_column = add_toggle_column(self.plugin_view, "Enable", 1)
+ #self.plugin_view = self.wtree.get_widget("plugin_view")
+ #self.plugin_store = gtk.ListStore(str, 'gboolean')
+ #self.plugin_view.set_model(self.plugin_store)
+ #self.plugin_name_column = add_text_column(self.plugin_view, "Plugin", 0)
+ #self.plugin_name_column.set_expand(True)
+ #self.plugin_toggle_column = add_toggle_column(self.plugin_view, "Enable", 1)
+
+ self.wtree.signal_autoconnect({"tray_toggle": self.tray_toggle,
+ })
- def show_pref(self, arg=None):
- self.prf.show_all()
- self.notebook.set_current_page(0)
- self.prf.run()
- self.prf.hide_all()
+ def tray_toggle(self, obj):
+ if obj.get_active():
+ self.wtree.get_widget("chk_min_on_close").set_sensitive(True)
+ else:
+ self.wtree.get_widget("chk_min_on_close").set_sensitive(False)
- def show_plugins(self, arg=None):
- self.prf.show_all()
- self.notebook.set_current_page(2)
- self.prf.run()
- self.prf.hide_all()
+ def set_pref(self, pref_file):
+ pass
+
+ def get_pref(self, pref_file):
+ pass
+
+ def show_dlg(self, conf=None, page=0):
+ self.dlg.show_all()
+ self.notebook.set_current_page(page)
+ # Set existing options
+ self.set_pref(conf)
+
+ self.dlg.run()
+ self.dlg.hide_all()
+
+class PluginsDialog:
+ def __init__(self):
+ pass
## A simple file open dialog. I'm going to improve it later,
@@ -137,4 +155,4 @@ def add_toggle_column(view, header, cid, toggled_signal=None):
view.append_column(column)
if toggled_signal is not None:
render.connect("toggled", toggled_signal, cid)
- return column
\ No newline at end of file
+ return column
diff --git a/src/glade/delugegtk.glade b/src/glade/delugegtk.glade
index a0b1b29e5..305b8619b 100644
--- a/src/glade/delugegtk.glade
+++ b/src/glade/delugegtk.glade
@@ -16,623 +16,152 @@
4
3
-
+
True
- 190
- True
+ GTK_TOOLBAR_BOTH_HORIZ
+ 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
-
-
- 3
- 4
- 10
- 11
-
-
-
-
- True
- 0
- <b>Estimated Time Remaining:</b>
- True
-
-
- 2
- 3
- 10
- 11
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 4
- 5
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 4
- 5
-
-
-
-
- True
- 0
- <b>Peers:</b>
- True
-
-
- 2
- 3
- 4
- 5
-
-
-
-
- True
- 0
- <b>Seeders:</b>
- True
-
-
- 4
- 5
-
-
-
-
- True
- 0
- True
-
-
- 1
- 4
-
-
-
-
- True
- 0
- <b>Total Size:</b>
- True
-
-
- 1
- 2
-
-
-
-
- True
- 0
- <b>Total Downloaded:</b>
- True
-
-
- 2
- 3
-
-
-
-
- True
- 0
- <b>Percentage Done:</b>
- True
-
-
- 5
- 6
-
-
-
-
- True
- 0
- <b>Downloaded this session:</b>
- True
-
-
- 6
- 7
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 1
- 2
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 2
- 3
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 5
- 6
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 6
- 7
-
-
-
-
- True
- 0
- <b>Tracker:</b>
- True
-
-
- 7
- 8
-
-
-
-
- True
- 0
- <b>Tracker Response:</b>
- True
-
-
- 8
- 9
-
-
-
-
- True
- 0
- <b>Tracker Status:</b>
- True
-
-
- 9
- 10
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 9
- 10
-
-
-
-
- True
- 0
- <b>Next Announce:</b>
- True
-
-
- 2
- 3
- 9
- 10
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 9
- 10
-
-
-
-
- True
- 0
- <b>Pieces:</b>
- True
-
-
- 2
- 3
- 1
- 2
-
-
-
-
- True
- 0
- <b>Total Uploaded:</b>
- True
-
-
- 2
- 3
- 2
- 3
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 1
- 2
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 2
- 3
-
-
-
-
- True
- 0
- <b>Share Ratio:</b>
- True
-
-
- 2
- 3
- 5
- 6
-
-
-
-
- True
- 0
- <b>Uploaded This Session:</b>
- True
-
-
- 2
- 3
- 6
- 7
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 5
- 6
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 6
- 7
-
-
-
-
- True
- 0
-
-
- 1
- 4
- 7
- 8
-
-
-
-
- True
- 0
-
-
- 1
- 4
- 8
- 9
-
-
-
-
- True
- 0
- <b>Name:</b>
- True
-
-
-
-
- True
- 0
- <b>Use compact storage allocation:</b>
- True
-
-
- 10
- 11
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 10
- 11
-
-
-
-
- True
- 0
- <b>Download Rate:</b>
- True
-
-
- 3
- 4
-
-
-
-
- True
- 0
-
-
- 1
- 2
- 3
- 4
-
-
-
-
- True
- 0
- <b>Upload Rate:</b>
- True
-
-
- 2
- 3
- 3
- 4
-
-
-
-
- True
- 0
-
-
- 3
- 4
- 3
- 4
-
-
-
-
-
-
-
-
- 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
+
+
+
+
+ True
+
+
+ False
+ False
+
+
+
+
+ True
+ Recheck Download
+ Recheck
+ gtk-yes
+
+
+
+ False
+
+
+
+
+ True
+ Update Tracker
+ Update Tracker
+ True
+ gtk-refresh
+
+
+
+ False
+
+
+
+
+ True
+ Clear Finished Torrents
+ Clear Finished
+ True
+ gtk-clear
+
+
+
+ False
+
+
+
+
+ True
+
+
+ False
+ 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
@@ -826,20 +355,6 @@
True
diff --git a/src/glade/dgtkpref.glade b/src/glade/dgtkpref.glade
index 3db766bc7..a6ab33cda 100644
--- a/src/glade/dgtkpref.glade
+++ b/src/glade/dgtkpref.glade
@@ -32,6 +32,7 @@
True
+ True
True
@@ -44,10 +45,15 @@
-
-
-
-
+
+ True
+ Enable system tray icon
+ True
+
+
+
+ 2
+
@@ -57,6 +63,9 @@
2
+ 1
+ 2
+ 12
@@ -78,23 +87,26 @@
True
+ True
True
2
2
-
+
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
True
- Ask me where to save each download
- True
+ 1
2
+ 1
+ 2
-
+
True
Save all downloads to:
True
@@ -106,15 +118,13 @@
-
+
True
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
+ Ask me where to save each download
+ True
- 1
2
- 1
- 2
@@ -137,25 +147,18 @@
True
+ True
True
1
2
-
- True
- Stop seeding torrents when
-their share ratio reaches:
- True
-
-
-
-
+
True
True
- 0.10000000000000001 0 10 0.10000000000000001 10 10
- 0.10000000149011612
+ 1 0 10 0.10000000000000001 10 10
+ 0.05000000074505806
2
True
@@ -164,6 +167,14 @@ their share ratio reaches:
2
+
+
+ True
+ Stop seeding torrents when
+their share ratio reaches:
+ True
+
+
@@ -184,8 +195,9 @@ their share ratio reaches:
True
+ True
-
+
True
Use compact storage allocation
True
@@ -256,27 +268,41 @@ their share ratio reaches:
-
+
True
- Test Port
+ Try from:
-
- 3
- 4
- 1
- 2
-
-
+
True
- label
+ to:
2
3
- 1
- 2
+
+
+
+
+ True
+ True
+ 0 0 100 1 10 10
+
+
+ 1
+ 2
+
+
+
+
+ True
+ True
+ 0 0 100 1 10 10
+
+
+ 3
+ 4
@@ -292,42 +318,28 @@ their share ratio reaches:
-
+
True
- True
- 0 0 100 1 10 10
-
-
- 3
- 4
-
-
-
-
- True
- True
- 0 0 100 1 10 10
-
-
- 1
- 2
-
-
-
-
- True
- to:
+ 0000
2
3
+ 1
+ 2
-
+
True
- Try from:
+ Test Port
+
+ 3
+ 4
+ 1
+ 2
+
@@ -355,32 +367,53 @@ their share ratio reaches:
4
2
-
+
True
- 0
- Maximum Upload Rate:
-
-
-
-
- True
- 0
- Maximum number of Uploads:
+ True
+ 0 0 100 1 10 10
+ 1
+ 2
+ 3
+ 4
+
+
+
+
+ True
+ True
+ 0 0 100 1 10 10
+
+
+ 1
+ 2
+ 2
+ 3
+
+
+
+
+ True
+ True
+ 0 0 100 1 10 10
+
+
+ 1
+ 2
1
2
-
+
True
- 0
- Maximum Download Rate:
+ True
+ 0 0 100 1 10 10
- 2
- 3
+ 1
+ 2
@@ -395,55 +428,34 @@ their share ratio reaches:
-
+
True
- True
- 0 0 100 1 10 10
+ 0
+ Maximum Download Rate:
- 1
- 2
-
-
-
-
- True
- True
- 0 0 100 1 10 10
-
-
- 1
- 2
- 1
- 2
-
-
-
-
- True
- True
- 0 0 100 1 10 10
-
-
- 1
- 2
2
3
-
+
True
- True
- 0 0 100 1 10 10
+ 0
+ Maximum number of Uploads:
- 1
- 2
- 3
- 4
+ 1
+ 2
+
+
+ True
+ 0
+ Maximum Upload Rate:
+
+
@@ -486,81 +498,6 @@ their share ratio reaches:
False
-
-
- True
- 2
- 2
-
-
- True
- False
- GTK_WRAP_WORD
-
-
- 1
- 2
- 10
- 10
-
-
-
-
- True
- GTK_BUTTONBOX_SPREAD
-
-
- True
- gtk-preferences
- True
-
-
-
-
- True
- gtk-apply
- True
-
-
- 1
-
-
-
-
- 1
- 2
- 1
- 2
- GTK_FILL
- GTK_FILL
-
-
-
-
- True
-
-
- 2
-
-
-
-
- 2
- False
-
-
-
-
- True
- Plugins
-
-
- tab
- 2
- False
- False
-
-
1
@@ -597,4 +534,128 @@ their share ratio reaches:
+
+ 480
+ 5
+ Preferences Dialog
+ 583
+ 431
+ False
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK
+ 2
+
+
+ True
+
+
+ True
+ 2
+ 2
+
+
+ True
+ False
+ GTK_WRAP_WORD
+
+
+ 1
+ 2
+ 10
+ 10
+
+
+
+
+ True
+ GTK_BUTTONBOX_SPREAD
+
+
+ True
+ gtk-preferences
+ True
+
+
+
+
+ True
+ gtk-apply
+ True
+
+
+ 1
+
+
+
+
+ 1
+ 2
+ 1
+ 2
+ GTK_FILL
+ GTK_FILL
+
+
+
+
+ True
+
+
+ 2
+
+
+
+
+ False
+
+
+
+
+ True
+ Plugins
+
+
+ tab
+ False
+ False
+
+
+
+
+ 1
+
+
+
+
+ True
+ GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK
+ GTK_BUTTONBOX_END
+
+
+ True
+ gtk-cancel
+ True
+
+
+
+
+ True
+ gtk-ok
+ True
+
+
+ 1
+
+
+
+
+ False
+ GTK_PACK_END
+
+
+
+
+