aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/gui_prefs.c
blob: e3f6e32370d3458c38bb2adce882f2faa465b12e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
/* gui_prefs.c
 * Dialog box for GUI preferences
 *
 * $Id: gui_prefs.c,v 1.4 2000/02/29 06:24:37 guy Exp $
 *
 * Ethereal - Network traffic analyzer
 * By Gerald Combs <gerald@zing.org>
 * Copyright 1998 Gerald Combs
 *
 * 
 * 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.
 * 
 * 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.
 * 
 * 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

#include <errno.h>

#ifndef __GLOBALS_H__
#include "globals.h"
#endif

#include "gui_prefs.h"
#include "gtkglobals.h"

#ifndef __PREFS_DLG_H__
#include "prefs_dlg.h"
#endif

static void scrollbar_menu_item_cb(GtkWidget *w, gpointer data);
static void plist_sel_browse_cb(GtkWidget *w, gpointer data);
static void ptree_sel_browse_cb(GtkWidget *w, gpointer data);
static void ptree_line_style_cb(GtkWidget *w, gpointer data);
static void ptree_expander_style_cb(GtkWidget *w, gpointer data);

static gboolean temp_gui_scrollbar_on_right;
static gboolean temp_gui_plist_sel_browse;
static gboolean temp_gui_ptree_sel_browse;
static gint temp_gui_ptree_line_style;
static gint temp_gui_ptree_expander_style;

GtkWidget*
gui_prefs_show(void)
{
	GtkWidget	*main_tb, *main_vb, *label;
	GtkWidget	*menu_item_false, *menu_item_true,
			*menu_item_0, *menu_item_1, *menu_item_2, *menu_item_3,
			*scrollbar_menu, *scrollbar_option_menu;

	temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
	temp_gui_plist_sel_browse = prefs.gui_plist_sel_browse;
	temp_gui_ptree_sel_browse = prefs.gui_ptree_sel_browse;
	temp_gui_ptree_line_style = prefs.gui_ptree_line_style;
	temp_gui_ptree_expander_style = prefs.gui_ptree_expander_style;

	/* Main vertical box */
	main_vb = gtk_vbox_new(FALSE, 5);
	gtk_container_border_width( GTK_CONTAINER(main_vb), 5 );

	/* Main table */
	main_tb = gtk_table_new(5, 2, 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 );


	/* Scrollbar placment */
	label = gtk_label_new("Vertical Scrollbar Placement:");
	gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
	gtk_table_attach_defaults( GTK_TABLE(main_tb), label, 0, 1, 0, 1 );

	/* Create a simple menu containing the LEFT/RIGHT choices for
	 * the scrollbar placement option */
	scrollbar_menu = gtk_menu_new();
	menu_item_false  = gtk_menu_item_new_with_label("Left");
	menu_item_true = gtk_menu_item_new_with_label("Right");
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_false );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_true );

	gtk_signal_connect( GTK_OBJECT(menu_item_false), "activate",
			scrollbar_menu_item_cb, GINT_TO_POINTER(FALSE) );
	gtk_signal_connect( GTK_OBJECT(menu_item_true), "activate",
			scrollbar_menu_item_cb, GINT_TO_POINTER(TRUE) );

	/* Create the option menu from the option */
	scrollbar_option_menu = gtk_option_menu_new();
	gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
			scrollbar_menu );
	gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
			temp_gui_scrollbar_on_right);
	gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
			1, 2, 0, 1 );


	/* Packet list selection browseable */
	label = gtk_label_new("Packet-list selection bar movement:");
	gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
	gtk_table_attach_defaults( GTK_TABLE(main_tb), label, 0, 1, 1, 2 );

	/* Create a simple menu containing the LEFT/RIGHT choices */
	scrollbar_menu = gtk_menu_new();
	menu_item_false  = gtk_menu_item_new_with_label("Selects");
	menu_item_true = gtk_menu_item_new_with_label("Browses");
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_false );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_true );

	gtk_signal_connect( GTK_OBJECT(menu_item_false), "activate",
			plist_sel_browse_cb, GINT_TO_POINTER(FALSE) );
	gtk_signal_connect( GTK_OBJECT(menu_item_true), "activate",
			plist_sel_browse_cb, GINT_TO_POINTER(TRUE) );

	/* Create the option menu from the option */
	scrollbar_option_menu = gtk_option_menu_new();
	gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
			scrollbar_menu );
	gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
			temp_gui_plist_sel_browse);
	gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
			1, 2, 1, 2 );


	/* Proto tree selection browseable */
	label = gtk_label_new("Protocol-tree selection bar movement:");
	gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
	gtk_table_attach_defaults( GTK_TABLE(main_tb), label, 0, 1, 2, 3 );

	/* Create a simple menu containing the LEFT/RIGHT choices */
	scrollbar_menu = gtk_menu_new();
	menu_item_false  = gtk_menu_item_new_with_label("Selects");
	menu_item_true = gtk_menu_item_new_with_label("Browses");
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_false );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_true );

	gtk_signal_connect( GTK_OBJECT(menu_item_false), "activate",
			ptree_sel_browse_cb, GINT_TO_POINTER(FALSE) );
	gtk_signal_connect( GTK_OBJECT(menu_item_true), "activate",
			ptree_sel_browse_cb, GINT_TO_POINTER(TRUE) );

	/* Create the option menu from the option */
	scrollbar_option_menu = gtk_option_menu_new();
	gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
			scrollbar_menu );
	gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
			temp_gui_ptree_sel_browse);
	gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
			1, 2, 2, 3 );


	/* Proto tree line style */
	label = gtk_label_new("Protocol-tree line style:");
	gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
	gtk_table_attach_defaults( GTK_TABLE(main_tb), label, 0, 1, 3, 4 );

	/* Create a menu */
	scrollbar_menu = gtk_menu_new();
	menu_item_0 = gtk_menu_item_new_with_label("None");
	menu_item_1 = gtk_menu_item_new_with_label("Solid");
	menu_item_2 = gtk_menu_item_new_with_label("Dotted");
	menu_item_3 = gtk_menu_item_new_with_label("Tabbed");
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_0 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_1 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_2 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_3 );

	gtk_signal_connect( GTK_OBJECT(menu_item_0), "activate",
			ptree_line_style_cb, GINT_TO_POINTER(0) );
	gtk_signal_connect( GTK_OBJECT(menu_item_1), "activate",
			ptree_line_style_cb, GINT_TO_POINTER(1) );
	gtk_signal_connect( GTK_OBJECT(menu_item_2), "activate",
			ptree_line_style_cb, GINT_TO_POINTER(2) );
	gtk_signal_connect( GTK_OBJECT(menu_item_3), "activate",
			ptree_line_style_cb, GINT_TO_POINTER(3) );

	/* Create the option menu from the option */
	scrollbar_option_menu = gtk_option_menu_new();
	gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
			scrollbar_menu );
	gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
			temp_gui_ptree_line_style);
	gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
			1, 2, 3, 4 );


	/* Proto tree expander style */
	label = gtk_label_new("Protocol-tree expander style:");
	gtk_misc_set_alignment( GTK_MISC(label), 1.0, 0.5 );
	gtk_table_attach_defaults( GTK_TABLE(main_tb), label, 0, 1, 4, 5 );

	/* Create a menu */
	scrollbar_menu = gtk_menu_new();
	menu_item_0 = gtk_menu_item_new_with_label("None");
	menu_item_1 = gtk_menu_item_new_with_label("Square");
	menu_item_2 = gtk_menu_item_new_with_label("Triangle");
	menu_item_3 = gtk_menu_item_new_with_label("Circular");
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_0 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_1 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_2 );
	gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_3 );

	gtk_signal_connect( GTK_OBJECT(menu_item_0), "activate",
			ptree_expander_style_cb, GINT_TO_POINTER(0) );
	gtk_signal_connect( GTK_OBJECT(menu_item_1), "activate",
			ptree_expander_style_cb, GINT_TO_POINTER(1) );
	gtk_signal_connect( GTK_OBJECT(menu_item_2), "activate",
			ptree_expander_style_cb, GINT_TO_POINTER(2) );
	gtk_signal_connect( GTK_OBJECT(menu_item_3), "activate",
			ptree_expander_style_cb, GINT_TO_POINTER(3) );

	/* Create the option menu from the option */
	scrollbar_option_menu = gtk_option_menu_new();
	gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
			scrollbar_menu );
	gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
			temp_gui_ptree_expander_style);
	gtk_table_attach_defaults( GTK_TABLE(main_tb), scrollbar_option_menu,
			1, 2, 4, 5 );

	/* Show 'em what we got */
	gtk_widget_show_all(main_vb);

	return(main_vb);
}


