NetSurf
con_home.c
Go to the documentation of this file.
1/*
2 * Copyright 2005 Richard Wilson <info@tinct.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#include <stdlib.h>
21
22#include "utils/messages.h"
23#include "utils/nsoption.h"
24
25#include "riscos/gui.h"
26#include "riscos/menus.h"
27#include "riscos/url_suggest.h"
28#include "riscos/wimp.h"
29#include "riscos/wimp_event.h"
30#include "riscos/configure.h"
32#include "riscos/dialog.h"
33
34#define HOME_URL_FIELD 3
35#define HOME_URL_GRIGHT 4
36#define HOME_OPEN_STARTUP 5
37#define HOME_DEFAULT_BUTTON 6
38#define HOME_CANCEL_BUTTON 7
39#define HOME_OK_BUTTON 8
40
41static void ro_gui_options_home_default(wimp_pointer *pointer);
42static bool ro_gui_options_home_ok(wimp_w w);
43static bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i,
44 wimp_menu *menu, wimp_pointer *pointer);
45
47{
48 /* set the current values */
50 nsoption_charp(homepage_url) ?
51 nsoption_charp(homepage_url) : "", true);
52
54 nsoption_bool(open_browser_at_startup));
55
58
59 /* initialise all functions for a newly created window */
70 ro_gui_wimp_event_set_help_prefix(w, "HelpHomeConfig");
72 return true;
73
74}
75
76void ro_gui_options_home_default(wimp_pointer *pointer)
77{
78 /* set the default values */
79 ro_gui_set_icon_string(pointer->w, HOME_URL_FIELD, "", true);
81}
82
84{
85 nsoption_set_charp(homepage_url,
87
88 nsoption_set_bool(open_browser_at_startup,
90
92 return true;
93}
94
95
96/**
97 * Callback to prepare menus in the Configure Home dialog. At present, this
98 * only has to handle the URL Suggestion pop-up.
99 *
100 * \param w The window handle owning the menu.
101 * \param i The icon handle owning the menu.
102 * \param *menu The menu to be prepared.
103 * \param *pointer The associated mouse click event block, or NULL
104 * on an Adjust-click re-opening.
105 * \return true if the event was handled; false if not.
106 */
107
108bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu,
109 wimp_pointer *pointer)
110{
111 if (menu != ro_gui_url_suggest_menu || i != HOME_URL_GRIGHT)
112 return false;
113
114 if (pointer != NULL)
116
117 return true;
118}
static bool ro_gui_options_home_ok(wimp_w w)
Definition: con_home.c:83
#define HOME_URL_FIELD
Definition: con_home.c:34
#define HOME_OK_BUTTON
Definition: con_home.c:39
static void ro_gui_options_home_default(wimp_pointer *pointer)
Definition: con_home.c:76
bool ro_gui_options_home_initialise(wimp_w w)
Definition: con_home.c:46
#define HOME_URL_GRIGHT
Definition: con_home.c:35
#define HOME_CANCEL_BUTTON
Definition: con_home.c:38
#define HOME_OPEN_STARTUP
Definition: con_home.c:36
static bool ro_gui_options_home_menu_prepare(wimp_w w, wimp_i i, wimp_menu *menu, wimp_pointer *pointer)
Callback to prepare menus in the Configure Home dialog.
Definition: con_home.c:108
#define HOME_DEFAULT_BUTTON
Definition: con_home.c:37
Automated RISC OS WIMP event handling (interface).
RISC OS option setting (interface).
void ro_gui_save_options(void)
Save the current options.
Definition: dialog.c:670
Localised message support (interface).
bool ro_gui_url_suggest_prepare_menu(void)
Builds the URL suggestion menu.
Definition: url_suggest.c:94
URL Suggestion Menu (interface).
wimp_menu * ro_gui_url_suggest_menu
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
Definition: nsoption.h:331
#define nsoption_set_bool(OPTION, VALUE)
set a boolean option in the default table
Definition: nsoption.h:344
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Definition: nsoption.h:372
#define nsoption_bool(OPTION)
Get the value of a boolean option.
Definition: nsoption.h:304
void ro_gui_set_icon_string(wimp_w w, wimp_i i, const char *text, bool is_utf8)
Set the contents of a text or sprite icon to a string.
Definition: wimp.c:269
void ro_gui_set_icon_shaded_state(wimp_w w, wimp_i i, bool state)
Set the shaded state of an icon.
Definition: wimp.c:487
const char * ro_gui_get_icon_string(wimp_w w, wimp_i i)
Read the contents of a text or sprite icon.
Definition: wimp.c:235
void ro_gui_set_icon_selected_state(wimp_w w, wimp_i i, bool state)
Set the selected state of an icon.
Definition: wimp.c:444
bool ro_gui_get_icon_selected_state(wimp_w w, wimp_i i)
Gets the selected state of an icon.
Definition: wimp.c:463
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_set_help_prefix(wimp_w w, const char *help_prefix)
Set the associated help prefix for a given window.
Definition: wimp_event.c:390
bool ro_gui_wimp_event_register_menu_gright(wimp_w w, wimp_i i, wimp_i gright, wimp_menu *menu)
Register an icon menu to be automatically handled.
Definition: wimp_event.c:1331
bool ro_gui_wimp_event_register_cancel(wimp_w w, wimp_i i)
Register a function to be called for the Cancel action on a window.
Definition: wimp_event.c:1403
bool ro_gui_wimp_event_memorise(wimp_w w)
Memorises the current state of any registered components in a window.
Definition: wimp_event.c:139
bool ro_gui_wimp_event_register_checkbox(wimp_w w, wimp_i i)
Register a checkbox to be automatically handled.
Definition: wimp_event.c:1349
bool ro_gui_wimp_event_register_menu_prepare(wimp_w w, bool(*callback)(wimp_w w, wimp_i i, wimp_menu *m, wimp_pointer *p))
Register a function to be called before a menu is (re-)opened.
Definition: wimp_event.c:1559
bool ro_gui_wimp_event_register_ok(wimp_w w, wimp_i i, bool(*callback)(wimp_w w))
Register a function to be called for the OK action on a window.
Definition: wimp_event.c:1417
bool ro_gui_wimp_event_register_button(wimp_w w, wimp_i i, void(*callback)(wimp_pointer *pointer))
Register a function to be called when a particular button is pressed.
Definition: wimp_event.c:1387
Automated RISC OS WIMP event handling (interface).