diff --git a/deluge.py b/deluge.py
index 2604c631f..ee259da1d 100644
--- a/deluge.py
+++ b/deluge.py
@@ -106,6 +106,8 @@ class DuplicateTorrentError(DelugeError):
class InvalidTorrentError(DelugeError):
pass
+class InvalidUniqueIDError(DelugeError):
+ pass
# A cached data item
@@ -343,6 +345,10 @@ class Manager:
# This is the EXTERNAL function, for the GUI. It returns the core_state + supp_state
def get_torrent_state(self, unique_ID):
+ # Check to see if unique_ID exists:
+ if self.state.queue.count(unique_ID) == 0:
+ raise InvalidUniqueIDError("Asked for a torrent that doesn't exist")
+
ret = self.get_core_torrent_state(unique_ID, True).copy()
# Add the deluge-level things to the deluge_core data
@@ -590,7 +596,7 @@ class Manager:
ret = unique_ID
self.unique_IDs[unique_ID] = torrent
- print torrents_with_unique_ID
+# print torrents_with_unique_ID
# Remove torrents from core, unique_IDs and queue
to_delete = []
for unique_ID in self.unique_IDs.keys():
diff --git a/delugegtk.py b/delugegtk.py
index 6ea16f6b1..b828527af 100755
--- a/delugegtk.py
+++ b/delugegtk.py
@@ -20,24 +20,18 @@
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
-import deluge
-
-import dcommon, dgtk
-
import sys, os, gettext
+import deluge, dcommon, dgtk
import pygtk
pygtk.require('2.0')
-import gtk
-import gtk.glade
-import gobject
-
+import gtk, gtk.glade, gobject
import xdg, xdg.BaseDirectory
class DelugeGTK:
def __init__(self):
#Start the Deluge Manager:
- self.manager = deluge.Manager("DL", "0500", "Deluge 0.5.0",
+ self.manager = deluge.Manager("DE", "0500", "Deluge 0.5.0",
os.path.expanduser("~") + "/Temp")
#xdg.BaseDirectory.save_config_path("deluge-svn"))
#Set up the interface:
@@ -46,7 +40,7 @@ class DelugeGTK:
self.window = self.wtree.get_widget("main_window")
self.toolbar = self.wtree.get_widget("tb_middle")
if(self.window):
- self.window.connect("destroy", gtk.main_quit)
+ self.window.connect("destroy", self.quit)
self.window.set_title(dcommon.PROGRAM_NAME + " " + dcommon.PROGRAM_VERSION)
self.window.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
@@ -68,9 +62,19 @@ class DelugeGTK:
## Edit Menu
"pref_clicked": self.prf.show_pref,
"plugins_clicked": self.prf.show_plugins,
- ## Torrent Menu
+ ## View Menu
+ "size_toggle": self.size_toggle,
+ "status_toggle": self.status_toggle,
+ "seeders_toggle": self.seeders_toggle,
+ "peers_toggle": self.peers_toggle,
+ "dl_toggle": self.dl_toggle,
+ "ul_toggle": self.ul_toggle,
+ "eta_toggle": self.eta_toggle,
+ "share_toggle": self.share_toggle,
## Help Menu
"show_about_dialog": self.abt.show,
+ ## Other events
+ "torrentrow_click": self.torrentview_clicked,
}
self.wtree.signal_autoconnect(actions)
@@ -123,7 +127,7 @@ class DelugeGTK:
## add torrents in manager to interface
for uid in self.manager.get_unique_IDs():
- self.store.append(self.get_list_from_uid(uid))
+ self.store.append(self.get_list_from_unique_id(uid))
## Start the timer that updates the interface
@@ -132,34 +136,41 @@ class DelugeGTK:
## Call via a timer to update the interface
def update(self):
- itr = self.store.get_iter_first()
- while itr is not None:
- uid = self.store.get_value(itr, 0)
- try:
- state = self.manager.get_torrent_state(uid)
- except deluge.DelugeError:
- print "Removing Torrent"
- self.store.remove(itr)
+ # Make sure that the interface still exists
+ try:
tab = self.wtree.get_widget("torrent_info").get_current_page()
- if tab == 0: #Torrent List
- tlist = self.get_list_from_uid(uid)
- for i in range(12):
- self.store.set_value(itr, i, tlist[i])
- itr = self.store.iter_next(itr)
- elif tab == 1: #Details Pane
- pass
- elif tab == 2: #Peers List
- pass
- elif tab == 3: #File List
- pass
-
+ except AttributeError:
+ return False
+ if tab == 0: #Torrent List
+ itr = self.store.get_iter_first()
+ while itr is not None:
+ uid = self.store.get_value(itr, 0)
+ try:
+ state = self.manager.get_torrent_state(uid)
+ tlist = self.get_list_from_unique_id(uid)
+ for i in range(12):
+ self.store.set_value(itr, i, tlist[i])
+ itr = self.store.iter_next(itr)
+ except deluge.InvalidUniqueIDError:
+ self.store.remove(itr)
+ if not self.store.iter_is_valid(itr):
+ itr = None
+ elif tab == 1: #Details Pane
+ pass
+ elif tab == 2: #Peers List
+ pass
+ elif tab == 3: #File List
+ pass
+ else:
+ pass
+
return True
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_uid(self, unique_id):
+ 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']
@@ -182,14 +193,43 @@ class DelugeGTK:
torrent = dgtk.show_file_open_dialog()
if torrent is not None:
uid = self.manager.add_torrent(torrent, ".", True)
- self.store.append(self.get_list_from_uid(uid))
+ self.store.append(self.get_list_from_unique_id(uid))
def remove_torrent(self, obj=None):
self.manager.remove_torrent(self.get_selected_torrent(), False)
+ def torrentview_clicked(self, widget, event):
+ pass
+
+ def size_toggle(self, obj):
+ self.size_column.set_visible(obj.get_active())
+
+
+ def status_toggle(self, obj):
+ self.status_column.set_visible(obj.get_active())
+
+ def seeders_toggle(self, obj):
+ self.seed_column.set_visible(obj.get_active())
+
+ def peers_toggle(self, obj):
+ self.peer_column.set_visible(obj.get_active())
+
+ def dl_toggle(self, obj):
+ self.dl_column.set_visible(obj.get_active())
+
+ def ul_toggle(self, obj):
+ self.ul_column.set_visible(obj.get_active())
+
+ def eta_toggle(self, obj):
+ self.eta_column.set_visible(obj.get_active())
+
+ def share_toggle(self, obj):
+ self.share_column.set_visible(obj.get_active())
+
def quit(self, obj=None):
self.manager.quit()
- self.window.destroy()
+ gtk.main_quit()
+
@@ -198,5 +238,4 @@ class DelugeGTK:
if __name__ == "__main__":
interface = DelugeGTK()
interface.start()
-
gtk.main()
\ No newline at end of file
diff --git a/dgtk.py b/dgtk.py
index d7284c4c7..46a853cd2 100644
--- a/dgtk.py
+++ b/dgtk.py
@@ -41,24 +41,7 @@ class TrayIcon:
self.tray.set_from_file(dcommon.get_pixmap("deluge32.png"))
self.tray.set_tooltip("Deluge Bittorrent Client")
-class TorrentPopup:
- def __init__(self, parent):
- self.parent = parent
- self.gladefile = dcommon.get_glade_file("dgtkpopups.glade")
- self.wtree = gtk.glade.XML(self.gladefile)
- self.menu = self.wtree.get_widget("torrent_popup")
- dic = {
- "size_toggle": self.size,
- "status_toggle": self.status,
- "seeders_toggle": self.seeders,
- "peers_toggle": self.peers,
- "dl_toggle": self.dl,
- "ul_toggle": self.ul,
- "eta_toggle": self.eta,
- "share_toggle": self.share
-
- }
- self.wtree.signal_autoconnect(dic)
+
def popup(self):
pass
@@ -152,6 +135,7 @@ def show_file_open_dialog():
def add_text_column(view, header, cid):
render = gtk.CellRendererText()
column = gtk.TreeViewColumn(header, render, text=cid)
+ column.set_clickable(True)
column.set_resizable(True)
column.set_expand(False)
view.append_column(column)
@@ -160,6 +144,7 @@ def add_text_column(view, header, cid):
def add_progress_column(view, header, pid, mid):
render = gtk.CellRendererProgress()
column = gtk.TreeViewColumn(header, render, value=pid, text=mid)
+ column.set_clickable(True)
column.set_resizable(True)
column.set_expand(False)
view.append_column(column)
@@ -169,6 +154,7 @@ def add_toggle_column(view, header, cid, toggled_signal=None):
render = gtk.CellRendererToggle()
render.set_property('activatable', True)
column = gtk.TreeViewColumn(header, render, active=cid)
+ column.set_clickable(True)
column.set_resizable(True)
column.set_expand(False)
view.append_column(column)
diff --git a/glade/delugegtk.glade b/glade/delugegtk.glade
index 9bd2e847c..1c731b15a 100644
--- a/glade/delugegtk.glade
+++ b/glade/delugegtk.glade
@@ -16,626 +16,162 @@
4
3
-
+
True
- True
+ GTK_TOOLBAR_BOTH_HORIZ
+ False
-
+
True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
-
-
- True
- True
- True
- False
-
-
-
+ Add Torrent
+ Add Torrent
+ True
+ gtk-add
+
- False
+ False
-
+
True
- Torrents
+ Remove Torrent
+ Remove Torrent
+ True
+ gtk-remove
+
- tab
- False
- False
+ False
-
+
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
-
-
- 3
- 4
- 4
- 5
-
-
-
-
- True
-
-
- 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
-
-
-
-
-
-
- 1
- False
+ False
+ False
-
+
True
- Details
+ Update Tracker
+ Update Tracker
+ True
+ gtk-refresh
+
- tab
- 1
- False
- False
+ False
-
+
True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
-
-
- True
-
-
+ Clear Finished Torrents
+ Clear Finished
+ True
+ gtk-clear
+
- 2
- False
+ False
-
+
True
- Peers
- tab
- 2
- False
- False
+ False
+ False
-
+
True
- True
- GTK_POLICY_AUTOMATIC
- GTK_POLICY_AUTOMATIC
-
-
- True
- True
-
-
+ Force Pause/Resume Torrent
+ Force Pause/Resume Torrent
+ True
+ gtk-media-pause
+
- 3
- False
+ False
-
+
True
- Files
- tab
- 3
- False
- False
+ 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
@@ -781,25 +317,13 @@
@@ -814,6 +340,8 @@
True
Seeders
True
+ True
+
@@ -821,6 +349,8 @@
True
Peers
True
+ True
+
@@ -828,6 +358,8 @@
True
Download
True
+ True
+
@@ -835,6 +367,8 @@
True
Upload
True
+ True
+
@@ -842,6 +376,8 @@
True
Time Remaining
True
+ True
+
@@ -849,6 +385,8 @@
True
Share Ratio
True
+ True
+
@@ -913,162 +451,627 @@
-
+
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
- GTK_TOOLBAR_BOTH_HORIZ
- False
+ True
-
+
True
- Add Torrent
- Add Torrent
- True
- gtk-add
-
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+
+
+ True
+ True
+ True
+ True
+ False
+
+
+
- False
+ False
-
+
True
- Remove Torrent
- Remove Torrent
- True
- gtk-remove
-
+ Torrents
- False
+ tab
+ False
+ False
-
+
True
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+
+
+ True
+
+
+ True
+ 10
+ 12
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 3
+ 4
+
+
+
+
+ True
+ 0
+ <b>Upload Rate:</b>
+ True
+
+
+ 2
+ 3
+ 3
+ 4
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 3
+ 4
+
+
+
+
+ True
+ 0
+ <b>Download Rate:</b>
+ True
+
+
+ 3
+ 4
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 10
+ 11
+
+
+
+
+ True
+ 0
+ <b>Use compact storage allocation:</b>
+ True
+
+
+ 10
+ 11
+
+
+
+
+ True
+ 0
+ <b>Name:</b>
+ True
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 4
+ 8
+ 9
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 4
+ 7
+ 8
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 6
+ 7
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 5
+ 6
+
+
+
+
+ True
+ 0
+ <b>Uploaded This Session:</b>
+ True
+
+
+ 2
+ 3
+ 6
+ 7
+
+
+
+
+ True
+ 0
+ <b>Share Ratio:</b>
+ True
+
+
+ 2
+ 3
+ 5
+ 6
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 2
+ 3
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 1
+ 2
+
+
+
+
+ True
+ 0
+ <b>Total Uploaded:</b>
+ True
+
+
+ 2
+ 3
+ 2
+ 3
+
+
+
+
+ True
+ 0
+ <b>Pieces:</b>
+ True
+
+
+ 2
+ 3
+ 1
+ 2
+
+
+
+
+ True
+ 0
+
+
+ 3
+ 4
+ 9
+ 10
+
+
+
+
+ True
+ 0
+ <b>Next Announce:</b>
+ True
+
+
+ 2
+ 3
+ 9
+ 10
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 9
+ 10
+
+
+
+
+ True
+ 0
+ <b>Tracker Status:</b>
+ True
+
+
+ 9
+ 10
+
+
+
+
+ True
+ 0
+ <b>Tracker Response:</b>
+ True
+
+
+ 8
+ 9
+
+
+
+
+ True
+ 0
+ <b>Tracker:</b>
+ True
+
+
+ 7
+ 8
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 6
+ 7
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 5
+ 6
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 2
+ 3
+
+
+
+
+ True
+ 0
+
+
+ 1
+ 2
+ 1
+ 2
+
+
+
+
+ True
+ 0
+ <b>Downloaded this session:</b>
+ True
+
+
+ 6
+ 7
+
+
+
+
+ True
+ 0
+ <b>Percentage Done:</b>
+ True
+
+
+ 5
+ 6
+
+
+
+
+ True
+ 0
+ <b>Total Downloaded:</b>
+ True
+
+
+ 2
+ 3
+
+
+
+
+ True
+ 0
+ <b>Total Size:</b>
+ True
+
+
+ 1
+ 2
+
+
+
+
+ True
+ 0
+ True
+
+
+ 1
+ 4
+
+
+
+
+ True
+ 0
+ <b>Seeders:</b>
+ True
+
+
+ 4
+ 5
+
+
+
+
+ True
+ 0
+ <b>Peers:</b>
+ True
+
+
+ 2
+ 3
+ 4
+ 5
+
+
+
+
+ True
+
+
+ 1
+ 2
+ 4
+ 5
+
+
+
+
+ True
+
+
+ 3
+ 4
+ 4
+ 5
+
+
+
+
+ True
+ 0
+ <b>Estimated Time Remaining:</b>
+ True
+
+
+ 2
+ 3
+ 10
+ 11
+
+
+
+
+ True
+
+
+ 3
+ 4
+ 10
+ 11
+
+
+
+
+
+
- False
- False
+ 1
+ False
-
+
True
- Update Tracker
- Update Tracker
- True
- gtk-refresh
-
+ Details
- False
+ tab
+ 1
+ False
+ False
-
+
True
- Clear Finished Torrents
- Clear Finished
- True
- gtk-clear
-
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+
+
+ True
+
+
- False
+ 2
+ False
-
+
True
+ Peers
- False
- False
+ tab
+ 2
+ False
+ False
-
+
True
- Force Pause/Resume Torrent
- Force Pause/Resume Torrent
- True
- gtk-media-pause
-
+ True
+ GTK_POLICY_AUTOMATIC
+ GTK_POLICY_AUTOMATIC
+
+
+ True
+ True
+
+
- False
+ 3
+ False
-
+
True
+ Files
- False
- False
-
-
-
-
- True
- Queue Torrent Up
- Move Up
- True
- gtk-go-up
-
-
-
- False
-
-
-
-
- True
- Queue Torrent Down
- Move Down
- True
- gtk-go-down
-
-
-
- False
+ tab
+ 3
+ False
+ False
- 1
- 2
-
- GTK_FILL
+ 3
+ 2
+ 3