aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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