diff options
author | 2010-08-01 23:59:16 -0400 | |
---|---|---|
committer | 2010-08-02 00:59:07 -0400 | |
commit | d8bfe8185fa53f80df702f48c52e241159cd5f6c (patch) | |
tree | d44e045e286c3f3a2e52cce08ad7bff99eae8c20 | |
parent | Added new lenses for future use. (diff) | |
download | ventoo-d8bfe8185fa53f80df702f48c52e241159cd5f6c.tar.gz ventoo-d8bfe8185fa53f80df702f48c52e241159cd5f6c.tar.bz2 ventoo-d8bfe8185fa53f80df702f48c52e241159cd5f6c.zip |
Added colors to text that the user can edit in the treeview to indicate possible errors or invalid text. Added the "addElement" function to AugEditTree that wraps these new colums in the treemodel to stay nuteral when an item is added. Updated all code to use this new function and not add rows manually.
-rw-r--r-- | src/ventoo/AugEditTree.py | 10 | ||||
-rw-r--r-- | src/ventoo/main.py | 12 |
2 files changed, 14 insertions, 8 deletions
diff --git a/src/ventoo/AugEditTree.py b/src/ventoo/AugEditTree.py index 5ad62cc..559cf7f 100644 --- a/src/ventoo/AugEditTree.py +++ b/src/ventoo/AugEditTree.py @@ -29,14 +29,15 @@ import augeas_utils class AugEditTree(gtk.TreeView): def __init__(self): - #make storage enable/disable label user entry - self.tv_store = gtk.TreeStore('gboolean', str, str) + #make storage enable/disable label user entry paint color + self.tv_store = gtk.TreeStore('gboolean', str, str, 'gboolean', str) #make widget gtk.TreeView.__init__(self, self.tv_store) #make renderers self.buttonRenderer = gtk.CellRendererToggle() self.labelRenderer = gtk.CellRendererText() self.entryRenderer = gtk.CellRendererText() + self.entryRenderer.set_property('background-set', True) self.buttonRenderer.set_property("activatable", True) self.entryRenderer.set_property("editable", True) self.entryRenderer.connect("edited", self.entry_edited) @@ -55,6 +56,8 @@ class AugEditTree(gtk.TreeView): self.columnButton.add_attribute(self.buttonRenderer, 'active', 0) self.columnLabel.add_attribute(self.labelRenderer, 'text', 1) self.columnEntry.add_attribute(self.entryRenderer, 'text', 2) + self.columnEntry.add_attribute(self.entryRenderer, 'background_set', 3) + self.columnEntry.add_attribute(self.entryRenderer, 'background', 4) #add columns self.append_column(self.columnButton) @@ -117,3 +120,6 @@ class AugEditTree(gtk.TreeView): """ def get_label_path_str(self, path): return self.get_label_path(self.tv_store.get_iter(path)) + + def addElement(self, parentIter, enabled, label, text): + return self.tv_store.append(parentIter, [enabled, label, text, False, '#C9C9C9']) diff --git a/src/ventoo/main.py b/src/ventoo/main.py index 68b1c23..28c35fa 100644 --- a/src/ventoo/main.py +++ b/src/ventoo/main.py @@ -296,14 +296,14 @@ class MainWindow(gtk.Window): have += 1 thisIndex = int(indexResult.group(1)) maxIndex = max(maxIndex, thisIndex) - created = model.append(modelPathIter, [True, indexResult.group(1), '-------']) + created = self.edit_tv.addElement(modelPathIter, True, indexResult.group(1), '-------') self.__buildEditModel(model, match, created, xmlRoot) lastLineWasDoc = False elif commentProg != None: #got a comment #only display the first line, the rest can be displayed in the doc frame when requested. if not lastLineWasDoc: docText = self.a.get(match) - created = model.append(modelPathIter, [True, osp.split(match)[1], docText]) + created = self.edit_tv.addElement(modelPathIter, True, osp.split(match)[1], docText) lastLineWasDoc = True #add the missing entries @@ -316,7 +316,7 @@ class MainWindow(gtk.Window): maxIndex += 1 needOption = not augeas_utils.matchExact(thisMult, have) if needOption: - created = model.append(modelPathIter, [False, str(maxIndex+1), '-------']) + created = self.edit_tv.addElement(modelPathIter, False, str(maxIndex+1), '-------') maxIndex += 1 else: listedNodes = [] #a list of nodes that we already found and know about. @@ -333,7 +333,7 @@ class MainWindow(gtk.Window): userData = self.a.get(match) #add all existing data if userData == None: userData = '' - created = model.append(modelPathIter, [True, osp.split(match)[1], userData]) + created = self.edit_tv.addElement(modelPathIter, True, osp.split(match)[1], userData) self.__buildEditModel(model, match, created, osp.join(xmlRoot, child.tag)) #add leaves if we're missing some required ones (in augeas itself) @@ -354,7 +354,7 @@ class MainWindow(gtk.Window): #tells the user that the tree COULD be undated along this 'child' variable/branch. needed = not augeas_utils.matchExact(childMult, have) if needed: - created = model.append(modelPathIter, [False, child.tag + '[' + str(have+1) + ']', '']) + created = self.edit_tv.addElement(modelPathIter, False, child.tag + '[' + str(have+1) + ']', '') #now search for and add nodes that haven't been added yet, and may not be in the VentooModule specifically. allInAugeas = self.a.match(osp.join(augeasFileRoot, '*')) @@ -364,7 +364,7 @@ class MainWindow(gtk.Window): #found that 'a' is not in listedNodes, but is in augeasTree, add it, if it is not supposed to be ignored. if not osp.split(a)[1].startswith('#'): #always ignore comments (delt with later) userData = self.a.get(a) - created = model.append(modelPathIter, [True, osp.split(a)[1], userData]) + created = self.edit_tv.addElement(modelPathIter, True, osp.split(a)[1], userData) self.__buildEditModel(model, a, created, osp.join(xmlRoot, 'ventoo_dynamic')) lastLineWasDoc = False else: |