[kupfer: 34/67] ui: Add "context actions" to the menu
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 34/67] ui: Add "context actions" to the menu
- Date: Sat, 19 Mar 2011 01:00:35 +0000 (UTC)
commit 56bf419ce0f24e870fdde47e00ecc4871aa3f319
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Mar 16 22:49:01 2011 +0100
ui: Add "context actions" to the menu
kupfer/ui/browser.py | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 5917a32..4e4fae4 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1269,6 +1269,19 @@ class Interface (gobject.GObject):
self.reset_text()
return True
+ def get_context_actions(self):
+ """
+ Get a list of (name, function) currently
+ active context actions
+ """
+ has_match = self.current.get_match_state() == State.Match
+ if has_match:
+ yield (_("Compose Command"), self.compose_action)
+ #yield (_("Comma Trick"), self.comma_trick)
+ yield (_("Select Selected Text"), self.select_selected_text)
+ if self.get_can_enter_text_mode():
+ yield (_("Toggle Text Mode"), self.toggle_text_mode_quick)
+
def _pane_reset(self, controller, pane, item):
wid = self._widget_for_pane(pane)
if not item:
@@ -1520,6 +1533,10 @@ class WindowController (pretty.OutputMixin):
self.put_away()
return True
+ def submenu_callback(menuitem, callback):
+ callback()
+ return True
+
def add_menu_item(icon, callback, label=None):
mitem = None
if label and not icon:
@@ -1534,6 +1551,13 @@ class WindowController (pretty.OutputMixin):
else:
add_menu_item(None, self.activate, _("Show Main Interface"))
menu.append(gtk.SeparatorMenuItem())
+ if context_menu:
+ for name, func in self.interface.get_context_actions():
+ mitem = gtk.MenuItem(label=name)
+ mitem.connect("activate", submenu_callback, func)
+ menu.append(mitem)
+ menu.append(gtk.SeparatorMenuItem())
+
add_menu_item(gtk.STOCK_PREFERENCES, kupferui.show_preferences)
add_menu_item(gtk.STOCK_HELP, kupferui.show_help)
add_menu_item(gtk.STOCK_ABOUT, kupferui.show_about_dialog)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]