[GTKUI] Rearrange the Status and Details tabs
This commit is contained in:
parent
09b5d2252c
commit
66e01991d6
|
@ -36,11 +36,29 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import deluge.component as component
|
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
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
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):
|
class DetailsTab(Tab):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Tab.__init__(self)
|
Tab.__init__(self)
|
||||||
|
@ -56,13 +74,15 @@ class DetailsTab(Tab):
|
||||||
(builder.get_object("summary_name"), None, ("name",)),
|
(builder.get_object("summary_name"), None, ("name",)),
|
||||||
(builder.get_object("summary_total_size"), fsize, ("total_size",)),
|
(builder.get_object("summary_total_size"), fsize, ("total_size",)),
|
||||||
(builder.get_object("summary_num_files"), str, ("num_files",)),
|
(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_torrent_path"), None, ("save_path",)),
|
||||||
(builder.get_object("summary_message"), str, ("message",)),
|
|
||||||
(builder.get_object("summary_hash"), str, ("hash",)),
|
(builder.get_object("summary_hash"), str, ("hash",)),
|
||||||
(builder.get_object("summary_comments"), str, ("comment",)),
|
(builder.get_object("summary_comments"), str, ("comment",)),
|
||||||
(builder.get_object("summary_owner"), str, ("owner",)),
|
(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):
|
def update(self):
|
||||||
|
@ -78,9 +98,9 @@ class DetailsTab(Tab):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get the torrent status
|
# Get the torrent status
|
||||||
status_keys = ["name", "total_size", "num_files", "tracker",
|
status_keys = ["name", "total_size", "num_files", "time_added", "completed_time",
|
||||||
"save_path", "message", "hash", "comment", "owner",
|
"save_path", "hash", "comment", "owner", "num_pieces", "piece_length",
|
||||||
"shared"]
|
"shared", "private"]
|
||||||
|
|
||||||
session = component.get("SessionProxy")
|
session = component.get("SessionProxy")
|
||||||
session.get_torrent_status(selected, status_keys).addCallback(self._on_get_torrent_status)
|
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
|
# Update all the label widgets
|
||||||
for widget in self.label_widgets:
|
for widget in self.label_widgets:
|
||||||
if widget[1] != None:
|
if widget[1] is not None:
|
||||||
args = []
|
args = []
|
||||||
try:
|
try:
|
||||||
for key in widget[2]:
|
for key in widget[2]:
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,6 +40,7 @@ from deluge.ui.client import client
|
||||||
from deluge.ui.gtkui.path_chooser import PathChooser
|
from deluge.ui.gtkui.path_chooser import PathChooser
|
||||||
from deluge.ui.gtkui.torrentdetails import Tab
|
from deluge.ui.gtkui.torrentdetails import Tab
|
||||||
|
|
||||||
|
|
||||||
class OptionsTab(Tab):
|
class OptionsTab(Tab):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Tab.__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_upload = builder.get_object("spin_max_upload")
|
||||||
self.spin_max_connections = builder.get_object("spin_max_connections")
|
self.spin_max_connections = builder.get_object("spin_max_connections")
|
||||||
self.spin_max_upload_slots = builder.get_object("spin_max_upload_slots")
|
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_prioritize_first_last = builder.get_object("chk_prioritize_first_last")
|
||||||
self.chk_sequential_download = builder.get_object("chk_sequential_download")
|
self.chk_sequential_download = builder.get_object("chk_sequential_download")
|
||||||
self.chk_auto_managed = builder.get_object("chk_auto_managed")
|
self.chk_auto_managed = builder.get_object("chk_auto_managed")
|
||||||
|
@ -118,7 +118,6 @@ class OptionsTab(Tab):
|
||||||
"max_upload_speed",
|
"max_upload_speed",
|
||||||
"max_connections",
|
"max_connections",
|
||||||
"max_upload_slots",
|
"max_upload_slots",
|
||||||
"private",
|
|
||||||
"prioritize_first_last",
|
"prioritize_first_last",
|
||||||
"is_auto_managed",
|
"is_auto_managed",
|
||||||
"stop_at_ratio",
|
"stop_at_ratio",
|
||||||
|
@ -139,7 +138,7 @@ class OptionsTab(Tab):
|
||||||
def _on_get_torrent_status(self, status):
|
def _on_get_torrent_status(self, status):
|
||||||
# We only want to update values that have been applied in the core. This
|
# 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.
|
# 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)
|
self.prev_status = {}.fromkeys(status.keys(), None)
|
||||||
|
|
||||||
if status != self.prev_status:
|
if status != self.prev_status:
|
||||||
|
@ -151,8 +150,6 @@ class OptionsTab(Tab):
|
||||||
self.spin_max_connections.set_value(status["max_connections"])
|
self.spin_max_connections.set_value(status["max_connections"])
|
||||||
if status["max_upload_slots"] != self.prev_status["max_upload_slots"]:
|
if status["max_upload_slots"] != self.prev_status["max_upload_slots"]:
|
||||||
self.spin_max_upload_slots.set_value(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"]:
|
if status["prioritize_first_last"] != self.prev_status["prioritize_first_last"]:
|
||||||
self.chk_prioritize_first_last.set_active(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"]:
|
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"]:
|
if status["move_on_completed"] != self.prev_status["move_on_completed"]:
|
||||||
self.chk_move_completed.set_active(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"]:
|
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"]:
|
if status["shared"] != self.prev_status["shared"]:
|
||||||
self.chk_shared.set_active(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"):
|
if not self.chk_sequential_download.get_property("visible"):
|
||||||
self.chk_sequential_download.show()
|
self.chk_sequential_download.show()
|
||||||
|
|
||||||
|
|
||||||
if self.button_apply.is_sensitive():
|
if self.button_apply.is_sensitive():
|
||||||
self.button_apply.set_sensitive(False)
|
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()
|
self.prev_torrent_id, self.spin_max_upload_slots.get_value_as_int()
|
||||||
)
|
)
|
||||||
if self.chk_prioritize_first_last.get_active() != \
|
if self.chk_prioritize_first_last.get_active() != \
|
||||||
self.prev_status["prioritize_first_last"] and \
|
self.prev_status["prioritize_first_last"] and \
|
||||||
not self.prev_status["storage_mode"] == "compact":
|
not self.prev_status["storage_mode"] == "compact":
|
||||||
client.core.set_torrent_prioritize_first_last(
|
client.core.set_torrent_prioritize_first_last(
|
||||||
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
|
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
|
||||||
)
|
)
|
||||||
if self.chk_sequential_download.get_active() != \
|
if self.chk_sequential_download.get_active() != \
|
||||||
self.prev_status["sequential_download"] and \
|
self.prev_status["sequential_download"] and \
|
||||||
not self.prev_status["storage_mode"] == "compact":
|
not self.prev_status["storage_mode"] == "compact":
|
||||||
client.core.set_torrent_sequential_download(
|
client.core.set_torrent_sequential_download(
|
||||||
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
|
self.prev_torrent_id, self.chk_prioritize_first_last.get_active()
|
||||||
)
|
)
|
||||||
|
@ -264,7 +261,6 @@ class OptionsTab(Tab):
|
||||||
self.button_apply.set_sensitive(True)
|
self.button_apply.set_sensitive(True)
|
||||||
dialog.run().addCallback(on_response)
|
dialog.run().addCallback(on_response)
|
||||||
|
|
||||||
|
|
||||||
def _on_chk_move_completed_toggled(self, widget):
|
def _on_chk_move_completed_toggled(self, widget):
|
||||||
value = self.chk_move_completed.get_active()
|
value = self.chk_move_completed.get_active()
|
||||||
self.move_completed_path_chooser.set_sensitive(value)
|
self.move_completed_path_chooser.set_sensitive(value)
|
||||||
|
|
|
@ -44,32 +44,27 @@ from deluge.ui.gtkui.piecesbar import PiecesBar
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def fpeer_sized(first, second):
|
def fpeer_sized(first, second):
|
||||||
return "%s (%s)" % (deluge.common.fsize(first), deluge.common.fsize(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):
|
def fratio(value):
|
||||||
if value < 0:
|
if value < 0:
|
||||||
return "∞"
|
return "∞"
|
||||||
return "%.3f" % value
|
return "%.3f" % value
|
||||||
|
|
||||||
|
|
||||||
def fpcnt(value):
|
def fpcnt(value):
|
||||||
return "%.2f%%" % value
|
return "%.2f%%" % value
|
||||||
|
|
||||||
|
|
||||||
def fspeed(value, max_value=-1):
|
def fspeed(value, max_value=-1):
|
||||||
if max_value > -1:
|
if max_value > -1:
|
||||||
return "%s (%s %s)" % (deluge.common.fspeed(value), max_value, _("KiB/s"))
|
return "%s (%s %s)" % (deluge.common.fspeed(value), max_value, _("KiB/s"))
|
||||||
else:
|
else:
|
||||||
return deluge.common.fspeed(value)
|
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):
|
def fdate_or_never(value):
|
||||||
"""Display value as date, eg 05/05/08 or Never"""
|
"""Display value as date, eg 05/05/08 or Never"""
|
||||||
|
@ -78,6 +73,7 @@ def fdate_or_never(value):
|
||||||
else:
|
else:
|
||||||
return "Never"
|
return "Never"
|
||||||
|
|
||||||
|
|
||||||
class StatusTab(Tab):
|
class StatusTab(Tab):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Tab.__init__(self)
|
Tab.__init__(self)
|
||||||
|
@ -96,9 +92,9 @@ class StatusTab(Tab):
|
||||||
apply_now=True
|
apply_now=True
|
||||||
)
|
)
|
||||||
self.label_widgets = [
|
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_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_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_download_speed"), fspeed, ("download_payload_rate", "max_download_speed")),
|
||||||
(builder.get_object("summary_upload_speed"), fspeed, ("upload_payload_rate", "max_upload_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_seed_rank"), str, ("seed_rank",)),
|
||||||
(builder.get_object("summary_auto_managed"), str, ("is_auto_managed",)),
|
(builder.get_object("summary_auto_managed"), str, ("is_auto_managed",)),
|
||||||
(builder.get_object("progressbar"), fpcnt, ("progress",)),
|
(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_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):
|
def update(self):
|
||||||
|
@ -130,18 +126,16 @@ class StatusTab(Tab):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Get the torrent status
|
# Get the torrent status
|
||||||
status_keys = ["progress", "num_pieces", "piece_length",
|
status_keys = [
|
||||||
"distributed_copies", "all_time_download", "total_payload_download",
|
"distributed_copies", "all_time_download", "total_payload_download",
|
||||||
"total_uploaded", "total_payload_upload", "download_payload_rate",
|
"total_uploaded", "total_payload_upload", "download_payload_rate", "max_download_speed",
|
||||||
"upload_payload_rate", "num_peers", "num_seeds", "total_peers",
|
"upload_payload_rate", "max_upload_speed", "num_peers", "num_seeds", "total_peers",
|
||||||
"total_seeds", "eta", "ratio", "next_announce",
|
"total_seeds", "eta", "ratio", "tracker_status", "next_announce", "active_time",
|
||||||
"tracker_status", "max_connections", "max_upload_slots",
|
"seeding_time", "seed_rank", "is_auto_managed", "progress", "last_seen_complete",
|
||||||
"max_upload_speed", "max_download_speed", "active_time",
|
"message", "tracker"
|
||||||
"seeding_time", "seed_rank", "is_auto_managed", "time_added",
|
]
|
||||||
"last_seen_complete", "completed_time"]
|
|
||||||
if self.config['show_piecesbar']:
|
if self.config['show_piecesbar']:
|
||||||
status_keys.extend(["pieces", "state"])
|
status_keys.extend(["pieces", "state", "num_pieces"])
|
||||||
|
|
||||||
|
|
||||||
component.get("SessionProxy").get_torrent_status(
|
component.get("SessionProxy").get_torrent_status(
|
||||||
selected, status_keys).addCallback(self._on_get_torrent_status)
|
selected, status_keys).addCallback(self._on_get_torrent_status)
|
||||||
|
@ -152,15 +146,15 @@ class StatusTab(Tab):
|
||||||
return
|
return
|
||||||
|
|
||||||
if status["is_auto_managed"]:
|
if status["is_auto_managed"]:
|
||||||
status["is_auto_managed"]=_("On")
|
status["is_auto_managed"] = _("On")
|
||||||
else:
|
else:
|
||||||
status["is_auto_managed"]=_("Off")
|
status["is_auto_managed"] = _("Off")
|
||||||
|
|
||||||
translate_tracker_status = {
|
translate_tracker_status = {
|
||||||
"Error" : _("Error"),
|
"Error": _("Error"),
|
||||||
"Warning" : _("Warning"),
|
"Warning": _("Warning"),
|
||||||
"Announce OK" : _("Announce OK"),
|
"Announce OK": _("Announce OK"),
|
||||||
"Announce Sent" : _("Announce Sent")
|
"Announce Sent": _("Announce Sent")
|
||||||
}
|
}
|
||||||
for key, value in translate_tracker_status.iteritems():
|
for key, value in translate_tracker_status.iteritems():
|
||||||
if key in status["tracker_status"]:
|
if key in status["tracker_status"]:
|
||||||
|
@ -169,7 +163,7 @@ class StatusTab(Tab):
|
||||||
|
|
||||||
# Update all the label widgets
|
# Update all the label widgets
|
||||||
for widget in self.label_widgets:
|
for widget in self.label_widgets:
|
||||||
if widget[1] != None:
|
if widget[1] is not None:
|
||||||
args = []
|
args = []
|
||||||
try:
|
try:
|
||||||
for key in widget[2]:
|
for key in widget[2]:
|
||||||
|
|
Loading…
Reference in New Issue