[GTKUI] Rearrange the Status and Details tabs

This commit is contained in:
Calum Lind 2014-02-17 22:02:55 +00:00
parent 09b5d2252c
commit 66e01991d6
4 changed files with 588 additions and 541 deletions

View File

@ -36,11 +36,29 @@
import logging
import deluge.component as component
from deluge.common import fsize, is_url
from deluge.common import fsize, is_url, fdate
from deluge.ui.gtkui.torrentdetails import Tab
log = logging.getLogger(__name__)
def fpeer_size_second(first, second):
return "%s (%s)" % (first, fsize(second))
def fdate_blank(value):
"""Display value as date, eg 05/05/08 or blank"""
if value > 0.0:
return fdate(value)
else:
return ""
def str_yes_no(value):
"""Return Yes or No to bool value"""
return _("Yes") if value else _("No")
class DetailsTab(Tab):
def __init__(self):
Tab.__init__(self)
@ -56,13 +74,15 @@ class DetailsTab(Tab):
(builder.get_object("summary_name"), None, ("name",)),
(builder.get_object("summary_total_size"), fsize, ("total_size",)),
(builder.get_object("summary_num_files"), str, ("num_files",)),
(builder.get_object("summary_tracker"), None, ("tracker",)),
(builder.get_object("summary_completed"), fdate_blank, ("completed_time",)),
(builder.get_object("summary_date_added"), fdate, ("time_added",)),
(builder.get_object("summary_private"), str_yes_no, ("private",)),
(builder.get_object("summary_torrent_path"), None, ("save_path",)),
(builder.get_object("summary_message"), str, ("message",)),
(builder.get_object("summary_hash"), str, ("hash",)),
(builder.get_object("summary_comments"), str, ("comment",)),
(builder.get_object("summary_owner"), str, ("owner",)),
(builder.get_object("summary_shared"), str, ("shared",))
(builder.get_object("summary_shared"), str_yes_no, ("shared",)),
(builder.get_object("summary_pieces"), fpeer_size_second, ("num_pieces", "piece_length")),
]
def update(self):
@ -78,9 +98,9 @@ class DetailsTab(Tab):
return
# Get the torrent status
status_keys = ["name", "total_size", "num_files", "tracker",
"save_path", "message", "hash", "comment", "owner",
"shared"]
status_keys = ["name", "total_size", "num_files", "time_added", "completed_time",
"save_path", "hash", "comment", "owner", "num_pieces", "piece_length",
"shared", "private"]
session = component.get("SessionProxy")
session.get_torrent_status(selected, status_keys).addCallback(self._on_get_torrent_status)
@ -92,7 +112,7 @@ class DetailsTab(Tab):
# Update all the label widgets
for widget in self.label_widgets:
if widget[1] != None:
if widget[1] is not None:
args = []
try:
for key in widget[2]:

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ from deluge.ui.client import client
from deluge.ui.gtkui.path_chooser import PathChooser
from deluge.ui.gtkui.torrentdetails import Tab
class OptionsTab(Tab):
def __init__(self):
Tab.__init__(self)
@ -53,7 +54,6 @@ class OptionsTab(Tab):
self.spin_max_upload = builder.get_object("spin_max_upload")
self.spin_max_connections = builder.get_object("spin_max_connections")
self.spin_max_upload_slots = builder.get_object("spin_max_upload_slots")
self.chk_private = builder.get_object("chk_private")
self.chk_prioritize_first_last = builder.get_object("chk_prioritize_first_last")
self.chk_sequential_download = builder.get_object("chk_sequential_download")
self.chk_auto_managed = builder.get_object("chk_auto_managed")
@ -118,7 +118,6 @@ class OptionsTab(Tab):
"max_upload_speed",
"max_connections",
"max_upload_slots",
"private",
"prioritize_first_last",
"is_auto_managed",
"stop_at_ratio",
@ -139,7 +138,7 @@ class OptionsTab(Tab):
def _on_get_torrent_status(self, status):
# We only want to update values that have been applied in the core. This
# is so we don't overwrite the user changes that haven't been applied yet.
if self.prev_status == None:
if self.prev_status is None:
self.prev_status = {}.fromkeys(status.keys(), None)
if status != self.prev_status:
@ -151,8 +150,6 @@ class OptionsTab(Tab):
self.spin_max_connections.set_value(status["max_connections"])
if status["max_upload_slots"] != self.prev_status["max_upload_slots"]:
self.spin_max_upload_slots.set_value(status["max_upload_slots"])
if status["private"] != self.prev_status["private"]:
self.chk_private.set_active(status["private"])
if status["prioritize_first_last"] != self.prev_status["prioritize_first_last"]:
self.chk_prioritize_first_last.set_active(status["prioritize_first_last"])
if status["is_auto_managed"] != self.prev_status["is_auto_managed"]:
@ -168,7 +165,8 @@ class OptionsTab(Tab):
if status["move_on_completed"] != self.prev_status["move_on_completed"]:
self.chk_move_completed.set_active(status["move_on_completed"])
if status["move_on_completed_path"] != self.prev_status["move_on_completed_path"]:
self.move_completed_path_chooser.set_text(status["move_on_completed_path"], cursor_end=False, default_text=True)
self.move_completed_path_chooser.set_text(status["move_on_completed_path"],
cursor_end=False, default_text=True)
if status["shared"] != self.prev_status["shared"]:
self.chk_shared.set_active(status["shared"])
@ -189,7 +187,6 @@ class OptionsTab(Tab):
if not self.chk_sequential_download.get_property("visible"):
self.chk_sequential_download.show()
if self.button_apply.is_sensitive():
self.button_apply.set_sensitive(False)
@ -213,14 +210,14 @@ class OptionsTab(Tab):
self.prev_torrent_id, self.spin_max_upload_slots.get_value_as_int()
)
if self.chk_prioritize_first_last.get_active() != \
self.prev_status["prioritize_first_last"] and \
not self.prev_status["storage_mode"] == "compact":
self.prev_status["prioritize_first_last"] and \
not self.prev_status["storage_mode"] == "compact":
client.core.set_torrent_prioritize_first_last(
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
)
if self.chk_sequential_download.get_active() != \
self.prev_status["sequential_download"] and \
not self.prev_status["storage_mode"] == "compact":
self.prev_status["sequential_download"] and \
not self.prev_status["storage_mode"] == "compact":
client.core.set_torrent_sequential_download(
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
)
@ -264,7 +261,6 @@ class OptionsTab(Tab):
self.button_apply.set_sensitive(True)
dialog.run().addCallback(on_response)
def _on_chk_move_completed_toggled(self, widget):
value = self.chk_move_completed.get_active()
self.move_completed_path_chooser.set_sensitive(value)

