Re: menu panel and the macintosh menu bar



As Miguel sugests I post my hack against libgnomeui to get MacOS style menus.
Please keep in mind I have never written a line of code before except for 
helloworld.c ;-) 

I know it's a dead easy hack, I'm not proud of it and it still doesn't work 
if focus follows mouse! It's just an idea, perhaps someone could tell me (in 
private, this list isn't the place for such elementary notions) what does 
'reparenting to the root window' mean (someone suggested me to do so but... I 
don't have a clue... does it mean the window is a leaf of the root window 
tree?) and how to do it...

I also tried to get the icon associated to the application owning the menu 
and place it on the menu to make it consistent with the foobar widget but 
apparently the X server returns an int not a pointer to pixmap data... I'm 
lost!)

On the other hand I used it for a while and it actually feels like a mac 
menu... although gmc doesn't work properly with it: if I close a gmc window 
the menu stays in place and a subsequent close segfaults (closing a gmc 
window doesn't destroy child objects so the menu stays there ready to do 
mischeif!)

Bah, think of it as a suggestion... 

bye,
Edo
-- 

I'd rather have two girls at 21 each than one girl at 42.
		-- W. C. Fields

--- gnome-app.c	Sat May  6 17:30:29 2000
+++ gnome-app.c	Fri Sep 22 15:26:42 2000
@@ -314,6 +314,60 @@
 	}
 }
 
+void
+MacOS_style_menu (GnomeApp *app)
+{
+	GtkWidget *menu_window;
+	GtkWidget *menubar;
+	GtkWidget *vbox;
+	
+/*	XWMHints *wmhints;
+	Pixmap *pixmap;	*/
+	
+	GdkPixmap *icon;
+	
+	
+	menubar = app->menubar;
+	gtk_menu_bar_set_shadow_type (GTK_MENU_BAR (menubar),
+									GTK_SHADOW_NONE);
+	
+	menu_window = gtk_window_new (GTK_WINDOW_POPUP);
+	gtk_window_set_default_size (GTK_WINDOW(menu_window),
+							gdk_screen_width(),
+							24);
+	
+	vbox = gtk_vbox_new (FALSE, 0);
+	
+/*	wmhints = XGetWMHints (GDK_DISPLAY(), GDK_WINDOW_XWINDOW(app));
+	pixmap = wmhints->icon_pixmap;
+	icon = gdk_pixmap_create_from_data (  menu_window,
+											NULL,
+											NULL,
+											NULL,
+											pixmap);
+
+	gtk_container_add (GTK_CONTAINER (menu_window), pixmap);*/
+	
+	gtk_container_add (GTK_CONTAINER (vbox), GTK_WIDGET (menubar));
+	gtk_container_add (GTK_CONTAINER (menu_window), GTK_WIDGET(vbox));
+	gtk_signal_connect_object_after (GTK_OBJECT(app),
+									"focus_in_event",
+									gtk_widget_show,
+									GTK_OBJECT(menu_window));
+	gtk_signal_connect_object_after (GTK_OBJECT(app),
+									"focus_out_event",
+									gtk_widget_hide,
+									GTK_OBJECT(menu_window));
+/*	gtk_signal_connect_object_after (GTK_OBJECT(app),
+									"delete_event",
+									gtk_widget_destroy,
+									GTK_WIDGET(menu_window));*/
+	gtk_widget_show (GTK_WIDGET (vbox));
+	gtk_widget_show (GTK_WIDGET (menubar));
+	gtk_widget_show (GTK_WIDGET (menu_window));
+}
+
+
 /**
  * gnome_app_set_menus
  * @app: Pointer to GNOME app object.
@@ -336,7 +390,7 @@
 	g_return_if_fail(menubar != NULL);
 	g_return_if_fail(GTK_IS_MENU_BAR(menubar));
 
-	behavior = (GNOME_DOCK_ITEM_BEH_EXCLUSIVE
+/*	behavior = (GNOME_DOCK_ITEM_BEH_EXCLUSIVE
 		    | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL);
 	
 	if (!gnome_preferences_get_menubar_detachable())
@@ -348,9 +402,9 @@
 
 	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;
@@ -374,10 +428,12 @@
 				    GNOME_DOCK_ITEM (dock_item),
 				    GNOME_DOCK_TOP,
 				    0, 0, 0, TRUE);
-
+	
 	gtk_widget_show (GTK_WIDGET (menubar));
 	gtk_widget_show (GTK_WIDGET (dock_item));
-
+*/
+	app->menubar = GTK_WIDGET (menubar);
+	MacOS_style_menu (app);
 	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);


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