[meld] Add a store column and a view pixbuf renderer to show filter validity
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Add a store column and a view pixbuf renderer to show filter validity
- Date: Tue, 15 Feb 2011 09:09:34 +0000 (UTC)
commit 822749666b04e01f32cefd1e94dde8ac79270743
Author: Kai Willadsen <kai willadsen gmail com>
Date: Tue Feb 8 18:25:57 2011 +1000
Add a store column and a view pixbuf renderer to show filter validity
The validity renderer has a fixed size
We want the validity renderer to reserve a portion of its cell,
otherwise the first time an invalid pattern is entered, everything
shuffles over, which looks bodgy.
data/ui/EditableList.ui | 29 +++++++++++++++++++----------
meld/preferences.py | 19 +++++++++++++++++--
2 files changed, 36 insertions(+), 12 deletions(-)
---
diff --git a/data/ui/EditableList.ui b/data/ui/EditableList.ui
index 36557af..fecda0b 100644
--- a/data/ui/EditableList.ui
+++ b/data/ui/EditableList.ui
@@ -10,6 +10,8 @@
<column type="gboolean"/>
<!-- column-name Pattern -->
<column type="gchararray"/>
+ <!-- column-name ValidPattern -->
+ <column type="gboolean"/>
</columns>
<signal name="row-inserted" handler="_update_sensitivity" swapped="no"/>
<signal name="rows-reordered" handler="_update_sensitivity" swapped="no"/>
@@ -48,35 +50,42 @@
<property name="rubber_banding">True</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
- <property name="title">Name</property>
+ <property name="title" translatable="yes">Active</property>
<child>
- <object class="GtkCellRendererText" id="cellrenderertext1">
- <property name="editable">True</property>
- <signal name="edited" handler="on_name_edited" swapped="no"/>
+ <object class="GtkCellRendererToggle" id="cellrenderertoggle1">
+ <signal name="toggled" handler="on_cellrenderertoggle_toggled" swapped="no"/>
</object>
<attributes>
- <attribute name="text">0</attribute>
+ <attribute name="activatable">3</attribute>
+ <attribute name="active">1</attribute>
</attributes>
</child>
</object>
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
- <property name="title" translatable="yes">Active</property>
+ <property name="title" translatable="yes">Name</property>
<child>
- <object class="GtkCellRendererToggle" id="cellrenderertoggle1">
- <signal name="toggled" handler="on_cellrenderertoggle_toggled" swapped="no"/>
+ <object class="GtkCellRendererText" id="cellrenderertext1">
+ <property name="editable">True</property>
+ <signal name="edited" handler="on_name_edited" swapped="no"/>
</object>
<attributes>
- <attribute name="active">1</attribute>
+ <attribute name="text">0</attribute>
</attributes>
</child>
</object>
</child>
<child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+ <object class="GtkTreeViewColumn" id="pattern_column">
<property name="title" translatable="yes">Pattern</property>
<child>
+ <object class="GtkCellRendererPixbuf" id="validity_renderer">
+ <property name="width">16</property>
+ <property name="height">16</property>
+ </object>
+ </child>
+ <child>
<object class="GtkCellRendererText" id="cellrenderertext2">
<property name="editable">True</property>
<signal name="edited" handler="on_pattern_edited" swapped="no"/>
diff --git a/meld/preferences.py b/meld/preferences.py
index 39cf691..3a4f4d6 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -1,4 +1,5 @@
### Copyright (C) 2002-2009 Stephen Kennedy <stevek gnome org>
+### Copyright (C) 2010-2011 Kai Willadsen <kai willadsen gmail com>
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
@@ -33,14 +34,20 @@ from util.sourceviewer import srcviewer
class FilterList(listwidget.ListWidget):
def __init__(self, prefs, key, filter_type):
- default_entry = [_("label"), False, _("pattern")]
+ default_entry = [_("label"), False, _("pattern"), True]
listwidget.ListWidget.__init__(self, default_entry)
self.prefs = prefs
self.key = key
+ self.filter_type = filter_type
+
+ self.pattern_column.set_cell_data_func(self.validity_renderer,
+ self.valid_icon_celldata)
for filtstring in getattr(self.prefs, self.key).split("\n"):
filt = meldapp.FilterEntry.parse(filtstring, filter_type)
- self.model.append([filt.label, filt.active, filt.filter_string])
+ valid = filt.filter is not None
+ self.model.append([filt.label, filt.active,
+ filt.filter_string, valid])
for signal in ('row-changed', 'row-deleted', 'row-inserted',
'rows-reordered'):
@@ -48,6 +55,11 @@ class FilterList(listwidget.ListWidget):
self._update_sensitivity()
+ def valid_icon_celldata(self, col, cell, model, it, user_data=None):
+ is_valid = model.get_value(it, 3)
+ icon_name = "gtk-dialog-warning" if not is_valid else None
+ cell.set_property("stock-id", icon_name)
+
def on_name_edited(self, ren, path, text):
self.model[path][0] = text
@@ -55,7 +67,10 @@ class FilterList(listwidget.ListWidget):
self.model[path][1] = not ren.get_active()
def on_pattern_edited(self, ren, path, text):
+ filt = meldapp.FilterEntry.compile_filter(text, self.filter_type)
+ valid = filt is not None
self.model[path][2] = text
+ self.model[path][3] = valid
def _update_filter_string(self, *args):
pref = []
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]