Add a new page to the Preferences notebook: a GUI page. The sole
[obnox/wireshark/wip.git] / gtk / gui_prefs.c
1 /* gui_prefs.c
2  * Dialog box for GUI preferences
3  *
4  * $Id: gui_prefs.c,v 1.1 1999/12/16 06:20:15 gram Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  * 
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <errno.h>
31
32 #ifndef __GLOBALS_H__
33 #include "globals.h"
34 #endif
35
36 #include "gui_prefs.h"
37 #include "gtkglobals.h"
38
39 #ifndef __PREFS_DLG_H__
40 #include "prefs_dlg.h"
41 #endif
42
43 static void scrollbar_menu_item_cb(GtkWidget *w, gpointer data);
44
45 static gboolean temp_gui_scrollbar_on_right;
46
47 GtkWidget*
48 gui_prefs_show(void)
49 {
50         GtkWidget       *main_vb, *hbox, *label;
51         GtkWidget       *menu_item_left, *menu_item_right,
52                         *scrollbar_menu, *scrollbar_option_menu;
53
54         temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
55
56         /* Main vertical box */
57         main_vb = gtk_vbox_new(FALSE, 5);
58         gtk_container_border_width(GTK_CONTAINER(main_vb), 5);
59
60         /* Scrollbar placment hbox */
61         hbox = gtk_hbox_new(FALSE, 5);
62         gtk_box_pack_start( GTK_BOX(main_vb), hbox, FALSE, FALSE, 5);
63
64         label = gtk_label_new("Vertical Scrollbar Placement:");
65         gtk_container_add( GTK_CONTAINER(hbox), label );
66
67         /* Create a simple menu containing the LEFT/RIGHT choices for
68          * the scrollbar placement option */
69         scrollbar_menu = gtk_menu_new();
70         menu_item_left  = gtk_menu_item_new_with_label("Left");
71         menu_item_right = gtk_menu_item_new_with_label("Right");
72         gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_left );
73         gtk_menu_append( GTK_MENU(scrollbar_menu), menu_item_right );
74
75         gtk_signal_connect( GTK_OBJECT(menu_item_left), "activate",
76                         scrollbar_menu_item_cb, GINT_TO_POINTER(FALSE) );
77         gtk_signal_connect( GTK_OBJECT(menu_item_right), "activate",
78                         scrollbar_menu_item_cb, GINT_TO_POINTER(TRUE) );
79
80         /* Create the option menu from the option */
81         scrollbar_option_menu = gtk_option_menu_new();
82         gtk_option_menu_set_menu( GTK_OPTION_MENU(scrollbar_option_menu),
83                         scrollbar_menu );
84         gtk_option_menu_set_history( GTK_OPTION_MENU(scrollbar_option_menu),
85                         temp_gui_scrollbar_on_right);
86         gtk_container_add( GTK_CONTAINER(hbox), scrollbar_option_menu );
87
88
89         /* Show 'em what we got */
90         gtk_widget_show_all(main_vb);
91
92         return(main_vb);
93 }
94
95
96 static void
97 scrollbar_menu_item_cb(GtkWidget *w, gpointer data)
98 {
99         gboolean        value = GPOINTER_TO_INT(data);
100
101         temp_gui_scrollbar_on_right = value;
102         set_scrollbar_placement(value);
103 }
104
105 void
106 gui_prefs_ok(GtkWidget *w)
107 {
108         prefs.gui_scrollbar_on_right = temp_gui_scrollbar_on_right;
109         gui_prefs_delete(w);
110 }
111
112 void
113 gui_prefs_save(GtkWidget *w)
114 {
115         gui_prefs_ok(w);
116 }
117
118 void
119 gui_prefs_cancel(GtkWidget *w)
120 {
121         /* Reset scrollbar placement value back to what the
122          * current preferences says it should be */
123         temp_gui_scrollbar_on_right = prefs.gui_scrollbar_on_right;
124         set_scrollbar_placement(prefs.gui_scrollbar_on_right);
125
126         gui_prefs_delete(w);
127 }
128
129 void
130 gui_prefs_delete(GtkWidget *w)
131 {
132 }