Enable expanding/collapsing filters
This commit is contained in:
parent
2b6b1a9ee7
commit
9bbc0fd8ea
|
@ -36,21 +36,21 @@ from deluge.ui.client import aclient
|
||||||
from deluge.configmanager import ConfigManager
|
from deluge.configmanager import ConfigManager
|
||||||
|
|
||||||
STATE_PIX = {
|
STATE_PIX = {
|
||||||
"All":"all",
|
"All": "all",
|
||||||
"Downloading":"downloading",
|
"Downloading": "downloading",
|
||||||
"Seeding":"seeding",
|
"Seeding": "seeding",
|
||||||
"Paused":"inactive",
|
"Paused": "inactive",
|
||||||
"Checking":"checking",
|
"Checking": "checking",
|
||||||
"Queued":"queued",
|
"Queued": "queued",
|
||||||
"Error":"alert",
|
"Error": "alert",
|
||||||
"Active":"active"
|
"Active": "active"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TRANSLATE = {
|
TRANSLATE = {
|
||||||
"state":"State",
|
"state": "States",
|
||||||
"tracker_host":"Tracker",
|
"tracker_host": "Trackers",
|
||||||
"label":"Label"
|
"label": "Labels"
|
||||||
}
|
}
|
||||||
|
|
||||||
FILTER_COLUMN = 5
|
FILTER_COLUMN = 5
|
||||||
|
@ -94,7 +94,7 @@ class FilterTreeView(component.Component):
|
||||||
|
|
||||||
# Create the liststore
|
# Create the liststore
|
||||||
#cat, value, label, count, pixmap, visible
|
#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:
|
#add Cat nodes:
|
||||||
self.cat_nodes = {}
|
self.cat_nodes = {}
|
||||||
|
@ -113,8 +113,9 @@ class FilterTreeView(component.Component):
|
||||||
self.label_view.append_column(column)
|
self.label_view.append_column(column)
|
||||||
|
|
||||||
#style:
|
#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_headers_visible(False)
|
||||||
|
self.label_view.set_level_indentation(-35)
|
||||||
|
|
||||||
self.label_view.set_model(self.treestore)
|
self.label_view.set_model(self.treestore)
|
||||||
self.label_view.get_selection().connect("changed", self.on_selection_changed)
|
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:
|
if not cat in self.cat_nodes:
|
||||||
self.cat_nodes[cat] = self.treestore.append(None, ["cat", cat, _t(cat), 0, None, False])
|
self.cat_nodes[cat] = self.treestore.append(None, ["cat", cat, _t(cat), 0, None, False])
|
||||||
|
|
||||||
|
|
||||||
#update rows
|
#update rows
|
||||||
visible_filters = []
|
visible_filters = []
|
||||||
for cat,filters in filter_items.iteritems():
|
for cat,filters in filter_items.iteritems():
|
||||||
|
@ -169,7 +169,6 @@ class FilterTreeView(component.Component):
|
||||||
if not f in visible_filters:
|
if not f in visible_filters:
|
||||||
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
|
self.treestore.set_value(self.filters[f], FILTER_COLUMN, False)
|
||||||
|
|
||||||
self.label_view.expand_all()
|
|
||||||
(model, row) = self.label_view.get_selection().get_selected()
|
(model, row) = self.label_view.get_selection().get_selected()
|
||||||
if not row:
|
if not row:
|
||||||
self.select_default_filter()
|
self.select_default_filter()
|
||||||
|
@ -194,16 +193,15 @@ class FilterTreeView(component.Component):
|
||||||
|
|
||||||
def render_cell_data(self, column, cell, model, row, data):
|
def render_cell_data(self, column, cell, model, row, data):
|
||||||
"cell renderer"
|
"cell renderer"
|
||||||
cat = model.get_value(row, 0)
|
cat = model.get_value(row, 0)
|
||||||
value = model.get_value(row, 1)
|
value = model.get_value(row, 1)
|
||||||
label = model.get_value(row, 2)
|
label = model.get_value(row, 2)
|
||||||
count = model.get_value(row, 3)
|
count = model.get_value(row, 3)
|
||||||
pix = model.get_value(row, 4)
|
pix = model.get_value(row, 4)
|
||||||
|
|
||||||
if (label == "") and cat == "label":
|
if label == "" and cat == "label":
|
||||||
label = _("no label")
|
label = _("no label")
|
||||||
|
|
||||||
|
|
||||||
if pix:
|
if pix:
|
||||||
self.renderpix.set_property("visible", True)
|
self.renderpix.set_property("visible", True)
|
||||||
else:
|
else:
|
||||||
|
@ -289,6 +287,13 @@ class FilterTreeView(component.Component):
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
# Prevent selecting a category label
|
# Prevent selecting a category label
|
||||||
if cat == "cat":
|
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
|
return True
|
||||||
|
|
||||||
elif event.button == 3:
|
elif event.button == 3:
|
||||||
|
@ -298,7 +303,7 @@ class FilterTreeView(component.Component):
|
||||||
if not path:
|
if not path:
|
||||||
return
|
return
|
||||||
row = self.model_filter.get_iter(path[0])
|
row = self.model_filter.get_iter(path[0])
|
||||||
self.cat = self.model_filter.get_value(row, 0)
|
self.cat = self.model_filter.get_value(row, 0)
|
||||||
self.value = self.model_filter.get_value(row, 1)
|
self.value = self.model_filter.get_value(row, 1)
|
||||||
self.count = self.model_filter.get_value(row, 3)
|
self.count = self.model_filter.get_value(row, 3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue