NetSurf
con_cache.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 <oslib/hourglass.h>
21
22#include "utils/nsoption.h"
23#include "utils/filename.h"
24#include "utils/messages.h"
25
26#include "riscos/gui.h"
27#include "riscos/wimp.h"
28#include "riscos/wimp_event.h"
29#include "riscos/configure.h"
31#include "riscos/dialog.h"
32
33
34#define CACHE_MEMORY_SIZE 3
35#define CACHE_MEMORY_DEC 4
36#define CACHE_MEMORY_INC 5
37#define CACHE_DISC_SIZE 10
38#define CACHE_DISC_DEC 11
39#define CACHE_DISC_INC 12
40#define CACHE_DISC_EXPIRE 15
41#define CACHE_DISC_EXPIRE_DEC 16
42#define CACHE_DISC_EXPIRE_INC 17
43#define CACHE_DEFAULT_BUTTON 19
44#define CACHE_CANCEL_BUTTON 20
45#define CACHE_OK_BUTTON 21
46
47static bool ro_gui_options_cache_click(wimp_pointer *pointer);
48static bool ro_gui_options_cache_ok(wimp_w w);
49
51{
52 /* set the current values */
54 (nsoption_int(memory_cache_size) * 10) >> 20, 1);
56 (int) ((nsoption_uint(disc_cache_size)) >> 20), 0);
58 (nsoption_int(disc_cache_age)), 0);
59
60 /* initialise all functions for a newly created window */
62 CACHE_MEMORY_INC, CACHE_MEMORY_DEC, 0, 640, 1, 1);
64 CACHE_DISC_INC, CACHE_DISC_DEC, 0, 4095, 1, 0);
67 1, 0);
72 ro_gui_wimp_event_set_help_prefix(w, "HelpCacheConfig");
74 return true;
75
76}
77
78bool ro_gui_options_cache_click(wimp_pointer *pointer)
79{
80 switch (pointer->i) {
82 /* set the default values */
84 120, 1);
86 1024, 0);
88 28, 0);
89 return true;
90 }
91 return false;
92}
93
95{
96 nsoption_set_int(memory_cache_size,
98 CACHE_MEMORY_SIZE, 1) + 1) << 20) - 1) / 10);
99 nsoption_set_uint(disc_cache_size,
100 (uint) (ro_gui_get_icon_decimal(w,
101 CACHE_DISC_SIZE, 0) << 20));
102 nsoption_set_int(disc_cache_age,
104
106 return true;
107}
#define CACHE_MEMORY_INC
Definition: con_cache.c:36
#define CACHE_DISC_DEC
Definition: con_cache.c:38
#define CACHE_CANCEL_BUTTON
Definition: con_cache.c:44
bool ro_gui_options_cache_initialise(wimp_w w)
Definition: con_cache.c:50
#define CACHE_DISC_EXPIRE_DEC
Definition: con_cache.c:41
#define CACHE_DISC_SIZE
Definition: con_cache.c:37
#define CACHE_DEFAULT_BUTTON
Definition: con_cache.c:43
static bool ro_gui_options_cache_click(wimp_pointer *pointer)
Definition: con_cache.c:78
#define CACHE_DISC_INC
Definition: con_cache.c:39
#define CACHE_MEMORY_SIZE
Definition: con_cache.c:34
static bool ro_gui_options_cache_ok(wimp_w w)
Definition: con_cache.c:94
#define CACHE_DISC_EXPIRE
Definition: con_cache.c:40
#define CACHE_DISC_EXPIRE_INC
Definition: con_cache.c:42
#define CACHE_MEMORY_DEC
Definition: con_cache.c:35
#define CACHE_OK_BUTTON
Definition: con_cache.c:45
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).
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
Definition: nsoption.h:279
#define nsoption_set_int(OPTION, VALUE)
set an integer option in the default table
Definition: nsoption.h:314
#define nsoption_uint(OPTION)
Get the value of an unsigned integer option.
Definition: nsoption.h:288
#define nsoption_set_uint(OPTION, VALUE)
set an unsigned integer option in the default table
Definition: nsoption.h:317
int ro_gui_get_icon_decimal(wimp_w w, wimp_i i, int decimal_places)
Get the contents of an icon as a number.
Definition: wimp.c:423
void ro_gui_set_icon_decimal(wimp_w w, wimp_i i, int value, int decimal_places)
Set the contents of an icon to a number.
Definition: wimp.c:392
General RISC OS WIMP/OS library functions (interface).
bool ro_gui_wimp_event_register_numeric_field(wimp_w w, wimp_i i, wimp_i up, wimp_i down, int min, int max, int stepping, int decimal_places)
Register a numeric field to be automatically handled.
Definition: wimp_event.c:1287
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_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_mouse_click(wimp_w w, bool(*callback)(wimp_pointer *pointer))
Register a function to be called for all mouse-clicks to icons in a window that don't have registered...
Definition: wimp_event.c:1439
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
Automated RISC OS WIMP event handling (interface).