From 7b0acb2b4440e0254320ca4b18ed565fe73048cb Mon Sep 17 00:00:00 2001 From: TingPing Date: Sun, 12 Jan 2014 17:00:26 -0500 Subject: [PATCH] Build with gtk-mac-integration - Use HexChat logo for dock icon - Use appmenu (not finished) --- configure.ac | 14 ++++++++++++++ src/common/cfgfiles.c | 3 +++ src/fe-gtk/fe-gtk.c | 15 +++++++++++++++ src/fe-gtk/fe-gtk.h | 9 +++++++++ src/fe-gtk/maingui.c | 4 ++++ 5 files changed, 45 insertions(+) diff --git a/configure.ac b/configure.ac index 085fbed4..688ffb38 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,7 @@ AH_VERBATIM([SOCKS],[#undef SOCKS]) AH_VERBATIM([USE_MSPROXY],[#undef USE_MSPROXY]) AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY]) AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES]) +AH_VERBATIM([HAVE_GTK_MAC],[#undef HAVE_GTK_MAC]) AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY]) AH_VERBATIM([USE_LIBCANBERRA],[#undef USE_LIBCANBERRA]) AH_VERBATIM([USE_IPV6],[#undef USE_IPV6]) @@ -206,6 +207,19 @@ fi GUI_LIBS="$GUI_LIBS $GTK_LIBS" GUI_CFLAGS="$GUI_CFLAGS $GTK_CFLAGS -DG_DISABLE_SINGLE_INCLUDES -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES" +dnl ********************************************************************* +dnl ** MAC_INTEGRATION ************************************************** +dnl ********************************************************************* + +_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0` +if test "x$_gdk_tgt" = xquartz; then + PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration, [ + GUI_LIBS="$GUI_LIBS $GTK_MAC_LIBS" + GUI_CFLAGS="$GUI_CFLAGS $GTK_MAC_CFLAGS" + AC_DEFINE(HAVE_GTK_MAC) + ]) +fi + dnl ********************************************************************* dnl ** PERL ************************************************************* dnl ********************************************************************* diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c index 9f1db75f..489eeda2 100644 --- a/src/common/cfgfiles.c +++ b/src/common/cfgfiles.c @@ -765,6 +765,9 @@ load_default_config(void) prefs.hex_gui_autoopen_dialog = 1; prefs.hex_gui_autoopen_recv = 1; prefs.hex_gui_autoopen_send = 1; +#ifdef HAVE_GTK_MAC + prefs.hex_gui_hide_menu = 1; +#endif prefs.hex_gui_input_attr = 1; prefs.hex_gui_input_icon = 1; prefs.hex_gui_input_nick = 1; diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c index f8954793..e930cb1f 100644 --- a/src/fe-gtk/fe-gtk.c +++ b/src/fe-gtk/fe-gtk.c @@ -63,6 +63,10 @@ GdkPixmap *channelwin_pix; static ca_context *ca_con; #endif +#ifdef HAVE_GTK_MAC +GtkosxApplication *osx_app; +#endif + /* === command-line parameter parsing : requires glib 2.6 === */ static char *arg_cfgdir = NULL; @@ -235,6 +239,10 @@ fe_args (int argc, char *argv[]) gtk_init (&argc, &argv); +#ifdef HAVE_GTK_MAC + osx_app = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); +#endif + return -1; } @@ -285,6 +293,9 @@ fe_init (void) key_init (); pixmaps_init (); +#ifdef HAVE_GTK_MAC + gtkosx_application_set_dock_icon_pixbuf (osx_app, pix_hexchat); +#endif channelwin_pix = pixmap_load_from_file (prefs.hex_text_background); input_style = create_input_style (gtk_style_new ()); } @@ -292,6 +303,10 @@ fe_init (void) void fe_main (void) { +#ifdef HAVE_GTK_MAC + gtkosx_application_ready(osx_app); +#endif + gtk_main (); /* sleep for 2 seconds so any QUIT messages are not lost. The */ diff --git a/src/fe-gtk/fe-gtk.h b/src/fe-gtk/fe-gtk.h index 623f2c01..ddb3324e 100644 --- a/src/fe-gtk/fe-gtk.h +++ b/src/fe-gtk/fe-gtk.h @@ -49,6 +49,11 @@ #endif #include + +#ifdef HAVE_GTK_MAC +#include +#endif + #include "banlist.h" #undef gtk_signal_connect @@ -65,6 +70,10 @@ #define flag_b flag_wid[8] #define NUM_FLAG_WIDS 9 +#ifdef HAVE_GTK_MAC +extern GtkosxApplication *osx_app; +#endif + struct server_gui { GtkWidget *rawlog_window; diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 0186e944..c2308621 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -3099,6 +3099,10 @@ 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