2006-01-07 03:37:54 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2005 Richard Wilson <info@tinct.net>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* 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/>.
|
2006-01-07 03:37:54 +03:00
|
|
|
*/
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
#include <stdbool.h>
|
2014-06-06 02:01:37 +04:00
|
|
|
#include <oslib/hourglass.h>
|
|
|
|
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "utils/filename.h"
|
|
|
|
#include "utils/messages.h"
|
|
|
|
|
2007-05-31 02:39:54 +04:00
|
|
|
#include "riscos/gui.h"
|
|
|
|
#include "riscos/wimp.h"
|
|
|
|
#include "riscos/wimp_event.h"
|
|
|
|
#include "riscos/configure.h"
|
|
|
|
#include "riscos/configure/configure.h"
|
2014-06-06 02:01:37 +04:00
|
|
|
#include "riscos/dialog.h"
|
2006-01-07 03:37:54 +03:00
|
|
|
|
|
|
|
|
|
|
|
#define CACHE_MEMORY_SIZE 3
|
|
|
|
#define CACHE_MEMORY_DEC 4
|
|
|
|
#define CACHE_MEMORY_INC 5
|
2014-06-08 21:29:03 +04:00
|
|
|
#define CACHE_DISC_SIZE 10
|
|
|
|
#define CACHE_DISC_DEC 11
|
|
|
|
#define CACHE_DISC_INC 12
|
|
|
|
#define CACHE_DISC_EXPIRE 15
|
|
|
|
#define CACHE_DISC_EXPIRE_DEC 16
|
|
|
|
#define CACHE_DISC_EXPIRE_INC 17
|
|
|
|
#define CACHE_DEFAULT_BUTTON 19
|
|
|
|
#define CACHE_CANCEL_BUTTON 20
|
|
|
|
#define CACHE_OK_BUTTON 21
|
2006-01-07 03:37:54 +03:00
|
|
|
|
|
|
|
static bool ro_gui_options_cache_click(wimp_pointer *pointer);
|
|
|
|
static bool ro_gui_options_cache_ok(wimp_w w);
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_cache_initialise(wimp_w w)
|
|
|
|
{
|
2006-01-07 03:37:54 +03:00
|
|
|
/* set the current values */
|
2006-11-27 18:35:18 +03:00
|
|
|
ro_gui_set_icon_decimal(w, CACHE_MEMORY_SIZE,
|
2012-03-22 13:34:34 +04:00
|
|
|
(nsoption_int(memory_cache_size) * 10) >> 20, 1);
|
2014-06-08 21:29:03 +04:00
|
|
|
ro_gui_set_icon_decimal(w, CACHE_DISC_SIZE,
|
2014-06-10 02:03:39 +04:00
|
|
|
(int) ((nsoption_uint(disc_cache_size)) >> 20), 0);
|
2014-06-08 21:29:03 +04:00
|
|
|
ro_gui_set_icon_decimal(w, CACHE_DISC_EXPIRE,
|
|
|
|
(nsoption_int(disc_cache_age)), 0);
|
2006-01-07 03:37:54 +03:00
|
|
|
|
|
|
|
/* initialise all functions for a newly created window */
|
|
|
|
ro_gui_wimp_event_register_numeric_field(w, CACHE_MEMORY_SIZE,
|
2010-04-28 15:58:37 +04:00
|
|
|
CACHE_MEMORY_INC, CACHE_MEMORY_DEC, 0, 640, 1, 1);
|
2014-06-08 21:29:03 +04:00
|
|
|
ro_gui_wimp_event_register_numeric_field(w, CACHE_DISC_SIZE,
|
2014-06-10 02:03:39 +04:00
|
|
|
CACHE_DISC_INC, CACHE_DISC_DEC, 0, 4095, 1, 0);
|
2014-06-08 21:29:03 +04:00
|
|
|
ro_gui_wimp_event_register_numeric_field(w, CACHE_DISC_EXPIRE,
|
|
|
|
CACHE_DISC_EXPIRE_INC, CACHE_DISC_EXPIRE_DEC, 1, 3650,
|
|
|
|
1, 0);
|
2006-01-07 03:37:54 +03:00
|
|
|
ro_gui_wimp_event_register_mouse_click(w, ro_gui_options_cache_click);
|
|
|
|
ro_gui_wimp_event_register_cancel(w, CACHE_CANCEL_BUTTON);
|
|
|
|
ro_gui_wimp_event_register_ok(w, CACHE_OK_BUTTON,
|
|
|
|
ro_gui_options_cache_ok);
|
|
|
|
ro_gui_wimp_event_set_help_prefix(w, "HelpCacheConfig");
|
|
|
|
ro_gui_wimp_event_memorise(w);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_cache_click(wimp_pointer *pointer)
|
|
|
|
{
|
2006-01-07 03:37:54 +03:00
|
|
|
switch (pointer->i) {
|
|
|
|
case CACHE_DEFAULT_BUTTON:
|
|
|
|
/* set the default values */
|
|
|
|
ro_gui_set_icon_decimal(pointer->w, CACHE_MEMORY_SIZE,
|
2014-06-08 21:29:03 +04:00
|
|
|
120, 1);
|
|
|
|
ro_gui_set_icon_decimal(pointer->w, CACHE_DISC_SIZE,
|
|
|
|
1024, 0);
|
|
|
|
ro_gui_set_icon_decimal(pointer->w, CACHE_DISC_EXPIRE,
|
|
|
|
28, 0);
|
2006-01-07 03:37:54 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-27 02:29:15 +04:00
|
|
|
bool ro_gui_options_cache_ok(wimp_w w)
|
|
|
|
{
|
2012-03-22 13:34:34 +04:00
|
|
|
nsoption_set_int(memory_cache_size,
|
|
|
|
(((ro_gui_get_icon_decimal(w,
|
|
|
|
CACHE_MEMORY_SIZE, 1) + 1) << 20) - 1) / 10);
|
2014-06-10 02:03:39 +04:00
|
|
|
nsoption_set_uint(disc_cache_size,
|
|
|
|
(uint) (ro_gui_get_icon_decimal(w,
|
|
|
|
CACHE_DISC_SIZE, 0) << 20));
|
2014-06-08 21:29:03 +04:00
|
|
|
nsoption_set_int(disc_cache_age,
|
|
|
|
ro_gui_get_icon_decimal(w, CACHE_DISC_EXPIRE, 0));
|
2006-01-07 03:37:54 +03:00
|
|
|
|
|
|
|
ro_gui_save_options();
|
|
|
|
return true;
|
|
|
|
}
|