1 /*
2 * Copyright 2006 Adrian Lees <adrianl@users.sourceforge.net>
3 *
4 * This file is part of NetSurf, http://www.netsurf-browser.org/
5 *
6 * NetSurf is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * NetSurf is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include <stdbool.h>
20
21 #include "utils/nsoption.h"
22
23 #include "riscos/gui.h"
24 #include "riscos/wimp.h"
25 #include "riscos/wimp_event.h"
26 #include "riscos/configure.h"
27 #include "riscos/configure/configure.h"
28 #include "riscos/dialog.h"
29
30 #define INTERFACE_STRIP_EXTNS_OPTION 2
31 #define INTERFACE_CONFIRM_OVWR_OPTION 3
32 #define INTERFACE_URL_COMPLETE_OPTION 6
33 #define INTERFACE_HISTORY_TOOLTIP_OPTION 7
34 #define INTERFACE_THUMBNAIL_ICONISE_OPTION 10
35 #define INTERFACE_DEFAULT_BUTTON 11
36 #define INTERFACE_CANCEL_BUTTON 12
37 #define INTERFACE_OK_BUTTON 13
38 #define INTERFACE_USE_EXTERNAL_HOTLIST 16
39 #define INTERFACE_EXTERNAL_HOTLIST_APP 18
40
41
42 static bool ro_gui_options_interface_click(wimp_pointer *pointer);
43 static void ro_gui_options_interface_default(wimp_pointer *pointer);
44 static bool ro_gui_options_interface_ok(wimp_w w);
45
ro_gui_options_interface_initialise(wimp_w w)46 bool ro_gui_options_interface_initialise(wimp_w w)
47 {
48 /* set the current values */
49 ro_gui_set_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION,
50 nsoption_bool(strip_extensions));
51 ro_gui_set_icon_selected_state(w, INTERFACE_CONFIRM_OVWR_OPTION,
52 nsoption_bool(confirm_overwrite));
53 ro_gui_set_icon_selected_state(w, INTERFACE_URL_COMPLETE_OPTION,
54 nsoption_bool(url_suggestion));
55 ro_gui_set_icon_selected_state(w, INTERFACE_HISTORY_TOOLTIP_OPTION,
56 nsoption_bool(history_tooltip));
57 ro_gui_set_icon_selected_state(w, INTERFACE_THUMBNAIL_ICONISE_OPTION,
58 nsoption_bool(thumbnail_iconise));
59 ro_gui_set_icon_selected_state(w, INTERFACE_USE_EXTERNAL_HOTLIST,
60 nsoption_bool(external_hotlists));
61 ro_gui_set_icon_string(w, INTERFACE_EXTERNAL_HOTLIST_APP,
62 (nsoption_charp(external_hotlist_app)) ?
63 nsoption_charp(external_hotlist_app) : "", false);
64
65 ro_gui_set_icon_shaded_state(w, INTERFACE_EXTERNAL_HOTLIST_APP,
66 !nsoption_bool(external_hotlists));
67
68 /* initialise all functions for a newly created window */
69 ro_gui_wimp_event_register_mouse_click(w,
70 ro_gui_options_interface_click);
71 ro_gui_wimp_event_register_button(w, INTERFACE_DEFAULT_BUTTON,
72 ro_gui_options_interface_default);
73 ro_gui_wimp_event_register_cancel(w, INTERFACE_CANCEL_BUTTON);
74 ro_gui_wimp_event_register_ok(w, INTERFACE_OK_BUTTON,
75 ro_gui_options_interface_ok);
76 ro_gui_wimp_event_set_help_prefix(w, "HelpInterfaceConfig");
77 ro_gui_wimp_event_memorise(w);
78 return true;
79
80 }
81
82
ro_gui_options_interface_click(wimp_pointer * pointer)83 bool ro_gui_options_interface_click(wimp_pointer *pointer)
84 {
85 bool shaded;
86
87 switch (pointer->i) {
88 case INTERFACE_USE_EXTERNAL_HOTLIST:
89 shaded = !ro_gui_get_icon_selected_state(pointer->w,
90 INTERFACE_USE_EXTERNAL_HOTLIST);
91 ro_gui_set_icon_shaded_state(pointer->w,
92 INTERFACE_EXTERNAL_HOTLIST_APP, shaded);
93 return false;
94 break;
95 }
96 return false;
97 }
98
99
100
ro_gui_options_interface_default(wimp_pointer * pointer)101 void ro_gui_options_interface_default(wimp_pointer *pointer)
102 {
103 ro_gui_set_icon_selected_state(pointer->w,
104 INTERFACE_STRIP_EXTNS_OPTION, true);
105 ro_gui_set_icon_selected_state(pointer->w,
106 INTERFACE_CONFIRM_OVWR_OPTION, true);
107 ro_gui_set_icon_selected_state(pointer->w,
108 INTERFACE_URL_COMPLETE_OPTION, true);
109 ro_gui_set_icon_selected_state(pointer->w,
110 INTERFACE_HISTORY_TOOLTIP_OPTION, true);
111 ro_gui_set_icon_selected_state(pointer->w,
112 INTERFACE_THUMBNAIL_ICONISE_OPTION, true);
113 ro_gui_set_icon_selected_state(pointer->w,
114 INTERFACE_USE_EXTERNAL_HOTLIST, false);
115 ro_gui_set_icon_string(pointer->w, INTERFACE_EXTERNAL_HOTLIST_APP,
116 "", false);
117 }
118
ro_gui_options_interface_ok(wimp_w w)119 bool ro_gui_options_interface_ok(wimp_w w)
120 {
121 nsoption_set_bool(strip_extensions,
122 ro_gui_get_icon_selected_state(w,
123 INTERFACE_STRIP_EXTNS_OPTION));
124 nsoption_set_bool(confirm_overwrite,
125 ro_gui_get_icon_selected_state(w,
126 INTERFACE_CONFIRM_OVWR_OPTION));
127 nsoption_set_bool(url_suggestion,
128 ro_gui_get_icon_selected_state(w,
129 INTERFACE_URL_COMPLETE_OPTION));
130 nsoption_set_bool(history_tooltip,
131 ro_gui_get_icon_selected_state(w,
132 INTERFACE_HISTORY_TOOLTIP_OPTION));
133 nsoption_set_bool(thumbnail_iconise,
134 ro_gui_get_icon_selected_state(w,
135 INTERFACE_THUMBNAIL_ICONISE_OPTION));
136 nsoption_set_bool(external_hotlists,
137 ro_gui_get_icon_selected_state(w,
138 INTERFACE_USE_EXTERNAL_HOTLIST));
139 nsoption_set_charp(external_hotlist_app,
140 strdup(ro_gui_get_icon_string(w,
141 INTERFACE_EXTERNAL_HOTLIST_APP)));
142
143 ro_gui_save_options();
144 return true;
145 }
146