[Xfce4-commits] <xfce4-notes-plugin:master> Add context menu for quick access to window list
Mike Massonnet
noreply at xfce.org
Tue Dec 1 18:38:02 CET 2009
Updating branch refs/heads/master
to 6940936c4ff4927315fd79a39769e49dcf9a4a31 (commit)
from 089487805ee0892447127df45214c3be01686b67 (commit)
commit 6940936c4ff4927315fd79a39769e49dcf9a4a31
Author: Mike Massonnet <mmassonnet at gmail.com>
Date: Tue Dec 1 17:32:28 2009 +0100
Add context menu for quick access to window list
ChangeLog | 10 ++++++++++
panel-plugin/application.vala | 33 +++++++++++++++++++++++++++++++++
panel-plugin/main.vala | 6 ++++++
3 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b25c3b7..ac07cdf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2009-12-01 Mike Massonnet <mmassonnet at xfce.org>
+Add context menu for quick access to window list
+ * panel-plugin/application.vala:
+ - New public function context_menu. It builds a menu to be used for
+ context menus like in the systray.
+ * panel-plugin/main.vala:
+ - Build the context menu as a submenu inside the right click action
+ menu of the panel plugin.
+
+2009-12-01 Mike Massonnet <mmassonnet at xfce.org>
+
Update build-env
2009-11-22 Mike Massonnet <mmassonnet at xfce.org>
diff --git a/panel-plugin/application.vala b/panel-plugin/application.vala
index dad4b0d..19f4f6d 100644
--- a/panel-plugin/application.vala
+++ b/panel-plugin/application.vala
@@ -493,6 +493,39 @@ namespace Xnp {
}
}
+ /**
+ * context_menu:
+ *
+ * Provides a GtkMenu to be used for right click context menus
+ * like in trayicons. Its items are destroyed/refreshed every
+ * time the menu is shown.
+ */
+ public Gtk.Menu context_menu () {
+ var menu = new Gtk.Menu ();
+
+ menu.show += (menu) => {
+ // Clean up menu
+ menu. at foreach ((w) => {
+ w.destroy ();
+ });
+
+ // Add fresh items
+ foreach (var win in this.window_list) {
+ var mi = new Gtk.MenuItem.with_label (win.name);
+ mi.set_data ("window", (void*)win);
+ mi.show ();
+ mi.activate += (i) => {
+ // Jump to win
+ var w = (Xnp.Window)i.get_data ("window");
+ w.present ();
+ };
+ menu.append (mi);
+ }
+ };
+
+ return menu;
+ }
+
}
}
diff --git a/panel-plugin/main.vala b/panel-plugin/main.vala
index 5f2f547..7da7847 100644
--- a/panel-plugin/main.vala
+++ b/panel-plugin/main.vala
@@ -72,6 +72,12 @@ public class NotesPlugin : GLib.Object {
panel_plugin.set_tooltip_text (_("Notes"));
panel_plugin.menu_show_configure ();
+ var mi = new Gtk.MenuItem.with_mnemonic (_("_Go"));
+ var menu = application.context_menu ();
+ mi.set_submenu (menu);
+ mi.show_all ();
+ panel_plugin.menu_insert_item (mi);
+
set_x_selection ();
panel_plugin.size_changed += (p, size) => {
More information about the Xfce4-commits
mailing list