diff options
author | raveit65 <[email protected]> | 2016-05-08 12:08:30 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-05-26 16:15:22 +0200 |
commit | 3551d1c5e7fff4665b12b607f87529995307338c (patch) | |
tree | 86eef2ae2a402866029bc404264ca0ccdf841fcd | |
parent | f800ce9e483940f5969bf1b29506f149b4a0511e (diff) | |
download | atril-3551d1c5e7fff4665b12b607f87529995307338c.tar.bz2 atril-3551d1c5e7fff4665b12b607f87529995307338c.tar.xz |
ev-window: add new gsetting to set the page cache size
https://bugzilla.gnome.org/show_bug.cgi?id=642683
inspired from:
https://git.gnome.org/browse/evince/commit/?id=392d8e3
https://git.gnome.org/browse/evince/commit/?id=e656398
-rw-r--r-- | data/org.mate.Atril.gschema.xml | 6 | ||||
-rw-r--r-- | shell/ev-window.c | 29 |
2 files changed, 32 insertions, 3 deletions
diff --git a/data/org.mate.Atril.gschema.xml b/data/org.mate.Atril.gschema.xml index 04195a33..439d11e7 100644 --- a/data/org.mate.Atril.gschema.xml +++ b/data/org.mate.Atril.gschema.xml @@ -25,6 +25,12 @@ <default>nothing</default> <summary>The URI of the directory last used to save a picture</summary> </key> + <key name="page-cache-size" type="u"> + <default>50</default> + <summary>Page cache size in MiB</summary> + <description>The maximum size that will be used to cache rendered pages, limits maximum zoom level.</description> + </key> + <child name="default" schema="org.mate.Atril.Default"/> </schema> diff --git a/shell/ev-window.c b/shell/ev-window.c index 42505b77..4092d77f 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -253,6 +253,7 @@ struct _EvWindowPrivate { #define GS_SCHEMA_NAME "org.mate.Atril" #define GS_OVERRIDE_RESTRICTIONS "override-restrictions" +#define GS_PAGE_CACHE_SIZE "page-cache-size" #define GS_AUTO_RELOAD "auto-reload" #define GS_LAST_DOCUMENT_DIRECTORY "document-directory" #define GS_LAST_PICTURES_DIRECTORY "pictures-directory" @@ -272,7 +273,6 @@ struct _EvWindowPrivate { #define EV_TOOLBARS_FILENAME "atril-toolbar.xml" #define MIN_SCALE 0.05409 -#define PAGE_CACHE_SIZE 52428800 /* 50MB */ #define MAX_RECENT_ITEM_LEN (40) @@ -1379,6 +1379,18 @@ setup_view_from_metadata (EvWindow *window) } static void +page_cache_size_changed (GSettings *settings, + gchar *key, + EvWindow *ev_window) +{ + guint page_cache_mb; + + page_cache_mb = g_settings_get_uint (settings, GS_PAGE_CACHE_SIZE); + ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), + page_cache_mb * 1024 * 1024); +} + +static void ev_window_setup_default (EvWindow *ev_window) { EvDocumentModel *model = ev_window->priv->model; @@ -1494,6 +1506,11 @@ ev_window_ensure_settings (EvWindow *ev_window) "changed::"GS_OVERRIDE_RESTRICTIONS, G_CALLBACK (override_restrictions_changed), ev_window); + g_signal_connect (priv->settings, + "changed::"GS_PAGE_CACHE_SIZE, + G_CALLBACK (page_cache_size_changed), + ev_window); + return priv->settings; } @@ -4335,17 +4352,19 @@ ev_window_update_max_min_scale (EvWindow *window) gdouble min_width, min_height; gdouble width, height; gdouble max_scale; + guint page_cache_mb; gint rotation = ev_document_model_get_rotation (window->priv->model); if (!window->priv->document) return; + page_cache_mb = g_settings_get_uint (window->priv->settings, GS_PAGE_CACHE_SIZE); dpi = get_screen_dpi (window) / 72.0; ev_document_get_min_page_size (window->priv->document, &min_width, &min_height); width = (rotation == 0 || rotation == 180) ? min_width : min_height; height = (rotation == 0 || rotation == 180) ? min_height : min_width; - max_scale = sqrt (PAGE_CACHE_SIZE / (width * dpi * 4 * height * dpi)); + max_scale = sqrt ((page_cache_mb * 1024 * 1024) / (width * dpi * 4 * height * dpi)); action = gtk_action_group_get_action (window->priv->action_group, ZOOM_CONTROL_ACTION); @@ -7445,6 +7464,7 @@ ev_window_init (EvWindow *ev_window) GtkWidget *menuitem; EggToolbarsModel *toolbars_model; GObject *mpkeys; + guint page_cache_mb; gchar *ui_path; #ifdef ENABLE_DBUS GDBusConnection *connection; @@ -7719,7 +7739,10 @@ ev_window_init (EvWindow *ev_window) ev_window, 0); #endif #endif - ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), PAGE_CACHE_SIZE); + page_cache_mb = g_settings_get_uint (ev_window_ensure_settings (ev_window), + GS_PAGE_CACHE_SIZE); + ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), + page_cache_mb * 1024 * 1024); ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model); ev_window->priv->password_view = ev_password_view_new (GTK_WINDOW (ev_window)); |