summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2014-05-27 02:58:44 -0400
committerTingPing <tingping@tingping.se>2014-05-27 02:58:44 -0400
commitf43b7524e0b4444ce138f04a3d9bed9ee5f29926 (patch)
treee95eda5ae483993d073bf1e0bf583e08e067f545
parentcd1b9f42be11b2245bbbecd3750e44af1e994389 (diff)
osx: Properly use app menu
Mentioned in #994
-rw-r--r--src/fe-gtk/fe-gtk.h2
-rw-r--r--src/fe-gtk/maingui.c4
-rw-r--r--src/fe-gtk/menu.c24
-rw-r--r--src/fe-gtk/menu.h3
4 files changed, 25 insertions, 8 deletions
diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h
index fbdb6678..9bf0a57f 100644
--- a/src/fe-gtk/fe-gtk.h
+++ b/src/fe-gtk/fe-gtk.h
@@ -182,7 +182,7 @@ typedef struct session_gui
 		GtkWidget *shbox, *shentry;	/* search bar hbox */
 		gulong search_changed_signal; /* hook for search change event so blanking the box doesn't suck */
 
-#define MENU_ID_NUM 13
+#define MENU_ID_NUM 14
 	GtkWidget *menu_item[MENU_ID_NUM+1]; /* some items we may change state of */
 
 	void *chanview;	/* chanview.h */
diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c
index d8b88b6d..5d65e66b 100644
--- a/src/fe-gtk/maingui.c
+++ b/src/fe-gtk/maingui.c
@@ -3108,10 +3108,6 @@ mg_create_menu (session_gui *gui, GtkWidget *table, int away_state)
 											gui->menu_item);
 	gtk_table_attach (GTK_TABLE (table), gui->menu, 0, 3, 0, 1,
 						   GTK_EXPAND | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-
-#ifdef HAVE_GTK_MAC
-	gtkosx_application_set_menu_bar(osx_app, GTK_MENU_SHELL(gui->menu));
-#endif
 }
 
 static void
diff --git a/src/fe-gtk/menu.c b/src/fe-gtk/menu.c
index 658f1c3e..93b2072c 100644
--- a/src/fe-gtk/menu.c
+++ b/src/fe-gtk/menu.c
@@ -1740,7 +1740,7 @@ menu_about (GtkWidget *wid, gpointer sess)
 }
 
 static struct mymenu mymenu[] = {
-	{N_("He_xChat"), 0, 0, M_NEWMENU, 0, 0, 1},
+	{N_("He_xChat"), 0, 0, M_NEWMENU, MENU_ID_HEXCHAT, 0, 1},
 	{N_("Network Li_st..."), menu_open_server_list, (char *)&pix_book, M_MENUPIX, 0, 0, 1, GDK_KEY_s},
 	{0, 0, 0, M_SEP, 0, 0, 0},
 
@@ -2249,9 +2249,17 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
 	char *key_theme = NULL;
 	GtkSettings *settings;
 	GSList *group = NULL;
+#ifdef HAVE_GTK_MAC
+	int appmenu_offset = 1; /* 0 is for about */
+#endif
 
 	if (bar)
+	{
 		menu_bar = gtk_menu_bar_new ();
+#ifdef HAVE_GTK_MAC
+		gtkosx_application_set_menu_bar (osx_app, GTK_MENU_SHELL (menu_bar));
+#endif
+	}
 	else
 		menu_bar = gtk_menu_new ();
 
@@ -2355,7 +2363,10 @@ menu_create_main (void *accel_group, int bar, int away, int toplevel,
 			menu_item = gtk_menu_item_new_with_mnemonic (_(mymenu[i].text));
 			/* record the English name for /menu */
 			g_object_set_data (G_OBJECT (menu_item), "name", mymenu[i].text);
-			gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);
+#ifdef HAVE_GTK_MAC /* Added to app menu, see below */
+			if (!bar || mymenu[i].id != MENU_ID_HEXCHAT)		
+#endif
+				gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), menu_item);
 			gtk_widget_show (menu_item);
 			break;
 
@@ -2457,6 +2468,15 @@ togitem:
 			/* this ends up in sess->gui->menu_item[MENU_ID_XXX] */
 			menu_widgets[mymenu[i].id] = item;
 
+#ifdef HAVE_GTK_MAC
+		/* We want HexChat to be the app menu, not including Quit or HexChat itself */
+		if (bar && item && i <= CLOSE_OFFSET + 1 && mymenu[i].id != MENU_ID_HEXCHAT)
+		{
+			if (!submenu || mymenu[i].type == M_MENUSUB)
+				gtkosx_application_insert_app_menu_item (osx_app, item, appmenu_offset++);
+		}
+#endif
+
 		i++;
 	}
 }
diff --git a/src/fe-gtk/menu.h b/src/fe-gtk/menu.h
index ca3dee63..db2dc70a 100644
--- a/src/fe-gtk/menu.h
+++ b/src/fe-gtk/menu.h
@@ -62,8 +62,9 @@ void menu_set_fullscreen (session_gui *gui, int fullscreen);
 #define MENU_ID_JOIN 11
 #define MENU_ID_USERMENU 12
 #define MENU_ID_FULLSCREEN 13
+#define MENU_ID_HEXCHAT 14
 
-#if (MENU_ID_NUM < MENU_ID_FULLSCREEN)
+#if (MENU_ID_NUM < MENU_ID_HEXCHAT)
 #error MENU_ID_NUM is set wrong
 #endif