View File

@ -44,32 +44,27 @@ from deluge.ui.gtkui.piecesbar import PiecesBar
log = logging.getLogger(__name__)
def fpeer_sized(first, second):
return "%s (%s)" % (deluge.common.fsize(first), deluge.common.fsize(second))
def fpeer_size_second(first, second):
return "%s (%s)" % (first, deluge.common.fsize(second))
def fratio(value):
if value < 0:
return ""
return "%.3f" % value
def fpcnt(value):
return "%.2f%%" % value
def fspeed(value, max_value=-1):
if max_value > -1:
return "%s (%s %s)" % (deluge.common.fspeed(value), max_value, _("KiB/s"))
else:
return deluge.common.fspeed(value)
def fdate(value):
"""Display value as date, eg 05/05/08 or blank"""
if value > 0.0:
return deluge.common.fdate(value)
else:
return ""
def fdate_or_never(value):
"""Display value as date, eg 05/05/08 or Never"""
@ -78,6 +73,7 @@ def fdate_or_never(value):
else:
return "Never"
class StatusTab(Tab):
def __init__(self):
Tab.__init__(self)
@ -96,9 +92,9 @@ class StatusTab(Tab):
apply_now=True
)
self.label_widgets = [
(builder.get_object("summary_pieces"), fpeer_size_second, ("num_pieces", "piece_length")),
(builder.get_object("summary_availability"), fratio, ("distributed_copies",)),
(builder.get_object("summary_total_downloaded"), fpeer_sized, ("all_time_download", "total_payload_download")),
(builder.get_object("summary_total_downloaded"), fpeer_sized, ("all_time_download",
"total_payload_download")),
(builder.get_object("summary_total_uploaded"), fpeer_sized, ("total_uploaded", "total_payload_upload")),
(builder.get_object("summary_download_speed"), fspeed, ("download_payload_rate", "max_download_speed")),
(builder.get_object("summary_upload_speed"), fspeed, ("upload_payload_rate", "max_upload_speed")),
@ -113,9 +109,9 @@ class StatusTab(Tab):
(builder.get_object("summary_seed_rank"), str, ("seed_rank",)),
(builder.get_object("summary_auto_managed"), str, ("is_auto_managed",)),
(builder.get_object("progressbar"), fpcnt, ("progress",)),
(builder.get_object("summary_date_added"), deluge.common.fdate, ("time_added",)),
(builder.get_object("summary_last_seen_complete"), fdate_or_never, ("last_seen_complete",)),
(builder.get_object("summary_completed"), fdate, ("completed_time",)),
(builder.get_object("summary_torrent_status"), str, ("message",)),
(builder.get_object("summary_tracker"), None, ("tracker",)),
]
def update(self):
@ -130,18 +126,16 @@ class StatusTab(Tab):
return
# Get the torrent status
status_keys = ["progress", "num_pieces", "piece_length",
status_keys = [
"distributed_copies", "all_time_download", "total_payload_download",
"total_uploaded", "total_payload_upload", "download_payload_rate",
"upload_payload_rate", "num_peers", "num_seeds", "total_peers",
"total_seeds", "eta", "ratio", "next_announce",
"tracker_status", "max_connections", "max_upload_slots",
"max_upload_speed", "max_download_speed", "active_time",
"seeding_time", "seed_rank", "is_auto_managed", "time_added",
"last_seen_complete", "completed_time"]
"total_uploaded", "total_payload_upload", "download_payload_rate", "max_download_speed",
"upload_payload_rate", "max_upload_speed", "num_peers", "num_seeds", "total_peers",
"total_seeds", "eta", "ratio", "tracker_status", "next_announce", "active_time",
"seeding_time", "seed_rank", "is_auto_managed", "progress", "last_seen_complete",
"message", "tracker"
]
if self.config['show_piecesbar']:
status_keys.extend(["pieces", "state"])
status_keys.extend(["pieces", "state", "num_pieces"])
component.get("SessionProxy").get_torrent_status(
selected, status_keys).addCallback(self._on_get_torrent_status)
@ -152,15 +146,15 @@ class StatusTab(Tab):
return
if status["is_auto_managed"]:
status["is_auto_managed"]=_("On")
status["is_auto_managed"] = _("On")
else:
status["is_auto_managed"]=_("Off")
status["is_auto_managed"] = _("Off")
translate_tracker_status = {
"Error" : _("Error"),
"Warning" : _("Warning"),
"Announce OK" : _("Announce OK"),
"Announce Sent" : _("Announce Sent")
"Error": _("Error"),
"Warning": _("Warning"),
"Announce OK": _("Announce OK"),
"Announce Sent": _("Announce Sent")
}
for key, value in translate_tracker_status.iteritems():
if key in status["tracker_status"]:
@ -169,7 +163,7 @@ class StatusTab(Tab):
# Update all the label widgets
for widget in self.label_widgets:
if widget[1] != None:
if widget[1] is not None:
args = []
try:
for key in widget[2]: