diff options
-rw-r--r-- | epan/prefs.c | 15 | ||||
-rw-r--r-- | epan/prefs.h | 1 | ||||
-rw-r--r-- | gtk/main.c | 16 | ||||
-rw-r--r-- | gtk/main_menu.c | 8 | ||||
-rw-r--r-- | gtk/prefs_gui.c | 18 |
5 files changed, 48 insertions, 10 deletions
diff --git a/epan/prefs.c b/epan/prefs.c index e450ce48ad..195f11c935 100644 --- a/epan/prefs.c +++ b/epan/prefs.c @@ -1158,6 +1158,7 @@ init_prefs(void) { prefs.gui_geometry_save_position = FALSE; prefs.gui_geometry_save_size = TRUE; prefs.gui_geometry_save_maximized= TRUE; + prefs.gui_macosx_style = TRUE; prefs.gui_console_open = console_open_never; prefs.gui_fileopen_style = FO_STYLE_LAST_OPENED; prefs.gui_recent_df_entries_max = 10; @@ -1641,6 +1642,7 @@ prefs_is_capture_device_hidden(const char *name) #define PRS_GUI_GEOMETRY_SAVE_POSITION "gui.geometry.save.position" #define PRS_GUI_GEOMETRY_SAVE_SIZE "gui.geometry.save.size" #define PRS_GUI_GEOMETRY_SAVE_MAXIMIZED "gui.geometry.save.maximized" +#define PRS_GUI_MACOSX_STYLE "gui.macosx_style" #define PRS_GUI_GEOMETRY_MAIN_X "gui.geometry.main.x" #define PRS_GUI_GEOMETRY_MAIN_Y "gui.geometry.main.y" #define PRS_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry.main.width" @@ -1970,6 +1972,13 @@ set_pref(gchar *pref_name, gchar *value, void *private_data _U_) else { prefs.gui_geometry_save_maximized = FALSE; } + } else if (strcmp(pref_name, PRS_GUI_MACOSX_STYLE) == 0) { + if (g_ascii_strcasecmp(value, "true") == 0) { + prefs.gui_macosx_style = TRUE; + } + else { + prefs.gui_macosx_style = FALSE; + } } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_X) == 0) { /* deprecated */ } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_Y) == 0) { /* deprecated */ } else if (strcmp(pref_name, PRS_GUI_GEOMETRY_MAIN_WIDTH) == 0) { /* deprecated */ @@ -2714,6 +2723,11 @@ write_prefs(char **pf_path_return) fprintf(pf, PRS_GUI_GEOMETRY_SAVE_MAXIMIZED ": %s\n", prefs.gui_geometry_save_maximized == TRUE ? "TRUE" : "FALSE"); + fprintf(pf, "\n# Use MacOS X style (Mac OS X with native GTK only)?\n"); + fprintf(pf, "# TRUE or FALSE (case-insensitive).\n"); + fprintf(pf, PRS_GUI_MACOSX_STYLE ": %s\n", + prefs.gui_macosx_style == TRUE ? "TRUE" : "FALSE"); + fprintf(pf, "\n# Open a console window (WIN32 only)?\n"); fprintf(pf, "# One of: NEVER, AUTOMATIC, ALWAYS\n"); fprintf(pf, PRS_GUI_CONSOLE_OPEN ": %s\n", @@ -3035,6 +3049,7 @@ copy_prefs(e_prefs *dest, e_prefs *src) dest->gui_geometry_save_position = src->gui_geometry_save_position; dest->gui_geometry_save_size = src->gui_geometry_save_size; dest->gui_geometry_save_maximized = src->gui_geometry_save_maximized; + dest->gui_macosx_style = src->gui_macosx_style; dest->gui_webbrowser = g_strdup(src->gui_webbrowser); dest->gui_window_title = g_strdup(src->gui_window_title); dest->gui_start_title = g_strdup(src->gui_start_title); diff --git a/epan/prefs.h b/epan/prefs.h index ae9414729b..07760a3745 100644 --- a/epan/prefs.h +++ b/epan/prefs.h @@ -123,6 +123,7 @@ typedef struct _e_prefs { gboolean gui_geometry_save_position; gboolean gui_geometry_save_size; gboolean gui_geometry_save_maximized; + gboolean gui_macosx_style; console_open_e gui_console_open; guint gui_recent_df_entries_max; guint gui_recent_files_count_max; diff --git a/gtk/main.c b/gtk/main.c index aabb651d1a..7798825590 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -174,6 +174,9 @@ #include <epan/crypt/airpdcap_ws.h> #endif +#ifdef HAVE_IGE_MAC_INTEGRATION +#include <ige-mac-menu.h> +#endif /* * Files under personal and global preferences directories in which @@ -3151,8 +3154,17 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs) /* Menu bar */ menubar = main_menu_new(&accel); - gtk_window_add_accel_group(GTK_WINDOW(top_level), accel); - gtk_widget_show(menubar); +#ifdef HAVE_IGE_MAC_INTEGRATION + if(prefs->gui_macosx_style) { + ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar)); + ige_mac_menu_set_global_key_handler_enabled(TRUE); + } else { +#endif + gtk_window_add_accel_group(GTK_WINDOW(top_level), accel); + gtk_widget_show(menubar); +#ifdef HAVE_IGE_MAC_INTEGRATION + } +#endif /* Main Toolbar */ main_tb = toolbar_new(); diff --git a/gtk/main_menu.c b/gtk/main_menu.c index f94c8dcac3..e85ecf4cc8 100644 --- a/gtk/main_menu.c +++ b/gtk/main_menu.c @@ -90,10 +90,6 @@ #include "gtk/main_toolbar.h" #include "gtk/main_welcome.h" -#ifdef HAVE_IGE_MAC_INTEGRATION -#include <ige-mac-menu.h> -#endif - typedef struct _menu_item { char *name; gint group; @@ -1050,10 +1046,6 @@ main_menu_new(GtkAccelGroup ** table) { if (table) *table = grp; -#ifdef HAVE_IGE_MAC_INTEGRATION - ige_mac_menu_set_menu_bar(GTK_MENU_SHELL(menubar)); -#endif - return menubar; } diff --git a/gtk/prefs_gui.c b/gtk/prefs_gui.c index cb2ac5ba55..337447a9d7 100644 --- a/gtk/prefs_gui.c +++ b/gtk/prefs_gui.c @@ -64,6 +64,8 @@ static gint recent_df_entries_changed_cb(GtkWidget *recent_df_entry _U_, #define GEOMETRY_SIZE_KEY "geometry_size" #define GEOMETRY_MAXIMIZED_KEY "geometry_maximized" +#define MACOSX_STYLE_KEY "macosx_style" + #define GUI_CONSOLE_OPEN_KEY "console_open" #define GUI_FILEOPEN_KEY "fileopen_behavior" #define GUI_FILEOPEN_PREVIEW_KEY "fileopen_preview_timeout" @@ -167,6 +169,7 @@ gui_prefs_show(void) GtkWidget *show_version_cb; GtkWidget *webbrowser_te; GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb; + GtkWidget *macosx_style_cb; GtkTooltips *tooltips = gtk_tooltips_new(); @@ -224,6 +227,16 @@ gui_prefs_show(void) "maximed state of the main window.", NULL); g_object_set_data(G_OBJECT(main_vb), GEOMETRY_MAXIMIZED_KEY, save_maximized_cb); +#ifdef HAVE_IGE_MAC_INTEGRATION + macosx_style_cb = create_preference_check_button(main_tb, pos++, + "MacOS X style", NULL, prefs.gui_macosx_style); + gtk_tooltips_set_tip(tooltips, macosx_style_cb, "Whether to create a " + "MacOS X look and feel. Checking this box will move the menu bar to " + "the top of the screen instead of the top of the Wireshark window. " + "Requires a restart of Wireshark to take effect.", NULL); + g_object_set_data(G_OBJECT(main_vb), MACOSX_STYLE_KEY, macosx_style_cb); +#endif + #ifdef _WIN32 /* How the console window should be opened */ console_open_om = create_preference_option_menu(main_tb, pos++, @@ -388,6 +401,11 @@ gui_prefs_fetch(GtkWidget *w) 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 + prefs.gui_macosx_style = + gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), MACOSX_STYLE_KEY)); +#endif + #ifdef _WIN32 prefs.gui_console_open = fetch_enum_value( g_object_get_data(G_OBJECT(w), GUI_CONSOLE_OPEN_KEY), gui_console_open_vals); |