Add 'Queued' label to SideBar.
Fix the labels filter from not displaying properly.
This commit is contained in:
parent
8de2946da2
commit
0e31d4243c
|
@ -211,6 +211,17 @@ class ListView:
|
||||||
else:
|
else:
|
||||||
return self.columns[name].column_indices[0]
|
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):
|
def on_menuitem_toggled(self, widget):
|
||||||
"""Callback for the generated column menuitems."""
|
"""Callback for the generated column menuitems."""
|
||||||
# Get the column name from the widget
|
# Get the column name from the widget
|
||||||
|
|
|
@ -57,6 +57,9 @@ class SideBar(component.Component):
|
||||||
self.liststore.append([_("Seeding"),
|
self.liststore.append([_("Seeding"),
|
||||||
gtk.gdk.pixbuf_new_from_file(
|
gtk.gdk.pixbuf_new_from_file(
|
||||||
deluge.common.get_pixmap("seeding16.png"))])
|
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"),
|
self.liststore.append([_("Paused"),
|
||||||
gtk.gdk.pixbuf_new_from_file(
|
gtk.gdk.pixbuf_new_from_file(
|
||||||
deluge.common.get_pixmap("inactive16.png"))])
|
deluge.common.get_pixmap("inactive16.png"))])
|
||||||
|
@ -104,9 +107,9 @@ class SideBar(component.Component):
|
||||||
component.get("TorrentView").set_filter("state",
|
component.get("TorrentView").set_filter("state",
|
||||||
"Downloading")
|
"Downloading")
|
||||||
if value == "Seeding":
|
if value == "Seeding":
|
||||||
component.get("TorrentView").set_filter("state",
|
component.get("TorrentView").set_filter("state", "Seeding")
|
||||||
"Seeding")
|
if value == "Queued":
|
||||||
|
component.get("TorrentView").set_filter("state", "Queued")
|
||||||
if value == "Paused":
|
if value == "Paused":
|
||||||
component.get("TorrentView").set_filter("state",
|
component.get("TorrentView").set_filter("state", "Paused")
|
||||||
"Paused")
|
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,8 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
def _on_session_state(self, state):
|
def _on_session_state(self, state):
|
||||||
for torrent_id in state:
|
for torrent_id in state:
|
||||||
self.add_row(torrent_id)
|
self.add_row(torrent_id)
|
||||||
|
|
||||||
|
self.update_filter()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
@ -201,7 +202,12 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
|
|
||||||
def set_filter(self, field, condition):
|
def set_filter(self, field, condition):
|
||||||
"""Sets filters for the torrentview.."""
|
"""Sets filters for the torrentview.."""
|
||||||
|
if self.filter != (None, None):
|
||||||
|
self.filter = (None, None)
|
||||||
|
self.update_filter()
|
||||||
|
|
||||||
self.filter = (field, condition)
|
self.filter = (field, condition)
|
||||||
|
self.update_filter()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def send_status_request(self, columns=None):
|
def send_status_request(self, columns=None):
|
||||||
|
@ -254,7 +260,7 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
client.get_torrents_status(
|
client.get_torrents_status(
|
||||||
self._on_get_torrents_status, torrent_ids, status_keys)
|
self._on_get_torrents_status, torrent_ids, status_keys)
|
||||||
|
|
||||||
def update(self):
|
def update_filter(self):
|
||||||
# Update the filter view
|
# Update the filter view
|
||||||
def foreachrow(model, path, row, data):
|
def foreachrow(model, path, row, data):
|
||||||
filter_column = self.columns["filter"].column_indices[0]
|
filter_column = self.columns["filter"].column_indices[0]
|
||||||
|
@ -266,10 +272,8 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
return
|
return
|
||||||
|
|
||||||
torrent_id = model.get_value(row, 0)
|
torrent_id = model.get_value(row, 0)
|
||||||
try:
|
value = model.get_value(row, self.get_state_field_column(field))
|
||||||
value = self.status[torrent_id][field]
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
# Condition is True, so lets show this row, if not we hide it
|
# Condition is True, so lets show this row, if not we hide it
|
||||||
if value == condition:
|
if value == condition:
|
||||||
model.set_value(row, filter_column, True)
|
model.set_value(row, filter_column, True)
|
||||||
|
@ -277,6 +281,8 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
model.set_value(row, filter_column, False)
|
model.set_value(row, filter_column, False)
|
||||||
|
|
||||||
self.liststore.foreach(foreachrow, self.filter)
|
self.liststore.foreach(foreachrow, self.filter)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
# Send a status request
|
# Send a status request
|
||||||
self.send_status_request()
|
self.send_status_request()
|
||||||
|
|
||||||
|
@ -349,6 +355,7 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
row,
|
row,
|
||||||
self.columns["torrent_id"].column_indices[0],
|
self.columns["torrent_id"].column_indices[0],
|
||||||
torrent_id)
|
torrent_id)
|
||||||
|
self.update()
|
||||||
|
|
||||||
def remove_row(self, torrent_id):
|
def remove_row(self, torrent_id):
|
||||||
"""Removes a row with torrent_id"""
|
"""Removes a row with torrent_id"""
|
||||||
|
|
Loading…
Reference in New Issue