]> jfr.im git - irc/hexchat/hexchat.git/commitdiff
osx: Properly use app menu
authorTingPing <redacted>
Tue, 27 May 2014 06:58:44 +0000 (02:58 -0400)
committerTingPing <redacted>
Tue, 27 May 2014 06:58:44 +0000 (02:58 -0400)
Mentioned in #994

src/fe-gtk/fe-gtk.h
src/fe-gtk/maingui.c
src/fe-gtk/menu.c
src/fe-gtk/menu.h

index fbdb6678059342d73658be5be6553b6af3260512..9bf0a57fcaaa7c8950a46befe35b29528ec8e749 100644 (file)
@@ -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 */
index d8b88b6dd3dccfc481bbd124809f3b837da4ab3b..5d65e66be3e498969c1990e4de2f2ba89c87bfbb 100644 (file)
@@ -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
index 658f1c3ec8a9b18c456262e8a98508b7f88223c0..93b2072c62d4298f3bdc86caf1f565f4602bf93e 100644 (file)
@@ -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++;
        }
 }
index ca3dee63f169ac62f8f3dce5aaa0a937e2eb52c7..db2dc70aafb94adb31b1080c0b93911de75fb843 100644 (file)
@@ -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