1999-12-16 06:20:18 +00:00
|
|
|
/* gui_prefs.c
|
|
|
|
* Dialog box for GUI preferences
|
|
|
|
*
|
2003-09-02 18:27:50 +00:00
|
|
|
* $Id: gui_prefs.c,v 1.40 2003/09/02 18:27:50 gerald Exp $
|
1999-12-16 06:20:18 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
2002-01-10 07:43:39 +00:00
|
|
|
* By Gerald Combs <gerald@ethereal.com>
|
1999-12-16 06:20:18 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-16 06:20:18 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-16 06:20:18 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2002-08-28 21:04:11 +00:00
|
|
|
*
|
1999-12-16 06:20:18 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2000-10-20 04:26:40 +00:00
|
|
|
#include <gtk/gtk.h>
|
1999-12-16 06:20:18 +00:00
|
|
|
|
2000-11-21 23:54:10 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "color_utils.h"
|
1999-12-16 06:20:18 +00:00
|
|
|
#include "globals.h"
|
|
|
|
#include "gui_prefs.h"
|
|
|
|
#include "gtkglobals.h"
|
2000-09-08 10:59:21 +00:00
|
|
|
#include "follow_dlg.h"
|
|
|
|
#include "help_dlg.h"
|
2000-08-21 22:30:04 +00:00
|
|
|
#include "prefs.h"
|
2002-01-13 20:35:12 +00:00
|
|
|
#include "prefs_dlg.h"
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
#include "ui_util.h"
|
2000-09-09 10:35:53 +00:00
|
|
|
#include "simple_dialog.h"
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
#include "dlg_utils.h"
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
#include "proto_draw.h"
|
2000-08-22 14:04:52 +00:00
|
|
|
#include "main.h"
|
2002-11-11 15:39:06 +00:00
|
|
|
#include "compat_macros.h"
|
1999-12-16 06:20:18 +00:00
|
|
|
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
static void font_browse_cb(GtkWidget *w, gpointer data);
|
|
|
|
static void font_browse_ok_cb(GtkWidget *w, GtkFontSelectionDialog *fs);
|
|
|
|
static void font_browse_destroy(GtkWidget *win, gpointer data);
|
2000-11-18 21:41:40 +00:00
|
|
|
static gint fetch_enum_value(gpointer control, const enum_val_t *enumvals);
|
2000-08-22 14:04:52 +00:00
|
|
|
static void color_browse_cb(GtkWidget *w, gpointer data);
|
|
|
|
static void update_text_color(GtkWidget *w, gpointer data);
|
|
|
|
static void update_current_color(GtkWidget *w, gpointer data);
|
|
|
|
static void color_ok_cb(GtkWidget *w, gpointer data);
|
2000-08-23 07:38:56 +00:00
|
|
|
static void color_cancel_cb(GtkWidget *w, gpointer data);
|
|
|
|
static gboolean color_delete_cb(GtkWidget *prefs_w, gpointer dummy);
|
2000-08-22 14:04:52 +00:00
|
|
|
static void color_destroy_cb(GtkWidget *w, gpointer data);
|
2000-08-23 07:38:56 +00:00
|
|
|
static void fetch_colors(void);
|
2000-08-21 22:30:04 +00:00
|
|
|
|
|
|
|
#define SCROLLBAR_PLACEMENT_KEY "scrollbar_placement"
|
|
|
|
#define PLIST_SEL_BROWSE_KEY "plist_sel_browse"
|
|
|
|
#define PTREE_SEL_BROWSE_KEY "ptree_sel_browse"
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-21 22:30:04 +00:00
|
|
|
#define PTREE_LINE_STYLE_KEY "ptree_line_style"
|
|
|
|
#define PTREE_EXPANDER_STYLE_KEY "ptree_expander_style"
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
#define ALTERN_COLORS_KEY "altern_colors"
|
|
|
|
#endif
|
2000-09-08 09:50:08 +00:00
|
|
|
#define HEX_DUMP_HIGHLIGHT_STYLE_KEY "hex_dump_highlight_style"
|
2001-12-31 04:41:50 +00:00
|
|
|
#define GEOMETRY_POSITION_KEY "geometry_position"
|
|
|
|
#define GEOMETRY_SIZE_KEY "geometry_size"
|
2000-08-21 22:30:04 +00:00
|
|
|
|
|
|
|
#define FONT_DIALOG_PTR_KEY "font_dialog_ptr"
|
|
|
|
#define FONT_CALLER_PTR_KEY "font_caller_ptr"
|
2000-08-22 14:04:52 +00:00
|
|
|
#define COLOR_DIALOG_PTR_KEY "color_dialog_ptr"
|
|
|
|
#define COLOR_CALLER_PTR_KEY "color_caller_ptr"
|
|
|
|
#define COLOR_SAMPLE_PTR_KEY "color_sample_ptr"
|
|
|
|
#define COLOR_SELECTION_PTR_KEY "color_selection_ptr"
|
2000-08-21 22:30:04 +00:00
|
|
|
|
2000-11-18 21:41:40 +00:00
|
|
|
static const enum_val_t scrollbar_placement_vals[] = {
|
2000-08-21 22:30:04 +00:00
|
|
|
{ "Left", FALSE },
|
|
|
|
{ "Right", TRUE },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2000-11-18 21:41:40 +00:00
|
|
|
static const enum_val_t selection_mode_vals[] = {
|
2000-08-21 22:30:04 +00:00
|
|
|
{ "Selects", FALSE },
|
|
|
|
{ "Browses", TRUE },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-11-18 21:41:40 +00:00
|
|
|
static const enum_val_t line_style_vals[] = {
|
2000-08-21 22:30:04 +00:00
|
|
|
{ "None", 0 },
|
|
|
|
{ "Solid", 1 },
|
|
|
|
{ "Dotted", 2 },
|
|
|
|
{ "Tabbed", 3 },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2000-11-18 21:41:40 +00:00
|
|
|
static const enum_val_t expander_style_vals[] = {
|
2000-08-21 22:30:04 +00:00
|
|
|
{ "None", 0 },
|
|
|
|
{ "Square", 1 },
|
|
|
|
{ "Triangle", 2 },
|
|
|
|
{ "Circular", 3 },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
static const enum_val_t altern_colors_vals[] = {
|
|
|
|
{ "No", FALSE },
|
|
|
|
{ "Yes", TRUE },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
#endif
|
1999-12-16 06:20:18 +00:00
|
|
|
|
2000-11-18 21:41:40 +00:00
|
|
|
static const enum_val_t highlight_style_vals[] = {
|
2000-09-08 09:50:08 +00:00
|
|
|
{ "Bold", 0 },
|
|
|
|
{ "Inverse", 1 },
|
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
2000-08-23 07:38:56 +00:00
|
|
|
/* Set to FALSE initially; set to TRUE if the user ever hits "OK" on
|
|
|
|
the "Colors..." dialog, so that we know that they (probably) changed
|
|
|
|
colors, and therefore that the "apply" function needs to recolor
|
|
|
|
any marked packets. */
|
|
|
|
static gboolean colors_changed;
|
|
|
|
|
2000-08-23 16:15:13 +00:00
|
|
|
/* 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;
|
|
|
|
|
2000-09-09 10:35:53 +00:00
|
|
|
/* 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;
|
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
#define GUI_TABLE_ROWS 8
|
1999-12-16 06:20:18 +00:00
|
|
|
GtkWidget*
|
|
|
|
gui_prefs_show(void)
|
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
GtkWidget *main_tb, *main_vb, *hbox, *font_bt, *color_bt;
|
|
|
|
GtkWidget *scrollbar_om, *plist_browse_om;
|
|
|
|
GtkWidget *ptree_browse_om, *highlight_style_om;
|
|
|
|
GtkWidget *save_position_cb, *save_size_cb;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
GtkWidget *expander_style_om, *line_style_om;
|
|
|
|
#else
|
|
|
|
GtkWidget *altern_colors_om;
|
|
|
|
#endif
|
|
|
|
int pos = 0;
|
1999-12-16 06:20:18 +00:00
|
|
|
|
2000-08-23 16:15:13 +00:00
|
|
|
/* The colors or font haven't been changed yet. */
|
2000-08-23 07:38:56 +00:00
|
|
|
colors_changed = FALSE;
|
2000-08-23 16:15:13 +00:00
|
|
|
font_changed = FALSE;
|
2000-08-23 07:38:56 +00:00
|
|
|
|
1999-12-16 06:20:18 +00:00
|
|
|
/* Main vertical box */
|
2000-09-08 09:50:08 +00:00
|
|
|
main_vb = gtk_vbox_new(FALSE, 7);
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
gtk_container_border_width( GTK_CONTAINER(main_vb), 5 );
|
1999-12-16 06:20:18 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
/* Main horizontal box */
|
|
|
|
/* XXX - Is therea a better way to center the table? */
|
|
|
|
hbox = gtk_hbox_new(FALSE, 7);
|
|
|
|
gtk_box_pack_start (GTK_BOX(main_vb), hbox, TRUE, FALSE, 0);
|
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
/* Main table */
|
2001-12-31 04:41:50 +00:00
|
|
|
main_tb = gtk_table_new(GUI_TABLE_ROWS, 3, FALSE);
|
|
|
|
gtk_box_pack_start( GTK_BOX(hbox), main_tb, TRUE, FALSE, 0 );
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
gtk_table_set_row_spacings( GTK_TABLE(main_tb), 10 );
|
|
|
|
gtk_table_set_col_spacings( GTK_TABLE(main_tb), 15 );
|
2001-12-31 04:41:50 +00:00
|
|
|
gtk_table_set_col_spacing( GTK_TABLE(main_tb), 1, 50 );
|
1999-12-16 06:20:18 +00:00
|
|
|
|
2000-08-21 22:30:04 +00:00
|
|
|
/* Scrollbar placement */
|
2002-11-03 17:38:45 +00:00
|
|
|
scrollbar_om = create_preference_option_menu(main_tb, pos++,
|
2002-01-20 20:05:18 +00:00
|
|
|
"Vertical scrollbar placement:", NULL, scrollbar_placement_vals,
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_scrollbar_on_right);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, SCROLLBAR_PLACEMENT_KEY, scrollbar_om);
|
1999-12-30 23:02:56 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
/* Packet list selection browseable */
|
2002-11-03 17:38:45 +00:00
|
|
|
plist_browse_om = create_preference_option_menu(main_tb, pos++,
|
2003-07-18 20:55:11 +00:00
|
|
|
"Packet list selection mode:", NULL, selection_mode_vals,
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_plist_sel_browse);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, PLIST_SEL_BROWSE_KEY, plist_browse_om);
|
1999-12-30 23:02:56 +00:00
|
|
|
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
/* Proto tree selection browseable */
|
2002-11-03 17:38:45 +00:00
|
|
|
ptree_browse_om = create_preference_option_menu(main_tb, pos++,
|
2003-07-18 20:55:11 +00:00
|
|
|
"Protocol tree selection mode:", NULL, selection_mode_vals,
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_sel_browse);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, PTREE_SEL_BROWSE_KEY, ptree_browse_om);
|
1999-12-30 23:02:56 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-01-11 06:43:18 +00:00
|
|
|
/* Tree line style */
|
2002-11-03 17:38:45 +00:00
|
|
|
line_style_om = create_preference_option_menu(main_tb, pos++,
|
2002-01-20 20:05:18 +00:00
|
|
|
"Tree line style:", NULL, line_style_vals,
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_line_style);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, PTREE_LINE_STYLE_KEY, line_style_om);
|
1999-12-30 23:02:56 +00:00
|
|
|
|
2002-01-11 06:43:18 +00:00
|
|
|
/* Tree expander style */
|
2002-11-03 17:38:45 +00:00
|
|
|
expander_style_om = create_preference_option_menu(main_tb, pos++,
|
2002-01-20 20:05:18 +00:00
|
|
|
"Tree expander style:", NULL, expander_style_vals,
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_expander_style);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, PTREE_EXPANDER_STYLE_KEY, expander_style_om);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
/* Alternating row colors in list and tree views */
|
|
|
|
altern_colors_om = create_preference_option_menu(main_tb, pos++,
|
|
|
|
"Alternating row colors in lists and trees:", NULL,
|
|
|
|
altern_colors_vals, prefs.gui_altern_colors);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, ALTERN_COLORS_KEY, altern_colors_om);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
1999-12-30 23:02:56 +00:00
|
|
|
|
2000-09-08 09:50:08 +00:00
|
|
|
/* Hex Dump highlight style */
|
2002-11-03 17:38:45 +00:00
|
|
|
highlight_style_om = create_preference_option_menu(main_tb, pos++,
|
2002-01-20 20:05:18 +00:00
|
|
|
"Hex display highlight style:", NULL, highlight_style_vals,
|
2000-09-08 09:50:08 +00:00
|
|
|
prefs.gui_hex_dump_highlight_style);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, HEX_DUMP_HIGHLIGHT_STYLE_KEY,
|
|
|
|
highlight_style_om);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-12-31 04:41:50 +00:00
|
|
|
/* Geometry prefs */
|
2002-11-03 17:38:45 +00:00
|
|
|
save_position_cb = create_preference_check_button(main_tb, pos++,
|
|
|
|
"Save window position:", NULL, prefs.gui_geometry_save_position);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, GEOMETRY_POSITION_KEY, save_position_cb);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
save_size_cb = create_preference_check_button(main_tb, pos++,
|
|
|
|
"Save window size:", NULL, prefs.gui_geometry_save_size);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(main_vb, GEOMETRY_SIZE_KEY, save_size_cb);
|
2002-01-13 20:35:12 +00:00
|
|
|
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
/* "Font..." button - click to open a font selection dialog box. */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
font_bt = gtk_button_new_with_label("Font...");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
font_bt = gtk_button_new_from_stock(GTK_STOCK_SELECT_FONT);
|
|
|
|
#endif
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(font_bt, "clicked", font_browse_cb, NULL);
|
2001-12-31 04:41:50 +00:00
|
|
|
gtk_table_attach_defaults( GTK_TABLE(main_tb), font_bt, 2, 3, 0, 1 );
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
2000-08-22 14:04:52 +00:00
|
|
|
/* "Colors..." button - click to open a color selection dialog box. */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
color_bt = gtk_button_new_with_label("Colors...");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
color_bt = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR);
|
|
|
|
#endif
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(color_bt, "clicked", color_browse_cb, NULL);
|
2001-12-31 04:41:50 +00:00
|
|
|
gtk_table_attach_defaults( GTK_TABLE(main_tb), color_bt, 2, 3, 1, 2 );
|
2000-08-22 14:04:52 +00:00
|
|
|
|
1999-12-16 06:20:18 +00:00
|
|
|
/* Show 'em what we got */
|
|
|
|
gtk_widget_show_all(main_vb);
|
|
|
|
|
|
|
|
return(main_vb);
|
|
|
|
}
|
|
|
|
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
/* Create a font dialog for browsing. */
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
font_browse_cb(GtkWidget *w, gpointer data _U_)
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
{
|
|
|
|
GtkWidget *caller = gtk_widget_get_toplevel(w);
|
|
|
|
GtkWidget *font_browse_w;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
static gchar *fixedwidths[] = { "c", "m", NULL };
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
/* Has a font dialog box already been opened for that top-level
|
|
|
|
widget? */
|
2002-11-11 15:39:06 +00:00
|
|
|
font_browse_w = OBJECT_GET_DATA(caller, FONT_DIALOG_PTR_KEY);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
if (font_browse_w != NULL) {
|
|
|
|
/* Yes. Just re-activate that dialog box. */
|
|
|
|
reactivate_window(font_browse_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now create a new dialog. */
|
|
|
|
font_browse_w = gtk_font_selection_dialog_new("Ethereal: Select Font");
|
|
|
|
gtk_window_set_transient_for(GTK_WINDOW(font_browse_w),
|
|
|
|
GTK_WINDOW(top_level));
|
|
|
|
|
|
|
|
/* Call a handler when we're destroyed, so we can inform
|
|
|
|
our caller, if any, that we've been destroyed. */
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(font_browse_w, "destroy", font_browse_destroy, NULL);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
/* Set its filter to show only fixed_width fonts. */
|
|
|
|
gtk_font_selection_dialog_set_filter(
|
|
|
|
GTK_FONT_SELECTION_DIALOG(font_browse_w),
|
2002-11-03 17:38:45 +00:00
|
|
|
GTK_FONT_FILTER_BASE, /* user can't change the filter */
|
|
|
|
GTK_FONT_ALL, /* bitmap or scalable are fine */
|
|
|
|
NULL, /* all foundries are OK */
|
|
|
|
NULL, /* all weights are OK (XXX - normal only?) */
|
|
|
|
NULL, /* all slants are OK (XXX - Roman only?) */
|
|
|
|
NULL, /* all setwidths are OK */
|
|
|
|
fixedwidths, /* ONLY fixed-width fonts */
|
|
|
|
NULL); /* all charsets are OK (XXX - ISO 8859/1 only?) */
|
|
|
|
#endif
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
/* Set the font to the current font.
|
2000-09-09 10:35:53 +00:00
|
|
|
XXX - GTK+ 1.2.8, and probably earlier versions, have a bug
|
|
|
|
wherein that doesn't necessarily cause that font to be
|
|
|
|
selected in the dialog box. I've sent to the GTK+ folk
|
|
|
|
a fix; hopefully, it'll show up in 1.2.9 if, as, and when
|
|
|
|
they put out a 1.2.9 release. */
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
gtk_font_selection_dialog_set_font_name(
|
|
|
|
GTK_FONT_SELECTION_DIALOG(font_browse_w), prefs.gui_font_name);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
/* Set the FONT_CALLER_PTR_KEY for the new dialog to point to
|
|
|
|
our caller. */
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(font_browse_w, FONT_CALLER_PTR_KEY, caller);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Set the FONT_DIALOG_PTR_KEY for the caller to point to us */
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(caller, FONT_DIALOG_PTR_KEY, font_browse_w);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Connect the ok_button to font_browse_ok_cb function and pass along a
|
|
|
|
pointer to the font selection box widget */
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(GTK_FONT_SELECTION_DIALOG(font_browse_w)->ok_button,
|
|
|
|
"clicked", font_browse_ok_cb, font_browse_w);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Connect the cancel_button to destroy the widget */
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(
|
|
|
|
GTK_FONT_SELECTION_DIALOG(font_browse_w)->cancel_button, "clicked",
|
|
|
|
gtk_widget_destroy, font_browse_w);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
/* Catch the "key_press_event" signal in the window, so that we can
|
|
|
|
catch the ESC key being pressed and act as if the "Cancel" button
|
|
|
|
had been selected. */
|
|
|
|
dlg_set_cancel(font_browse_w,
|
2002-11-03 17:38:45 +00:00
|
|
|
GTK_FONT_SELECTION_DIALOG(font_browse_w)->cancel_button);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
gtk_widget_show(font_browse_w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
font_browse_ok_cb(GtkWidget *w _U_, GtkFontSelectionDialog *fs)
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
gchar *font_name;
|
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gchar *bold_font_name;
|
2000-09-09 10:35:53 +00:00
|
|
|
GdkFont *new_r_font, *new_b_font;
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
PangoFontDescription *new_r_font, *new_b_font;
|
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
|
|
|
|
font_name = g_strdup(gtk_font_selection_dialog_get_font_name(
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
GTK_FONT_SELECTION_DIALOG(fs)));
|
2000-10-09 06:28:49 +00:00
|
|
|
if (font_name == NULL) {
|
2000-10-09 06:38:36 +00:00
|
|
|
/* 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_CRIT | ESD_TYPE_MODAL, NULL,
|
2000-10-09 06:28:49 +00:00
|
|
|
"You have not selected a font.");
|
|
|
|
return;
|
|
|
|
}
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-09 10:35:53 +00:00
|
|
|
/* Get the name that the boldface version of that font would have. */
|
|
|
|
bold_font_name = boldify(font_name);
|
|
|
|
|
|
|
|
/* Now load those fonts, just to make sure we can. */
|
|
|
|
new_r_font = gdk_font_load(font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
new_r_font = pango_font_description_from_string(font_name);
|
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
if (new_r_font == NULL) {
|
|
|
|
/* Oops, that font didn't work.
|
|
|
|
Tell the user, but don't tear down the font selection
|
|
|
|
dialog, so that they can try again. */
|
2000-10-09 06:38:36 +00:00
|
|
|
simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
|
2000-09-09 10:35:53 +00:00
|
|
|
"The font you selected cannot be loaded.");
|
|
|
|
|
|
|
|
g_free(font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-09 10:35:53 +00:00
|
|
|
g_free(bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-09 10:35:53 +00:00
|
|
|
new_b_font = gdk_font_load(bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
new_b_font = pango_font_description_copy(new_r_font);
|
|
|
|
pango_font_description_set_weight(new_b_font,
|
|
|
|
PANGO_WEIGHT_BOLD);
|
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
if (new_b_font == NULL) {
|
|
|
|
/* Oops, that font didn't work.
|
|
|
|
Tell the user, but don't tear down the font selection
|
|
|
|
dialog, so that they can try again. */
|
2000-10-09 06:38:36 +00:00
|
|
|
simple_dialog(ESD_TYPE_CRIT | ESD_TYPE_MODAL, NULL,
|
2000-09-09 10:35:53 +00:00
|
|
|
"The font you selected doesn't have a boldface version.");
|
|
|
|
|
|
|
|
g_free(font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-09 10:35:53 +00:00
|
|
|
g_free(bold_font_name);
|
|
|
|
gdk_font_unref(new_r_font);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
pango_font_description_free(new_r_font);
|
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
font_changed = TRUE;
|
|
|
|
new_font_name = font_name;
|
|
|
|
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
gtk_widget_hide(GTK_WIDGET(fs));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(fs));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
font_browse_destroy(GtkWidget *win, gpointer data _U_)
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
{
|
|
|
|
GtkWidget *caller;
|
|
|
|
|
|
|
|
/* Get the widget that requested that we be popped up, if any.
|
|
|
|
(It should arrange to destroy us if it's destroyed, so
|
|
|
|
that we don't get a pointer to a non-existent window here.) */
|
2002-11-11 15:39:06 +00:00
|
|
|
caller = OBJECT_GET_DATA(win, FONT_CALLER_PTR_KEY);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
if (caller != NULL) {
|
|
|
|
/* Tell it we no longer exist. */
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(caller, FONT_DIALOG_PTR_KEY, NULL);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now nuke this window. */
|
|
|
|
gtk_grab_remove(GTK_WIDGET(win));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(win));
|
|
|
|
}
|
1999-12-30 23:02:56 +00:00
|
|
|
|
2000-08-21 22:30:04 +00:00
|
|
|
static gint
|
2000-11-18 21:41:40 +00:00
|
|
|
fetch_enum_value(gpointer control, const enum_val_t *enumvals)
|
2000-08-21 22:30:04 +00:00
|
|
|
{
|
2002-01-13 20:35:12 +00:00
|
|
|
return fetch_preference_option_menu_val(GTK_WIDGET(control), enumvals);
|
2000-08-21 22:30:04 +00:00
|
|
|
}
|
|
|
|
|
1999-12-16 06:20:18 +00:00
|
|
|
void
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
gui_prefs_fetch(GtkWidget *w)
|
1999-12-16 06:20:18 +00:00
|
|
|
{
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_scrollbar_on_right = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, SCROLLBAR_PLACEMENT_KEY),
|
|
|
|
scrollbar_placement_vals);
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_plist_sel_browse = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, PLIST_SEL_BROWSE_KEY), selection_mode_vals);
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_sel_browse = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, PTREE_SEL_BROWSE_KEY), selection_mode_vals);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_line_style = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, PTREE_LINE_STYLE_KEY), line_style_vals);
|
2000-08-21 22:30:04 +00:00
|
|
|
prefs.gui_ptree_expander_style = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, PTREE_EXPANDER_STYLE_KEY), expander_style_vals);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
prefs.gui_altern_colors = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, ALTERN_COLORS_KEY), altern_colors_vals);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-09-08 09:50:08 +00:00
|
|
|
prefs.gui_hex_dump_highlight_style = fetch_enum_value(
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_GET_DATA(w, HEX_DUMP_HIGHLIGHT_STYLE_KEY),
|
|
|
|
highlight_style_vals);
|
2002-08-28 21:04:11 +00:00
|
|
|
prefs.gui_geometry_save_position =
|
2002-11-11 15:39:06 +00:00
|
|
|
gtk_toggle_button_get_active(OBJECT_GET_DATA(w,
|
2001-12-31 04:41:50 +00:00
|
|
|
GEOMETRY_POSITION_KEY));
|
2002-08-28 21:04:11 +00:00
|
|
|
prefs.gui_geometry_save_size =
|
2002-11-11 15:39:06 +00:00
|
|
|
gtk_toggle_button_get_active(OBJECT_GET_DATA(w, GEOMETRY_SIZE_KEY));
|
2000-08-23 07:38:56 +00:00
|
|
|
|
2000-09-09 10:35:53 +00:00
|
|
|
if (font_changed) {
|
|
|
|
if (prefs.gui_font_name != NULL)
|
|
|
|
g_free(prefs.gui_font_name);
|
|
|
|
prefs.gui_font_name = g_strdup(new_font_name);
|
|
|
|
}
|
|
|
|
|
2000-08-23 18:52:38 +00:00
|
|
|
if (colors_changed)
|
2002-01-13 20:35:12 +00:00
|
|
|
fetch_colors();
|
1999-12-16 06:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-05 11:56:00 +00:00
|
|
|
gui_prefs_apply(GtkWidget *w _U_)
|
1999-12-16 06:20:18 +00:00
|
|
|
{
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-08 10:59:21 +00:00
|
|
|
GdkFont *new_r_font, *new_b_font;
|
|
|
|
char *bold_font_name;
|
|
|
|
GdkFont *old_r_font = NULL, *old_b_font = NULL;
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
PangoFontDescription *new_r_font, *new_b_font;
|
|
|
|
PangoFontDescription *old_r_font = NULL, *old_b_font = NULL;
|
|
|
|
#endif
|
2000-08-23 16:15:13 +00:00
|
|
|
|
|
|
|
if (font_changed) {
|
2000-09-09 10:35:53 +00:00
|
|
|
/* XXX - what if the world changed out from under
|
|
|
|
us, so that one or both of these fonts cannot
|
|
|
|
be loaded? */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-08 10:59:21 +00:00
|
|
|
new_r_font = gdk_font_load(prefs.gui_font_name);
|
2000-09-09 10:35:53 +00:00
|
|
|
bold_font_name = boldify(prefs.gui_font_name);
|
|
|
|
new_b_font = gdk_font_load(bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
new_r_font = pango_font_description_from_string(prefs.gui_font_name);
|
|
|
|
new_b_font = pango_font_description_copy(new_r_font);
|
|
|
|
pango_font_description_set_weight(new_b_font,
|
|
|
|
PANGO_WEIGHT_BOLD);
|
|
|
|
#endif
|
2000-09-09 10:35:53 +00:00
|
|
|
set_plist_font(new_r_font);
|
|
|
|
set_ptree_font_all(new_r_font);
|
|
|
|
old_r_font = m_r_font;
|
|
|
|
old_b_font = m_b_font;
|
2001-03-02 23:10:12 +00:00
|
|
|
set_fonts(new_r_font, new_b_font);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-09 10:35:53 +00:00
|
|
|
g_free(bold_font_name);
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
}
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
|
2000-09-08 10:59:21 +00:00
|
|
|
/* Redraw the hex dump windows, in case either the font or the
|
|
|
|
highlight style changed. */
|
|
|
|
redraw_hex_dump_all();
|
|
|
|
|
|
|
|
/* Redraw the help window. */
|
|
|
|
help_redraw();
|
|
|
|
|
|
|
|
/* Redraw the "Follow TCP Stream" windows, in case either the font
|
|
|
|
or the colors to use changed. */
|
|
|
|
follow_redraw_all();
|
|
|
|
|
2002-01-11 07:40:32 +00:00
|
|
|
set_scrollbar_placement_all();
|
Changed the protocol tree widget from a GtkTree to a GtkCTree. The two reasons
I did this:
First, Havoc Pennington, in "GTK+/Gnome Application Development", in
Appendix seciton A.3.88, recommends using GtkCTree instead of GtkTree
because GtkCtree is faster, and GtkTree has limitation on its total row
height: since it must fit inside a GdkWindow, it is limited to 32,768
pixels of height. GtkTree is more flexible with regards to the types of
widgets that can be placed in the tree, but since we deal only with text,
that doesn't matter, at least for now.
Secondly, a GtkTree doesn't allow arrow-key navigation (at least as far
as I could tell). It always bothered me that the up and down arrow keys
worked in the packet list and in the hex dump, but no in the protocol tree.
GtkCTree does allow arrow-key navigation. In fact, GtkCTree is a subclass
of GtkCList (the packet list widget), so they behave a lot alike.
I went ahead and fixed the selection bar which has been bothering Richard
for a long time now. :) In the GUI preferences dialogue, you can now set
both the packet list selection bar and the protocol tree selection bar
to either "browse" or "select" mode. "browse" mode is what you're used to:
the arrow keys move an outline of the selection bar, but do not change
the selection. "select" mode does change the selection when the arrow keys
are pressed. The default behavior is set to "select", which seems more
natural for a first-time user.
svn path=/trunk/; revision=1393
1999-12-29 20:10:12 +00:00
|
|
|
set_plist_sel_browse(prefs.gui_plist_sel_browse);
|
2000-02-29 06:24:41 +00:00
|
|
|
set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
|
2002-11-03 17:38:45 +00:00
|
|
|
set_tree_styles_all();
|
2000-08-23 07:38:56 +00:00
|
|
|
if (colors_changed)
|
|
|
|
update_marked_frames();
|
2000-09-08 10:59:21 +00:00
|
|
|
|
|
|
|
/* We're no longer using the old fonts; unreference them. */
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-09-08 10:59:21 +00:00
|
|
|
if (old_r_font != NULL)
|
|
|
|
gdk_font_unref(old_r_font);
|
|
|
|
if (old_b_font != NULL)
|
|
|
|
gdk_font_unref(old_b_font);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
if (old_r_font != NULL)
|
|
|
|
pango_font_description_free(old_r_font);
|
|
|
|
if (old_b_font != NULL)
|
|
|
|
pango_font_description_free(old_b_font);
|
|
|
|
#endif
|
1999-12-16 06:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Instead of each set of built-in preferences having "ok", "save",
"cancel", and "delete" methods, give them:
"fetch" - fetch from the notebook tab any values not already
stored in "prefs", and store them there, but doesn't apply them;
"apply" - apply the settings in "prefs";
"destroy" - clean up any windows created from the tab.
As we no longer have "cancel" methods, we don't have per-preference code
to revert preference values; instead, we have the common preference
dialog box code make a copy of all the current preferences, and, when
the "Cancel" button is clicked, free the current preferences and copy
the saved preferences to it, and apply the preferences.
Add an "Apply" button to the preference dialog box, which applies the
current preferences without closing the dialog box.
Treat a request to delete the preferences dialog box as equivalent to
clicking "Cancel".
Have a "remember_ptree_widget()" routine to remember all protocol tree
widgets, and use the list of those widgets when we set GUI preferences
for the protocol tree widgets, rather than setting the main protocol
tree widget and then using the list of packet windows. Move that code
out of "main.c" to "proto_draw.c", as it's not used by anything in
"main.c", but is used by stuff in "proto_draw.c".
Make the font one of the preferences we can set on the fly for protocol
tree widgets. Also make it something we can set on the fly for the
packet list widget.
svn path=/trunk/; revision=2316
2000-08-21 08:09:17 +00:00
|
|
|
gui_prefs_destroy(GtkWidget *w)
|
1999-12-16 06:20:18 +00:00
|
|
|
{
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
GtkWidget *caller = gtk_widget_get_toplevel(w);
|
|
|
|
GtkWidget *fs;
|
|
|
|
|
|
|
|
/* Is there a font selection dialog associated with this
|
|
|
|
Preferences dialog? */
|
2002-11-11 15:39:06 +00:00
|
|
|
fs = OBJECT_GET_DATA(caller, FONT_DIALOG_PTR_KEY);
|
Instead of having the normal-weight and bold fonts set separately,
generate the name of the boldface font from the Roman font; if the two
fonts don't have the same widths, the display will look weird when a
field is selected, and it's a bit of a pain for the user to have to
select *two* fonts.
On UNIX/X, default to
"-*-fixed-medium-r-semicondensed-*-*-120-*-*-*-*-*-" rather than to
"-*-lucidatypewriter-medium-r-normal-*-*-120-*-*-*-*-iso8859-1" - some
Linux distributions appear to lack the Lucida typewriter font.
Add a "gui.font_name" preference to the preferences file, specifying the
normal-weight font to use. Have it settable from the "GUI" tab in the
Preferences dialog box - the "Font..." button, when clicked, pops up a
font selection dialog box.
If we either can't open the selected font or the boldfaced version of
the font, default to "6x13" and "6x13bold" as fallbacks - the former
will probably be "fixed", and the latter would be "fixedbold" if X
actually created such an alias, but it doesn't so we use "6x13bold"
instead.
svn path=/trunk/; revision=2304
2000-08-20 07:53:45 +00:00
|
|
|
|
|
|
|
if (fs != NULL) {
|
|
|
|
/* Yes. Destroy it. */
|
|
|
|
gtk_widget_destroy(fs);
|
|
|
|
}
|
2000-08-22 14:04:52 +00:00
|
|
|
|
|
|
|
/* Is there a color selection dialog associated with this
|
|
|
|
Preferences dialog? */
|
2002-11-11 15:39:06 +00:00
|
|
|
fs = OBJECT_GET_DATA(caller, COLOR_DIALOG_PTR_KEY);
|
2000-08-22 14:04:52 +00:00
|
|
|
|
|
|
|
if (fs != NULL) {
|
|
|
|
/* Yes. Destroy it. */
|
|
|
|
gtk_widget_destroy(fs);
|
|
|
|
}
|
2000-09-09 10:35:53 +00:00
|
|
|
|
|
|
|
/* Free up any saved font name. */
|
2001-04-17 18:49:55 +00:00
|
|
|
if (new_font_name != NULL) {
|
2000-09-09 10:35:53 +00:00
|
|
|
g_free(new_font_name);
|
2001-04-17 18:49:55 +00:00
|
|
|
new_font_name = NULL;
|
|
|
|
}
|
2000-08-22 14:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* color selection part */
|
|
|
|
|
|
|
|
#define MAX_HANDLED_COL 2
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
GdkColor color;
|
|
|
|
char *label;
|
|
|
|
} color_info_t;
|
|
|
|
|
|
|
|
static color_info_t color_info[MAX_HANDLED_COL] = {
|
|
|
|
#define MFG_IDX 0
|
|
|
|
{ {0.0, 0.0, 0.0, 0.0}, "Marked frame foreground" },
|
|
|
|
#define MBG_IDX 1
|
|
|
|
{ {0.0, 0.0, 0.0, 0.0}, "Marked frame background" }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SAMPLE_MARKED_TEXT "Sample marked frame text\n"
|
|
|
|
|
|
|
|
#define CS_RED 0
|
|
|
|
#define CS_GREEN 1
|
|
|
|
#define CS_BLUE 2
|
|
|
|
#define CS_OPACITY 3
|
|
|
|
|
|
|
|
static GdkColor *curcolor = NULL;
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
color_browse_cb(GtkWidget *w, gpointer data _U_)
|
2000-08-22 14:04:52 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
GtkWidget *main_vb, *main_tb, *label, *optmenu, *menu, *menuitem;
|
|
|
|
GtkWidget *sample, *colorsel, *bbox, *cancel_bt, *ok_bt, *color_w;
|
2002-11-03 17:38:45 +00:00
|
|
|
int i;
|
2000-08-22 14:04:52 +00:00
|
|
|
GtkWidget *caller = gtk_widget_get_toplevel(w);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gdouble scolor[4];
|
|
|
|
int width, height;
|
|
|
|
#else
|
|
|
|
GtkTextBuffer *buffer;
|
|
|
|
GtkTextIter iter;
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-23 10:38:43 +00:00
|
|
|
/* Has a color dialog box already been opened for that top-level
|
2000-08-23 07:38:56 +00:00
|
|
|
widget? */
|
2002-11-11 15:39:06 +00:00
|
|
|
color_w = OBJECT_GET_DATA(caller, COLOR_DIALOG_PTR_KEY);
|
2000-08-22 14:04:52 +00:00
|
|
|
|
|
|
|
if (color_w != NULL) {
|
2000-08-23 07:38:56 +00:00
|
|
|
/* Yes. Just re-activate that dialog box. */
|
2000-08-22 14:04:52 +00:00
|
|
|
reactivate_window(color_w);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-11-21 23:54:10 +00:00
|
|
|
color_t_to_gdkcolor(&color_info[MFG_IDX].color, &prefs.gui_marked_fg);
|
|
|
|
color_t_to_gdkcolor(&color_info[MBG_IDX].color, &prefs.gui_marked_bg);
|
2000-08-22 14:04:52 +00:00
|
|
|
curcolor = &color_info[MFG_IDX].color;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
|
|
|
|
scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
|
|
|
|
scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
|
|
|
|
scolor[CS_OPACITY] = 1.0;
|
2002-11-03 17:38:45 +00:00
|
|
|
#endif
|
2000-08-22 14:04:52 +00:00
|
|
|
|
2000-08-23 07:38:56 +00:00
|
|
|
/* Now create a new dialog.
|
|
|
|
You can't put your own extra widgets into a color selection
|
|
|
|
dialog, as you can with a file selection dialog, so we have to
|
|
|
|
construct our own dialog and put a color selection widget
|
|
|
|
into it. */
|
2000-08-23 06:56:31 +00:00
|
|
|
color_w = dlg_window_new("Ethereal: Select Color");
|
2000-08-23 07:38:56 +00:00
|
|
|
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(color_w, "delete_event", color_delete_cb, NULL);
|
2002-11-03 17:38:45 +00:00
|
|
|
|
|
|
|
/* Call a handler when we're destroyed, so we can inform our caller,
|
|
|
|
if any, that we've been destroyed. */
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(color_w, "destroy", color_destroy_cb, NULL);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-22 14:04:52 +00:00
|
|
|
main_vb = gtk_vbox_new(FALSE, 5);
|
|
|
|
gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
|
|
|
|
gtk_container_add (GTK_CONTAINER (color_w), main_vb);
|
|
|
|
main_tb = gtk_table_new(3, 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:");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), label, 0, 1, 0, 1);
|
|
|
|
gtk_widget_show(label);
|
|
|
|
|
|
|
|
colorsel = gtk_color_selection_new();
|
|
|
|
optmenu = gtk_option_menu_new();
|
|
|
|
menu = gtk_menu_new();
|
|
|
|
for (i = 0; i < MAX_HANDLED_COL; i++){
|
|
|
|
menuitem = gtk_menu_item_new_with_label(color_info[i].label);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(menuitem, COLOR_SELECTION_PTR_KEY, colorsel);
|
|
|
|
SIGNAL_CONNECT(menuitem, "activate", update_current_color,
|
|
|
|
&color_info[i].color);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_widget_show(menuitem);
|
|
|
|
gtk_menu_append(GTK_MENU (menu), menuitem);
|
|
|
|
}
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu), menu);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), optmenu, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show(optmenu);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
sample = gtk_text_new(FALSE, FALSE);
|
|
|
|
height = sample->style->font->ascent + sample->style->font->descent;
|
|
|
|
width = gdk_string_width(sample->style->font, SAMPLE_MARKED_TEXT);
|
2002-11-11 15:39:06 +00:00
|
|
|
WIDGET_SET_SIZE(GTK_WIDGET(sample), width, height);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_text_set_editable(GTK_TEXT(sample), FALSE);
|
2002-08-28 21:04:11 +00:00
|
|
|
gtk_text_insert(GTK_TEXT(sample), NULL,
|
|
|
|
&color_info[MFG_IDX].color,
|
2000-08-22 14:04:52 +00:00
|
|
|
&color_info[MBG_IDX].color,
|
|
|
|
SAMPLE_MARKED_TEXT, -1);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
sample = gtk_text_view_new();
|
|
|
|
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sample));
|
|
|
|
gtk_text_view_set_editable(GTK_TEXT_VIEW(sample), FALSE);
|
|
|
|
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(sample), FALSE);
|
|
|
|
gtk_text_buffer_create_tag(buffer, "color", "foreground-gdk",
|
|
|
|
&color_info[MFG_IDX].color, "background-gdk",
|
|
|
|
&color_info[MBG_IDX].color, NULL);
|
|
|
|
gtk_text_buffer_get_start_iter(buffer, &iter);
|
|
|
|
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, SAMPLE_MARKED_TEXT,
|
|
|
|
-1, "color", NULL);
|
|
|
|
#endif
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), sample, 2, 3, 0, 2);
|
|
|
|
gtk_widget_show(sample);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2002-08-28 21:04:11 +00:00
|
|
|
gtk_color_selection_set_color(GTK_COLOR_SELECTION(colorsel),
|
2000-08-22 14:04:52 +00:00
|
|
|
&scolor[CS_RED]);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(colorsel),
|
|
|
|
curcolor);
|
|
|
|
#endif
|
2003-09-02 18:27:50 +00:00
|
|
|
gtk_table_attach_defaults(GTK_TABLE(main_tb), colorsel, 0, 3, 2, 3);
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(colorsel, COLOR_SAMPLE_PTR_KEY, sample);
|
|
|
|
SIGNAL_CONNECT(colorsel, "color-changed", update_text_color, NULL);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_widget_show(colorsel);
|
|
|
|
gtk_widget_show(main_vb);
|
|
|
|
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(color_w, COLOR_CALLER_PTR_KEY, caller);
|
|
|
|
OBJECT_SET_DATA(caller, COLOR_DIALOG_PTR_KEY, color_w);
|
2000-08-22 14:04:52 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
/* Ok, Cancel Buttons */
|
2000-08-22 14:04:52 +00:00
|
|
|
bbox = gtk_hbutton_box_new();
|
|
|
|
gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
|
|
gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
|
2003-09-02 18:27:50 +00:00
|
|
|
gtk_box_pack_end(GTK_BOX(main_vb), bbox, FALSE, FALSE, 5);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_widget_show(bbox);
|
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
ok_bt = gtk_button_new_with_label ("OK");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
ok_bt = gtk_button_new_from_stock(GTK_STOCK_OK);
|
|
|
|
#endif
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT(ok_bt, "clicked", color_ok_cb, color_w);
|
2000-08-22 14:04:52 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS(ok_bt, GTK_CAN_DEFAULT);
|
|
|
|
gtk_box_pack_start(GTK_BOX (bbox), ok_bt, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_grab_default(ok_bt);
|
|
|
|
gtk_widget_show(ok_bt);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
cancel_bt = gtk_button_new_with_label ("Cancel");
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
cancel_bt = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
|
|
|
|
#endif
|
2002-11-11 15:39:06 +00:00
|
|
|
SIGNAL_CONNECT_OBJECT(cancel_bt, "clicked", gtk_widget_destroy, color_w);
|
2003-09-02 18:27:50 +00:00
|
|
|
GTK_WIDGET_SET_FLAGS(cancel_bt, GTK_CAN_DEFAULT);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX (bbox), cancel_bt, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(cancel_bt);
|
|
|
|
dlg_set_cancel(color_w, cancel_bt);
|
|
|
|
|
|
|
|
gtk_widget_show(color_w);
|
1999-12-16 06:20:18 +00:00
|
|
|
}
|
2000-08-22 14:04:52 +00:00
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
update_text_color(GtkWidget *w, gpointer data _U_) {
|
2002-11-11 15:39:06 +00:00
|
|
|
GtkWidget *sample = OBJECT_GET_DATA(w, COLOR_SAMPLE_PTR_KEY);
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gdouble scolor[4];
|
2000-08-22 14:04:52 +00:00
|
|
|
|
|
|
|
gtk_color_selection_get_color(GTK_COLOR_SELECTION(w), &scolor[CS_RED]);
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-22 14:04:52 +00:00
|
|
|
curcolor->red = (gushort) (scolor[CS_RED] * 65535.0);
|
|
|
|
curcolor->green = (gushort) (scolor[CS_GREEN] * 65535.0);
|
|
|
|
curcolor->blue = (gushort) (scolor[CS_BLUE] * 65535.0);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(sample));
|
|
|
|
GtkTextTag *tag;
|
|
|
|
|
|
|
|
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(w), curcolor);
|
|
|
|
#endif
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
|
|
|
gtk_text_freeze(GTK_TEXT(sample));
|
|
|
|
gtk_text_set_point(GTK_TEXT(sample), 0);
|
|
|
|
gtk_text_forward_delete(GTK_TEXT(sample),
|
|
|
|
gtk_text_get_length(GTK_TEXT(sample)));
|
2002-08-28 21:04:11 +00:00
|
|
|
gtk_text_insert(GTK_TEXT(sample), NULL,
|
|
|
|
&color_info[MFG_IDX].color,
|
2000-08-22 14:04:52 +00:00
|
|
|
&color_info[MBG_IDX].color,
|
|
|
|
SAMPLE_MARKED_TEXT, -1);
|
2002-11-03 17:38:45 +00:00
|
|
|
gtk_text_thaw(GTK_TEXT(sample));
|
|
|
|
#else
|
|
|
|
tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(buffer),
|
|
|
|
"color");
|
|
|
|
g_object_set(tag, "foreground-gdk", &color_info[MFG_IDX].color,
|
|
|
|
"background-gdk", &color_info[MBG_IDX].color, NULL);
|
|
|
|
#endif
|
2000-08-22 14:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_current_color(GtkWidget *w, gpointer data)
|
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
GtkColorSelection *colorsel;
|
2002-11-03 17:38:45 +00:00
|
|
|
#if GTK_MAJOR_VERSION < 2
|
2000-08-22 14:04:52 +00:00
|
|
|
gdouble scolor[4];
|
|
|
|
|
2002-11-11 15:39:06 +00:00
|
|
|
colorsel = GTK_COLOR_SELECTION(OBJECT_GET_DATA(w, COLOR_SELECTION_PTR_KEY));
|
2000-08-22 14:04:52 +00:00
|
|
|
curcolor = (GdkColor *)data;
|
|
|
|
scolor[CS_RED] = (gdouble) (curcolor->red) / 65535.0;
|
|
|
|
scolor[CS_GREEN] = (gdouble) (curcolor->green) / 65535.0;
|
|
|
|
scolor[CS_BLUE] = (gdouble) (curcolor->blue) / 65535.0;
|
|
|
|
scolor[CS_OPACITY] = 1.0;
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_color_selection_set_color(colorsel, &scolor[CS_RED]);
|
2002-11-03 17:38:45 +00:00
|
|
|
#else
|
|
|
|
colorsel = GTK_COLOR_SELECTION(g_object_get_data(G_OBJECT(w),
|
|
|
|
COLOR_SELECTION_PTR_KEY));
|
|
|
|
curcolor = (GdkColor *)data;
|
|
|
|
gtk_color_selection_set_current_color(colorsel, curcolor);
|
|
|
|
#endif
|
2000-08-22 14:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
color_ok_cb(GtkWidget *w _U_, gpointer data)
|
2000-08-22 14:04:52 +00:00
|
|
|
{
|
2000-08-23 07:38:56 +00:00
|
|
|
/* We assume the user actually changed a color here. */
|
|
|
|
colors_changed = TRUE;
|
|
|
|
|
|
|
|
gtk_widget_hide(GTK_WIDGET(data));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
color_cancel_cb(GtkWidget *w _U_, gpointer data)
|
2000-08-23 07:38:56 +00:00
|
|
|
{
|
|
|
|
/* Revert the colors to the current preference settings. */
|
2000-11-21 23:54:10 +00:00
|
|
|
color_t_to_gdkcolor(&color_info[MFG_IDX].color, &prefs.gui_marked_fg);
|
|
|
|
color_t_to_gdkcolor(&color_info[MBG_IDX].color, &prefs.gui_marked_bg);
|
2000-08-22 14:04:52 +00:00
|
|
|
gtk_widget_hide(GTK_WIDGET(data));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(data));
|
2000-08-23 07:38:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Treat this as a cancel, by calling "color_cancel_cb()".
|
|
|
|
XXX - that'll destroy the Select Color dialog; will that upset
|
|
|
|
a higher-level handler that says "OK, we've been asked to delete
|
|
|
|
this, so destroy it"? */
|
|
|
|
static gboolean
|
2002-03-05 11:56:00 +00:00
|
|
|
color_delete_cb(GtkWidget *prefs_w _U_, gpointer dummy _U_)
|
2000-08-23 07:38:56 +00:00
|
|
|
{
|
|
|
|
color_cancel_cb(NULL, NULL);
|
|
|
|
return FALSE;
|
2000-08-22 14:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-03-05 11:56:00 +00:00
|
|
|
color_destroy_cb(GtkWidget *w, gpointer data _U_)
|
2000-08-22 14:04:52 +00:00
|
|
|
{
|
2002-11-11 15:39:06 +00:00
|
|
|
GtkWidget *caller = OBJECT_GET_DATA(w, COLOR_CALLER_PTR_KEY);
|
2000-08-22 14:04:52 +00:00
|
|
|
if (caller != NULL) {
|
2002-11-11 15:39:06 +00:00
|
|
|
OBJECT_SET_DATA(caller, COLOR_DIALOG_PTR_KEY, NULL);
|
2000-08-22 14:04:52 +00:00
|
|
|
}
|
|
|
|
gtk_grab_remove(GTK_WIDGET(w));
|
|
|
|
gtk_widget_destroy(GTK_WIDGET(w));
|
|
|
|
}
|
|
|
|
|
2000-08-23 07:38:56 +00:00
|
|
|
static void
|
|
|
|
fetch_colors(void)
|
|
|
|
{
|
2000-11-21 23:54:10 +00:00
|
|
|
gdkcolor_to_color_t(&prefs.gui_marked_fg, &color_info[MFG_IDX].color);
|
|
|
|
gdkcolor_to_color_t(&prefs.gui_marked_bg, &color_info[MBG_IDX].color);
|
2000-08-23 07:38:56 +00:00
|
|
|
}
|