UI tweaks.

This commit is contained in:
Andrew Resch 2007-11-30 06:20:47 +00:00
parent f817de3575
commit e32f603103
8 changed files with 171 additions and 150 deletions

View File

@ -127,7 +127,10 @@ def fspeed(bps):
def fpeer(num_peers, total_peers):
"""Returns a formatted string num_peers (total_peers)"""
return str(str(num_peers) + " (" + str(total_peers) + ")")
if total_peers > -1:
return str(str(num_peers) + " (" + str(total_peers) + ")")
else:
return str(num_peers)
def ftime(seconds):
"""Returns a formatted time string"""

View File

@ -128,17 +128,6 @@ class Torrent:
# Adjust progress to be 0-100 value
progress = status.progress*100
# Get the total number of seeds and peers
if status.num_complete == -1:
total_seeds = status.num_seeds
else:
total_seeds = status.num_complete
if status.num_incomplete == -1:
total_peers = status.num_peers - status.num_seeds
else:
total_peers = status.num_incomplete
# Set the state to 'Paused' if the torrent is paused.
state = status.state
if status.paused:
@ -168,8 +157,8 @@ class Torrent:
"upload_payload_rate": status.upload_payload_rate,
"num_peers": status.num_peers - status.num_seeds,
"num_seeds": status.num_seeds,
"total_peers": total_peers,
"total_seeds": total_seeds,
"total_peers": status.num_incomplete,
"total_seeds": status.num_complete,
"total_wanted": status.total_wanted,
"eta": self.get_eta(),
"ratio": self.get_ratio(),

View File

@ -531,7 +531,8 @@ class TorrentManager:
torrent_id = str(alert.handle.info_hash())
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(_("Announce OK"))
if alert.msg != "Got peers from DHT":
self.torrents[torrent_id].set_tracker_status(_("Announce OK"))
except KeyError:
log.debug("torrent_id doesn't exist.")
@ -555,10 +556,8 @@ class TorrentManager:
log.debug("on_alert_tracker")
# Get the torrent_id
torrent_id = str(alert.handle.info_hash())
tracker_status = "%s: %s (%s=%s, %s=%s)" % \
(_("Alert"), str(alert.msg()),
_("HTTP code"), alert.status_code,
_("times in a row"), alert.times_in_row)
tracker_status = "%s: %s" % \
(_("Alert"), str(alert.msg()).strip('"')[8:])
# Set the tracker status for the torrent
try:
self.torrents[torrent_id].set_tracker_status(tracker_status)

View File

