aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ventoo/main.py')
-rw-r--r--src/ventoo/main.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/ventoo/main.py b/src/ventoo/main.py
index 0f662a9..f12f736 100644
--- a/src/ventoo/main.py
+++ b/src/ventoo/main.py
@@ -55,7 +55,9 @@ class MainWindow(gtk.Window):
self.docWindow.load_url("about:blank")
self.mainToolbar = gtk.Toolbar()
self.diffButton = gtk.ToolButton(None, "Diff!")
+ self.changeRootButton = gtk.ToolButton(None, "Select Root")
self.diffButton.connect("clicked", self.diffPressed, None)
+ self.changeRootButton.connect("clicked", self.changeRootPressed, None)
self.showErrorsButton = gtk.ToolButton(None, "Augeas Errors")
self.showRCUpdateButton = gtk.ToolButton(None, "rc-update")
self.showRCUpdateButton.connect("clicked", self.showRCUpdate, None)
@@ -63,6 +65,7 @@ class MainWindow(gtk.Window):
self.mainToolbar.insert(self.diffButton, -1)
self.mainToolbar.insert(self.showErrorsButton, -1)
self.mainToolbar.insert(self.showRCUpdateButton, -1)
+ self.mainToolbar.insert(self.changeRootButton, -1)
self.rootBox.pack_start(self.mainToolbar, False, False)
self.mainPaned = gtk.HPaned()
self.rootBox.pack_start(self.docBox)
@@ -201,6 +204,22 @@ class MainWindow(gtk.Window):
self.a.set(augPath, enteredValue)
print("set " + augPath + " '" + enteredValue + "'")
+ def changeRootPressed(self, button, data=None):
+ dialog = gtk.FileChooserDialog("Select a new system root", self, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ dialog.add_button("Select", 1)
+ dialog.add_button("Cancel", 0)
+ response = dialog.run()
+ dialog.hide()
+ newFolder = dialog.get_current_folder()
+ if response == 1 and newFolder != None:
+ global sandboxDir
+ sandboxDir = newFolder
+ self.a = augeas.Augeas(sandboxDir, None, augeas.Augeas.SAVE_NEWFILE)
+ self.refreshAugeasFileList()
+ self.edit_tv.clear()
+ self.hideApplyDiffButton()
+ print("Root switched to " + sandboxDir)
+
def diffPressed(self, button, data=None):
#show the diff for the current file.
try:
@@ -261,7 +280,7 @@ class MainWindow(gtk.Window):
def refreshAugeasFileList(self):
#reload the file selection list from augeas internals.
self.files_tv.clearFiles()
- fileList = augeas_utils.accumulateFiles(self.a)
+ fileList = augeas_utils.accumulateFiles(self.a, "/files", [])
for f in fileList:
ex = VentooModule.moduleExists(augeas_utils.getVentooModuleNameFromSysPath(self.a, osp.join('/', f)))
self.files_tv.addPath(f, ex)
@@ -448,12 +467,9 @@ if __name__ == '__main__':
sys.path.append('/tmp')
print('Starting augeas...')
- #None could be a 'loadpath'
a = augeas.Augeas(sandboxDir, None, augeas.Augeas.SAVE_NEWFILE)
print('Creating window...')
- if sandboxDir == '/':
- pass
#Note, it IS possible to create mutiple windows and augeas
#instances to edit multiple "roots" at the same time.
window = MainWindow(a)