[GTKUI] Use less verbose units to improve look and gain physical space

* Use markup in gtkui to reduce font size of displayed units.
 * Reduced statusbar item sizes using markup and <small> tag. Provides an
   interim solution to #1326 and has reduced width from 930px to ~600px.
 * Integer value for Progress bar value in Peers and Files Tabs.
 * Remove trailing zeros for Pieces size in Details Tab.
 * Change position of Share Ratio in Status Tab.
 * Increase minimum width of column from 10px to 20px for listview.
 * Use shortform units e.g. Columns, Title speed, Status tab, Status bar.
 * Use less precision displaying values in columns.
This commit is contained in:
Calum Lind 2016-05-16 23:45:50 +01:00
parent 258ad95b7a
commit a5bc73f0b3
10 changed files with 245 additions and 226 deletions

View File

@ -17,8 +17,8 @@ from deluge.ui.gtkui.torrentdetails import Tab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def fpeer_size_second(first, second): def fpieces_num_size(num_pieces, piece_size):
return "%s (%s)" % (first, fsize(second)) return "%s (%s)" % (num_pieces, fsize(piece_size, precision=0))
def fdate_or_dash(value): def fdate_or_dash(value):
@ -57,7 +57,7 @@ class DetailsTab(Tab):
(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_yes_no, ("shared",)), (builder.get_object("summary_shared"), str_yes_no, ("shared",)),
(builder.get_object("summary_pieces"), fpeer_size_second, ("num_pieces", "piece_length")), (builder.get_object("summary_pieces"), fpieces_num_size, ("num_pieces", "piece_length")),
] ]
self.status_keys = [status for widget in self.label_widgets for status in widget[2]] self.status_keys = [status for widget in self.label_widgets for status in widget[2]]

View File

@ -433,7 +433,7 @@ class FilesTab(Tab):
# Catch the unusal error found when moving folders around # Catch the unusal error found when moving folders around
value = 0 value = 0
self.treestore[parent][3] = value self.treestore[parent][3] = value
self.treestore[parent][2] = "%.2f%%" % value self.treestore[parent][2] = "%i%%" % value
return completed_bytes return completed_bytes
get_completed_bytes(self.treestore.iter_children(root)) get_completed_bytes(self.treestore.iter_children(root))
@ -464,7 +464,7 @@ class FilesTab(Tab):
continue continue
try: try:
progress_string = "%.2f%%" % (status["file_progress"][index] * 100) progress_string = "%i%%" % (status["file_progress"][index] * 100)
except IndexError: except IndexError:
continue continue
if row[2] != progress_string: if row[2] != progress_string:

View File

@ -246,58 +246,11 @@
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment45">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label39">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Uploaded:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment44">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label38">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Downloaded:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="summary_total_uploaded"> <object class="GtkLabel" id="summary_total_uploaded">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">5</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -312,7 +265,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">5</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -322,33 +274,11 @@
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment48">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label42">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Down Speed:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="summary_download_speed"> <object class="GtkLabel" id="summary_download_speed">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">5</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -356,35 +286,11 @@
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment49">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label43">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Up Speed:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="summary_upload_speed"> <object class="GtkLabel" id="summary_upload_speed">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="xpad">5</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -394,29 +300,6 @@
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment50">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label45">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">ETA:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="summary_eta"> <object class="GtkLabel" id="summary_eta">
<property name="visible">True</property> <property name="visible">True</property>
@ -527,38 +410,6 @@
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="label41">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Share Ratio:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="summary_share_ratio">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">4</property>
<property name="right_attach">5</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkVSeparator" id="vseparator1"> <object class="GtkVSeparator" id="vseparator1">
<property name="visible">True</property> <property name="visible">True</property>
@ -596,11 +447,138 @@
<packing> <packing>
<property name="left_attach">3</property> <property name="left_attach">3</property>
<property name="right_attach">4</property> <property name="right_attach">4</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="summary_share_ratio">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkAlignment" id="alignment44">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label38">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Downloaded:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment48">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label42">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Down Speed:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment49">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label43">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Up Speed:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment50">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label45">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">ETA:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment45">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label39">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Uploaded:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="summary_seed_rank"> <object class="GtkLabel" id="summary_seed_rank">
<property name="visible">True</property> <property name="visible">True</property>
@ -610,6 +588,29 @@
<packing> <packing>
<property name="left_attach">4</property> <property name="left_attach">4</property>
<property name="right_attach">5</property> <property name="right_attach">5</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="right_padding">5</property>
<child>
<object class="GtkLabel" id="label41">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Share Ratio:</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
<packing>
<property name="top_attach">4</property> <property name="top_attach">4</property>
<property name="bottom_attach">5</property> <property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>

