static void rpcprogs_init_grid(GtkWidget *grid_parent) { GtkWidget *tmp; grid = ws_gtk_grid_new(); ws_gtk_grid_set_homogeneous(GTK_GRID(grid), TRUE); gtk_container_add(GTK_CONTAINER(grid_parent), grid); tmp = gtk_label_new("Program"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 0, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_LEFT); tmp = gtk_label_new("Version"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 1, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT); tmp = gtk_label_new("Calls"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 2, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT); tmp = gtk_label_new("Min SRT"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 3, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT); tmp = gtk_label_new("Max SRT"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 4, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT); tmp = gtk_label_new("Avg SRT"); ws_gtk_grid_attach_defaults(GTK_GRID(grid), tmp, 5, 0, 1, 1); gtk_label_set_justify(GTK_LABEL(tmp), GTK_JUSTIFY_RIGHT); }
GtkWidget* gui_prefs_show(void) { GtkWidget *main_grid, *main_vb; #ifdef _WIN32 GtkWidget *console_open_om, *enable_update_cb; #endif GtkWidget *fileopen_rb, *fileopen_dir_te, *fileopen_preview_te; GtkWidget *recent_files_count_max_te, *recent_df_entries_max_te, *ask_unsaved_cb, *find_wrap_cb; GtkWidget *use_pref_save_cb; GtkWidget *show_version_om; GtkWidget *auto_scroll_cb, *scroll_percent_te; GtkWidget *webbrowser_te; GtkWidget *save_position_cb, *save_size_cb, *save_maximized_cb; #if defined(HAVE_IGE_MAC_INTEGRATION) || defined(HAVE_GTKOSXAPPLICATION) GtkWidget *macosx_style_cb; #endif GtkWidget *expert_info_eyecandy_cb; int pos = 0; char current_val_str[128]; /* The columns haven't been changed yet */ cfile.columns_changed = FALSE; /* Main vertical box */ main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 7, FALSE); gtk_container_set_border_width( GTK_CONTAINER(main_vb), 5 ); /* Main grid */ main_grid = ws_gtk_grid_new(); gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0); #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_vexpand(GTK_WIDGET(main_grid), FALSE); /* Ignore VEXPAND requests from children */ #endif ws_gtk_grid_set_row_spacing(GTK_GRID(main_grid), 10); ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 15); /* Geometry prefs */ save_position_cb = create_preference_check_button(main_grid, pos++, "Save window position:", "Save the position of the main window.", prefs.gui_geometry_save_position); g_object_set_data(G_OBJECT(main_vb), GEOMETRY_POSITION_KEY, save_position_cb); save_size_cb = create_preference_check_button(main_grid, pos++, "Save window size:", "Save the size of the main window.", prefs.gui_geometry_save_size); g_object_set_data(G_OBJECT(main_vb), GEOMETRY_SIZE_KEY, save_size_cb); save_maximized_cb = create_preference_check_button(main_grid, pos++, "Save maximized state:", "Save the maximized state of the main window.", prefs.gui_geometry_save_maximized); g_object_set_data(G_OBJECT(main_vb), GEOMETRY_MAXIMIZED_KEY, save_maximized_cb); #ifdef _WIN32 enable_update_cb = create_preference_check_button(main_grid, pos++, "Check for updates:", "Periodically check for new versions of Wireshark.", prefs.gui_update_enabled); g_object_set_data(G_OBJECT(main_vb), ENABLE_UPDATE_KEY, enable_update_cb); #endif #if defined(HAVE_IGE_MAC_INTEGRATION) || defined(HAVE_GTKOSXAPPLICATION) macosx_style_cb = create_preference_check_button(main_grid, pos++, "Mac OS X style", "Create a Mac OS 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.", prefs.gui_macosx_style); 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_grid, pos++, "Open a console window", "Whether to open a console window " "(Automatic will open a console if messages appear).", gui_console_open_vals, prefs.gui_console_open); g_object_set_data(G_OBJECT(main_vb), GUI_CONSOLE_OPEN_KEY, console_open_om); #endif /* Allow user to select where they want the File Open dialog to open to * by default */ fileopen_rb = create_preference_radio_buttons(main_grid, pos++, "\"File Open\" dialog behavior:", "Which directory the \"File Open\" dialog should start with.", gui_fileopen_vals, prefs.gui_fileopen_style); /* Directory to default File Open dialog to */ fileopen_dir_te = create_preference_entry(main_grid, pos++, "Directory:", "The \"File Open\" dialog defaults always to this directory.", prefs.gui_fileopen_dir); g_object_set_data(G_OBJECT(main_vb), GUI_FILEOPEN_KEY, fileopen_rb); g_object_set_data(G_OBJECT(main_vb), GUI_FILEOPEN_DIR_KEY, fileopen_dir_te); g_signal_connect(fileopen_rb, "clicked", G_CALLBACK(fileopen_selected_cb), main_vb); g_signal_connect(fileopen_dir_te, "focus-out-event", G_CALLBACK(fileopen_dir_changed_cb), main_vb); /* File Open dialog preview timeout */ fileopen_preview_te = create_preference_entry(main_grid, pos++, "\"File Open\" preview timeout:", "Reading preview data in the \"File Open\" dialog will be stopped after given seconds.", open_file_preview_str); g_snprintf(current_val_str, sizeof(current_val_str), "%d", prefs.gui_fileopen_preview); gtk_entry_set_text(GTK_ENTRY(fileopen_preview_te), current_val_str); g_object_set_data(G_OBJECT(main_vb), GUI_FILEOPEN_PREVIEW_KEY, fileopen_preview_te); g_signal_connect(fileopen_preview_te, "focus_out_event", G_CALLBACK(fileopen_preview_changed_cb), main_vb); /* Number of recent entries in the display filter list ... */ recent_df_entries_max_te = create_preference_entry(main_grid, pos++, "Maximum recent filters:", "Maximum number of recent entries in filter display list.", recent_df_entries_max_str); g_snprintf(current_val_str, sizeof(current_val_str), "%d", prefs.gui_recent_df_entries_max); gtk_entry_set_text(GTK_ENTRY(recent_df_entries_max_te), current_val_str); g_object_set_data(G_OBJECT(main_vb), GUI_RECENT_DF_ENTRIES_KEY, recent_df_entries_max_te); g_signal_connect(recent_df_entries_max_te, "focus_out_event", G_CALLBACK(recent_df_entries_changed_cb), main_vb); /* Number of entries in the recent_files list ... */ recent_files_count_max_te = create_preference_entry(main_grid, pos++, "Maximum recent files:", "Maximum number of entries in the \"File/Open Recent\" list.", recent_files_count_max_str); g_snprintf(current_val_str, sizeof(current_val_str), "%d", prefs.gui_recent_files_count_max); gtk_entry_set_text(GTK_ENTRY(recent_files_count_max_te), current_val_str); g_object_set_data(G_OBJECT(main_vb), GUI_RECENT_FILES_COUNT_KEY, recent_files_count_max_te); g_signal_connect(recent_files_count_max_te, "focus_out_event", G_CALLBACK(recent_files_count_changed_cb), main_vb); fileopen_selected_cb(NULL, main_vb); /* ask for unsaved capture files? */ ask_unsaved_cb = create_preference_check_button(main_grid, pos++, "Confirm unsaved capture files:", "Whether a dialog should pop up in case of an unsaved capture file.", prefs.gui_ask_unsaved); g_object_set_data(G_OBJECT(main_vb), GUI_ASK_UNSAVED_KEY, ask_unsaved_cb); /* do we want to wrap when searching for data? */ find_wrap_cb = create_preference_check_button(main_grid, pos++, "Wrap to end/beginning of file during a find:", "Whether a search should wrap in a capture file.", prefs.gui_find_wrap); g_object_set_data(G_OBJECT(main_vb), GUI_FIND_WRAP_KEY, find_wrap_cb); /* show an explicit Save button for settings dialogs (preferences and alike)? */ use_pref_save_cb = create_preference_check_button(main_grid, pos++, "Settings dialogs show a save button:", "Whether the various settings dialogs (e.g. Preferences) should " "use an explicit save button - for advanced users.", prefs.gui_use_pref_save); g_object_set_data(G_OBJECT(main_vb), GUI_USE_PREF_SAVE_KEY, use_pref_save_cb); /* Show version in welcome and/or title screen */ show_version_om = create_preference_option_menu(main_grid, pos++, "Welcome screen and title bar shows version", "Whether version should be shown in the start page and/or main screen's title bar.", gui_version_placement_vals, prefs.gui_version_placement); g_object_set_data(G_OBJECT(main_vb), GUI_SHOW_VERSION_KEY, show_version_om); /* Whether to auto scroll when expanding items */ auto_scroll_cb = create_preference_check_button(main_grid, pos++, "Auto scroll on expansion:", "Whether the details view should be automatically scrolled up when expanding an item.", prefs.gui_auto_scroll_on_expand ); g_object_set_data(G_OBJECT(main_vb), GUI_AUTO_SCROLL_KEY, auto_scroll_cb); /* Where to auto scroll to when expanding items */ scroll_percent_te = create_preference_entry(main_grid, pos++, "Auto scroll percentage:", "Where to scroll the expanded item to within the view e.g. 0% = top of view, 50% = center of view.", scroll_percent_preview_str); g_snprintf(current_val_str, sizeof(current_val_str), "%d", prefs.gui_auto_scroll_percentage); gtk_entry_set_text(GTK_ENTRY(scroll_percent_te), current_val_str); g_object_set_data(G_OBJECT(main_vb), GUI_SCROLL_PERCENT_KEY, scroll_percent_te); g_signal_connect(scroll_percent_te, "focus_out_event", G_CALLBACK(scroll_percent_changed_cb), main_vb); /* Webbrowser */ if (browser_needs_pref()) { webbrowser_te = create_preference_entry(main_grid, pos++, "Web browser command:", "Command line to desired browser.", prefs.gui_webbrowser); gtk_entry_set_text(GTK_ENTRY(webbrowser_te), prefs.gui_webbrowser); g_object_set_data(G_OBJECT(main_vb), GUI_WEBBROWSER_KEY, webbrowser_te); } /* Enable Expert Infos Dialog Tab Label "eye-candy" */ expert_info_eyecandy_cb = create_preference_check_button(main_grid, pos++, "Display icons in the Expert Infos dialog tab labels:", "Whether icon images should be displayed in the Expert Infos dialog tab labels.", prefs.gui_expert_composite_eyecandy ); g_object_set_data(G_OBJECT(main_vb), GUI_EXPERT_EYECANDY_KEY, expert_info_eyecandy_cb); /* Show 'em what we got */ gtk_widget_show_all(main_vb); return(main_vb); }
GtkWidget * font_color_prefs_show(void) { GtkWidget *main_vb, *main_grid, *label, *combo_box; GtkWidget *font_sample, *color_sample, *colorsel; static const gchar *mt[] = { "Marked packet foreground", /* MFG_IDX 0*/ "Marked packet background", /* MBG_IDX 1*/ "Ignored packet foreground", /* IFG_IDX 2*/ "Ignored packet background", /* IBG_IDX 3*/ "'Follow Stream' client foreground", /* CFG_IDX 4*/ "'Follow Stream' client background", /* CBG_IDX 5*/ "'Follow Stream' server foreground", /* SFG_IDX 6*/ "'Follow Stream' server background", /* SBG_IDX 7*/ "Valid filter text entry", /* FTV_IDX 8*/ "Invalid filter text entry", /* FTI_IDX 9*/ "Deprecated filter text entry" /* FTD_IDX 10*/ }; int mcount = sizeof(mt) / sizeof (gchar *); GtkTextBuffer *buf; GtkTextIter iter; GRand *rand_state = g_rand_new(); GString *preview_string = g_string_new(""); int i; #define GRID_FONT_ROW 0 #define GRID_COLOR_ROW 1 #define GRID_COLOR_SEL_ROW 3 /* The font hasn't been changed yet. */ font_changed = FALSE; color_t_to_gdkxxx(&tcolors[MFG_IDX], &prefs.gui_marked_fg); color_t_to_gdkxxx(&tcolors[MBG_IDX], &prefs.gui_marked_bg); color_t_to_gdkxxx(&tcolors[IFG_IDX], &prefs.gui_ignored_fg); color_t_to_gdkxxx(&tcolors[IBG_IDX], &prefs.gui_ignored_bg); color_t_to_gdkxxx(&tcolors[CFG_IDX], &prefs.st_client_fg); color_t_to_gdkxxx(&tcolors[CBG_IDX], &prefs.st_client_bg); color_t_to_gdkxxx(&tcolors[SFG_IDX], &prefs.st_server_fg); color_t_to_gdkxxx(&tcolors[SBG_IDX], &prefs.st_server_bg); color_t_to_gdkxxx(&tcolors[FTV_IDX], &prefs.gui_text_valid); color_t_to_gdkxxx(&tcolors[FTI_IDX], &prefs.gui_text_invalid); color_t_to_gdkxxx(&tcolors[FTD_IDX], &prefs.gui_text_deprecated); color_t_to_gdkxxx(&filter_text_fg, &filter_text_fg_color); #if ! GTK_CHECK_VERSION(3,4,0) for (i=0; i<MAX_IDX; i++) { tcolors_orig[i] = tcolors[i]; } #endif curcolor = &tcolors[CFG_IDX]; /* Enclosing containers for each row of widgets */ main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE); gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5); main_grid = ws_gtk_grid_new(); gtk_box_pack_start(GTK_BOX(main_vb), main_grid, FALSE, FALSE, 0); ws_gtk_grid_set_row_spacing(GTK_GRID(main_grid), 40); ws_gtk_grid_set_column_spacing(GTK_GRID(main_grid), 15); gtk_widget_show(main_grid); label = gtk_label_new("Main window font:"); gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f); ws_gtk_grid_attach_extended(GTK_GRID(main_grid), label, 0, GRID_FONT_ROW, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0); gtk_widget_show(label); font_button = gtk_font_button_new_with_font(prefs.gui_gtk2_font_name); gtk_font_button_set_title(GTK_FONT_BUTTON(font_button), "Wireshark: Font"); ws_gtk_grid_attach(GTK_GRID(main_grid), font_button, 1, GRID_FONT_ROW, 1, 1); gtk_widget_show(font_button); g_string_printf(preview_string, " %s 0123456789", font_pangrams[g_rand_int_range(rand_state, 0, NUM_FONT_PANGRAMS)]); font_sample = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(font_sample), FALSE); buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(font_sample)); gtk_text_buffer_get_start_iter(buf, &iter); srand((unsigned int) time(NULL)); gtk_text_buffer_insert(buf, &iter, preview_string->str, -1); ws_gtk_grid_attach_extended(GTK_GRID(main_grid), font_sample, 2, GRID_FONT_ROW, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0); g_signal_connect(font_button, "font-set", G_CALLBACK(select_font), NULL); gtk_widget_show(font_sample); g_string_free(preview_string, TRUE); g_object_set_data(G_OBJECT(font_button), FONT_SAMPLE_KEY, font_sample); label = gtk_label_new("Colors:"); gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f); ws_gtk_grid_attach_extended(GTK_GRID(main_grid), label, 0, GRID_COLOR_ROW, 1, 1, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0,0); gtk_widget_show(label); /* We have to create this now, and configure it below. */ #if GTK_CHECK_VERSION(3,4,0) /* XXX: There appears to be a bug in the GTK3 GtkColorChooserWidget such that * when in the GtkColorChooserWidget "customize" mode (aka "color-edit" mode) * selecting a color doesn't trigger a "motify::rgba" callback. * The effect is that the sample text FG/BG colors don't update for the GTK3 * GtkColorChooserWidget in "custon color edit node"). * I expect use of the "customize mode" will be minimal and that the bug will * not be very noticeable. * (A GTK3 bug report has beem submitted. */ #endif colorsel = gtk_color_xxx_new(); combo_box = gtk_combo_box_text_new(); for (i = 0; i < mcount; i++){ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), mt[i]); } gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), CFG_IDX); g_signal_connect(combo_box, "changed", G_CALLBACK(update_current_color), colorsel); ws_gtk_grid_attach(GTK_GRID(main_grid), combo_box, 1, GRID_COLOR_ROW, 1, 1); gtk_widget_show(combo_box); color_sample = gtk_text_view_new(); update_font(user_font_get_regular(), font_sample, color_sample); gtk_text_view_set_editable(GTK_TEXT_VIEW(color_sample), FALSE); buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(color_sample)); gtk_text_buffer_get_start_iter(buf, &iter); gtk_text_buffer_create_tag(buf, "marked", TAG_PROP_FG_COLOR, &tcolors[MFG_IDX], TAG_PROP_BG_COLOR, &tcolors[MBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "ignored", TAG_PROP_FG_COLOR, &tcolors[IFG_IDX], TAG_PROP_BG_COLOR, &tcolors[IBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "client", TAG_PROP_FG_COLOR, &tcolors[CFG_IDX], TAG_PROP_BG_COLOR, &tcolors[CBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "server", TAG_PROP_FG_COLOR, &tcolors[SFG_IDX], TAG_PROP_BG_COLOR, &tcolors[SBG_IDX], NULL); gtk_text_buffer_create_tag(buf, "text_valid", TAG_PROP_FG_COLOR, &filter_text_fg, TAG_PROP_BG_COLOR, &tcolors[FTV_IDX], NULL); gtk_text_buffer_create_tag(buf, "text_invalid", TAG_PROP_FG_COLOR, &filter_text_fg, TAG_PROP_BG_COLOR, &tcolors[FTI_IDX], NULL); gtk_text_buffer_create_tag(buf, "text_deprecated", TAG_PROP_FG_COLOR, &filter_text_fg, TAG_PROP_BG_COLOR, &tcolors[FTD_IDX], NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_MARKED_TEXT, -1, "marked", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_IGNORED_TEXT, -1, "ignored", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_CLIENT_TEXT, -1, "client", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_SERVER_TEXT, -1, "server", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_TEXT_VALID_TEXT, -1, "text_valid", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_TEXT_INVALID_TEXT, -1, "text_invalid", NULL); gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_TEXT_DEPRECATED_TEXT, -1, "text_deprecated", NULL); ws_gtk_grid_attach_extended(GTK_GRID(main_grid), color_sample, 2, GRID_COLOR_ROW, 1, 2, (GtkAttachOptions)(GTK_EXPAND|GTK_FILL), (GtkAttachOptions)0, 0, 0); gtk_widget_show(color_sample); gtk_color_xxx_set_yyy(GTK_COLOR_XXX(colorsel), curcolor); ws_gtk_grid_attach_extended(GTK_GRID(main_grid), colorsel, 1, GRID_COLOR_SEL_ROW, 2, 1, (GtkAttachOptions)(GTK_FILL|GTK_EXPAND), (GtkAttachOptions)0, 0, 0); g_object_set_data(G_OBJECT(combo_box), COLOR_SAMPLE_KEY, color_sample); g_object_set_data(G_OBJECT(colorsel), COLOR_SAMPLE_KEY, color_sample); g_signal_connect(colorsel, COLOR_CHANGED_SIGNAL, G_CALLBACK(update_text_color), NULL); gtk_widget_show(colorsel); g_rand_free(rand_state); gtk_widget_show(main_vb); return main_vb; }