aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Harvey <chris@basementcode.com>2010-08-07 20:07:52 -0400
committerChristopher Harvey <chris@basementcode.com>2010-08-07 20:07:52 -0400
commita0bcb9100e9ee73fbe05c5c6521d77ea4644f280 (patch)
tree9b9bc130fae2c90ea9b71447d908cb283eff1421
parentMerge remote branch 'origin/master' (diff)
downloadventoo-a0bcb9100e9ee73fbe05c5c6521d77ea4644f280.tar.gz
ventoo-a0bcb9100e9ee73fbe05c5c6521d77ea4644f280.tar.bz2
ventoo-a0bcb9100e9ee73fbe05c5c6521d77ea4644f280.zip
Added the change root feature.
-rw-r--r--src/ventoo/AugFileTree.py3
-rw-r--r--src/ventoo/main.py24
2 files changed, 22 insertions, 5 deletions
diff --git a/src/ventoo/AugFileTree.py b/src/ventoo/AugFileTree.py
index 336a06e..bcf03dd 100644
--- a/src/ventoo/AugFileTree.py
+++ b/src/ventoo/AugFileTree.py
@@ -51,7 +51,8 @@ class AugFileTree(gtk.TreeView):
def getSelectedConfigFilePath(self):
currentSelection = self.get_selection()
if currentSelection.count_selected_rows()!=1:
- raise RuntimeException("User selected more that one row from the file list...should never be possible.")
+ #raise RuntimeException("User selected more that one row from the file list...should never be possible.")
+ return
selectedSystemPathTuple = currentSelection.get_selected()
selectedIter = selectedSystemPathTuple[1]
return self.tv_store.get_value(selectedIter, 0)
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)