View File

@ -520,7 +520,7 @@ class ListView(object):
column.set_clickable(True) column.set_clickable(True)
column.set_resizable(True) column.set_resizable(True)
column.set_expand(False) column.set_expand(False)
column.set_min_width(10) column.set_min_width(20)
column.set_reorderable(True) column.set_reorderable(True)
column.set_visible(not hidden) column.set_visible(not hidden)
column.connect('button-press-event', column.connect('button-press-event',

View File

@ -300,9 +300,9 @@ class MainWindow(component.Component):
def update(self): def update(self):
# Update the window title # Update the window title
def _on_get_session_status(status): def _on_get_session_status(status):
download_rate = deluge.common.fsize_short(status["payload_download_rate"]) download_rate = deluge.common.fspeed(status["payload_download_rate"], precision=0, shortform=True)
upload_rate = deluge.common.fsize_short(status["payload_upload_rate"]) upload_rate = deluge.common.fspeed(status["payload_upload_rate"], precision=0, shortform=True)
self.window.set_title("%s%s %s%s - Deluge" % (_("D:"), download_rate, _("U:"), upload_rate)) self.window.set_title(_("D: %s U: %s - Deluge" % (download_rate, upload_rate)))
if self.config["show_rate_in_title"]: if self.config["show_rate_in_title"]:
client.core.get_session_status(["payload_download_rate", client.core.get_session_status(["payload_download_rate",
"payload_upload_rate"]).addCallback(_on_get_session_status) "payload_upload_rate"]).addCallback(_on_get_session_status)
@ -311,7 +311,7 @@ class MainWindow(component.Component):
if value: if value:
self.update() self.update()
else: else:
self.window.set_title("Deluge") self.window.set_title(_("Deluge"))
def on_newversionavailable_event(self, new_version): def on_newversionavailable_event(self, new_version):
if self.config["show_new_releases"]: if self.config["show_new_releases"]:

View File

@ -25,9 +25,9 @@ log = logging.getLogger(__name__)
def cell_data_progress(column, cell, model, row, data): def cell_data_progress(column, cell, model, row, data):
value = model.get_value(row, data) value = model.get_value(row, data) * 100
cell.set_property("value", value * 100) cell.set_property("value", value)
cell.set_property("text", "%.2f%%" % (value * 100)) cell.set_property("text", "%i%%" % value)
class PeersTab(Tab): class PeersTab(Tab):

View File

@ -18,8 +18,8 @@ from deluge.ui.gtkui.torrentdetails import Tab
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
def fpeer_sized(first, second): def ftotal_sized(first, second):
return "%s (%s)" % (fsize(first), fsize(second)) return "%s (%s)" % (fsize(first, shortform=True), fsize(second, shortform=True))
def fratio(value): def fratio(value):
@ -31,16 +31,18 @@ def fratio(value):
def fpcnt(value, state): def fpcnt(value, state):
if state: textstr = _(state)
state = _(state) + " " if state not in ("Error", "Seeding") and value < 100:
return "%s%.2f%%" % (state, value) textstr = ('%s %.2f' % (textstr, value)).rstrip('0').rstrip('.') + '%'
return textstr
def fspeed_max(value, max_value=-1): def fspeed_max(value, max_value=-1):
value = fspeed(value, shortform=True)
if max_value > -1: if max_value > -1:
return "%s (%s %s)" % (fspeed(value), max_value, _("KiB/s")) return "%s (%s %s)" % (value, max_value, _("K/s"))
else: else:
return fspeed(value) return value
def fdate_or_never(value): def fdate_or_never(value):
@ -59,6 +61,14 @@ def ftime_or_dash(value):
return "-" return "-"
def fseed_rank_or_dash(seed_rank, seeding_time):
"""Display value if seeding otherwise dash"""
if seeding_time > 0.0:
return str(seed_rank)
else:
return "-"
class StatusTab(Tab): class StatusTab(Tab):
def __init__(self): def __init__(self):
Tab.__init__(self) Tab.__init__(self)
@ -74,9 +84,9 @@ class StatusTab(Tab):
self.label_widgets = [ self.label_widgets = [
(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", (builder.get_object("summary_total_downloaded"), ftotal_sized, ("all_time_download",
"total_payload_download")), "total_payload_download")),
(builder.get_object("summary_total_uploaded"), fpeer_sized, ("total_uploaded", "total_payload_upload")), (builder.get_object("summary_total_uploaded"), ftotal_sized, ("total_uploaded", "total_payload_upload")),
(builder.get_object("summary_download_speed"), fspeed_max, ("download_payload_rate", "max_download_speed")), (builder.get_object("summary_download_speed"), fspeed_max, ("download_payload_rate", "max_download_speed")),
(builder.get_object("summary_upload_speed"), fspeed_max, ("upload_payload_rate", "max_upload_speed")), (builder.get_object("summary_upload_speed"), fspeed_max, ("upload_payload_rate", "max_upload_speed")),
(builder.get_object("summary_seeds"), fpeer, ("num_seeds", "total_seeds")), (builder.get_object("summary_seeds"), fpeer, ("num_seeds", "total_seeds")),
@ -85,7 +95,7 @@ class StatusTab(Tab):
(builder.get_object("summary_share_ratio"), fratio, ("ratio",)), (builder.get_object("summary_share_ratio"), fratio, ("ratio",)),
(builder.get_object("summary_active_time"), ftime_or_dash, ("active_time",)), (builder.get_object("summary_active_time"), ftime_or_dash, ("active_time",)),
(builder.get_object("summary_seed_time"), ftime_or_dash, ("seeding_time",)), (builder.get_object("summary_seed_time"), ftime_or_dash, ("seeding_time",)),
(builder.get_object("summary_seed_rank"), str, ("seed_rank",)), (builder.get_object("summary_seed_rank"), fseed_rank_or_dash, ("seed_rank", "seeding_time")),
(builder.get_object("progressbar"), fpcnt, ("progress", "state")), (builder.get_object("progressbar"), fpcnt, ("progress", "state")),
(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_torrent_status"), str, ("message",)), (builder.get_object("summary_torrent_status"), str, ("message",)),

View File

@ -12,8 +12,8 @@ import logging
import gobject import gobject
import gtk import gtk
import deluge.common
import deluge.component as component import deluge.component as component
from deluge.common import fsize, fspeed, get_pixmap
from deluge.configmanager import ConfigManager from deluge.configmanager import ConfigManager
from deluge.ui.client import client from deluge.ui.client import client
from deluge.ui.gtkui import common, dialogs from deluge.ui.gtkui import common, dialogs
@ -22,7 +22,7 @@ log = logging.getLogger(__name__)
class StatusBarItem(object): class StatusBarItem(object):
def __init__(self, image=None, stock=None, text=None, callback=None, tooltip=None): def __init__(self, image=None, stock=None, text=None, markup=False, callback=None, tooltip=None):
self._widgets = [] self._widgets = []
self._ebox = gtk.EventBox() self._ebox = gtk.EventBox()
self._hbox = gtk.HBox() self._hbox = gtk.HBox()
@ -41,7 +41,10 @@ class StatusBarItem(object):
self.set_image_from_stock(stock) self.set_image_from_stock(stock)
# Add text # Add text
self.set_text(text) if markup:
self.set_markup(text)
else:
self.set_text(text)
if callback is not None: if callback is not None:
self.set_callback(callback) self.set_callback(callback)
@ -149,25 +152,25 @@ class StatusBar(component.Component):
self.connections_item = self.add_item( self.connections_item = self.add_item(
stock=gtk.STOCK_NETWORK, stock=gtk.STOCK_NETWORK,
callback=self._on_connection_item_clicked, callback=self._on_connection_item_clicked,
tooltip=_("Connections"), pack_start=True) tooltip=_("Connections (Limit)"), pack_start=True)
self.download_item = self.add_item( self.download_item = self.add_item(
image=deluge.common.get_pixmap("downloading16.png"), image=get_pixmap("downloading16.png"),
callback=self._on_download_item_clicked, callback=self._on_download_item_clicked,
tooltip=_("Download Speed"), pack_start=True) tooltip=_("Download Speed (Limit)"), pack_start=True)
self.upload_item = self.add_item( self.upload_item = self.add_item(
image=deluge.common.get_pixmap("seeding16.png"), image=get_pixmap("seeding16.png"),
callback=self._on_upload_item_clicked, callback=self._on_upload_item_clicked,
tooltip=_("Upload Speed"), pack_start=True) tooltip=_("Upload Speed (Limit)"), pack_start=True)
self.traffic_item = self.add_item( self.traffic_item = self.add_item(
image=deluge.common.get_pixmap("traffic16.png"), image=get_pixmap("traffic16.png"),
callback=self._on_traffic_item_clicked, callback=self._on_traffic_item_clicked,
tooltip=_("Protocol Traffic Download/Upload"), pack_start=True) tooltip=_("Protocol Traffic (Down:Up)"), pack_start=True)
self.dht_item = StatusBarItem( self.dht_item = StatusBarItem(
image=deluge.common.get_pixmap("dht16.png"), tooltip=_("DHT Nodes")) image=get_pixmap("dht16.png"), tooltip=_("DHT Nodes"))
self.diskspace_item = self.add_item( self.diskspace_item = self.add_item(
stock=gtk.STOCK_HARDDISK, stock=gtk.STOCK_HARDDISK,
@ -176,8 +179,10 @@ class StatusBar(component.Component):
self.health_item = self.add_item( self.health_item = self.add_item(
stock=gtk.STOCK_DIALOG_ERROR, stock=gtk.STOCK_DIALOG_ERROR,
text=_("No Incoming Connections!"), text=_("<b><small>Port Issue</small></b>"),
callback=self._on_health_icon_clicked, pack_start=True) markup=True,
tooltip=_("No incoming connections, check port forwarding"),
callback=self._on_health_icon_clicked)
self.external_ip_item = self.add_item( self.external_ip_item = self.add_item(
tooltip=_("External IP Address"), pack_start=True) tooltip=_("External IP Address"), pack_start=True)
@ -221,10 +226,10 @@ class StatusBar(component.Component):
self.hbox.pack_start( self.hbox.pack_start(
self.not_connected_item.get_eventbox(), expand=False, fill=False) self.not_connected_item.get_eventbox(), expand=False, fill=False)
def add_item(self, image=None, stock=None, text=None, callback=None, tooltip=None, pack_start=False): def add_item(self, image=None, stock=None, text=None, markup=False, callback=None, tooltip=None, pack_start=False):
"""Adds an item to the status bar""" """Adds an item to the status bar"""
# The return tuple.. we return whatever widgets we add # The return tuple.. we return whatever widgets we add
item = StatusBarItem(image, stock, text, callback, tooltip) item = StatusBarItem(image, stock, text, markup, callback, tooltip)
if pack_start: if pack_start:
self.hbox.pack_start(item.get_eventbox(), expand=False, fill=False) self.hbox.pack_start(item.get_eventbox(), expand=False, fill=False)
else: else:
@ -298,8 +303,8 @@ class StatusBar(component.Component):
self.remove_item(self.dht_item) self.remove_item(self.dht_item)
def _on_get_session_status(self, status): def _on_get_session_status(self, status):
self.download_rate = deluge.common.fspeed(status["payload_download_rate"]) self.download_rate = fspeed(status["payload_download_rate"], precision=0, shortform=True)
self.upload_rate = deluge.common.fspeed(status["payload_upload_rate"]) self.upload_rate = fspeed(status["payload_upload_rate"], precision=0, shortform=True)
self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024 self.download_protocol_rate = (status["download_rate"] - status["payload_download_rate"]) / 1024
self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024 self.upload_protocol_rate = (status["upload_rate"] - status["payload_upload_rate"]) / 1024
self.num_connections = status["num_peers"] self.num_connections = status["num_peers"]
@ -319,7 +324,7 @@ class StatusBar(component.Component):
def _on_get_free_space(self, space): def _on_get_free_space(self, space):
if space >= 0: if space >= 0:
self.diskspace_item.set_text(deluge.common.fsize(space)) self.diskspace_item.set_markup("<small>%s</small>" % fsize(space, shortform=True))
else: else:
self.diskspace_item.set_markup("<span foreground=\"red\">" + _("Error") + "</span>") self.diskspace_item.set_markup("<span foreground=\"red\">" + _("Error") + "</span>")
@ -333,44 +338,44 @@ class StatusBar(component.Component):
def _on_get_external_ip(self, external_ip): def _on_get_external_ip(self, external_ip):
ip = external_ip if external_ip else _("n/a") ip = external_ip if external_ip else _("n/a")
self.external_ip_item.set_markup(_("<b>IP</b> %s") % ip) self.external_ip_item.set_markup(_("<b>IP</b> <small>%s</small>") % ip)
def update_connections_label(self): def update_connections_label(self):
# Set the max connections label # Set the max connections label
if self.max_connections_global < 0: if self.max_connections_global < 0:
label_string = "%s" % self.num_connections label_string = "%s" % self.num_connections
else: else:
label_string = "%s (%s)" % (self.num_connections, self.max_connections_global) label_string = "%s <small>(%s)</small>" % (self.num_connections, self.max_connections_global)
self.connections_item.set_text(label_string) self.connections_item.set_markup(label_string)
def update_dht_label(self): def update_dht_label(self):
# Set the max connections label # Set the max connections label
self.dht_item.set_text("%s" % (self.dht_nodes)) self.dht_item.set_markup("<small>%s</small>" % (self.dht_nodes))
def update_download_label(self): def update_download_label(self):
# Set the download speed label # Set the download speed label
if self.max_download_speed <= 0: if self.max_download_speed <= 0:
label_string = self.download_rate label_string = self.download_rate
else: else:
label_string = "%s (%s %s)" % ( label_string = "%s <small>(%i %s)</small>" % (
self.download_rate, self.max_download_speed, _("KiB/s")) self.download_rate, self.max_download_speed, _("K/s"))
self.download_item.set_text(label_string) self.download_item.set_markup(label_string)
def update_upload_label(self): def update_upload_label(self):
# Set the upload speed label # Set the upload speed label
if self.max_upload_speed <= 0: if self.max_upload_speed <= 0:
label_string = self.upload_rate label_string = self.upload_rate
else: else:
label_string = "%s (%s %s)" % ( label_string = "%s <small>(%i %s)</small>" % (
self.upload_rate, self.max_upload_speed, _("KiB/s")) self.upload_rate, self.max_upload_speed, _("K/s"))
self.upload_item.set_text(label_string) self.upload_item.set_markup(label_string)
def update_traffic_label(self): def update_traffic_label(self):
label_string = "%i/%i %s" % (self.download_protocol_rate, self.upload_protocol_rate, _("KiB/s")) label_string = "<small>%i:%i %s</small>" % (self.download_protocol_rate, self.upload_protocol_rate, _("K/s"))
self.traffic_item.set_text(label_string) self.traffic_item.set_markup(label_string)
def update(self): def update(self):
self.send_status_request() self.send_status_request()
@ -379,9 +384,9 @@ class StatusBar(component.Component):
log.debug("_on_set_unlimit_other %s", core_key) log.debug("_on_set_unlimit_other %s", core_key)
other_dialog_info = { other_dialog_info = {
"max_download_speed": (_("Download Speed Limit"), _("Set the maximum download speed"), "max_download_speed": (_("Download Speed Limit"), _("Set the maximum download speed"),
_("KiB/s"), "downloading.svg", self.max_download_speed), _("K/s"), "downloading.svg", self.max_download_speed),
"max_upload_speed": (_("Upload Speed Limit"), _("Set the maximum upload speed"), "max_upload_speed": (_("Upload Speed Limit"), _("Set the maximum upload speed"),
_("KiB/s"), "seeding.svg", self.max_upload_speed), _("K/s"), "seeding.svg", self.max_upload_speed),
"max_connections_global": (_("Incoming Connections"), _("Set the maximum incoming connections"), "max_connections_global": (_("Incoming Connections"), _("Set the maximum incoming connections"),
"", gtk.STOCK_NETWORK, self.max_connections_global) "", gtk.STOCK_NETWORK, self.max_connections_global)
} }
@ -413,7 +418,7 @@ class StatusBar(component.Component):
self.config["tray_download_speed_list"], self.config["tray_download_speed_list"],
self._on_set_download_speed, self._on_set_download_speed,
self.max_download_speed, self.max_download_speed,
_("KiB/s"), show_notset=True, show_other=True) _("K/s"), show_notset=True, show_other=True)
menu.show_all() menu.show_all()
menu.popup(None, None, None, event.button, event.time) menu.popup(None, None, None, event.button, event.time)
@ -426,7 +431,7 @@ class StatusBar(component.Component):
self.config["tray_upload_speed_list"], self.config["tray_upload_speed_list"],
self._on_set_upload_speed, self._on_set_upload_speed,
self.max_upload_speed, self.max_upload_speed,
_("KiB/s"), show_notset=True, show_other=True) _("K/s"), show_notset=True, show_other=True)
menu.show_all() menu.show_all()
menu.popup(None, None, None, event.button, event.time) menu.popup(None, None, None, event.button, event.time)

