summaryrefslogtreecommitdiff
path: root/riscos/configure/con_inter.c
blob: 30b82429284700cee858217e60ee37331e2209d3 (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
/*
 * Copyright 2006 Adrian Lees <adrianl@users.sourceforge.net>
 *
 * This file is part of NetSurf, http://www.netsurf-browser.org/
 *
 * NetSurf 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; version 2 of the License.
 *
 * NetSurf 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, see <http://www.gnu.org/licenses/>.
 */

#include <stdbool.h>

#include "utils/nsoption.h"

#include "riscos/dialog.h"
#include "riscos/gui.h"
#include "riscos/wimp.h"
#include "riscos/wimp_event.h"
#include "riscos/configure.h"
#include "riscos/configure/configure.h"

#define INTERFACE_STRIP_EXTNS_OPTION 2
#define INTERFACE_CONFIRM_OVWR_OPTION 3
#define INTERFACE_URL_COMPLETE_OPTION 6
#define INTERFACE_HISTORY_TOOLTIP_OPTION 7
#define INTERFACE_THUMBNAIL_ICONISE_OPTION 10
#define INTERFACE_DEFAULT_BUTTON 11
#define INTERFACE_CANCEL_BUTTON 12
#define INTERFACE_OK_BUTTON 13
#define INTERFACE_USE_EXTERNAL_HOTLIST 16
#define INTERFACE_EXTERNAL_HOTLIST_APP 18


static bool ro_gui_options_interface_click(wimp_pointer *pointer);
static void ro_gui_options_interface_default(wimp_pointer *pointer);
static bool ro_gui_options_interface_ok(wimp_w w);

bool ro_gui_options_interface_initialise(wimp_w w)
{
	/* set the current values */
	ro_gui_set_icon_selected_state(w, INTERFACE_STRIP_EXTNS_OPTION,
                                       nsoption_bool(strip_extensions));
	ro_gui_set_icon_selected_state(w, INTERFACE_CONFIRM_OVWR_OPTION,
                                       nsoption_bool(confirm_overwrite));
	ro_gui_set_icon_selected_state(w, INTERFACE_URL_COMPLETE_OPTION,
                                       nsoption_bool(url_suggestion));
	ro_gui_set_icon_selected_state(w, INTERFACE_HISTORY_TOOLTIP_OPTION,
                                       nsoption_bool(history_tooltip));
	ro_gui_set_icon_selected_state(w, INTERFACE_THUMBNAIL_ICONISE_OPTION,
                                       nsoption_bool(thumbnail_iconise));
	ro_gui_set_icon_selected_state(w, INTERFACE_USE_EXTERNAL_HOTLIST,
                                       nsoption_bool(external_hotlists));
	ro_gui_set_icon_string(w, INTERFACE_EXTERNAL_HOTLIST_APP,
                               (nsoption_charp(external_hotlist_app)) ?
                               nsoption_charp(external_hotlist_app) : "", false);

	ro_gui_set_icon_shaded_state(w, INTERFACE_EXTERNAL_HOTLIST_APP,
                                     !nsoption_bool(external_hotlists));

	/* initialise all functions for a newly created window */
	ro_gui_wimp_event_register_mouse_click(w,
			ro_gui_options_interface_click);
	ro_gui_wimp_event_register_button(w, INTERFACE_DEFAULT_BUTTON,
			ro_gui_options_interface_default);
	ro_gui_wimp_event_register_cancel(w, INTERFACE_CANCEL_BUTTON);
	ro_gui_wimp_event_register_ok(w, INTERFACE_OK_BUTTON,
			ro_gui_options_interface_ok);
	ro_gui_wimp_event_set_help_prefix(w, "HelpInterfaceConfig");
	ro_gui_wimp_event_memorise(w);
	return true;

}


bool ro_gui_options_interface_click(wimp_pointer *pointer)
{
	bool	shaded;

	switch (pointer->i) {
		case INTERFACE_USE_EXTERNAL_HOTLIST:
			shaded = !ro_gui_get_icon_selected_state(pointer->w,
					INTERFACE_USE_EXTERNAL_HOTLIST);
			ro_gui_set_icon_shaded_state(pointer->w,
					INTERFACE_EXTERNAL_HOTLIST_APP, shaded);
			return false;
			break;
	}
	return false;
}



void ro_gui_options_interface_default(wimp_pointer *pointer)
{
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_STRIP_EXTNS_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_CONFIRM_OVWR_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_URL_COMPLETE_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_HISTORY_TOOLTIP_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_THUMBNAIL_ICONISE_OPTION, true);
	ro_gui_set_icon_selected_state(pointer->w,
			INTERFACE_USE_EXTERNAL_HOTLIST, false);
	ro_gui_set_icon_string(pointer->w, INTERFACE_EXTERNAL_HOTLIST_APP,
			"", false);
}

bool ro_gui_options_interface_ok(wimp_w w)
{
	nsoption_set_bool(strip_extensions, 
			ro_gui_get_icon_selected_state(w, 
					INTERFACE_STRIP_EXTNS_OPTION));
	nsoption_set_bool(confirm_overwrite, 
                          ro_gui_get_icon_selected_state(w,
                                        INTERFACE_CONFIRM_OVWR_OPTION));
	nsoption_set_bool(url_suggestion, 
                          ro_gui_get_icon_selected_state(w,
                                        INTERFACE_URL_COMPLETE_OPTION));
	nsoption_set_bool(history_tooltip, 
                          ro_gui_get_icon_selected_state(w,
                                        INTERFACE_HISTORY_TOOLTIP_OPTION));
	nsoption_set_bool(thumbnail_iconise, 
                          ro_gui_get_icon_selected_state(w,
                                        INTERFACE_THUMBNAIL_ICONISE_OPTION));
	nsoption_set_bool(external_hotlists, 
                          ro_gui_get_icon_selected_state(w,
                                        INTERFACE_USE_EXTERNAL_HOTLIST));
	nsoption_set_charp(external_hotlist_app,
                           strdup(ro_gui_get_icon_string(w,
                                        INTERFACE_EXTERNAL_HOTLIST_APP)));

	ro_gui_save_options();
	return true;
}