Re: global (MacOS Style) menubar applet [initial patch]



Jacob Ulysses Berkman wrote:
> 
> Mark <jamess1 wwnet com> writes:
> 
> > Hello,
> >     Attached is an initial patch for the gnome global menu.
> 
> Can you re-send using unified diff format?  (cvs diff -u ...)

Here they are.

Mark
? control-center-patch.diff
Index: capplets/ui-properties/ui-properties.c
===================================================================
RCS file: /cvs/gnome/control-center/capplets/ui-properties/ui-properties.c,v
retrieving revision 1.19.2.4
diff -u -r1.19.2.4 ui-properties.c
--- capplets/ui-properties/ui-properties.c	2000/11/09 05:11:22	1.19.2.4
+++ capplets/ui-properties/ui-properties.c	2000/11/15 01:58:37
@@ -23,7 +23,6 @@
  */
 
 #include <config.h>
-#include <locale.h>
 #include "capplet-widget.h"
 
 static GtkWidget *capplet;
@@ -99,6 +98,13 @@
 	{NULL, NULL, NULL, NULL, NULL}
 };
 
+static gchar const *menubar_placement_name [] = {
+  N_("Menu placement"),
+  N_("Inside application window"),
+  N_("Inside panel applet"),
+  NULL
+};
+
 static gchar const *menubar_detachable_name [] = {
 	N_("Can detach and move menus"),
 	NULL
@@ -117,6 +123,10 @@
 	NULL
 };
 static WidgetLayout menu_options[] = {
+  {menubar_placement_name, NULL,
+   gnome_preferences_get_menubar_placement,
+   gnome_preferences_set_menubar_placement,
+   NULL},
 	{menubar_detachable_name, NULL,
 	 gnome_preferences_get_menubar_detachable,
 	 gnome_preferences_set_menubar_detachable,
@@ -565,7 +575,6 @@
 {
 	GtkWidget *the_capplet;
 
-	setlocale(LC_ALL, "");
 	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
 	textdomain (PACKAGE);
 	changing = TRUE;
? gnome-core-patch.diff
? panel/global-menu.c
? panel/global-menu.gnorba
? panel/global-menu
Index: idl/gnome-panel.idl
===================================================================
RCS file: /cvs/gnome/gnome-core/idl/gnome-panel.idl,v
retrieving revision 1.52
diff -u -r1.52 gnome-panel.idl
--- idl/gnome-panel.idl	2000/02/07 22:49:17	1.52
+++ idl/gnome-panel.idl	2000/11/15 01:56:31
@@ -171,6 +171,10 @@
 		oneway void freeze_changes ();
 		oneway void thaw_changes ();
 	};
+
+        interface GlobalMenu : Applet {
+	  oneway void show_menu (in unsigned long xwin);
+	};
 	
 	interface StatusSpot {
 		oneway void remove ();
Index: panel/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-core/panel/Makefile.am,v
retrieving revision 1.168.4.1
diff -u -r1.168.4.1 Makefile.am
--- panel/Makefile.am	2000/10/23 19:41:28	1.168.4.1
+++ panel/Makefile.am	2000/11/15 01:56:31
@@ -17,7 +17,7 @@
 	-I$(includedir) $(GNOME_INCLUDEDIR) $(ORB_CFLAGS) \
 	@PIXBUF_CFLAGS@
 
-bin_PROGRAMS = panel gnome-panel-properties-capplet
+bin_PROGRAMS = panel gnome-panel-properties-capplet global-menu
 noinst_PROGRAMS = bad-applet
 
 libpanel_appletincludedir = $(includedir)
@@ -160,6 +160,17 @@
 	$(GNOME_CAPPLET_LIBS)	\
 	$(INTLLIBS) @PIXBUF_LIBS@
 
+
+global_menu_SOURCES = \
+	global-menu.c \
+	$(CORBA_SRCLIST)
+
+global_menu_LDADD = $(GNOME_LIBDIR) $(GNORBA_LIBS) $(ORB_LIBS) \
+	$(GNOMEUI_LIBS) $(INTLLIBS) @PIXBUF_LIBS@
+
+global_menu_LDFLAGS=-export-dynamic
+
+
 data_DATA = panelrc
 
 ## Why not just make this via configure?  Because @datadir@ will be
@@ -191,7 +202,8 @@
 	panel.hints			\
 	gnome-panel-properties.desktop	\
 	nothing.cP			\
-	title-item.gob
+	title-item.gob			\
+	global-menu.gnorba
 
 ## Put `exec' in the name because this should be installed by
 ## `install-exec', not `install-data'.
@@ -221,7 +233,7 @@
 	  && mv dockletsConf.tmp dockletsConf.sh
 
 panelgnorbadir  = $(sysconfdir)/CORBA/servers
-panelgnorba_DATA = panel.gnorba
+panelgnorba_DATA = panel.gnorba global-menu.gnorba
 
 soundlistdir = $(sysconfdir)/sound/events
 soundlist_DATA = panel.soundlist
Index: panel/menu.c
===================================================================
RCS file: /cvs/gnome/gnome-core/panel/menu.c,v
retrieving revision 1.331.4.3
diff -u -r1.331.4.3 menu.c
--- panel/menu.c	2000/10/18 01:55:11	1.331.4.3
+++ panel/menu.c	2000/11/15 01:56:34
@@ -995,6 +995,14 @@
 	load_menu_applet (menudir, flags, TRUE, FALSE, NULL, panel, 0, FALSE);
 }
 
+static void
+add_global_menu_to_panel (GtkWidget *widget, gpointer data)
+{
+	load_extern_applet("gnome_global_menu", NULL,
+			   get_panel_from_menu_data(widget),
+			   0, FALSE, FALSE);
+}
+
 /*most of this function stolen from the real gtk_menu_popup*/
 static void
 restore_grabs(GtkWidget *w, gpointer data)
@@ -3806,6 +3814,16 @@
 			   GTK_SIGNAL_FUNC(add_menu_to_panel),
 			   "~/.gnome/apps/");
 	setup_internal_applet_drag(submenuitem, "MENU:~/.gnome/apps/");
+
+	menuitem = gtk_menu_item_new ();
+	gtk_widget_lock_accelerators (menuitem);
+	setup_menuitem_try_pixmap (menuitem, 
+				   "gnome-gmenu.png",
+				   _("Global Menu"), SMALL_ICON_SIZE);
+	gtk_menu_append (GTK_MENU (menu), menuitem);
+	gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
+			   GTK_SIGNAL_FUNC(add_global_menu_to_panel),NULL);
+	setup_internal_applet_drag(menuitem, "LAUNCHER:ASK");
 
 	menuitem = gtk_menu_item_new ();
 	gtk_widget_lock_accelerators (menuitem);
? gnome-libs-patch.diff
? idl/gnome-panel.idl
? libgnomeui/gnome-panel-stubs.c
? libgnomeui/gnome-panel-skels.c
? libgnomeui/gnome-panel-common.c
? libgnomeui/gnome-panel.h
? libgnomeui/my_gnome_panel_idl
Index: libgnomeui/Makefile.am
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/Makefile.am,v
retrieving revision 1.165.4.11
diff -u -r1.165.4.11 Makefile.am
--- libgnomeui/Makefile.am	2000/10/24 00:48:54	1.165.4.11
+++ libgnomeui/Makefile.am	2000/11/15 01:57:05
@@ -27,7 +27,18 @@
 
 EXTRA_HEADERS = 
 
+CORBA_SRCLIST = gnome-panel-stubs.c gnome-panel-skels.c gnome-panel-common.c gnome-panel.h
+
+# try to make these get cleaned properly
+CLEANFILES += $(CORBA_SRCLIST) my_gnome_panel_idl
+
+$(CORBA_SRCLIST): my_gnome_panel_idl
+
+my_gnome_panel_idl: $(top_srcdir)/idl/gnome-panel.idl $(ORBIT_IDL)
+	if $(ORBIT_IDL) ` GNOME_CONFIG@ --cflags idl` $< ; then touch my_gnome_panel_idl; else /bin/false; fi
+
 libgnomeui_la_SOURCES = \
+	$(CORBA_SRCLIST)		\
 	gnome-about.c			\
 	gnome-animator.c		\
 	gnome-app.c			\
@@ -105,6 +116,7 @@
 	gtkdial.c			\
 	gtkpixmapmenuitem.c
 
+
 ## this lists all the non-generated headers
 gnome_headers = \
 	gnome-about.h			\
@@ -264,8 +276,9 @@
 	gnometypebuiltins_ids.c			\
 	gnometypebuiltins_evals.c
 
-libgnomeui_la_LDFLAGS = -version-info 44:1:12 -rpath $(libdir)
-libgnomeui_la_LIBADD = $(LIBGNOMEUI_LIBS)
+libgnomeui_la_LDFLAGS = -version-info 44:1:12 -rpath $(libdir) -export-dynamic
+libgnomeui_la_LIBADD = $(LIBGNOMEUI_LIBS) \
+	-lgnorba $(ORBIT_LIBS)
 
 gnome_segv_LDADD =	\
 	libgnomeui.la 					\
Index: libgnomeui/gnome-app.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-app.c,v
retrieving revision 1.94.4.3
diff -u -r1.94.4.3 gnome-app.c
--- libgnomeui/gnome-app.c	2000/05/04 10:51:24	1.94.4.3
+++ libgnomeui/gnome-app.c	2000/11/15 01:57:05
@@ -18,7 +18,10 @@
 
 #include "config.h"
 #include <string.h>
+#include <gdk/gdkx.h>
 #include <gtk/gtk.h>
+#include <sched.h>
+#include <orb/orbit.h>
 #include "libgnome/gnome-defs.h"
 #include "libgnome/gnome-i18nP.h"
 #include "libgnome/gnome-util.h"
@@ -27,9 +30,12 @@
 #include "libgnomeui/gnome-preferences.h"
 #include "libgnomeui/gnome-dock.h"
 #include "libgnomeui/gnome-window-icon.h"
+#include "libgnorba/gnorba.h"
 
 #include "gnome-app.h"
 
+#include "gnome-panel.h"
+
 #define LAYOUT_CONFIG_PATH      "Placement/Dock"
 
 static void gnome_app_class_init (GnomeAppClass *class);
@@ -43,6 +49,7 @@
 
 static GtkWindowClass *parent_class;
 
+
 static gchar *
 read_layout_config (GnomeApp *app)
 {
@@ -131,6 +138,7 @@
 	app->enable_layout_config = TRUE;
 	gnome_window_icon_set_from_default (GTK_WINDOW (app));
 }
+	
 
 static void
 gnome_app_show (GtkWidget *widget)
@@ -213,6 +221,7 @@
 	return GTK_WIDGET (app);
 }
 
+
 /**
  * gnome_app_construct
  * @app: Pointer to newly-created GNOME app object.
@@ -314,6 +323,43 @@
 	}
 }
 
+static GNOME_GlobalMenu global_menu = CORBA_OBJECT_NIL;
+static gboolean showing_menu = FALSE;
+
+static void
+show_global_menu (GnomeApp *app)
+{
+	CORBA_Environment ev;
+	GtkWidget *menu;
+
+	if (showing_menu)
+		return;
+
+	CORBA_exception_init(&ev);
+	menu = gtk_object_get_data (GTK_OBJECT (app), "menu");
+	showing_menu = TRUE;
+
+        global_menu = goad_server_activate_with_repo_id(NULL,
+							  "IDL:GNOME/GlobalMenu:1.0",
+							  GOAD_ACTIVATE_EXISTING_ONLY, NULL);
+
+	if (global_menu != CORBA_OBJECT_NIL) {
+		if (!GTK_WIDGET_REALIZED(menu)) {
+		        gtk_widget_realize (menu);
+			g_print ("realized\n");
+		}
+		GNOME_GlobalMenu_show_menu (global_menu, 
+					    GDK_WINDOW_XWINDOW (menu->window),
+					    &ev);
+	}
+
+	gtk_widget_show (menu);
+
+	CORBA_exception_free(&ev);
+	showing_menu = FALSE;
+}
+
+
 /**
  * gnome_app_set_menus
  * @app: Pointer to GNOME app object.
@@ -326,9 +372,12 @@
 void
 gnome_app_set_menus (GnomeApp *app, GtkMenuBar *menubar)
 {
+	GtkWidget *prevbar;
 	GtkWidget *dock_item;
+	GtkWidget *menu;
 	GtkAccelGroup *ag;
 	GnomeDockItemBehavior behavior;
+	GnomeMenubarPlacement placement = gnome_preferences_get_menubar_placement();
 
 	g_return_if_fail(app != NULL);
 	g_return_if_fail(GNOME_IS_APP(app));
@@ -336,6 +385,32 @@
 	g_return_if_fail(menubar != NULL);
 	g_return_if_fail(GTK_IS_MENU_BAR(menubar));
 
+	prevbar = app->menubar;
+	app->menubar = GTK_WIDGET (menubar);
+	gtk_widget_show (GTK_WIDGET (menubar));
+
+	ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
+	if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
+	        gtk_window_add_accel_group(GTK_WINDOW(app), ag);
+
+	if (placement == GNOME_MENUBAR_PLACEMENT_GLOBAL) {
+		menu = gtk_object_get_data (GTK_OBJECT (app), "menu"); 
+		if (!menu) {
+			menu = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+			gtk_object_set_data (GTK_OBJECT (app), "menu", menu);
+			gtk_container_add (GTK_CONTAINER (menu), GTK_WIDGET(menubar));
+			gtk_signal_connect_after (GTK_OBJECT(app),
+						  "focus_in_event",
+						  show_global_menu,
+						  NULL);
+		} else {
+			gtk_container_remove (GTK_CONTAINER (menu), GTK_WIDGET(prevbar));
+			gtk_container_add (GTK_CONTAINER (menu), GTK_WIDGET(menubar));
+		}
+		return;
+	}
+
+
 	behavior = (GNOME_DOCK_ITEM_BEH_EXCLUSIVE
 		    | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
 	
@@ -345,12 +420,11 @@
 	dock_item = gnome_dock_item_new (GNOME_APP_MENUBAR_NAME,
 					 behavior);
 	gtk_container_add (GTK_CONTAINER (dock_item), GTK_WIDGET (menubar));
-
-	app->menubar = GTK_WIDGET (menubar);
 
-	/* To have menubar relief agree with the toolbar (and have the relief outside of
-	 * smaller handles), substitute the dock item's relief for the menubar's relief,
-	 * but don't change the size of the menubar in the process. */
+	/* To have menubar relief agree with the toolbar (and have the
+	 * relief outside of smaller handles), substitute the dock
+	 * item's relief for the menubar's relief, but don't change
+	 * the size of the menubar in the process. */
 	gtk_menu_bar_set_shadow_type (GTK_MENU_BAR (app->menubar), GTK_SHADOW_NONE);
 	if (gnome_preferences_get_menubar_relief ()) {
 		guint border_width;
@@ -375,12 +449,7 @@
 				    GNOME_DOCK_TOP,
 				    0, 0, 0, TRUE);
 
