diff options
author | 2010-06-10 14:34:02 -0400 | |
---|---|---|
committer | 2010-06-10 14:34:02 -0400 | |
commit | 1ad48aa1f21aa9707950c4e02478e6b65a1630bf (patch) | |
tree | a84416fee39a251843d636aff79fada9c60f9260 | |
parent | Added mostly working setup.py script. (diff) | |
parent | Apply button merges changes. (diff) | |
download | ventoo-1ad48aa1f21aa9707950c4e02478e6b65a1630bf.tar.gz ventoo-1ad48aa1f21aa9707950c4e02478e6b65a1630bf.tar.bz2 ventoo-1ad48aa1f21aa9707950c4e02478e6b65a1630bf.zip |
Merge branch 'work'
-rw-r--r-- | src/frontend/main.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/frontend/main.py b/src/frontend/main.py index 4383dc3..eded4cc 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) @@ -198,8 +202,14 @@ class MainWindow(gtk.Window): outFile.write("</html>\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): + 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() win.show_all() @@ -299,6 +309,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)+'[*]')) + matches = list(set(matches)) #remove dups from matches listedNodes.extend(matches) #add leaves if we're missing some required ones (in augeas itself) @@ -314,7 +325,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)+'[*]')) - + matches = list(set(matches)) #remove dups from matches for match in matches: userData = self.a.get(match) #add all existing data if userData == None: @@ -381,7 +392,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. @@ -391,6 +403,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] @@ -409,6 +427,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) |