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