Global Menu in Gnome Shell, Progress



Dear all, and Owen,

I was able to embed the Global Menu widget into the top panel via the
newly added shell-gtkwindow-actor.

Although looking crappy, it works.

Regards,

Yu


Index: configure.ac
===================================================================
--- configure.ac	(revision 173)
+++ configure.ac	(working copy)
@@ -23,6 +23,8 @@
 PKG_CHECK_MODULES(BIG, clutter-cairo-0.8 gtk+-2.0 librsvg-2.0)
 PKG_CHECK_MODULES(TRAY, gtk+-2.0)
 PKG_CHECK_MODULES(TASKPANEL, libwnck-1.0 dbus-glib-1)
+
+PKG_CHECK_MODULES(GNOMENU, libgnomenu)
 # We require libgnomeui for generating thumbnails for recent files with GnomeThumbnailFactory.
 # We'll switch to using GnomeDesktopThumbnailFactory once the branch of gnome-desktop that contains
 # it becomes stable.
 
Index: src/shell-globalmenu-actor.c
===================================================================
--- src/shell-globalmenu-actor.c	(revision 0)
+++ src/shell-globalmenu-actor.c	(revision 0)
@@ -0,0 +1,45 @@
+#include "shell-globalmenu-actor.h"
+#include "shell-gtkwindow-actor.h"
+#include "libgnomenu/globalmenu.h"
+#include "libgnomenu/monitor.h"
+
+static void on_window_changed(GnomenuMonitor * monitor, gulong prev, GnomenuGlobalMenu * gm);
+ClutterActor *shell_globalmenu_actor_new (ClutterStage *stage) {
+
+  GtkWindow * win = gtk_window_new(GTK_WINDOW_POPUP);
+  GnomenuGlobalMenu * gm = gnomenu_global_menu_new();
+  GnomenuMonitor * monitor = gnomenu_monitor_new();
+
+  gtk_container_add(GTK_CONTAINER(win), gm);
+
+  g_object_set_data_full(G_OBJECT(win), "monitor", monitor, g_object_unref);
+
+  Window stage_xwin;
+  GdkWindow * stage_window;
+  stage_xwin = clutter_x11_get_stage_window (stage);
+  stage_window = gdk_window_lookup (stage_xwin);
+  if (stage_window)
+    g_object_ref (stage_window);
+  else
+    stage_window = gdk_window_foreign_new (stage_xwin);
+
+  gtk_widget_realize(win);
+  gtk_widget_set_parent_window (win, stage_window);
+  gdk_window_reparent (((GtkWidget*)win)->window, stage_window, 0, 0);
+  gtk_widget_set_size_request (win, 400, 24);
+  gtk_widget_show_all(win);
+
+  g_signal_connect(monitor, "window-changed", on_window_changed, gm);
+
+  ClutterActor * rt = shell_gtk_window_actor_new(win);
+
+   /** really should modify the gi tags **/
+   g_object_ref(rt);
+   g_assert(rt != NULL);
+   return rt;
+}
+
+static void on_window_changed(GnomenuMonitor * monitor, gulong prev, GnomenuGlobalMenu * gm) {
+	gulong xid = gnomenu_monitor_get_current_xid(monitor);
+	gnomenu_global_menu_switch_to(gm, xid);
+}
Index: src/shell-globalmenu-actor.h
===================================================================
--- src/shell-globalmenu-actor.h	(revision 0)
+++ src/shell-globalmenu-actor.h	(revision 0)
@@ -0,0 +1,9 @@
+#ifndef __SHELL_GLOBAL_MENU_ACTOR_H__
+#define __SHELL_GLOBAL_MENU_ACTOR_H__
+
+#include <clutter/glx/clutter-glx.h>
+#include <gtk/gtk.h>
+
+ClutterActor *shell_globalmenu_actor_new (ClutterStage * stage);
+
+#endif /* __SHELL_GLOBAL_MENU_ACTOR_H__ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 173)
+++ src/Makefile.am	(working copy)
@@ -38,6 +38,8 @@
 	shell-app-monitor.h			\
 	shell-gtkwindow-actor.c			\
 	shell-gtkwindow-actor.h			\
+	shell-globalmenu-actor.c			\
+	shell-globalmenu-actor.h			\
 	shell-process.c				\
 	shell-process.h				\
 	shell-global.c				\
@@ -75,6 +77,7 @@
 libgnome_shell_la_LDFLAGS = -avoid-version -module
 libgnome_shell_la_LIBADD =	\
 	$(MUTTER_PLUGIN_LIBS)	\
+	$(GNOMENU_LIBS)	\
         $(LIBGNOMEUI_LIBS)      \
 	libbig-1.0.la		\
 	libtidy-1.0.la		\
Index: js/ui/panel.js
===================================================================
--- js/ui/panel.js	(revision 173)
+++ js/ui/panel.js	(working copy)
@@ -8,6 +8,7 @@
 
 const Button = imports.ui.button;
 const Main = imports.ui.main;
+const Gnomenu = imports.gi.Gnomenu;
 
 const PANEL_HEIGHT = 32;
 const TRAY_HEIGHT = 24;
@@ -65,6 +66,9 @@
             });
         this._traymanager.manage_stage(global.stage);
 
+		this._globalmenu = Shell.globalmenu_actor_new(global.stage);
+		this._box.append(this._globalmenu, Big.BoxPackFlags.NONE);
+		
         // TODO: decide what to do with the rest of the panel in the overlay mode (make it fade-out, become non-reactive, etc.)
         // We get into the overlay mode on button-press-event as opposed to button-release-event because eventually we'll probably
         // have the overlay act like a menu that allows the user to release the mouse on the activity the user wants

Attachment: Screenshot-Untitled Window.png
Description: PNG image



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]