aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Harvey <chris@basementcode.com>2010-07-05 03:46:13 -0400
committerChristopher Harvey <chris@basementcode.com>2010-07-05 03:46:13 -0400
commit1dab9452ab6e734c4e80b7df4b863d1a9f9ef0be (patch)
treeaa68f1c76d065410de10200b383f3f2b0bf069fe
parentAdded comesBefore to VentooModule (diff)
downloadventoo-1dab9452ab6e734c4e80b7df4b863d1a9f9ef0be.tar.gz
ventoo-1dab9452ab6e734c4e80b7df4b863d1a9f9ef0be.tar.bz2
ventoo-1dab9452ab6e734c4e80b7df4b863d1a9f9ef0be.zip
Changed the code that adds new nodes to the tree, so that it respects the order in the module xml files.
-rw-r--r--src/ventoo/main.py30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/ventoo/main.py b/src/ventoo/main.py
index 00a2dee..68b1c23 100644
--- a/src/ventoo/main.py
+++ b/src/ventoo/main.py
@@ -103,20 +103,30 @@ class MainWindow(gtk.Window):
else:
augPath = osp.join('files', augeas_utils.stripBothSlashes(self.currentConfigFilePath), self.edit_tv.get_label_path(thisIter))
if enabled: #this row was just added, update augeas tree.
- indexes = path.split(':')
- beforeIndex = int(indexes[len(indexes)-1])-1
- if beforeIndex >= 0:
- beforePath = ""
- for i in indexes[0:len(indexes)-1]:
- beforePath = beforePath + str(i) + ":"
- beforePath = beforePath + str(beforeIndex)
- augBeforePath = self.edit_tv.get_label_path_str(beforePath)
+ parentIter = model.iter_parent(thisIter)
+ if parentIter == None:
+ siblingIter = model.get_iter_root()
+ else:
+ siblingIter = model.iter_children(parentIter)
+ labelPath = self.edit_tv.get_label_path_str(path)
+ newLabel = osp.split(labelPath)[1]
+ while siblingIter != None:
+ try:
+ if model.get_string_from_iter(thisIter) != model.get_string_from_iter(siblingIter) and not self.currentModule.comesBefore(model.get_value(siblingIter, 1),
+ re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1)):
+ break
+ except ValueError:
+ pass #Don't know about either the first or second arg, so order shouldn't matter for this one. try next.
+ siblingIter = model.iter_next(siblingIter)
+ augBeforePath = osp.split(labelPath)[0]
+ if siblingIter != None:
+ augBeforePath = osp.join(augBeforePath, model.get_value(siblingIter, 1))
if not aug_root == '/':
augBeforePath = osp.join('files', osp.relpath(self.currentConfigFilePath, aug_root), augBeforePath)
else:
augBeforePath = osp.join('files', augeas_utils.stripBothSlashes(self.currentConfigFilePath), augBeforePath)
- self.a.insert(augBeforePath, re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1), False)
- print("ins "+re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1)+" after "+augBeforePath)
+ self.a.insert(augBeforePath, re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1), True)
+ print("ins "+re.match('^.+/(.+?)(?:\\[[0-9]+\\])?$', augPath).group(1)+" before "+augBeforePath)
self.a.set(augPath, '')
print("set "+augPath+" ''")
else: #this row was deleted, update augeas tree in the refresh