static void
scrollbar_menu_item_cb(GtkWidget *w, gpointer data)
{
	gboolean	value = GPOINTER_TO_INT(data);

	temp_gui_scrollbar_on_right = value;
	set_scrollbar_placement_all(value);
}

static void
plist_sel_browse_cb(GtkWidget *w, gpointer data)
{
	gboolean	value = GPOINTER_TO_INT(data);

	temp_gui_plist_sel_browse = value;
	set_plist_sel_browse(value);
}

static void
ptree_sel_browse_cb(GtkWidget *w, gpointer data)
{
	gboolean	value = GPOINTER_TO_INT(data);

	temp_gui_ptree_sel_browse = value;
	set_ptree_sel_browse_all(value);
}

static void
ptree_line_style_cb(GtkWidget *w, gpointer data)
{
	gint	value = GPOINTER_TO_INT(data);

	temp_gui_ptree_line_style = value;
	set_ptree_line_style_all(value);
}

static void
ptree_expander_style_cb(GtkWidget *w, gpointer data)
{
	gint	value = GPOINTER_TO_INT(data);

	temp_gui_ptree_expander_style = value;
	set_ptree_expander_style_all(value);
}


void
gui_prefs_ok(GtkWidget *w)
{
	prefs.gui_scrollbar_on_right = temp_gui_scrollbar_on_right;
	prefs.gui_plist_sel_browse = temp_gui_plist_sel_browse;
	prefs.gui_ptree_sel_browse = temp_gui_ptree_sel_browse;
	prefs.gui_ptree_line_style = temp_gui_ptree_line_style;
	prefs.gui_ptree_expander_style = temp_gui_ptree_expander_style;

	gui_prefs_delete(w);
}

void
gui_prefs_save(GtkWidget *w)
{
	gui_prefs_ok(w);
}

void
gui_prefs_cancel(GtkWidget *w)
{
	/* Reset GUI preference values back to what the
	 * current preferences says they should be */
	temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
	temp_gui_plist_sel_browse = prefs.gui_plist_sel_browse;
	temp_gui_ptree_sel_browse = prefs.gui_ptree_sel_browse;
	temp_gui_ptree_line_style = prefs.gui_ptree_line_style;
	temp_gui_ptree_expander_style = prefs.gui_ptree_expander_style;

	set_scrollbar_placement_all(prefs.gui_scrollbar_on_right);
	set_plist_sel_browse(prefs.gui_plist_sel_browse);
	set_ptree_sel_browse_all(prefs.gui_ptree_sel_browse);
	set_ptree_line_style_all(prefs.gui_ptree_line_style);
	set_ptree_expander_style_all(prefs.gui_ptree_expander_style);

	gui_prefs_delete(w);
}

void
gui_prefs_delete(GtkWidget *w)
{
}