diff --git a/dcommon.py b/dcommon.py index c1c626b9d..0884ae9ef 100644 --- a/dcommon.py +++ b/dcommon.py @@ -55,6 +55,34 @@ class DelugePreferences: f.flush() f.close() +# Returns formatted string describing filesize +# fsize_b should be in bytes +# Returned value will be in either KB, MB, or GB +def fsize(fsize_b): + fsize_kb = float (fsize_b / 1024.0) + if fsize_kb < 1000: + return '%.1f KB'%fsize_kb + fsize_mb = float (fsize_kb / 1024.0) + if fsize_mb < 1000: + return '%.1f MB'%fsize_mb + fsize_gb = float (fsize_mb / 1024.0) + return '%.1f GB'%fsize_gb + +# Returns a formatted string representing a percentage +def fpcnt(dec): + return '%.2f%%'%(dec * 100) + +# Returns a formatted string representing transfer rate +def frate(bps): + return '%s/s'%(fsize(bps)) + +def fseed(state): + return str(str(state['num_seeds']) + " (" + str(state['total_seeds']) + ")") + +def fpeer(state): + return str(str(state['num_peers']) + " (" + str(state['total_peers']) + ")") + + def get_glade_file(fname): return GLADE_DIR + "/" + fname @@ -65,4 +93,4 @@ def open_url_in_browser(dialog, link): try: webbrowser.open(link) except webbrowser.Error: - print "Error: no webbrowser found" \ No newline at end of file + print "Error: no webbrowser found" diff --git a/delugegtk.py b/delugegtk.py index 376d76a4a..d8d939db8 100755 --- a/delugegtk.py +++ b/delugegtk.py @@ -143,13 +143,15 @@ class DelugeGTK(dbus.service.Object): self.text_summary_total_uploaded = self.wtree.get_widget("summary_total_uploaded") self.text_summary_download_rate = self.wtree.get_widget("summary_download_rate") self.text_summary_upload_rate = self.wtree.get_widget("summary_upload_rate") + self.text_summary_seeders = self.wtree.get_widget("summary_seeders") + self.text_summary_peers = self.wtree.get_widget("summary_peers") self.text_summary_percentage_done = self.wtree.get_widget("summary_percentage_done") self.text_summary_share_ratio = self.wtree.get_widget("summary_share_ratio") self.text_summary_downloaded_this_session = self.wtree.get_widget("summary_downloaded_this_session") self.text_summary_uplodaded_this_session = self.wtree.get_widget("summary_uploaded_this_session") self.text_summary_tracker = self.wtree.get_widget("summary_tracker") self.text_summary_tracker_response = self.wtree.get_widget("summary_tracker_response") - self.text_summary_tacker_status = self.wtree.get_widget("summary_tracker_status") + self.text_summary_tracker_status = self.wtree.get_widget("summary_tracker_status") self.text_summary_next_announce = self.wtree.get_widget("summary_next_announce") self.text_summary_compact_allocation = self.wtree.get_widget("summary_compact_allocation") self.text_summary_eta = self.wtree.get_widget("summary_eta") @@ -224,22 +226,25 @@ class DelugeGTK(dbus.service.Object): self.store.remove(itr) if not self.store.iter_is_valid(itr): itr = None - if tab == 0: #Details Pane + if tab == 0: #Details Paneself.text_summary_seeders = self.wtree.get_widget("summary_seeders") + state = self.manager.get_torrent_state(self.get_selected_torrent()) self.text_summary_title.set_text(str(state["name"])) - self.text_summary_total_size.set_text(str(state["total_size"])) + self.text_summary_total_size.set_text(dcommon.fsize(state["total_size"])) self.text_summary_pieces.set_text(str(state["pieces"])) - self.text_summary_total_downloaded.set_text(str(state["total_download"])) - self.text_summary_total_uploaded.set_text(str(state["total_upload"])) - self.text_summary_download_rate.set_text(str(state["download_rate"])) - self.text_summary_upload_rate.set_text(str(state["upload_rate"])) - self.text_summary_percentage_done.set_text(str(state["progress"])) - self.text_summary_share_ratio.set_text(str(self.calc_share_ratio(state))) + self.text_summary_total_downloaded.set_text(dcommon.fsize(state["total_download"])) + self.text_summary_total_uploaded.set_text(dcommon.fsize(state["total_upload"])) + self.text_summary_download_rate.set_text(dcommon.frate(state["download_rate"])) + self.text_summary_upload_rate.set_text(dcommon.frate(state["upload_rate"])) + 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_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"])) #self.text_summary_tracker_response.set_text(str(state[""])) - self.text_summary_tacker_status.set_text(str(state["tracker_ok"])) + self.text_summary_tracker_status.set_text(str(state["tracker_ok"])) self.text_summary_next_announce.set_text(str(state["next_announce"])) #self.text_summary_compact_allocation.set_text(str(state[""])) #self.text_summary_eta.set_text(str(state[""])) @@ -260,12 +265,12 @@ class DelugeGTK(dbus.service.Object): def calc_share_ratio(self, torrent_state): if torrent_state["total_upload"] == 0: - return 0 + return "0" elif torrent_state["total_download"] == 0: - return "infinite" + return "Undefined" else: ratio = float(torrent_state["total_upload"]) / float(torrent_state["total_download"]) - return ratio + return dcommon.fpcnt(ratio) def get_selected_torrent(self): return self.store.get_value(self.view.get_selection().get_selected()[1], 0) @@ -275,15 +280,15 @@ class DelugeGTK(dbus.service.Object): state = self.manager.get_torrent_state(unique_id) queue = int(state['queue_pos']) + 1 name = state['name'] - size = state['total_size'] - progress = int(state['progress'] * 100) + size = dcommon.fsize(state['total_size']) + progress =state['progress'] message = deluge.STATE_MESSAGES[state['state']] - seeds = str(state['num_seeds']) + " (" + str(state['total_seeds']) + ")" - peers = str(state['num_peers']) + " (" + str(state['total_peers']) + ")" - dlrate = state['download_rate'] - ulrate = state['upload_rate'] + seeds = dcommon.fseed(state) + peers = dcommon.fpeer(state) + dlrate = dcommon.frate(state['download_rate']) + ulrate = dcommon.frate(state['upload_rate']) eta = "NULL" - share = "NULL" + share = self.calc_share_ratio(state) return [unique_id, queue, name, size, progress, message, seeds, peers, dlrate, ulrate, eta, share] @@ -339,7 +344,6 @@ class DelugeGTK(dbus.service.Object): def quit(self, obj=None): self.manager.quit() gtk.main_quit() - @@ -347,4 +351,4 @@ class DelugeGTK(dbus.service.Object): ## For testing purposes, create a copy of the interface if __name__ == "__main__": interface = DelugeGTK() - interface.start() \ No newline at end of file + interface.start() diff --git a/glade/delugegtk.glade b/glade/delugegtk.glade index c2cc2d4c1..a0b1b29e5 100644 --- a/glade/delugegtk.glade +++ b/glade/delugegtk.glade @@ -5,8 +5,8 @@ True Deluge - 640 - 401 + 650 + 639 @@ -16,173 +16,623 @@ 4 3 - + True - GTK_TOOLBAR_BOTH_HORIZ - False + 190 + True - + 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 + + + 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 + + - - 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 - Force Pause/Resume Torrent - Force Pause/Resume Torrent - True - gtk-media-pause - - - - 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 - - 1 - 2 - - GTK_FILL - - - - - True - GTK_TOOLBAR_BOTH_HORIZ - - - 1 - 2 - 1 - 2 - GTK_FILL - - - - - True - GTK_TOOLBAR_BOTH_HORIZ - False - - - 2 3 - 1 - 2 - - GTK_FILL + 2 + 3 + + + + + True + + + 3 + 3 + 4 + @@ -410,606 +860,173 @@ - + True + GTK_TOOLBAR_BOTH_HORIZ + False + 2 3 - 3 - 4 - + 1 + 2 + + GTK_FILL - + True - 190 + GTK_TOOLBAR_BOTH_HORIZ + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + GTK_TOOLBAR_BOTH_HORIZ + False - + 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 - 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 - - - - - True - Details - - - tab - False - False - - - - - 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 + Force Pause/Resume Torrent + Force Pause/Resume Torrent + True + gtk-media-pause + + + + 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