Enable expanding/collapsing filters

This commit is contained in:
Andrew Resch 2008-11-23 08:04:03 +00:00
parent 2b6b1a9ee7
commit 9bbc0fd8ea
1 changed files with 24 additions and 19 deletions

View File

@ -36,21 +36,21 @@ from deluge.ui.client import aclient
from deluge.configmanager import ConfigManager
STATE_PIX = {
"All":"all",
"Downloading":"downloading",
"Seeding":"seeding",
"Paused":"inactive",
"Checking":"checking",
"Queued":"queued",
"Error":"alert",
"Active":"active"
"All": "all",
"Downloading": "downloading",
"Seeding": "seeding",
"Paused": "inactive",
"Checking": "checking",
"Queued": "queued",
"Error": "alert",
"Active": "active"
}
TRANSLATE = {
"state":"State",
"tracker_host":"Tracker",
"label":"Label"
"state": "States",
"tracker_host": "Trackers",
"label": "Labels"
}
FILTER_COLUMN = 5
@ -94,7 +94,7 @@ class FilterTreeView(component.Component):
# Create the liststore
#cat, value, label, count, pixmap, visible
self.treestore = gtk.TreeStore(str, str,str, int, gtk.gdk.Pixbuf, bool)
self.treestore = gtk.TreeStore(str, str, str, int, gtk.gdk.Pixbuf, bool)
#add Cat nodes:
self.cat_nodes = {}
@ -113,8 +113,9 @@ class FilterTreeView(component.Component):
self.label_view.append_column(column)
#style:
self.label_view.set_show_expanders(False)
self.label_view.set_show_expanders(True)
self.label_view.set_headers_visible(False)
self.label_view.set_level_indentation(-35)
self.label_view.set_model(self.treestore)
self.label_view.get_selection().connect("changed", self.on_selection_changed)
@ -149,7 +150,6 @@ class FilterTreeView(component.Component):
if not cat in self.cat_nodes:
self.cat_nodes[cat] = self.treestore.append(None, ["cat", cat, _t(cat), 0, None, False])
#update rows
visible_filters = []
for cat,filters in filter_items.iteritems():
@ -169,7 +169,6 @@ class FilterTreeView(component.Component):
if not f in visible_filters:
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
self.label_view.expand_all()
(model, row) = self.label_view.get_selection().get_selected()
if not row:
self.select_default_filter()
@ -200,10 +199,9 @@ class FilterTreeView(component.Component):
count = model.get_value(row, 3)
pix = model.get_value(row, 4)
if (label == "") and cat == "label":
if label == "" and cat == "label":
label = _("no label")
if pix:
self.renderpix.set_property("visible", True)
else:
@ -289,6 +287,13 @@ class FilterTreeView(component.Component):
if event.button == 1:
# Prevent selecting a category label
if cat == "cat":
if self.label_view.row_expanded(path):
self.label_view.collapse_row(path)
else:
self.label_view.expand_row(path, False)
(model, row) = self.label_view.get_selection().get_selected()
if not row:
self.select_default_filter()
return True
elif event.button == 3: