Index: acinclude.m4 =================================================================== --- acinclude.m4 (révision 32913) +++ acinclude.m4 (copie de travail) @@ -1777,6 +1777,19 @@ GTK_LIBS="$GTK_LIBS -ligemacintegration" ]) fi + + if test x$have_ige_mac == x + then + AC_CHECK_LIB(igemacintegration, gtk_osxapplication_set_menu_bar, + [ + AC_DEFINE(HAVE_GTKOSXAPPLICATION, 1, + [Define to 1 if the the Gtk+ framework or a separate library inclues the GtkOSXApplication Integration functions.]) + have_ige_mac=yes + # We don't want gtk stuff in LIBS (which is reset below) so + # manually set GTK_LIBS (which is more appropriate) + GTK_LIBS="$GTK_LIBS -ligemacintegration" + ]) + fi CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" ]) Index: gtk/menus.c =================================================================== --- gtk/menus.c (révision 32913) +++ gtk/menus.c (copie de travail) @@ -105,6 +105,10 @@ #include #endif +#ifdef HAVE_GTKOSXAPPLICATION +#include +#endif + typedef struct _menu_item { char *name; gint group; @@ -1170,6 +1174,13 @@ IgeMacMenuGroup *group; #endif +#ifdef HAVE_GTKOSXAPPLICATION + GtkOSXApplication *theApp; + GtkWidget * item; + GtkOSXApplicationMenuGroup *group; + GtkWidget * dock_menu; +#endif + grp = gtk_accel_group_new(); if (initialize) @@ -1206,6 +1217,48 @@ g_signal_connect(quit_item, "activate", G_CALLBACK(file_quit_cmd_cb), NULL); ige_mac_menu_set_quit_menu_item(GTK_MENU_ITEM(quit_item)); #endif + +#ifdef HAVE_GTKOSXAPPLICATION + theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); + + if(prefs.gui_macosx_style) { + gtk_osxapplication_set_menu_bar(theApp, GTK_MENU_SHELL(menubar)); + gtk_osxapplication_set_use_quartz_accelerators(theApp, TRUE); + + group = gtk_osxapplication_add_app_menu_group (theApp); + item = gtk_item_factory_get_item(main_menu_factory,"/Help/About Wireshark"); + gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item)); + + group = gtk_osxapplication_add_app_menu_group (theApp); + item = gtk_item_factory_get_item(main_menu_factory,"/Edit/Preferences..."); + gtk_osxapplication_add_app_menu_item(theApp, group,GTK_MENU_ITEM (item)); + + group = gtk_osxapplication_add_app_menu_group (theApp); + item = gtk_item_factory_get_item(main_menu_factory,"/Help"); + gtk_osxapplication_set_help_menu(theApp,GTK_MENU_ITEM(item)); + + // Quit item is not needed + gtk_item_factory_delete_item(main_menu_factory,"/File/Quit"); + } + + + //generate dock menu + dock_menu = gtk_menu_new(); + + item = gtk_menu_item_new_with_label("Start"); + g_signal_connect_data (item, "activate", G_CALLBACK (capture_start_cb),0,0, 0); + gtk_menu_append(dock_menu, item); + + item = gtk_menu_item_new_with_label("Stop"); + g_signal_connect_data (item, "activate", G_CALLBACK (capture_stop_cb),0,0, 0); + gtk_menu_append(dock_menu, item); + + item = gtk_menu_item_new_with_label("Restart"); + g_signal_connect_data (item, "activate", G_CALLBACK (capture_restart_cb),0,0, 0); + gtk_menu_append(dock_menu, item); + + gtk_osxapplication_set_dock_menu(theApp, GTK_MENU_SHELL(dock_menu)); +#endif if (table) *table = grp; Index: gtk/main.c =================================================================== --- gtk/main.c (révision 32913) +++ gtk/main.c (copie de travail) @@ -183,6 +183,10 @@ #include "gtk/new_packet_list.h" #endif +#ifdef HAVE_GTKOSXAPPLICATION +#include +#endif + /* * Files under personal and global preferences directories in which * GTK settings for Wireshark are stored. @@ -1767,6 +1771,9 @@ static void main_capture_callback(gint event, capture_options *capture_opts, gpointer user_data _U_) { +#ifdef HAVE_GTKOSXAPPLICATION + GtkOSXApplication *theApp; +#endif switch(event) { case(capture_cb_capture_prepared): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture prepared"); @@ -1775,6 +1782,10 @@ case(capture_cb_capture_update_started): g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update started"); main_capture_cb_capture_update_started(capture_opts); + #ifdef HAVE_GTKOSXAPPLICATION + theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); + gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsiconcap48_xpm)); + #endif break; case(capture_cb_capture_update_continue): /*g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture update continue");*/ @@ -1798,6 +1809,10 @@ g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_DEBUG, "Callback: capture stopping"); /* Beware: this state won't be called, if the capture child * closes the capturing on it's own! */ + #ifdef HAVE_GTKOSXAPPLICATION + theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); + gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm)); + #endif break; default: g_warning("main_capture_callback: event %u unknown", event); @@ -2039,7 +2054,10 @@ dfilter_t *jump_to_filter = NULL; int optind_initial; int status; - +#ifdef HAVE_GTKOSXAPPLICATION + GtkOSXApplication *theApp; +#endif + #ifdef HAVE_LIBPCAP #if defined(_WIN32) || defined(HAVE_PCAP_CREATE) #define OPTSTRING_B "B:" @@ -2984,6 +3002,13 @@ profile_store_persconffiles (FALSE); +#ifdef HAVE_GTKOSXAPPLICATION + theApp = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL); + gtk_osxapplication_set_dock_icon_pixbuf(theApp,gdk_pixbuf_new_from_xpm_data(wsicon64_xpm)); + gtk_osxapplication_ready(theApp); + +#endif + g_log(LOG_DOMAIN_MAIN, G_LOG_LEVEL_INFO, "Wireshark is up and ready to go"); /* we'll enter the GTK loop now and hand the control over to GTK ... */ @@ -3003,6 +3028,10 @@ /* hide the (unresponsive) main window, while asking the user to close the console window */ gtk_widget_hide(top_level); +#ifdef HAVE_GTKOSXAPPLICATION + g_object_unref(theApp); +#endif + /* Shutdown windows sockets */ WSACleanup(); @@ -3541,13 +3570,13 @@ /* Menu bar */ menubar = main_menu_new(&accel); -#ifdef HAVE_IGE_MAC_INTEGRATION +#if defined HAVE_IGE_MAC_INTEGRATION || defined HAVE_GTKOSXAPPLICATION /* MacOS X native menus are created and displayed by main_menu_new() */ if(!prefs_p->gui_macosx_style) { #endif gtk_window_add_accel_group(GTK_WINDOW(top_level), accel); gtk_widget_show(menubar); -#ifdef HAVE_IGE_MAC_INTEGRATION +#if defined HAVE_IGE_MAC_INTEGRATION || defined HAVE_GTKOSXAPPLICATION } #endif Index: gtk/prefs_gui.c =================================================================== --- gtk/prefs_gui.c (révision 32913) +++ gtk/prefs_gui.c (copie de travail) @@ -173,7 +173,7 @@ GtkWidget *show_version_cb; GtkWidget *webbrowser_te; GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb; -#ifdef HAVE_IGE_MAC_INTEGRATION +#if defined HAVE_IGE_MAC_INTEGRATION || defined HAVE_GTKOSXAPPLICATION GtkWidget *macosx_style_cb; #endif @@ -232,7 +232,7 @@ prefs.gui_geometry_save_maximized); g_object_set_data(G_OBJECT(main_vb), GEOMETRY_MAXIMIZED_KEY, save_maximized_cb); -#ifdef HAVE_IGE_MAC_INTEGRATION +#if defined HAVE_IGE_MAC_INTEGRATION || defined HAVE_GTKOSXAPPLICATION macosx_style_cb = create_preference_check_button(main_tb, pos++, "MacOS X style", "Whether to create a MacOS X look and feel. Checking this box will move the " @@ -408,7 +408,7 @@ prefs.gui_geometry_save_maximized = gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GEOMETRY_MAXIMIZED_KEY)); -#ifdef HAVE_IGE_MAC_INTEGRATION +#if defined HAVE_IGE_MAC_INTEGRATION || defined HAVE_GTKOSXAPPLICATION prefs.gui_macosx_style = gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), MACOSX_STYLE_KEY)); #endif