osx: Properly use app menu

Mentioned in #994
This commit is contained in:
TingPing 2014-05-27 02:58:44 -04:00
parent cd1b9f42be
commit f43b7524e0
4 changed files with 25 additions and 8 deletions

View 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 */

View 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

View 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,6 +2363,9 @@ 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);
#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++;
}
}

View 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