From b08a2a60f5beddccfe7d3013fa7f725ef0bb46d5 Mon Sep 17 00:00:00 2001 From: Christopher Harvey Date: Thu, 3 Jun 2010 11:23:53 -0400 Subject: Added graphical apply button. Used to apply diffs once the user is happy with the changes. Diffs are not appled, just the button is there. --- src/frontend/main.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/frontend/main.py b/src/frontend/main.py index d12d8db..3131ec2 100644 --- a/src/frontend/main.py +++ b/src/frontend/main.py @@ -67,6 +67,10 @@ class MainWindow(gtk.Window): self.rootBox.pack_start(self.mainToolbar, False, False) self.mainPaned = gtk.HPaned() self.rootBox.pack_start(self.docBox) + self.applyDiffButton = gtk.Button("Apply diff") + self.applyDiffButton.connect("clicked", self.applyDiffPressed, None) + self.rootBox.pack_start(self.applyDiffButton, False, False) + self.hideApplyDiffButton() self.files_tv = AugFileTree.AugFileTree() self.edit_tv = AugEditTree.AugEditTree() self.edit_tv.connect("cursor-changed", self.nodeChanged, None) @@ -185,8 +189,12 @@ class MainWindow(gtk.Window): outFile.write("\n") outFile.close() self.docWindow.load_url("file:///tmp/ventooDiff.html") + #TODO: check to make sure diff is correctly displayed (html file found) + self.showApplyDiffButton() - + def applyDiffPressed(self, button, data=None): + pass + def showRCUpdate(self, button, data=None): win = RcUpdateWindow.RcUpdateWindow() win.show_all() @@ -333,7 +341,8 @@ class MainWindow(gtk.Window): Called when the user picks a new file to view. """ def fileSelectionChanged(self, tv, data=None): - #uer picked a new file to edit. + #user picked a new file to edit. + self.hideApplyDiffButton() self.currentConfigFilePath = self.files_tv.getSelectedConfigFilePath() #update the display...and get new module info. #thse path manipulations are sketchy, should make this code clearer. @@ -343,6 +352,12 @@ class MainWindow(gtk.Window): self.currentModule = VentooModule.VentooModule(augeas_utils.getVentooModuleNameFromSysPath(a, tmp)) self.refreshAugeasEditTree() + def hideApplyDiffButton(self): + self.applyDiffButton.hide() + + def showApplyDiffButton(self): + self.applyDiffButton.show() + if __name__ == '__main__': if len(sys.argv) > 1: sandboxDir = sys.argv[1] @@ -361,6 +376,7 @@ if __name__ == '__main__': #instances to edit multiple "roots" at the same time. window = MainWindow(a) window.show_all() + window.hideApplyDiffButton() #TODO: overload show_all to preserve apply button state. #clear the diff storage place... shutil.rmtree(augeas_utils.getDiffRoot(), True) -- cgit v1.2.3-65-gdbad From 0b8f10991a4ac5af02805fc421152172b584536e Mon Sep 17 00:00:00 2001 From: Christopher Harvey Date: Fri, 4 Jun 2010 13:46:05 -0400 Subject: Marked broken places --- src/frontend/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/frontend/main.py b/src/frontend/main.py index d12d8db..a5d793f 100644 --- a/src/frontend/main.py +++ b/src/frontend/main.py @@ -275,6 +275,7 @@ class MainWindow(gtk.Window): childMult = self.currentModule.getMultOf(osp.join(xmlRoot, child.tag)) matches = self.a.match(osp.join(augeasFileRoot, child.tag)) matches.extend(self.a.match(osp.join(augeasFileRoot, child.tag)+'[*]')) + #TODO: remove duplicates listedNodes.extend(matches) #add leaves if we're missing some required ones (in augeas itself) @@ -290,7 +291,7 @@ class MainWindow(gtk.Window): #update the matches, since we have added stuff to augeas, based on previous matches matches = self.a.match(osp.join(augeasFileRoot, child.tag)) matches.extend(self.a.match(osp.join(augeasFileRoot, child.tag)+'[*]')) - + #TODO: remove duplicates. for match in matches: userData = self.a.get(match) #add all existing data if userData == None: -- cgit v1.2.3-65-gdbad From 88dd556582a4ed8f06d84c7f8d95ecce32b727d9 Mon Sep 17 00:00:00 2001 From: Christopher Harvey Date: Fri, 4 Jun 2010 13:57:33 -0400 Subject: Removed duplicates that sometimes appeard in the tree. --- src/frontend/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/main.py b/src/frontend/main.py index 85348f2..2c1e63a 100644 --- a/src/frontend/main.py +++ b/src/frontend/main.py @@ -283,7 +283,7 @@ class MainWindow(gtk.Window): childMult = self.currentModule.getMultOf(osp.join(xmlRoot, child.tag)) matches = self.a.match(osp.join(augeasFileRoot, child.tag)) matches.extend(self.a.match(osp.join(augeasFileRoot, child.tag)+'[*]')) - #TODO: remove duplicates + matches = list(set(matches)) #remove dups from matches listedNodes.extend(matches) #add leaves if we're missing some required ones (in augeas itself) @@ -299,7 +299,7 @@ class MainWindow(gtk.Window): #update the matches, since we have added stuff to augeas, based on previous matches matches = self.a.match(osp.join(augeasFileRoot, child.tag)) matches.extend(self.a.match(osp.join(augeasFileRoot, child.tag)+'[*]')) - #TODO: remove duplicates. + matches = list(set(matches)) #remove dups from matches for match in matches: userData = self.a.get(match) #add all existing data if userData == None: -- cgit v1.2.3-65-gdbad From 9fa39542cdce1165de13c972ef54555266cdf744 Mon Sep 17 00:00:00 2001 From: Christopher Harvey Date: Thu, 10 Jun 2010 12:05:31 -0400 Subject: Apply button merges changes. --- src/frontend/main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/frontend/main.py b/src/frontend/main.py index 2c1e63a..1f1102e 100644 --- a/src/frontend/main.py +++ b/src/frontend/main.py @@ -193,7 +193,9 @@ class MainWindow(gtk.Window): self.showApplyDiffButton() def applyDiffPressed(self, button, data=None): - pass + diffFiles = [self.currentConfigFilePath, augeas_utils.getDiffLocation(self.a, self.currentConfigFilePath)] + #merge diffFiles[0] <- diffFiles[1] + shutil.copyfile(diffFiles[1], diffFiles[0]) def showRCUpdate(self, button, data=None): win = RcUpdateWindow.RcUpdateWindow() -- cgit v1.2.3-65-gdbad