summaryrefslogtreecommitdiff
path: root/portato/gui/windows/main.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-02-18 23:15:24 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-02-18 23:15:24 +0100
commit1cd876636b1a2470186c36625b61c218654b0033 (patch)
tree713c67d43e9b367aa8ee309614f52b956d09c509 /portato/gui/windows/main.py
parentedffa4112136c525e5db84ec1b1a59ebd7a4a5c8 (diff)
parent4dfc7b063ec7dc476462e843bfecd07fd02cb25e (diff)
downloadportato-1cd876636b1a2470186c36625b61c218654b0033.tar.gz
portato-1cd876636b1a2470186c36625b61c218654b0033.tar.bz2
portato-1cd876636b1a2470186c36625b61c218654b0033.zip
Converted to GtkBuilder
Diffstat (limited to '')
-rw-r--r--portato/gui/windows/main.py100
1 files changed, 39 insertions, 61 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 443fa76..2ee4447 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -43,7 +43,7 @@ from ..dialogs import (blocked_dialog, changed_flags_dialog, io_ex_dialog,
from ..exceptions import PreReqError
# even more GUI stuff
-from .basic import Window, Popup
+from .basic import Window
from .about import AboutWindow
from .plugin import PluginWindow
from .preference import PreferenceWindow
@@ -62,7 +62,6 @@ class PackageTable:
self.main = main
self.tree = main.tree
self.window = main.window
- self.tree.signal_autoconnect(self)
# all the package data is in this one VB
self.vb = self.tree.get_widget("packageVB")
@@ -481,13 +480,24 @@ class MainWindow (Window):
plugin.load_plugins()
menus = [p.menus for p in plugin.get_plugin_queue().get_plugins()]
if menus:
- self.tree.get_widget("pluginMenuItem").set_no_show_all(False)
- pluginMenu = self.tree.get_widget("pluginMenu")
+ uim = self.tree.get_widget("uimanager")
+ ag = self.tree.get_widget("pluginActionGroup")
+ ctr = 0
for m in itt.chain(*menus):
- item = gtk.MenuItem(m.label)
- item.connect("activate", m.call)
- pluginMenu.append(item)
+
+ # create action
+ aname = "plugin%d" % ctr
+ a = gtk.Action(aname, m.label, None, None)
+ a.connect("activate", m.call)
+ ag.add_action(a)
+
+ # add to UI
+ mid = uim.new_merge_id()
+ uim.add_ui(mid, "ui/menubar/pluginMenu", aname, aname, gtk.UI_MANAGER_MENUITEM, False)
+
+ ctr += 1
+
splash(_("Building frontend"))
# set paned position
@@ -554,18 +564,11 @@ class MainWindow (Window):
self.packageTable = PackageTable(self)
# popups
- self.consolePopup = Popup("consolePopup", self, self.__file__)
- self.trayPopup = Popup("systrayPopup", self)
+ self.consolePopup = self.tree.get_ui("consolePopup")
+ self.trayPopup = self.tree.get_ui("systrayPopup")
# pause menu items
self.emergePaused = False
- self.pauseItems = {}
- self.pauseItems["tray"] = self.trayPopup.tree.get_widget("pauseItemTray")
- self.pauseItems["popup"] = self.consolePopup.tree.get_widget("pauseItemPopup")
- self.pauseItems["menu"] = self.tree.get_widget("pauseItemMenu")
-
- for k,v in self.pauseItems.iteritems():
- self.pauseItems[k] = (v, v.connect_after("activate", self.cb_pause_emerge(k)))
# systray
if self.cfg.get_boolean("showSystray", "GUI"):
@@ -1772,50 +1775,13 @@ class MainWindow (Window):
self.queue.append(package, update = True, oneshot = set, forceUpdate = True)
- def cb_pause_emerge (self, curr):
- """
- This method returns a callback for a "pause emerge" toggle button.
- It is needed as there are different toggle buttons of this type and if one is clicked,
- the others should be marked too.
-
- @param curr: The button to return the callback for.
- @type curr: gtk.ToggleButton
- """
- def pause (cb):
- """
- The actual callback.
-
- Mark all other buttons too.
-
- @param cb: The button which got toggled.
- @type cb: gtk.ToggleButton
- """
-
- # pause or continue
- self.emergePaused = cb.get_active()
- if not self.emergePaused:
- self.queue.continue_emerge()
- #self.tray.set_from_file(APP_ICON)
- else:
- self.queue.stop_emerge()
- #self.tray.set_from_file(os.path.join(ICON_DIR, "pausing.png"))
-
- # block the handlers of the other buttons
- # so that calling "set_active" does not call this callback recursivly
- for v in self.pauseItems.itervalues():
- v[0].handler_block(v[1])
-
- # mark the others
- for k, v in self.pauseItems.iteritems():
- if k != curr:
- v[0].set_active(self.emergePaused)
-
- # unblock
- for v in self.pauseItems.itervalues():
- v[0].handler_unblock(v[1])
-
- return False
- return pause
+ def cb_pause_emerge (self, action):
+ # pause or continue
+ self.emergePaused = action.get_active()
+ if not self.emergePaused:
+ self.queue.continue_emerge()
+ else:
+ self.queue.stop_emerge()
def cb_kill_clicked (self, *args):
"""
@@ -1823,7 +1789,7 @@ class MainWindow (Window):
"""
self.queue.kill_emerge()
if self.emergePaused: # unmark the "pause emerge" buttons
- self.pauseItems["menu"][0].set_active(False) # calling one button is enough (see: cb_pause_emerge)
+ self.tree.get_widget("generalActionGroup").get_action("pauseAction").set_active(False)
def cb_copy_clicked (self, *args):
"""
@@ -1879,6 +1845,18 @@ class MainWindow (Window):
else:
self.window.iconify()
+ def cb_testing_toggled (self, *args):
+ return self.packageTable.cb_testing_toggled(*args)
+ def cb_masked_toggled (self, *args):
+ return self.packageTable.cb_masked_toggled(*args)
+ def cb_button_pressed (self, *args):
+ return self.packageTable.cb_button_pressed(*args)
+ def cb_package_revert_clicked (self, *args):
+ return self.packageTable.cb_package_revert_clicked(*args)
+ def cb_package_unmerge_clicked (self, *args):
+ return self.packageTable.cb_package_unmerge_clicked(*args)
+ def cb_package_emerge_clicked (self, *args):
+ return self.packageTable.cb_package_emerge_clicked(*args)
def cb_use_flag_toggled (self, *args):
return self.packageTable.cb_use_flag_toggled(*args)