@ -904,6 +904,7 @@
<widget class="GtkLabel" id="summary_num_files">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -917,6 +918,7 @@
<widget class="GtkLabel" id="summary_total_size">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -931,7 +933,8 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
<property name="wrap_mode">PANGO_WRAP_CHAR</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1048,7 +1051,8 @@
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
<property name="wrap_mode">PANGO_WRAP_CHAR</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1062,6 +1066,9 @@
<widget class="GtkLabel" id="summary_tracker_status">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_CHAR</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1075,6 +1082,8 @@
<widget class="GtkLabel" id="summary_next_announce">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
@ -1111,7 +1120,8 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="wrap">True</property>
<property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property>
<property name="wrap_mode">PANGO_WRAP_CHAR</property>
<property name="selectable">True</property>
</widget>
<packing>
<property name="left_attach">1</property>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Sat Nov 24 21:20:04 2007 -->
<!--Generated with glade3 3.4.0 on Thu Nov 29 00:22:05 2007 -->
<glade-interface>
<widget class="GtkDialog" id="pref_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -263,7 +263,7 @@
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">Automatically add torrent files that are placed in this folder.</property>
<property name="label" translatable="yes">Client Auto Add:</property>
<property name="label" translatable="yes">Client Folder:</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
@ -296,7 +296,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Daemon Auto Add:</property>
<property name="label" translatable="yes">Daemon Folder:</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
@ -568,6 +568,7 @@
<widget class="GtkSpinButton" id="spin_port_min">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="max_length">5</property>
<property name="xalign">1</property>
<property name="adjustment">0 0 65535 1 10 10</property>
@ -597,6 +598,7 @@
<widget class="GtkSpinButton" id="spin_port_max">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="max_length">5</property>
<property name="xalign">1</property>
<property name="adjustment">0 0 65535 1 10 10</property>
@ -1078,71 +1080,40 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkLabel" id="label16">
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_global">
<widget class="GtkSpinButton" id="spin_max_upload">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="digits">1</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
@ -1167,43 +1138,74 @@ Either</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload">
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="digits">1</property>
<property name="numeric">True</property>
<property name="tooltip" translatable="yes">The maximum download speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Download Speed (KiB/s):</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_global">
<widget class="GtkSpinButton" id="spin_max_connections_global">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots for all torrents. Set -1 for unlimited.</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="max_length">4</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">GTK_UPDATE_IF_VALID</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum number of connections allowed. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">The maximum upload speed for all torrents. Set -1 for unlimited.</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Speed (KiB/s):</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>
@ -1247,29 +1249,24 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">15</property>
<child>
<widget class="GtkLabel" id="label18">
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_connections_per_torrent">
<property name="visible">True</property>
@ -1287,19 +1284,24 @@ Either</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spin_max_upload_slots_per_torrent">
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip" translatable="yes">The maximum upload slots per torrent. Set -1 for unlimited.</property>
<property name="xalign">1</property>
<property name="adjustment">-1 -1 9000 1 10 10</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Connections:</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Maximum Upload Slots:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@ -1550,15 +1552,33 @@ Either</property>
<property name="n_columns">2</property>
<property name="column_spacing">10</property>
<child>
<widget class="GtkEntry" id="txt_open_folder_location">
<widget class="GtkRadioButton" id="radio_open_folder_stock">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Open folder with:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_custom">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Custom:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_open_folder_stock</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
@ -1588,38 +1608,20 @@ Thunar</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_custom">
<widget class="GtkEntry" id="txt_open_folder_location">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Custom:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_open_folder_stock</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_open_folder_stock">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Open folder with:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_toggle"/>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@ -43,7 +43,10 @@ from deluge.log import LOG as log
def cell_data_speed(column, cell, model, row, data):
"""Display value as a speed, eg. 2 KiB/s"""
speed = int(model.get_value(row, data))
speed_str = deluge.common.fspeed(speed)
speed_str = ""
if speed > 0:
speed_str = deluge.common.fspeed(speed)
cell.set_property('text', speed_str)
def cell_data_size(column, cell, model, row, data):
@ -57,7 +60,11 @@ def cell_data_peer(column, cell, model, row, data):
column1, column2 = data
first = int(model.get_value(row, column1))
second = int(model.get_value(row, column2))
cell.set_property('text', '%d (%d)' % (first, second))
# Only display a (total) if second is greater than -1
if second > -1:
cell.set_property('text', '%d (%d)' % (first, second))
else:
cell.set_property('text', '%d' % first)
def cell_data_time(column, cell, model, row, data):
"""Display value as time, eg 1m10s"""

View File

@ -465,6 +465,7 @@ class Preferences(component.Component):
# Disable the port spinners if random ports is selected.
if widget == self.glade.get_widget("chk_random_port"):
log.debug("chk_random_port set to: %s", value)
self.glade.get_widget("spin_port_min").set_sensitive(not value)
self.glade.get_widget("spin_port_max").set_sensitive(not value)

View File

@ -45,30 +45,40 @@ import deluge.ui.client as client
from deluge.log import LOG as log
import deluge.ui.gtkui.listview as listview
# Status icons.. Create them from file only once to avoid constantly
# re-creating them.
icon_downloading = gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("downloading16.png"))
icon_seeding = gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("seeding16.png"))
icon_inactive = gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("inactive16.png"))
def cell_data_statusicon(column, cell, model, row, data):
"""Display text with an icon"""
state = model.get_value(row, data)
icon = None
if state == deluge.common.TORRENT_STATE.index("Connecting"):
fname = "downloading16.png"
icon = icon_downloading
if state == deluge.common.TORRENT_STATE.index("Downloading"):
fname = "downloading16.png"
icon = icon_downloading
if state == deluge.common.TORRENT_STATE.index("Downloading Metadata"):
fname = "downloading16.png"
icon = icon_downloading
if state == deluge.common.TORRENT_STATE.index("Queued"):
fname = "inactive16.png"
icon = icon_inactive
if state == deluge.common.TORRENT_STATE.index("Paused"):
fname = "inactive16.png"
icon = icon_inactive
if state == deluge.common.TORRENT_STATE.index("Checking"):
fname = "downloading16.png"
icon = icon_downloading
if state == deluge.common.TORRENT_STATE.index("Allocating"):
fname = "downloading16.png"
icon = icon_downloading
if state == deluge.common.TORRENT_STATE.index("Finished"):
fname = "seeding16.png"
icon = icon_seeding
if state == deluge.common.TORRENT_STATE.index("Seeding"):
fname = "seeding16.png"
icon = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap(fname))
cell.set_property("pixbuf", icon)
icon = icon_seeding
if icon != None:
cell.set_property("pixbuf", icon)
def cell_data_progress(column, cell, model, row, data):
"""Display progress bar with text"""