summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/gtk/CMakeLists.txt2
-rw-r--r--ui/gtk/Makefile.common4
-rw-r--r--ui/gtk/prefs_dlg.c52
-rw-r--r--ui/gtk/prefs_dlg.h18
-rw-r--r--ui/gtk/prefs_font_color.c (renamed from ui/gtk/prefs_stream.c)227
-rw-r--r--ui/gtk/prefs_font_color.h (renamed from ui/gtk/prefs_stream.h)24
-rw-r--r--ui/gtk/prefs_gui.c124
-rw-r--r--ui/gtk/prefs_gui.h2
8 files changed, 247 insertions, 206 deletions
diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt
index c2a25fe670..0fa4fb363d 100644
--- a/ui/gtk/CMakeLists.txt
+++ b/ui/gtk/CMakeLists.txt
@@ -94,7 +94,7 @@ set(WIRESHARK_GTK_SRC
prefs_filter_expressions.c
prefs_gui.c
prefs_layout.c
- prefs_stream.c
+ prefs_font_color.c
print_dlg.c
profile_dlg.c
progress_dlg.c
diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common
index 7c9bc2754a..cf3bccf18d 100644
--- a/ui/gtk/Makefile.common
+++ b/ui/gtk/Makefile.common
@@ -113,7 +113,7 @@ WIRESHARK_GTK_SRC = \
prefs_filter_expressions.c \
prefs_gui.c \
prefs_layout.c \
- prefs_stream.c \
+ prefs_font_color.c \
print_dlg.c \
profile_dlg.c \
progress_dlg.c \
@@ -315,7 +315,7 @@ noinst_HEADERS = \
prefs_filter_expressions.h \
prefs_gui.h \
prefs_layout.h \
- prefs_stream.h \
+ prefs_font_color.h \
profile_dlg.h \
proto_dlg.h \
proto_help.h \
diff --git a/ui/gtk/prefs_dlg.c b/ui/gtk/prefs_dlg.c
index 739184c25f..348b8cd800 100644
--- a/ui/gtk/prefs_dlg.c
+++ b/ui/gtk/prefs_dlg.c
@@ -43,7 +43,7 @@
#include "ui/gtk/prefs_column.h"
#include "ui/gtk/prefs_dlg.h"
#include "ui/gtk/prefs_filter_expressions.h"
-#include "ui/gtk/prefs_stream.h"
+#include "ui/gtk/prefs_font_color.h"
#include "ui/gtk/prefs_gui.h"
#include "ui/gtk/prefs_layout.h"
#include "ui/gtk/prefs_capture.h"
@@ -55,6 +55,7 @@
#include "ui/gtk/uat_gui.h"
#include "ui/gtk/old-gtk-compat.h"
#include "ui/gtk/file_dlg.h"
+#include "ui/gtk/dlg_utils.h"
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
@@ -90,7 +91,7 @@ static GtkWidget *create_preference_filename_entry(GtkWidget *, int,
#define E_GUI_LAYOUT_PAGE_KEY "gui_layout_page"
#define E_GUI_COLUMN_PAGE_KEY "gui_column_options_page"
#define E_GUI_FONT_PAGE_KEY "gui_font_options_page"
-#define E_GUI_COLORS_PAGE_KEY "gui_colors_options_page"
+#define E_GUI_FONT_COLORS_PAGE_KEY "gui_font_colors_options_page"
#define E_CAPTURE_PAGE_KEY "capture_options_page"
#define E_NAMERES_PAGE_KEY "nameres_options_page"
#define E_FILTER_EXPRESSIONS_PAGE_KEY "filter_expressions_page"
@@ -157,7 +158,7 @@ pref_show(pref_t *pref, gpointer user_data)
label_string = g_malloc(label_len);
g_strlcpy(label_string, title, label_len);
- tooltip_txt = pref->description? g_strdup_printf("%s.%s: %s\n%s",
+ tooltip_txt = pref->description? g_strdup_printf("%s.%s: %s\n%s",
module->name,
pref->name,
get_pref_type_string(pref->type),
@@ -300,7 +301,7 @@ prefs_tree_page_add(const gchar *title, gint page_nr,
/* add a page to the notebook */
static GtkWidget *
-prefs_nb_page_add(GtkWidget *notebook, const gchar *title, GtkWidget *page, const char *page_key)
+prefs_nb_page_add(GtkWidget *notebook, const gchar *title _U_, GtkWidget *page, const char *page_key)
{
GtkWidget *sw;
GtkWidget *frame;
@@ -309,7 +310,9 @@ prefs_nb_page_add(GtkWidget *notebook, const gchar *title, GtkWidget *page, cons
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_widget_show(sw);
- frame = gtk_frame_new(title);
+ frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), DLG_OUTER_MARGIN);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), frame);
gtk_widget_show(frame);
@@ -406,8 +409,9 @@ module_prefs_show(module_t *module, gpointer user_data)
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(main_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
/* Frame */
- frame = gtk_frame_new(module->description);
- gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
+ frame = gtk_frame_new(NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(frame), DLG_OUTER_MARGIN);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(main_sw), frame);
g_object_set_data(G_OBJECT(main_sw), E_PAGESW_FRAME_KEY, frame);
@@ -458,7 +462,6 @@ prefs_page_cb(GtkWidget *w _U_, gpointer dummy _U_, PREFS_PAGE_E prefs_page)
{
GtkWidget *top_hb, *bbox, *prefs_nb, *ct_sb,
*ok_bt, *apply_bt, *save_bt, *cancel_bt, *help_bt;
- GtkWidget *gui_font_pg;
gchar label_str[MAX_TREE_NODE_NAME_LEN];
struct ct_struct cts;
GtkTreeStore *store;
@@ -556,30 +559,9 @@ prefs_page_cb(GtkWidget *w _U_, gpointer dummy _U_, PREFS_PAGE_E prefs_page)
columns_iter = prefs_tree_page_add(label_str, cts.page, store, &gui_iter);
columns_page = cts.page++;
- /* GUI Font prefs */
- g_strlcpy(label_str, "Font", MAX_TREE_NODE_NAME_LEN);
- gui_font_pg = gui_font_prefs_show();
- prefs_nb_page_add(prefs_nb, label_str, gui_font_pg, E_GUI_FONT_PAGE_KEY);
- prefs_tree_page_add(label_str, cts.page, store, &gui_iter);
- cts.page++;
-
- gtk_container_set_border_width( GTK_CONTAINER(gui_font_pg), 5 );
-
- /* IMPORTANT: the following gtk_font_selection_set_font_name() function will
- only work if the widget and it's corresponding window is already shown
- (so don't put the following into gui_font_prefs_show()) !!! */
-
- /* We set the current font now, because setting it appears not to work
- when run before appending the frame to the notebook. */
-#if GTK_CHECK_VERSION(3,2,0)
- gtk_font_chooser_set_font(GTK_FONT_CHOOSER(gui_font_pg), prefs.gui_font_name);
-#else
- gtk_font_selection_set_font_name(
- GTK_FONT_SELECTION(gui_font_pg), prefs.gui_font_name);
-#endif /* GTK_CHECK_VERSION(3,2,0) */
/* GUI Colors prefs */
- g_strlcpy(label_str, "Colors", MAX_TREE_NODE_NAME_LEN);
- prefs_nb_page_add(prefs_nb, label_str, stream_prefs_show(), E_GUI_COLORS_PAGE_KEY);
+ g_strlcpy(label_str, "Font and Colors", MAX_TREE_NODE_NAME_LEN);
+ prefs_nb_page_add(prefs_nb, label_str, font_color_prefs_show(), E_GUI_FONT_COLORS_PAGE_KEY);
prefs_tree_page_add(label_str, cts.page, store, &gui_iter);
cts.page++;
@@ -1342,7 +1324,7 @@ prefs_main_fetch_all(GtkWidget *dlg, gboolean *must_redissect)
gui_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_GUI_PAGE_KEY));
layout_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_GUI_LAYOUT_PAGE_KEY));
column_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_GUI_COLUMN_PAGE_KEY));
- stream_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_GUI_COLORS_PAGE_KEY));
+ font_color_prefs_fetch(g_object_get_data(G_OBJECT(dlg), E_GUI_FONT_COLORS_PAGE_KEY));
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
@@ -1374,10 +1356,10 @@ prefs_main_apply_all(GtkWidget *dlg, gboolean redissect)
*/
prefs_apply_all();
- gui_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_PAGE_KEY), redissect);
+ gui_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_PAGE_KEY));
layout_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_LAYOUT_PAGE_KEY));
column_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_COLUMN_PAGE_KEY));
- stream_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_COLORS_PAGE_KEY));
+ font_color_prefs_apply(g_object_get_data(G_OBJECT(dlg), E_GUI_FONT_COLORS_PAGE_KEY), redissect);
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
@@ -1417,7 +1399,7 @@ prefs_main_destroy_all(GtkWidget *dlg)
gui_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_GUI_PAGE_KEY));
layout_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_GUI_LAYOUT_PAGE_KEY));
column_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_GUI_COLUMN_PAGE_KEY));
- stream_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_GUI_COLORS_PAGE_KEY));
+ font_color_prefs_destroy(g_object_get_data(G_OBJECT(dlg), E_GUI_FONT_COLORS_PAGE_KEY));
#ifdef HAVE_LIBPCAP
#ifdef _WIN32
diff --git a/ui/gtk/prefs_dlg.h b/ui/gtk/prefs_dlg.h
index 433ec5b43b..440443ce87 100644
--- a/ui/gtk/prefs_dlg.h
+++ b/ui/gtk/prefs_dlg.h
@@ -26,8 +26,8 @@
#define __PREFS_DLG_H__
/** @defgroup prefs_group Preferences
- *
- * All GUI related preferences things. Please note, that some GUI related things
+ *
+ * All GUI related preferences things. Please note, that some GUI related things
* are saved in the recent file, which is processed in recent.h.
*
* The Preference dialog has the following page submodules:
@@ -38,8 +38,8 @@
ui [ label="User Interface" URL="\ref prefs_gui.h"];
layout [ label="UI: Layout" URL="\ref prefs_layout.h"];
columns [ label="UI: Columns" URL="\ref prefs_column.h"];
- font [ label="UI: Font" URL="\ref prefs_gui.h"];
- colors [ label="UI: Colors" URL="\ref prefs_stream.h"];
+ font [ label="UI: Font" URL="\ref prefs_font_colors.h"];
+ colors [ label="UI: Colors" URL="\ref prefs_font_colors.h"];
capture [ label="Capture" URL="\ref prefs_capture.h"];
print [ label="Printing" URL="\ref prefs_print.h"];
nameres [ label="Name resolution" URL="\ref prefs_nameres.h"];
@@ -71,14 +71,14 @@ typedef enum {
} PREFS_PAGE_E;
/** Show the preferences dialog.
- *
+ *
* @param widget parent widget (unused)
* @param data unused
*/
extern void prefs_cb(GtkWidget *widget, gpointer data);
/** Show the preferences dialog in given page.
- *
+ *
* @param widget parent widget (unused)
* @param data unused
* @param prefs_page page to show
@@ -86,7 +86,7 @@ extern void prefs_cb(GtkWidget *widget, gpointer data);
extern void prefs_page_cb(GtkWidget *widget, gpointer data, PREFS_PAGE_E prefs_page);
/** Show the protocol properties dialog.
- *
+ *
* @param widget parent widget (unused)
* @param data unused
*/
@@ -119,7 +119,7 @@ extern GtkWidget *create_preference_radio_buttons(GtkWidget *main_tb, int table_
const enum_val_t *enumvals, gint current_val);
/** Get the currently selected value from a radio button.
- *
+ *
* @param button the button from create_preference_radio_buttons()
* @param enumvals the same enum vals as in create_preference_radio_buttons()
* @return the index of the currently selected item
@@ -141,7 +141,7 @@ extern GtkWidget *create_preference_option_menu(GtkWidget *main_tb, int table_ro
const enum_val_t *enumvals, gint current_val);
/** Get the currently selected value from an option menu.
- *
+ *
* @param optmenu the option menu from create_preference_option_menu()
* @param enumvals the same enum vals as in create_preference_option_menu()
* @return the index of the currently selected item
diff --git a/ui/gtk/prefs_stream.c b/ui/gtk/prefs_font_color.c
index 92d582e17d..396ef497ed 100644
--- a/ui/gtk/prefs_stream.c
+++ b/ui/gtk/prefs_font_color.c
@@ -1,5 +1,5 @@
-/* stream_prefs.c
- * Dialog boxes for preferences for the stream window
+/* prefs_font_color.c
+ * Font and Color preferences widget
*
* $Id$
*
@@ -31,12 +31,17 @@
#include "../color.h"
#include "../print.h"
+#include "ui/recent.h"
+#include "ui/simple_dialog.h"
+
#include "ui/gtk/color_utils.h"
+#include "ui/gtk/follow_tcp.h"
+#include "ui/gtk/font_utils.h"
#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/prefs_stream.h"
#include "ui/gtk/keys.h"
-#include "ui/gtk/follow_tcp.h"
#include "ui/gtk/old-gtk-compat.h"
+#include "ui/gtk/packet_panes.h"
+#include "ui/gtk/prefs_font_color.h"
#define SAMPLE_MARKED_TEXT "Sample marked packet text\n"
#define SAMPLE_IGNORED_TEXT "Sample ignored packet text\n"
@@ -51,24 +56,45 @@
#define SFG_IDX 6
#define SBG_IDX 7
#define MAX_IDX 8 /* set this to the number of IDX values */
-#define STREAM_SAMPLE_KEY "stream_entry"
+#define COLOR_SAMPLE_KEY "text_color_sample"
+#define FONT_SAMPLE_KEY "font_sample"
#define STREAM_CS_KEY "stream_colorselection"
#define CS_RED 0
#define CS_GREEN 1
#define CS_BLUE 2
#define CS_OPACITY 3
+static void select_font(GtkWidget *, gpointer);
+static void update_font(PangoFontDescription *, GtkWidget *, GtkWidget *);
static void update_text_color(GtkWidget *, gpointer);
static void update_current_color(GtkWidget *, gpointer);
static GdkColor tcolors[MAX_IDX], *curcolor = NULL;
+/* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
+ the "Font..." dialog, so that we know that they (probably) changed
+ the font, and therefore that the "apply" function needs to take care
+ of that */
+static gboolean font_changed;
+
+/* Font name from the font dialog box; if "font_changed" is TRUE, this
+ has been set to the name of the font the user selected. */
+static gchar *new_font_name;
+
+static GtkWidget *font_button;
+
+static const char *font_pangrams[] = {
+ "Example GIF query packets have jumbo window sizes",
+ "Lazy badgers move unique waxy jellyfish packets"
+};
+#define NUM_FONT_PANGRAMS (sizeof font_pangrams / sizeof font_pangrams[0])
+
GtkWidget *
-stream_prefs_show(void)
+font_color_prefs_show(void)
{
GtkWidget *main_vb, *main_tb, *label, *combo_box;
- GtkWidget *sample, *colorsel;
- int width, height, i;
+ GtkWidget *font_sample, *color_sample, *colorsel;
+ int i;
const gchar *mt[] = {
"Marked packet foreground", /* MFG_IDX 0*/
"Marked packet background", /* MBG_IDX 1*/
@@ -82,7 +108,11 @@ stream_prefs_show(void)
int mcount = sizeof(mt) / sizeof (gchar *);
GtkTextBuffer *buf;
GtkTextIter iter;
- PangoLayout *layout;
+ GRand *rand_state = g_rand_new();
+ GString *preview_string = g_string_new("");
+
+ /* The font hasn't been changed yet. */
+ font_changed = FALSE;
color_t_to_gdkcolor(&tcolors[MFG_IDX], &prefs.gui_marked_fg);
color_t_to_gdkcolor(&tcolors[MBG_IDX], &prefs.gui_marked_bg);
@@ -99,17 +129,43 @@ stream_prefs_show(void)
main_vb = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 5, FALSE);
gtk_container_set_border_width(GTK_CONTAINER(main_vb), 5);
- main_tb = gtk_table_new(3, 3, FALSE);
+ main_tb = gtk_table_new(4, 3, FALSE);
gtk_box_pack_start(GTK_BOX(main_vb), main_tb, FALSE, FALSE, 0);
gtk_table_set_row_spacings(GTK_TABLE(main_tb), 10);
gtk_table_set_col_spacings(GTK_TABLE(main_tb), 15);
gtk_widget_show(main_tb);
- label = gtk_label_new("Set:");
+ label = gtk_label_new("Main window font:");
gtk_misc_set_alignment(GTK_MISC(label), 1.0f, 0.5f);
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 0, 1);
gtk_widget_show(label);
+ font_button = gtk_font_button_new_with_font(prefs.gui_font_name);
+ gtk_font_button_set_title(GTK_FONT_BUTTON(font_button), "Wireshark: Font");
+ gtk_table_attach(GTK_TABLE(main_tb), font_button, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+ 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);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), font_sample, 2, 3, 0, 1);
+ 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);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 1, 2);
+ gtk_widget_show(label);
+
/* We have to create this now, and configure it below. */
colorsel = gtk_color_selection_new();
@@ -119,17 +175,14 @@ stream_prefs_show(void)
}
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), CFG_IDX);
g_signal_connect(combo_box, "changed", G_CALLBACK(update_current_color), colorsel);
- gtk_table_attach(GTK_TABLE(main_tb), combo_box, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
+ gtk_table_attach(GTK_TABLE(main_tb), combo_box, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show(combo_box);
- sample = gtk_text_view_new();
- layout = gtk_widget_create_pango_layout(sample, SAMPLE_SERVER_TEXT);
- pango_layout_get_pixel_size(layout, &width, &height);
- g_object_unref(G_OBJECT(layout));
- gtk_widget_set_size_request(sample, width, height * 2);
- gtk_text_view_set_editable(GTK_TEXT_VIEW(sample), FALSE);
- buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sample));
+ 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",
"foreground-gdk", &tcolors[MFG_IDX],
@@ -151,25 +204,88 @@ stream_prefs_show(void)
"client", NULL);
gtk_text_buffer_insert_with_tags_by_name(buf, &iter, SAMPLE_SERVER_TEXT, -1,
"server", NULL);
- gtk_table_attach_defaults(GTK_TABLE(main_tb), sample, 2, 3, 0, 2);
- gtk_widget_show(sample);
+ gtk_table_attach_defaults(GTK_TABLE(main_tb), color_sample, 2, 3, 1, 3);
+ gtk_widget_show(color_sample);
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel),
curcolor);
- gtk_table_attach(GTK_TABLE(main_tb), colorsel, 0, 3, 2, 3,
+ gtk_table_attach(GTK_TABLE(main_tb), colorsel, 0, 3, 3, 4,
GTK_SHRINK, GTK_SHRINK, 0, 0);
- g_object_set_data(G_OBJECT(colorsel), STREAM_SAMPLE_KEY, sample);
+
+ 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", G_CALLBACK(update_text_color), NULL);
gtk_widget_show(colorsel);
+ g_rand_free(rand_state);
gtk_widget_show(main_vb);
return(main_vb);
}
static void
+update_font(PangoFontDescription *font, GtkWidget *font_sample _U_, GtkWidget *color_sample _U_) {
+
+ if (!font_sample || !color_sample) return;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_font(font_sample, font);
+ gtk_widget_override_font(color_sample, font);
+#else
+ gtk_widget_modify_font(font_sample, font);
+ gtk_widget_modify_font(color_sample, font);
+#endif
+
+}
+
+static gboolean
+font_fetch(void)
+{
+ gchar *font_name;
+
+ if (!font_button) return FALSE;
+
+ font_name = g_strdup(gtk_font_button_get_font_name(
+ GTK_FONT_BUTTON(font_button)));
+ if (font_name == NULL) {
+ /* No font was selected; let the user know, but don't
+ tear down the font selection dialog, so they can
+ try again. */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "You have not selected a font.");
+ return FALSE;
+ }
+
+ if (!user_font_test(font_name)) {
+ /* The font isn't usable; "user_font_test()" has already
+ told the user why. Don't tear down the font selection
+ dialog. */
+ g_free(font_name);
+ return FALSE;
+ }
+ new_font_name = font_name;
+ return TRUE;
+}
+
+static void
+select_font(GtkWidget *w, gpointer data _U_)
+{
+ GtkWidget *font_sample = g_object_get_data(G_OBJECT(w), FONT_SAMPLE_KEY);
+ GtkWidget *color_sample = g_object_get_data(G_OBJECT(w), COLOR_SAMPLE_KEY);
+ const gchar *font_name;
+
+ if (!font_sample || !color_sample) return;
+
+ font_name = gtk_font_button_get_font_name(GTK_FONT_BUTTON(w));
+ if (font_name) {
+ PangoFontDescription *font = pango_font_description_from_string(font_name);
+ update_font(font, font_sample, color_sample);
+ }
+}
+
+static void
update_text_color(GtkWidget *w, gpointer data _U_) {
- GtkTextView *sample = g_object_get_data(G_OBJECT(w), STREAM_SAMPLE_KEY);
+ GtkTextView *sample = g_object_get_data(G_OBJECT(w), COLOR_SAMPLE_KEY);
GtkTextBuffer *buf;
GtkTextTag *tag;
@@ -195,15 +311,21 @@ update_current_color(GtkWidget *combo_box, gpointer data)
{
GtkColorSelection *colorsel = data;
int i;
+ GtkTextView *color_sample = g_object_get_data(G_OBJECT(combo_box), COLOR_SAMPLE_KEY);
+ GtkTextIter iter;
i = gtk_combo_box_get_active (GTK_COMBO_BOX(combo_box));
curcolor = &tcolors[i];
gtk_color_selection_set_current_color(colorsel, curcolor);
+
+ gtk_text_buffer_get_start_iter(gtk_text_view_get_buffer(color_sample), &iter);
+ gtk_text_iter_set_line(&iter, i/2);
+ gtk_text_view_scroll_to_iter(color_sample, &iter, 0.0, FALSE, 0, 0);
}
void
-stream_prefs_fetch(GtkWidget *w _U_)
+font_color_prefs_fetch(GtkWidget *w _U_)
{
gdkcolor_to_color_t(&prefs.gui_marked_fg, &tcolors[MFG_IDX]);
gdkcolor_to_color_t(&prefs.gui_marked_bg, &tcolors[MBG_IDX]);
@@ -213,15 +335,64 @@ stream_prefs_fetch(GtkWidget *w _U_)
gdkcolor_to_color_t(&prefs.st_client_bg, &tcolors[CBG_IDX]);
gdkcolor_to_color_t(&prefs.st_server_fg, &tcolors[SFG_IDX]);
gdkcolor_to_color_t(&prefs.st_server_bg, &tcolors[SBG_IDX]);
+
+ /*
+ * XXX - we need to have a way to fetch the preferences into
+ * local storage and only set the permanent preferences if there
+ * weren't any errors in those fetches, as there are several
+ * places where there *can* be a bad preference value.
+ */
+ if (font_fetch()) {
+ if (strcmp(new_font_name, prefs.gui_font_name) != 0) {
+ font_changed = TRUE;
+ g_free(prefs.gui_font_name);
+ prefs.gui_font_name = g_strdup(new_font_name);
+ }
+ }
}
void
-stream_prefs_apply(GtkWidget *w _U_)
+font_color_prefs_apply(GtkWidget *w _U_, gboolean redissect)
{
- follow_tcp_redraw_all();
+ if (font_changed) {
+ /* This redraws the packet bytes windows. */
+ switch (user_font_apply()) {
+
+ case FA_SUCCESS:
+ break;
+
+ case FA_FONT_NOT_RESIZEABLE:
+ /* "user_font_apply()" popped up an alert box. */
+ /* turn off zooming - font can't be resized */
+ recent.gui_zoom_level = 0;
+ break;
+
+ case FA_FONT_NOT_AVAILABLE:
+ /* We assume this means that the specified size
+ isn't available. */
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "That font isn't available at the specified zoom level;\n"
+ "turning zooming off.");
+ recent.gui_zoom_level = 0;
+ break;
+ }
+ } else if (!redissect) {
+ /* Redraw the packet bytes windows, in case the
+ highlight style changed, only if we aren't redissecting the whole file.
+ XXX - do it only if the highlight style *did* change. */
+ redraw_packet_bytes_all();
+ }
+
+ follow_tcp_redraw_all();
}
void
-stream_prefs_destroy(GtkWidget *w _U_)
+font_color_prefs_destroy(GtkWidget *w _U_)
{
+ /* Free up any saved font name. */
+ if (new_font_name != NULL) {
+ g_free(new_font_name);
+ new_font_name = NULL;
+ }
+ font_button = NULL;
}
diff --git a/ui/gtk/prefs_stream.h b/ui/gtk/prefs_font_color.h
index 209c99de21..330f065f3d 100644
--- a/ui/gtk/prefs_stream.h
+++ b/ui/gtk/prefs_font_color.h
@@ -1,4 +1,4 @@
-/* stream_prefs.h
+/* prefs_font_color.h
* Definitions for stream preferences window
*
* $Id$
@@ -23,8 +23,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __STREAM_PREFS_H__
-#define __STREAM_PREFS_H__
+#ifndef __PREFS_FONT_COLOR_H__
+#define __PREFS_FONT_COLOR_H__
/** @file
* "User Interface: Colors" preferences page.
@@ -32,28 +32,28 @@
* @ingroup prefs_group
*/
-/** Build a Colors preferences page.
+/** Build a Font and Colors preferences page.
*
* @return the new preferences page
*/
-GtkWidget *stream_prefs_show(void);
+GtkWidget *font_color_prefs_show(void);
/** Fetch preference values from page.
*
- * @param widget widget from stream_prefs_show()
+ * @param widget widget from font_color_prefs_show()
*/
-void stream_prefs_fetch(GtkWidget *widget);
+void font_color_prefs_fetch(GtkWidget *widget);
/** Apply preference values from page.
*
- * @param widget widget from stream_prefs_show()
+ * @param widget widget from font_color_prefs_show()
*/
-void stream_prefs_apply(GtkWidget *widget);
+void font_color_prefs_apply(GtkWidget *widget, gboolean);
/** Destroy preference values from page.
*
- * @param widget widget from stream_prefs_show()
+ * @param widget widget from font_color_prefs_show()
*/
-void stream_prefs_destroy(GtkWidget *widget);
+void font_color_prefs_destroy(GtkWidget *widget);
-#endif
+#endif /* __PREFS_FONT_COLOR__ */
diff --git a/ui/gtk/prefs_gui.c b/ui/gtk/prefs_gui.c
index eafb5a9963..bb74311085 100644
--- a/ui/gtk/prefs_gui.c
+++ b/ui/gtk/prefs_gui.c
@@ -143,18 +143,6 @@ static const enum_val_t gui_fileopen_vals[] = {
{ NULL, NULL, 0 }
};
-/* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
- the "Font..." dialog, so that we know that they (probably) changed
- the font, and therefore that the "apply" function needs to take care
- of that */
-static gboolean font_changed;
-
-/* Font name from the font dialog box; if "font_changed" is TRUE, this
- has been set to the name of the font the user selected. */
-static gchar *new_font_name;
-
-static GtkWidget *font_browse_w;
-
/* Used to contain the string from the Recent Files Count Max pref item */
static char recent_files_count_max_str[128] = "";
@@ -193,9 +181,6 @@ gui_prefs_show(void)
int pos = 0;
char current_val_str[128];
- /* The font haven't been changed yet. */
- font_changed = FALSE;
-
/* The columns haven't been changed yet */
cfile.columns_changed = FALSE;
@@ -382,56 +367,6 @@ gui_prefs_show(void)
}
-/* Create a font widget for browsing. */
-GtkWidget *
-gui_font_prefs_show(void)
-{
- /* Create the font selection widget. */
-#if GTK_CHECK_VERSION(3,2,0)
- font_browse_w = gtk_font_chooser_widget_new();
-#else
- font_browse_w = (GtkWidget *) gtk_font_selection_new();
-#endif /* GTK_CHECK_VERSION(3,2,0) */
- gtk_widget_show(font_browse_w);
-
- return font_browse_w;
-}
-
-
-static gboolean
-font_fetch(void)
-{
- gchar *font_name;
-
-
-#if GTK_CHECK_VERSION(3,2,0)
- font_name = g_strdup(gtk_font_chooser_get_font(
- GTK_FONT_CHOOSER(font_browse_w)));
-#else
- font_name = g_strdup(gtk_font_selection_get_font_name(
- GTK_FONT_SELECTION(font_browse_w)));
-#endif /* GTK_CHECK_VERSION(3,2,0) */
- if (font_name == NULL) {
- /* No font was selected; let the user know, but don't
- tear down the font selection dialog, so they can
- try again. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "You have not selected a font.");
- return FALSE;
- }
-
- if (!user_font_test(font_name)) {
- /* The font isn't usable; "user_font_test()" has already
- told the user why. Don't tear down the font selection
- dialog. */
- g_free(font_name);
- return FALSE;
- }
- new_font_name = font_name;
- return TRUE;
-}
-
-
static gint
fetch_enum_value(gpointer control, const enum_val_t *enumvals)
{
@@ -480,7 +415,7 @@ gui_prefs_fetch(GtkWidget *w)
prefs.gui_version_placement =
fetch_enum_value(g_object_get_data(G_OBJECT(w), GUI_SHOW_VERSION_KEY), gui_version_placement_vals);
- prefs.gui_auto_scroll_on_expand =
+ prefs.gui_auto_scroll_on_expand =
gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GUI_AUTO_SCROLL_KEY));
if (browser_needs_pref()) {
@@ -492,25 +427,12 @@ gui_prefs_fetch(GtkWidget *w)
prefs.gui_expert_composite_eyecandy =
gtk_toggle_button_get_active(g_object_get_data(G_OBJECT(w), GUI_EXPERT_EYECANDY_KEY));
- /*
- * XXX - we need to have a way to fetch the preferences into
- * local storage and only set the permanent preferences if there
- * weren't any errors in those fetches, as there are several
- * places where there *can* be a bad preference value.
- */
- if (font_fetch()) {
- if (strcmp(new_font_name, prefs.gui_font_name) != 0) {
- font_changed = TRUE;
- g_free(prefs.gui_font_name);
- prefs.gui_font_name = g_strdup(new_font_name);
- }
- }
}
void
-gui_prefs_apply(GtkWidget *w _U_ , gboolean redissect)
+gui_prefs_apply(GtkWidget *w _U_)
{
#ifdef _WIN32
@@ -520,39 +442,10 @@ gui_prefs_apply(GtkWidget *w _U_ , gboolean redissect)
}
#endif
- if (font_changed) {
- /* This redraws the packet bytes windows. */
- switch (user_font_apply()) {
-
- case FA_SUCCESS:
- break;
-
- case FA_FONT_NOT_RESIZEABLE:
- /* "user_font_apply()" popped up an alert box. */
- /* turn off zooming - font can't be resized */
- recent.gui_zoom_level = 0;
- break;
-
- case FA_FONT_NOT_AVAILABLE:
- /* We assume this means that the specified size
- isn't available. */
- simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
- "That font isn't available at the specified zoom level;\n"
- "turning zooming off.");
- recent.gui_zoom_level = 0;
- break;
- }
- } else if (!redissect) {
- /* Redraw the packet bytes windows, in case the
- highlight style changed, only if we aren't redissecting the whole file.
- XXX - do it only if the highlight style *did* change. */
- redraw_packet_bytes_all();
- }
-
/* Redisplay the main window's title */
main_titlebar_update();
- /* Redisplay the default welcome header message in case the "show
+ /* Redisplay the default welcome header message in case the "show
* version" option was changed. */
welcome_header_set_message(NULL);
@@ -573,11 +466,6 @@ gui_prefs_apply(GtkWidget *w _U_ , gboolean redissect)
void
gui_prefs_destroy(GtkWidget *w _U_)
{
- /* Free up any saved font name. */
- if (new_font_name != NULL) {
- g_free(new_font_name);
- new_font_name = NULL;
- }
}
static gboolean
@@ -693,7 +581,7 @@ fileopen_selected_cb(GtkWidget *mybutton_rb _U_, gpointer parent_w)
}
static gboolean
-scroll_percent_changed_cb(GtkWidget *recent_files_entry _U_,
+scroll_percent_changed_cb(GtkWidget *recent_files_entry _U_,
GdkEvent *event _U_, gpointer parent_w)
{
GtkWidget *scroll_percent_te;
@@ -701,12 +589,12 @@ scroll_percent_changed_cb(GtkWidget *recent_files_entry _U_,
scroll_percent_te = (GtkWidget*)g_object_get_data(G_OBJECT(parent_w), GUI_SCROLL_PERCENT_KEY);
- /*
+ /*
* Now, just convert the string to a number and store it in the prefs field ...
*/
newval = (guint)strtol(gtk_entry_get_text(GTK_ENTRY(scroll_percent_te)), NULL, 10);
-
+
if (newval <= 100) {
prefs.gui_auto_scroll_percentage = newval;
}
diff --git a/ui/gtk/prefs_gui.h b/ui/gtk/prefs_gui.h
index 632308afd4..0cbf52c27e 100644
--- a/ui/gtk/prefs_gui.h
+++ b/ui/gtk/prefs_gui.h
@@ -47,7 +47,7 @@ extern void gui_prefs_fetch(GtkWidget *widget);
*
* @param widget widget from gui_prefs_show()
*/
-extern void gui_prefs_apply(GtkWidget *widget, gboolean);
+extern void gui_prefs_apply(GtkWidget *widget);
/** Destroy preference values from page.
*