-	gtk_widget_show (GTK_WIDGET (menubar));
 	gtk_widget_show (GTK_WIDGET (dock_item));
-
-	ag = gtk_object_get_data(GTK_OBJECT(app), "GtkAccelGroup");
-	if (ag && !g_slist_find(gtk_accel_groups_from_object (GTK_OBJECT (app)), ag))
-	        gtk_window_add_accel_group(GTK_WINDOW(app), ag);
 }
 
 
Index: libgnomeui/gnome-init.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-init.c,v
retrieving revision 1.100.4.6
diff -u -r1.100.4.6 gnome-init.c
--- libgnomeui/gnome-init.c	2000/09/21 11:45:38	1.100.4.6
+++ libgnomeui/gnome-init.c	2000/11/15 01:57:05
@@ -45,6 +45,7 @@
 #include "libgnomeui/gnome-init.h"
 #include "libgnomeui/gnome-winhints.h"
 #include "libgnomeui/gnome-window-icon.h"
+#include "libgnorba/gnorba.h"
 #ifdef HAVE_LOCALE_H
 #include <locale.h>
 #endif
@@ -423,6 +424,7 @@
 			   int flags,
 			   poptContext *return_ctx)
 {
+        CORBA_Environment ev;
 	poptContext ctx;
 	char *appdesc;
 
@@ -467,6 +469,9 @@
 	/* reduce mem usage (hopefully) */
 	gnome_config_sync();
 	g_blow_chunks();
+
+        CORBA_exception_init (&ev);
+        gnorba_CORBA_init (&argc, argv, 0, &ev);
 
 	return 0;
 }
Index: libgnomeui/gnome-preferences.c
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-preferences.c,v
retrieving revision 1.31
diff -u -r1.31 gnome-preferences.c
--- libgnomeui/gnome-preferences.c	1999/07/05 22:47:53	1.31
+++ libgnomeui/gnome-preferences.c	2000/11/15 01:57:06
@@ -47,6 +47,7 @@
   TRUE,               /* Menus have a tearoff bar */
   TRUE,               /* Menu items have icons in them */
   TRUE,               /* Disable the Imlib cache */
+  GNOME_MENUBAR_PLACEMENT_LOCAL, /* Menubar Placement */
   GTK_WINDOW_DIALOG,  /* Dialogs are treated specially */
   GTK_WIN_POS_CENTER, /* Put dialogs in center of screen. */
   GNOME_MDI_NOTEBOOK, /* Use notebook MDI mode. */
