summaryrefslogtreecommitdiff
path: root/geneticone/gui/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'geneticone/gui/gtk')
-rw-r--r--geneticone/gui/gtk/dialogs.py30
-rw-r--r--geneticone/gui/gtk/windows.py37
2 files changed, 40 insertions, 27 deletions
diff --git a/geneticone/gui/gtk/dialogs.py b/geneticone/gui/gtk/dialogs.py
index cb643ce..7607fd4 100644
--- a/geneticone/gui/gtk/dialogs.py
+++ b/geneticone/gui/gtk/dialogs.py
@@ -12,20 +12,27 @@
import gtk
+def io_ex_dialog (io_ex):
+ string = io_ex.strerror
+ if io_ex.filename:
+ string = string+": "+io_ex.filename
+
+ dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, string)
+ ret = dialog.run()
+ dialog.destroy()
+ return ret
+
def blocked_dialog (blocked, blocks):
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, blocked+" is blocked by "+blocks+".\nPlease unmerge the blocking package.")
- dialog.run()
+ ret = dialog.run()
dialog.destroy()
+ return ret
def not_root_dialog ():
errorMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "You cannot (un)merge without being root.")
- errorMB.run()
+ ret = errorMB.run()
errorMB.destroy()
-
-def masked_dialog (cpv):
- dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, cpv+" seems to be masked.\nPlease edit the appropriate file(s) to unmask it and restart Genetic/One.\n")
- dialog.run()
- dialog.destroy()
+ return ret
def unmask_dialog (cpv):
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, cpv+" seems to be masked.\nDo you want to unmask it and its dependencies?.\n")
@@ -35,19 +42,22 @@ def unmask_dialog (cpv):
def nothing_found_dialog ():
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "Package not found!")
- dialog.run()
+ ret = dialog.run()
dialog.destroy()
+ return ret
def changed_flags_dialog (what = "flags"):
hintMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK,
"You have changed %s. Genetic/One will write these changes into the appropriate files. Please backup them if you think it is necessairy." % what)
- hintMB.run()
+ ret = hintMB.run()
hintMB.destroy()
+ return ret
def remove_deps_dialog ():
infoMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "You cannot remove dependencies. :)")
- infoMB.run()
+ ret = infoMB.run()
infoMB.destroy()
+ return ret
def remove_queue_dialog ():
askMB = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, "Do you really want to clear the whole queue?")
diff --git a/geneticone/gui/gtk/windows.py b/geneticone/gui/gtk/windows.py
index 8c6febb..8623e51 100644
--- a/geneticone/gui/gtk/windows.py
+++ b/geneticone/gui/gtk/windows.py
@@ -195,13 +195,11 @@ class PreferenceWindow (AbstractDialog):
for box in self.checkboxes:
self.tree.get_widget(box).\
- set_active(self.cfg.get_boolean(\
- self.cfg.const[self.checkboxes[box]]))
+ set_active(self.cfg.get_boolean(self.checkboxes[box]))
for edit in self.edits:
self.tree.get_widget(edit).\
- set_text(self.cfg.get(\
- self.cfg.const[self.edits[edit]]))
+ set_text(self.cfg.get(self.edits[edit]))
self.window.show_all()
@@ -209,19 +207,19 @@ class PreferenceWindow (AbstractDialog):
"""Sets all options in the Config-instance."""
for box in self.checkboxes:
- self.cfg.set_boolean(\
- self.cfg.const[self.checkboxes[box]],\
- self.tree.get_widget(box).get_active())
+ self.cfg.set_boolean(self.checkboxes[box], self.tree.get_widget(box).get_active())
for edit in self.edits:
- self.cfg.set(\
- self.cfg.const[self.edits[edit]],\
- self.tree.get_widget(edit).get_text())
+ self.cfg.set(self.edits[edit],self.tree.get_widget(edit).get_text())
def cb_ok_clicked(self, button):
"""Saves, writes to config-file and closes the window."""
self._save()
- self.cfg.write()
+ try:
+ self.cfg.write()
+ except IOError, e:
+ io_ex_dialog(e)
+
self.window.destroy()
def cb_cancel_clicked (self, button):
@@ -577,7 +575,12 @@ class MainWindow (Window):
self.db.populate()
# config
- self.cfg = Config(CONFIG_LOCATION)
+ try:
+ self.cfg = Config(CONFIG_LOCATION)
+ except IOError, e:
+ io_ex_dialog(e)
+ raise e
+
self.cfg.modify_external_configs()
# set vpaned position
@@ -746,7 +749,7 @@ class MainWindow (Window):
if not self.doUpdate:
self.queue.emerge(force=True)
else:
- self.queue.update_world(force=True, newuse = self.cfg.get_boolean(self.cfg.const["newuse_opt"]), deep = self.cfg.get_boolean(self.cfg.const["deep_opt"]))
+ self.queue.update_world(force=True, newuse = self.cfg.get_boolean("newuse_opt"), deep = self.cfg.get_boolean("deep_opt"))
self.doUpdate = False
def cb_unmerge_clicked (self, button):
@@ -762,7 +765,7 @@ class MainWindow (Window):
not_root_dialog()
else:
- updating = backend.update_world(newuse = self.cfg.get_boolean(self.cfg.const["newuse_opt"]), deep = self.cfg.get_boolean(self.cfg.const["deep_opt"]))
+ updating = backend.update_world(newuse = self.cfg.get_boolean("newuse_opt"), deep = self.cfg.get_boolean("deep_opt"))
debug("updating list:", [(x.get_cpv(), y.get_cpv()) for x,y in updating])
try:
@@ -802,7 +805,7 @@ class MainWindow (Window):
not_root_dialog()
else:
self.notebook.set_current_page(self.CONSOLE_PAGE)
- cmd = self.cfg.get(self.cfg.const["syncCmd_opt"])
+ cmd = self.cfg.get("syncCmd_opt")
if cmd != "emerge --sync":
cmd = cmd.split()
@@ -861,12 +864,12 @@ class MainWindow (Window):
store, it = sel.get_selected()
if it:
package = store.get_value(it, 0)
- if not self.cfg.get_local(package, self.cfg.const["oneshot_opt"]):
+ if not self.cfg.get_local(package, "oneshot_opt"):
set = True
else:
set = False
- self.cfg.set_local(package, self.cfg.const["oneshot_opt"], set)
+ self.cfg.set_local(package, "oneshot_opt", set)
self.queue.append(package, update = True, oneshot = set, forceUpdate = True)
def cb_destroy (self, widget):