diff --git a/deluge/core/core.py b/deluge/core/core.py index 7e2d79654..e862df16d 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -129,19 +129,15 @@ class Core(dbus.service.Object): self.torrent_paused(torrent_id) @dbus.service.method(dbus_interface="org.deluge_torrent.Deluge", - in_signature="s", out_signature="ay") - def get_torrent_info(self, torrent_id): - # Pickle the info dictionary from the torrent and return it - info = self.torrents[torrent_id].get_info() - info = pickle.dumps(info) - return info - - @dbus.service.method(dbus_interface="org.deluge_torrent.Deluge", - in_signature="s", + in_signature="sas", out_signature="ay") - def get_torrent_status(self, torrent_id): + def get_torrent_status(self, torrent_id, keys): + # Convert the array of strings to a python list of strings + nkeys = [] + for key in keys: + nkeys.append(str(key)) # Pickle the status dictionary from the torrent and return it - status = self.torrents[torrent_id].get_status() + status = self.torrents[torrent_id].get_status(nkeys) status = pickle.dumps(status) return status diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index 27e7f675d..e0673d16e 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -71,21 +71,15 @@ class Torrent: return eta - def get_info(self): - """Returns the torrents info.. stuff that remains constant, such as - name.""" - - return { - "name": self.handle.torrent_info().name(), - "total_size": self.handle.torrent_info().total_size(), - "num_pieces": self.handle.status().num_pieces - } - - def get_status(self): - """Returns the torrent status""" + def get_status(self, keys): + """Returns the status of the torrent based on the keys provided""" + # Create the full dictionary status = self.handle.status() - return { + full_status = { + "name": self.handle.torrent_info().name(), + "total_size": self.handle.torrent_info().total_size(), + "num_pieces": self.handle.status().num_pieces, "state": int(status.state), "paused": status.paused, "progress": status.progress, @@ -98,5 +92,14 @@ class Torrent: "num_seeds": status.num_seeds, "total_wanted": status.total_wanted, "eta": self.get_eta(), - "queue": self.queue[self.torrent_id] + "queue": self.queue[self.torrent_id] } + + # Create the desired status dictionary and return it + status_dict = {} + + for key in keys: + if key in full_status: + status_dict[key] = full_status[key] + + return status_dict diff --git a/deluge/core/torrentmanager.py b/deluge/core/torrentmanager.py index af125e287..f28403a29 100644 --- a/deluge/core/torrentmanager.py +++ b/deluge/core/torrentmanager.py @@ -132,7 +132,10 @@ class TorrentManager: except: return False - return True + return True + + def resume(self, torrent_id): + pass def save_state(self): """Save the state of the TorrentManager to the torrents.state file""" diff --git a/deluge/ui/functions.py b/deluge/ui/functions.py index b48cd573c..0c594da9a 100644 --- a/deluge/ui/functions.py +++ b/deluge/ui/functions.py @@ -134,9 +134,9 @@ def get_torrent_info(core, torrent_id): info = pickle.loads(info) return info -def get_torrent_status(core, torrent_id): +def get_torrent_status(core, torrent_id, keys): """Builds the status dictionary and returns it""" - status = core.get_torrent_status(torrent_id) + status = core.get_torrent_status(torrent_id, keys) # Join the array of bytes into a string for pickle to read status = "".join(chr(b) for b in status) # De-serialize the object diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 1ec630877..5bf073b36 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -13,708 +13,186 @@ 4 3 - + True + False - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - - - True - True - True - True - False - - - - + Add Torrent + Add Torrent + True + gtk-add + - False + False - + True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - - - True - False - True - - - True - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_POLICY_AUTOMATIC - GTK_POLICY_NEVER - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_RESIZE_QUEUE - - - True - 1 - 2 - 10 - - - True - 0 - - - True - 10 - 10 - 15 - 15 - - - True - 5 - - - True - 0.10000000149 - - - False - False - - - - - True - 4 - 4 - 5 - - - True - 0 - - - 1 - 2 - - - - - True - 0 - - - 3 - 4 - - - - - True - 0 - - - 1 - 2 - 1 - 2 - - - - - True - 0 - - - 3 - 4 - 1 - 2 - - - - - True - 0 - - - 1 - 2 - 2 - 3 - - - - - True - 0 - - - 3 - 4 - 2 - 3 - - - - - True - 0 - - - 1 - 2 - 3 - 4 - - - - - True - 0 - - - 3 - 4 - 3 - 4 - - - - - True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - - - - - - True - 5 - - - True - 0 - <b>Uploaded:</b> - True - - - - - 1 - 2 - - - - - True - 5 - - - True - 0 - <b>Seeders:</b> - True - - - - - 2 - 3 - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - - 3 - 4 - - - - - True - 15 - 5 - - - True - 0 - <b>Rate:</b> - True - - - - - 2 - 3 - - - - - True - 15 - 5 - - - True - 0 - <b>Rate:</b> - True - - - - - 2 - 3 - 1 - 2 - - - - - True - 15 - 5 - - - True - 0 - <b>Peers:</b> - True - - - - - 2 - 3 - 2 - 3 - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 3 - 4 - - - - - False - 1 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Statistics</b> - True - - - label_item - - - - - - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 0 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 10 - 10 - 15 - 15 - - - True - 6 - 2 - 2 - - - True - 0 - - - 1 - 2 - 5 - 6 - - - - - - True - 0 - - - 1 - 2 - 4 - 5 - - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 1 - 2 - 3 - 4 - - - - - - True - 0 - - - 1 - 2 - 2 - 3 - - - - - - True - 0 - - - 1 - 2 - 1 - 2 - - - - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 1 - 2 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Name:</b> - True - - - - - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Total Size:</b> - True - - - - - 1 - 2 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Pieces:</b> - True - - - - - 2 - 3 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 0 - 1 - <b>Tracker:</b> - True - - - - - 3 - 4 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Tracker Status:</b> - True - - - - - 4 - 5 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Next Announce:</b> - True - - - - - 5 - 6 - GTK_FILL - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Torrent Info</b> - True - - - label_item - - - - - 1 - 2 - GTK_FILL - - - - - - - - - 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 - - - - + 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 + False + Start / Pause + Pause + True + gtk-media-pause + + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Resume + gtk-media-play + + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + False + + + + + True + Queue Torrent Up + Move Up + True + gtk-go-up + + + + False + + + + + True + Queue Torrent Down + Move Down + True + gtk-go-down + + + + False + + + + + True + + + False + False + + + + + True + Preferences + Preferences + True + gtk-preferences + + + + False + + + + + True + Plugins + Plugins + True + gtk-disconnect + + + + False - 3 - 2 - 3 + 1 + 2 + GTK_FILL - + True + 1 + 2 + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + False + + + 2 3 - 3 - 4 - + 1 + 2 + + GTK_FILL @@ -890,179 +368,709 @@ - + True - False - 2 3 - 1 - 2 - - GTK_FILL + 3 + 4 + - + True - - - 1 - 2 - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - False - - True - Add Torrent - Add Torrent - True - gtk-add - - - - False - - - - - True - False - Remove Torrent - Remove Torrent - True - gtk-remove - - - - False - - - - - True - Clear Finished Torrents - Clear Finished - True - gtk-clear - - - - False - - - - - True - - - False - False - - - - - True - False - Start / Pause - Pause - True - gtk-media-pause - - - - False - - - - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Resume - gtk-media-play - + + + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + + + True + True + True + True + False + + + + - False + False + False - + True - False - Queue Torrent Up - Move Up - True - gtk-go-up - + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + + + True + False + True + + + True + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_POLICY_AUTOMATIC + GTK_POLICY_NEVER + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + GTK_RESIZE_QUEUE + + + True + 1 + 2 + 10 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 0 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 10 + 10 + 15 + 15 + + + True + 6 + 2 + 2 + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Next Announce:</b> + True + + + + + 5 + 6 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Tracker Status:</b> + True + + + + + 4 + 5 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Tracker:</b> + True + + + + + 3 + 4 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Pieces:</b> + True + + + + + 2 + 3 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Total Size:</b> + True + + + + + 1 + 2 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 1 + 2 + + + + + + True + 0 + + + 1 + 2 + 1 + 2 + + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 1 + 2 + 3 + 4 + + + + + + True + 0 + + + 1 + 2 + 4 + 5 + + + + + + True + 0 + + + 1 + 2 + 5 + 6 + + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Torrent Info</b> + True + + + label_item + + + + + 1 + 2 + GTK_FILL + + + + + True + 0 + + + True + 10 + 10 + 15 + 15 + + + True + 5 + + + True + 0.10000000149 + + + False + False + + + + + True + 4 + 4 + 5 + + + True + 15 + 5 + + + True + 0 + <b>ETA:</b> + True + + + + + 2 + 3 + 3 + 4 + + + + + True + 15 + 5 + + + True + 0 + <b>Peers:</b> + True + + + + + 2 + 3 + 2 + 3 + + + + + True + 15 + 5 + + + True + 0 + <b>Rate:</b> + True + + + + + 2 + 3 + 1 + 2 + + + + + True + 15 + 5 + + + True + 0 + <b>Rate:</b> + True + + + + + 2 + 3 + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + + 3 + 4 + + + + + True + 5 + + + True + 0 + <b>Seeders:</b> + True + + + + + 2 + 3 + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + + + True + 0 + + + 3 + 4 + 3 + 4 + + + + + True + 0 + + + 1 + 2 + 3 + 4 + + + + + True + 0 + + + 3 + 4 + 2 + 3 + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + 0 + + + 3 + 4 + 1 + 2 + + + + + True + 0 + + + 1 + 2 + 1 + 2 + + + + + True + 0 + + + 3 + 4 + + + + + True + 0 + + + 1 + 2 + + + + + False + 1 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Statistics</b> + True + + + label_item + + + + + + GTK_FILL + + + + + + + + + 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 + + + + - False - - - - - True - False - Queue Torrent Down - Move Down - True - gtk-go-down - - - - False - - - - - True - - - False - False - - - - - True - Preferences - Preferences - True - gtk-preferences - - - - False - - - - - True - Plugins - Plugins - True - gtk-disconnect - - - - False + False + False - 1 - 2 - GTK_FILL + 3 + 2 + 3 diff --git a/deluge/ui/gtkui/glade/torrent_menu.glade b/deluge/ui/gtkui/glade/torrent_menu.glade index f6006fd3c..774cc3716 100644 --- a/deluge/ui/gtkui/glade/torrent_menu.glade +++ b/deluge/ui/gtkui/glade/torrent_menu.glade @@ -25,6 +25,7 @@ Resume selected torrents. Resu_me True + True diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 5264d9d53..98bf7b119 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -153,11 +153,15 @@ class TorrentView: def update(self): """Update the view, this is likely called by a timer""" - # This function is used for the foreach method of the treemodel def update_row(model, path, row, user_data): torrent_id = self.torrent_model.get_value(row, 0) - status = functions.get_torrent_status(self.core, torrent_id) + status_keys = ["queue", "progress", "state", "num_seeds", + "num_peers", "download_payload_rate", "upload_payload_rate", + "eta"] + status = functions.get_torrent_status(self.core, torrent_id, + status_keys) + # Set values for each column in the row self.torrent_model.set_value(row, TORRENT_VIEW_COL_QUEUE, status["queue"]+1) @@ -186,16 +190,18 @@ class TorrentView: def add_row(self, torrent_id): """Adds a new torrent row to the treeview""" # Get the status and info dictionaries - status = functions.get_torrent_status(self.core, torrent_id) - info = functions.get_torrent_info(self.core, torrent_id) - + status_keys = ["queue", "name", "total_size", "progress", "state", + "num_seeds", "num_peers", "download_payload_rate", + "upload_payload_rate", "eta"] + status = functions.get_torrent_status(self.core, torrent_id, + status_keys) # Insert the row with info provided from core self.torrent_model.insert(status["queue"], [ torrent_id, status["queue"]+1, None, - info["name"], - info["total_size"], + status["name"], + status["total_size"], status["progress"]*100, status["state"], status["num_seeds"],