From 98ca371b15596a2d9ffe120ddb1ed47e62583da2 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 11 Feb 2011 20:24:27 +0000 Subject: [PATCH] Sidebar: Enabled strings for translation and added icons to Trackers filter --- deluge/data/pixmaps/tracker_all16.png | Bin 0 -> 1097 bytes deluge/data/pixmaps/tracker_warning16.png | Bin 0 -> 683 bytes deluge/ui/gtkui/filtertreeview.py | 79 ++++++++++++++++------ 3 files changed, 59 insertions(+), 20 deletions(-) create mode 100644 deluge/data/pixmaps/tracker_all16.png create mode 100644 deluge/data/pixmaps/tracker_warning16.png diff --git a/deluge/data/pixmaps/tracker_all16.png b/deluge/data/pixmaps/tracker_all16.png new file mode 100644 index 0000000000000000000000000000000000000000..36756bbcc50598f12930a2ef3c2cf4fa5a7f6b1d GIT binary patch literal 1097 zcmV-P1h)H$P)Mh5=KJ?A0000XbVXQnQ*U*0V`TtnbaZe!FE46oZEay=E^T#lX=7+% zY-}!LdTD0kUH||CUr9tkR5*=QlS^n^WdKIc|KB^WkauDp&DcClXq+ZcN}_p~P+O=X zU8rD#rXJlA3k|;FP;f5UmkYG zOUg&eii>VsxzsH>TI*zWMG-sU3=3;PHUcqgerZ!3nn$;)(siQ~6CYU51*v(%+qMKKSgCKX z4fVCZ_g0Tq;?|IwMCwi)MU@~l$~=OcaX_g@GIH&b)*jz5);peb;+^Z7)sV z{poY5l#P)qu)3YVciM+#=2+c|U>h;coN7eV1VRWb8_s_^T8PH8ol;13^~+B#2!Q1N z0qa{4>Kj|1pOnj{!L}ItV}`MNQ|#;|&^5UF{_7Id6rUVl!JO{v7=4uIxE{5N=j?k3?^_nbn=BG z68i=(SG!P3;c>h0);d^P+eX-VjJyqSR!?P2wj+lWj3mwy2cb}if^btfvPoxin0lO7 zTAENwp_HPfp^`__bL2%8AkZyat*>rIUd6H=f|$%mXf* z@iNeLibNtxBAw^ZHV~)7Q%`OuT z2Z=_**jgE(SmwyG)RYvq{N>@_3s$Me#q5(kLZJZRaFF?xZ8mmeL?aRMsSx|g7~yb` zOxC2)ThE_U3rYxnlL7yonN&La^MlD*^F&QOmSr=)w1R(ei(EWFF0o5K86%SgX7DCM%L7&ED!8Zx5Unt&MfkTU&_`l3+B=`exW3zdvPX z4C7X?es5GwOjySR&p7eM7hOV#Au08KA?QRYOCc65%l2c5@!-szV>$m1)CR6}i*V)1 P00000NkvXXu0mjf>s09q literal 0 HcmV?d00001 diff --git a/deluge/data/pixmaps/tracker_warning16.png b/deluge/data/pixmaps/tracker_warning16.png new file mode 100644 index 0000000000000000000000000000000000000000..219432c44d6d57179930a1f307e3c48e89afc4ab GIT binary patch literal 683 zcmV;c0#yBpP)9ZU- zJm)h#N36B9OZl!8l{jy(t%?rAOVLMmqg_w6eGMq>y)vcgVLftjGBlAF9eeFAD|h6A zE}R^fL{3yPr&Mn2T8*$-E~ff=U-q*n`~fdev1JxTbp*C|xhmOVUs`ok zzR29t3Uf;<=zIxfo7nVFZtFWUZGo+8;x%;gK_u#V;(Dmm5wgBRt}BAd^db=#H}1!q z5?flkA?`mwMYt95bB+$G=>9QmP@|A`C}bRLYaiV|foat+iSC#*xqblnbVV{P9i2tL!53jp$NhCXHZJksZSZf_Ci#QEQYK%adAKLHL=TMO?5xw}p?AtWG(o^r zGKvGxc)xmJ7U^GS{qOYvaThoE#u-y@^77*b3)bSc>2-_<`yxD(PT%>k`3YlFonmk< R;ST@+002ovPDHLkV1l9fDaHT* literal 0 HcmV?d00001 diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index d7a242840..1b10e9246 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtkui/filtertreeview.py @@ -39,6 +39,7 @@ import gtk import gtk.glade import logging import pkg_resources +import glib import deluge.component as component import deluge.common @@ -58,21 +59,38 @@ STATE_PIX = { "Active": "active" } - -TRANSLATE = { - "state": "States", - "tracker_host": "Trackers", - "label": "Labels", - "owner": "Owner" +TRACKER_PIX = { + "All": "tracker_all", + "Error": "tracker_warning", } -FILTER_COLUMN = 5 +def _(message): return message + +TRANSLATE = { + "state": _("States"), + "tracker_host": _("Trackers"), + "label": _("Labels"), + "owner": _("Owner"), + "All": _("All"), + "Downloading": _("Downloading"), + "Seeding": _("Seeding"), + "Paused": _("Paused"), + "Checking": _("Checking"), + "Queued": _("Queued"), + "Error": _("Error"), + "Active": _("Active"), + "none": _("None"), + "no_label": _("No Label"), +} + +del _ def _t(text): if text in TRANSLATE: text = TRANSLATE[text] return _(text) +FILTER_COLUMN = 5 #sidebar-treeview class FilterTreeView(component.Component): @@ -87,7 +105,7 @@ class FilterTreeView(component.Component): self.tracker_icons = component.get("TrackerIcons") self.label_view = gtk.TreeView() - self.sidebar.add_tab(self.label_view, "filters", _("Filters")) + self.sidebar.add_tab(self.label_view, "filters", "Filters") #set filter to all when hidden: self.sidebar.notebook.connect("hide", self._on_hide) @@ -109,7 +127,7 @@ class FilterTreeView(component.Component): self.treestore = gtk.TreeStore(str, str, str, int, gtk.gdk.Pixbuf, bool) # Create the column - column = gtk.TreeViewColumn(_("Filters")) + column = gtk.TreeViewColumn("Filters") column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) render = gtk.CellRendererPixbuf() self.renderpix = render @@ -147,7 +165,7 @@ class FilterTreeView(component.Component): self.filters = {} #initial order of state filter: - self.cat_nodes["state"] = self.treestore.append(None, ["cat", "state", _("State"), 0, None, False]) + self.cat_nodes["state"] = self.treestore.append(None, ["cat", "state", _t("State"), 0, None, False]) self.update_row("state", "All" , 0) self.update_row("state", "Downloading" , 0) self.update_row("state", "Seeding" , 0) @@ -155,6 +173,11 @@ class FilterTreeView(component.Component): self.update_row("state", "Paused" , 0) self.update_row("state", "Queued" , 0) + self.cat_nodes["tracker_host"] = self.treestore.append(None, ["cat", "tracker_host", _t("Trackers"), 0, None, False]) + self.update_row("tracker_host", "All" , 0) + self.update_row("tracker_host", "Error" , 0) + self.update_row("tracker_host", "" , 0) + # We set to this expand the rows on start-up self.expand_rows = True @@ -211,8 +234,16 @@ class FilterTreeView(component.Component): else: pix = self.get_pixmap(cat, value) label = value - if cat == "state": - label = _(value) + + if cat == "state" or cat == "tracker_host": + label = _t(value) + + if label == "": + if cat == "tracker_host": + label = _t("none") + elif cat == "label": + label = _t("no_label") + row = self.treestore.append(self.cat_nodes[cat],[cat, value, label, count , pix, True]) self.filters[(cat, value)] = row @@ -231,9 +262,6 @@ class FilterTreeView(component.Component): count = model.get_value(row, 3) pix = model.get_value(row, 4) - if label == "" and cat == "label": - label = _("no label") - if pix: self.renderpix.set_property("visible", True) else: @@ -251,11 +279,23 @@ class FilterTreeView(component.Component): cell.set_property('text', txt) def get_pixmap(self, cat, value): + pix = None if cat == "state": - pix = STATE_PIX.get(value, "dht") - return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix)) + pix = STATE_PIX.get(value, None) + elif cat == "tracker_host": + pix = TRACKER_PIX.get(value, None) - return None + if pix: + try: + return gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap("%s16.png" % pix)) + except glib.GError as e: + log.warning(e) + return self.get_transparent_pix(16, 16) + + def get_transparent_pix(self, width, height): + pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height) + pix.fill(0x0000000) + return pix def set_row_image(self, cat, value, filename): pix = None @@ -265,8 +305,7 @@ class FilterTreeView(component.Component): log.debug(e) if not pix: - pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) - pix.fill(0x00000000) + pix = self.get_transparent_pix(16, 16) row = self.filters[(cat, value)] self.treestore.set_value(row, 4, pix) return False