View File

@ -14,6 +14,7 @@ import gtk
import deluge.common import deluge.common
import deluge.component as component import deluge.component as component
from deluge.common import fspeed
from deluge.configmanager import ConfigManager from deluge.configmanager import ConfigManager
from deluge.ui.client import client from deluge.ui.client import client
from deluge.ui.gtkui import dialogs from deluge.ui.gtkui import dialogs
@ -192,8 +193,8 @@ class SystemTray(component.Component):
self.build_tray_bwsetsubmenu() self.build_tray_bwsetsubmenu()
def _on_get_session_status(self, status): def _on_get_session_status(self, status):
self.download_rate = deluge.common.fsize(status["payload_download_rate"]) self.download_rate = fspeed(status["payload_download_rate"], shortform=True)
self.upload_rate = deluge.common.fsize(status["payload_upload_rate"]) self.upload_rate = fspeed(status["payload_upload_rate"], shortform=True)
def update(self): def update(self):
if not self.config["enable_system_tray"]: if not self.config["enable_system_tray"]:
@ -214,11 +215,11 @@ class SystemTray(component.Component):
if max_download_speed == -1: if max_download_speed == -1:
max_download_speed = _("Unlimited") max_download_speed = _("Unlimited")
else: else:
max_download_speed = "%s %s" % (max_download_speed, _("KiB/s")) max_download_speed = "%s %s" % (max_download_speed, _("K/s"))
if max_upload_speed == -1: if max_upload_speed == -1:
max_upload_speed = _("Unlimited") max_upload_speed = _("Unlimited")
else: else:
max_upload_speed = "%s %s" % (max_upload_speed, _("KiB/s")) max_upload_speed = "%s %s" % (max_upload_speed, _("K/s"))
msg = '%s\n%s: %s (%s)\n%s: %s (%s)' % ( msg = '%s\n%s: %s (%s)\n%s: %s (%s)' % (
_("Deluge"), _("Down"), self.download_rate, _("Deluge"), _("Down"), self.download_rate,
@ -235,14 +236,14 @@ class SystemTray(component.Component):
submenu_bwdownset = build_menu_radio_list( submenu_bwdownset = build_menu_radio_list(
self.config["tray_download_speed_list"], self.on_tray_setbwdown, self.config["tray_download_speed_list"], self.on_tray_setbwdown,
self.max_download_speed, self.max_download_speed,
_("KiB/s"), show_notset=True, show_other=True _("K/s"), show_notset=True, show_other=True
) )
# Create the Upload speed list sub-menu # Create the Upload speed list sub-menu
submenu_bwupset = build_menu_radio_list( submenu_bwupset = build_menu_radio_list(
self.config["tray_upload_speed_list"], self.on_tray_setbwup, self.config["tray_upload_speed_list"], self.on_tray_setbwup,
self.max_upload_speed, self.max_upload_speed,
_("KiB/s"), show_notset=True, show_other=True _("K/s"), show_notset=True, show_other=True
) )
# Add the sub-menus to the tray menu # Add the sub-menus to the tray menu
self.builder.get_object("menuitem_download_limit").set_submenu( self.builder.get_object("menuitem_download_limit").set_submenu(
@ -393,7 +394,7 @@ class SystemTray(component.Component):
if widget.get_name() == "unlimited": if widget.get_name() == "unlimited":
set_value(-1) set_value(-1)
elif widget.get_name() == "other": elif widget.get_name() == "other":
dialog = dialogs.OtherDialog(header, text, _("KiB/s"), image, default) dialog = dialogs.OtherDialog(header, text, _("K/s"), image, default)
dialog.run().addCallback(set_value) dialog.run().addCallback(set_value)
else: else:
set_value(widget.get_children()[0].get_text().split(" ")[0]) set_value(widget.get_children()[0].get_text().split(" ")[0])

View File

@ -140,7 +140,7 @@ def cell_data_progress(column, cell, model, row, data):
# Marked for translate states text are in filtertreeview # Marked for translate states text are in filtertreeview
textstr = _(state_str) textstr = _(state_str)
if state_str not in ("Error", "Seeding") and value < 100: if state_str not in ("Error", "Seeding") and value < 100:
textstr = "%s %.2f%%" % (textstr, value) textstr = "%s %i%%" % (textstr, value)
if func_last_value["cell_data_progress"][1] != textstr: if func_last_value["cell_data_progress"][1] != textstr:
func_last_value["cell_data_progress"][1] = textstr func_last_value["cell_data_progress"][1] = textstr
@ -172,10 +172,11 @@ def cell_data_speed(cell, model, row, data, cache_key):
return return
func_last_value[cache_key] = speed func_last_value[cache_key] = speed
speed_str = ""
if speed > 0: if speed > 0:
speed_str = common.fspeed(speed) speed_str = common.fspeed(speed, shortform=True)
cell.set_property('text', speed_str) cell.set_property("markup", "{0} <small>{1}</small>".format(*tuple(speed_str.split())))
else:
cell.set_property("text", "")
def cell_data_speed_down(column, cell, model, row, data): def cell_data_speed_down(column, cell, model, row, data):
@ -196,10 +197,11 @@ def cell_data_speed_limit(cell, model, row, data, cache_key):
return return
func_last_value[cache_key] = speed func_last_value[cache_key] = speed
speed_str = ""
if speed > 0: if speed > 0:
speed_str = common.fspeed(speed * 1024) speed_str = common.fspeed(speed * 1024, shortform=True)
cell.set_property('text', speed_str) cell.set_property("markup", "{0} <small>{1}</small>".format(*tuple(speed_str.split())))
else:
cell.set_property("text", "")
def cell_data_speed_limit_down(column, cell, model, row, data): def cell_data_speed_limit_down(column, cell, model, row, data):
@ -213,7 +215,7 @@ def cell_data_speed_limit_up(column, cell, model, row, data):
def cell_data_size(column, cell, model, row, data): def cell_data_size(column, cell, model, row, data):
"""Display value in terms of size, eg. 2 MB""" """Display value in terms of size, eg. 2 MB"""
size = model.get_value(row, data) size = model.get_value(row, data)
cell.set_property('text', common.fsize(size)) cell.set_property('text', common.fsize(size, shortform=True))
def cell_data_peer(column, cell, model, row, data): def cell_data_peer(column, cell, model, row, data):
@ -241,13 +243,13 @@ def cell_data_time(column, cell, model, row, data):
def cell_data_ratio(cell, model, row, data, cache_key): def cell_data_ratio(cell, model, row, data, cache_key):
"""Display value as a ratio with a precision of 3.""" """Display value as a ratio with a precision of 2."""
ratio = model.get_value(row, data) ratio = model.get_value(row, data)
# Previous value in cell is the same as for this value, so ignore # Previous value in cell is the same as for this value, so ignore
if func_last_value[cache_key] == ratio: if func_last_value[cache_key] == ratio:
return return
func_last_value[cache_key] = ratio func_last_value[cache_key] = ratio
cell.set_property('text', "" if ratio < 0 else "%.3f" % ratio) cell.set_property("text", "" if ratio < 0 else ("%.1f" % ratio).rstrip("0").rstrip("."))
def cell_data_ratio_seeds_peers(column, cell, model, row, data): def cell_data_ratio_seeds_peers(column, cell, model, row, data):
@ -270,7 +272,7 @@ def cell_data_date(column, cell, model, row, data, key):
return return
func_last_value[key] = date func_last_value[key] = date
date_str = common.fdate(date) if date > 0 else "" date_str = common.fdate(date, date_only=True) if date > 0 else ""
cell.set_property('text', date_str) cell.set_property('text', date_str)
cell_data_date_added = partial(cell_data_date, key="cell_data_date_added") cell_data_date_added = partial(cell_data_date, key="cell_data_date_added")
@ -285,5 +287,5 @@ def cell_data_date_or_never(column, cell, model, row, data):
return return
func_last_value["cell_data_date_or_never"] = value func_last_value["cell_data_date_or_never"] = value
date_str = common.fdate(value) if value > 0 else _("Never") date_str = common.fdate(value, date_only=True) if value > 0 else _("Never")
cell.set_property('text', date_str) cell.set_property('text', date_str)