@@ -118,6 +119,15 @@
 #define STATUSBAR_INTERACTIVE_KEY  "StatusBar_is_Interactive"
 #define STATUSBAR_METER_ON_RIGHT   "StatusBar_Meter_on_Right"
 
+#define MENUBAR_PLACEMENT_KEY      "MenubarPlacement"
+
+static const gchar * const menubar_placements [] = {
+  "Local",
+  "Global"
+};
+
+#define NUM_MENUBAR_PLACEMENTS 2
+
 #define MENUBAR_DETACHABLE_KEY     "Menubar_detachable"
 #define MENUBAR_RELIEF_KEY         "Menubar_relieved"
 
@@ -268,6 +278,15 @@
   gnome_config_pop_prefix();
   gnome_config_push_prefix(APP);
 
+  s = gnome_config_get_string(MENUBAR_PLACEMENT_KEY);
+
+  if ( ! enum_from_strings((int*) &settings->menubar_placement, s,
+			   menubar_placements, NUM_MENUBAR_PLACEMENTS) ) {
+    g_warning("Didn't recognize menubar placement in libgnomeui config");
+  }  
+
+  g_free(s);
+
   b = gnome_config_get_bool_with_default(MENUBAR_DETACHABLE_KEY"=true",
 					 NULL);
   settings->menubar_detachable = b;
@@ -375,6 +394,8 @@
   gnome_config_pop_prefix();
   gnome_config_push_prefix(APP);
 
+  gnome_config_set_string(MENUBAR_PLACEMENT_KEY, 
+			  menubar_placements[settings->menubar_placement]);
   gnome_config_set_bool(MENUBAR_DETACHABLE_KEY,
 			settings->menubar_detachable);
   gnome_config_set_bool(MENUBAR_RELIEF_KEY,
@@ -552,6 +573,20 @@
 gnome_preferences_set_statusbar_meter_on_right (gboolean statusbar_meter_on_right)
 {
   prefs.statusbar_meter_on_right = statusbar_meter_on_right;
+}
+
+
+/* Placement of the menu bars, either global (contained in an applet)
+   or local (contained the application window). */
+GnomeMenubarPlacement
+                  gnome_preferences_get_menubar_placement   (void)
+{
+  return prefs.menubar_placement;
+}
+
+void              gnome_preferences_set_menubar_placement   (GnomeMenubarPlacement p)
+{
+  prefs.menubar_placement = p;
 }
 
 
Index: libgnomeui/gnome-preferences.h
===================================================================
RCS file: /cvs/gnome/gnome-libs/libgnomeui/gnome-preferences.h,v
retrieving revision 1.22
diff -u -r1.22 gnome-preferences.h
--- libgnomeui/gnome-preferences.h	1999/01/18 04:23:49	1.22
+++ libgnomeui/gnome-preferences.h	2000/11/15 01:57:06
@@ -15,6 +15,12 @@
 
 BEGIN_GNOME_DECLS
 
+/* Menu Placement */
+typedef enum {
+  GNOME_MENUBAR_PLACEMENT_LOCAL,
+  GNOME_MENUBAR_PLACEMENT_GLOBAL
+}GnomeMenubarPlacement;
+
 /* Global config choices. App-specific choices are handled in GnomeApp. */
 
 typedef struct _GnomePreferences GnomePreferences;
@@ -39,6 +45,7 @@
   int menus_have_tearoff : 1;
   int menus_have_icons : 1;
   int disable_imlib_cache : 1;
+  GnomeMenubarPlacement menubar_placement;
   GtkWindowType dialog_type;
   GtkWindowPosition dialog_position;
   GnomeMDIMode mdi_mode;
@@ -70,6 +77,11 @@
 gboolean          gnome_preferences_get_statusbar_meter_on_right (void);
 void              gnome_preferences_set_statusbar_meter_on_right (gboolean status_meter_on_right);
 
+/* Placement of the menu bars, either global (contained in an applet)
+   or local (contained the application window). */
+GnomeMenubarPlacement
+                  gnome_preferences_get_menubar_placement   (void);
+void              gnome_preferences_set_menubar_placement   (GnomeMenubarPlacement p);
 
 /* Whether menubars can be detached */
 gboolean          gnome_preferences_get_menubar_detachable   (void);


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