From 8e29e517d59f0d04dd2d09c6b8760aa1236a1abf Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 9 Jun 2014 13:10:56 +0100 Subject: fix disc cache size option to be unsigned --- amiga/gui_options.c | 6 +++--- desktop/netsurf.c | 2 +- desktop/options.h | 2 +- gtk/dialogs/preferences.c | 23 ++++++++++++++++++++++- gtk/res/options.gtk2.ui | 8 ++++---- gtk/res/options.gtk3.ui | 6 +++--- utils/nsoption.h | 3 +++ 7 files changed, 37 insertions(+), 13 deletions(-) diff --git a/amiga/gui_options.c b/amiga/gui_options.c index 0b01a93d4..3a6451b97 100755 --- a/amiga/gui_options.c +++ b/amiga/gui_options.c @@ -1157,7 +1157,7 @@ void ami_gui_opts_open(void) LAYOUT_AddChild, gow->objects[GID_OPTS_CACHE_DISC] = IntegerObject, GA_ID, GID_OPTS_CACHE_DISC, GA_RelVerify, TRUE, - INTEGER_Number, nsoption_int(disc_cache_size) / 1048576, + INTEGER_Number, nsoption_uint(disc_cache_size) / 1048576, INTEGER_Minimum, 0, INTEGER_Maximum, 4096, INTEGER_Arrows, TRUE, @@ -1750,8 +1750,8 @@ void ami_gui_opts_use(bool save) GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_MEM],(ULONG *)&nsoption_int(memory_cache_size)); nsoption_set_int(memory_cache_size, nsoption_int(memory_cache_size) * 1048576); - GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_int(disc_cache_size)); - nsoption_set_int(disc_cache_size, nsoption_int(disc_cache_size) * 1048576); + GetAttr(INTEGER_Number,gow->objects[GID_OPTS_CACHE_DISC],(ULONG *)&nsoption_uint(disc_cache_size)); + nsoption_set_uint(disc_cache_size, nsoption_uint(disc_cache_size) * 1048576); GetAttr(GA_Selected,gow->objects[GID_OPTS_OVERWRITE],(ULONG *)&data); if (data) { diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 153810705..a1bc42b93 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -191,7 +191,7 @@ nserror netsurf_init(const char *messages, const char *store_path) hlcache_parameters.llcache.limit -= image_cache_parameters.limit; /* set backing store target limit */ - hlcache_parameters.llcache.store.limit = nsoption_int(disc_cache_size); + hlcache_parameters.llcache.store.limit = nsoption_uint(disc_cache_size); /* set backing store hysterissi to 20% */ hlcache_parameters.llcache.store.hysteresis = (hlcache_parameters.llcache.store.limit * 20) / 100;; diff --git a/desktop/options.h b/desktop/options.h index 391dfbc08..33ecb7554 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -89,7 +89,7 @@ NSOPTION_STRING(accept_charset, NULL) NSOPTION_INTEGER(memory_cache_size, 12 * 1024 * 1024) /** Preferred expiry size of disc cache / bytes. */ -NSOPTION_INTEGER(disc_cache_size, 1024 * 1024 * 1024) +NSOPTION_UINT(disc_cache_size, 1024 * 1024 * 1024) /** Preferred expiry age of disc cache / days. */ NSOPTION_INTEGER(disc_cache_age, 28) diff --git a/gtk/dialogs/preferences.c b/gtk/dialogs/preferences.c index f80500dfa..58bb8b4d9 100644 --- a/gtk/dialogs/preferences.c +++ b/gtk/dialogs/preferences.c @@ -108,6 +108,27 @@ nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \ ((gdouble)nsoption_int(OPTION)) / MULTIPLIER); \ } +#define SPINBUTTON_UINT_SIGNALS(WIDGET, OPTION, MULTIPLIER) \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \ + struct ppref *priv); \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_valuechanged(GtkSpinButton *spinbutton, \ + struct ppref *priv) \ +{ \ + nsoption_set_uint(OPTION, \ + round(gtk_spin_button_get_value(spinbutton) * MULTIPLIER)); \ +} \ + \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv); \ +G_MODULE_EXPORT void \ +nsgtk_preferences_##WIDGET##_realize(GtkWidget *widget, struct ppref *priv) \ +{ \ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), \ + ((gdouble)nsoption_uint(OPTION)) / MULTIPLIER); \ +} + #define ENTRY_SIGNALS(WIDGET, OPTION) \ G_MODULE_EXPORT void \ nsgtk_preferences_##WIDGET##_changed(GtkEditable *editable, struct ppref *priv); \ @@ -372,7 +393,7 @@ SPINBUTTON_SIGNALS(spinHistoryAge, history_age, 1.0) SPINBUTTON_SIGNALS(spinMemoryCacheSize, memory_cache_size, (1024*1024)) /* disc cache size */ -SPINBUTTON_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024)) +SPINBUTTON_UINT_SIGNALS(spinDiscCacheSize, disc_cache_size, (1024*1024)) /* disc cache age */ diff --git a/gtk/res/options.gtk2.ui b/gtk/res/options.gtk2.ui index ebe7b91f5..b0d45bb2f 100644 --- a/gtk/res/options.gtk2.ui +++ b/gtk/res/options.gtk2.ui @@ -2653,10 +2653,10 @@ 16 - 16 - 2048 - 4 - 16 + 1024 + 4096 + 32 + 256 28 diff --git a/gtk/res/options.gtk3.ui b/gtk/res/options.gtk3.ui index a795c2bf5..02e4df47c 100644 --- a/gtk/res/options.gtk3.ui +++ b/gtk/res/options.gtk3.ui @@ -9,13 +9,13 @@ 1 - 2048 - 16 + 4096 + 1024 4 16 - 2048 + 1024 16 4 16 diff --git a/utils/nsoption.h b/utils/nsoption.h index d111729aa..134223aa5 100644 --- a/utils/nsoption.h +++ b/utils/nsoption.h @@ -308,6 +308,9 @@ int nsoption_snoptionf(char *string, size_t size, enum nsoption_e option, const /** set an integer option in the default table */ #define nsoption_set_int(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.i = VALUE +/** set an unsigned integer option in the default table */ +#define nsoption_set_uint(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.u = VALUE + /** set a colour option in the default table */ #define nsoption_set_colour(OPTION, VALUE) nsoptions[NSOPTION_##OPTION].value.c = VALUE -- cgit v1.2.3