Add 'Queued' label to SideBar.

Fix the labels filter from not displaying properly.
This commit is contained in:
Andrew Resch 2008-03-03 09:05:02 +00:00
parent 8de2946da2
commit 0e31d4243c
3 changed files with 31 additions and 10 deletions

View File

@ -211,6 +211,17 @@ class ListView:
else:
return self.columns[name].column_indices[0]
def get_state_field_column(self, field):
"""Returns the column number for the state field"""
for column in self.columns.keys():
if self.columns[column].status_field == None:
continue
for f in self.columns[column].status_field:
if field == f:
return self.columns[column].column_indices[
self.columns[column].status_field.index(f)]
def on_menuitem_toggled(self, widget):
"""Callback for the generated column menuitems."""
# Get the column name from the widget

View File

@ -57,6 +57,9 @@ class SideBar(component.Component):
self.liststore.append([_("Seeding"),
gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("seeding16.png"))])
self.liststore.append([_("Queued"),
gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("queued16.png"))])
self.liststore.append([_("Paused"),
gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("inactive16.png"))])
@ -104,9 +107,9 @@ class SideBar(component.Component):
component.get("TorrentView").set_filter("state",
"Downloading")
if value == "Seeding":
component.get("TorrentView").set_filter("state",
"Seeding")
component.get("TorrentView").set_filter("state", "Seeding")
if value == "Queued":
component.get("TorrentView").set_filter("state", "Queued")
if value == "Paused":
component.get("TorrentView").set_filter("state",
"Paused")
component.get("TorrentView").set_filter("state", "Paused")

View File

@ -187,7 +187,8 @@ class TorrentView(listview.ListView, component.Component):
def _on_session_state(self, state):
for torrent_id in state:
self.add_row(torrent_id)
self.update_filter()
self.update()
def stop(self):
@ -201,7 +202,12 @@ class TorrentView(listview.ListView, component.Component):
def set_filter(self, field, condition):
"""Sets filters for the torrentview.."""
if self.filter != (None, None):
self.filter = (None, None)
self.update_filter()
self.filter = (field, condition)
self.update_filter()
self.update()
def send_status_request(self, columns=None):
@ -254,7 +260,7 @@ class TorrentView(listview.ListView, component.Component):
client.get_torrents_status(
self._on_get_torrents_status, torrent_ids, status_keys)
def update(self):
def update_filter(self):
# Update the filter view
def foreachrow(model, path, row, data):
filter_column = self.columns["filter"].column_indices[0]
@ -266,10 +272,8 @@ class TorrentView(listview.ListView, component.Component):
return
torrent_id = model.get_value(row, 0)
try:
value = self.status[torrent_id][field]
except:
return
value = model.get_value(row, self.get_state_field_column(field))
# Condition is True, so lets show this row, if not we hide it
if value == condition:
model.set_value(row, filter_column, True)
@ -277,6 +281,8 @@ class TorrentView(listview.ListView, component.Component):
model.set_value(row, filter_column, False)
self.liststore.foreach(foreachrow, self.filter)
def update(self):
# Send a status request
self.send_status_request()
@ -349,6 +355,7 @@ class TorrentView(listview.ListView, component.Component):
row,
self.columns["torrent_id"].column_indices[0],
torrent_id)
self.update()
def remove_row(self, torrent_id):
"""Removes a row with torrent_id"""