diff options
author | raveit65 <[email protected]> | 2016-06-02 16:59:42 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2016-06-02 16:59:42 +0200 |
commit | 662f9e950be9d3e283157f9ed965931fc449aabb (patch) | |
tree | 18fa75f16abed8b2afd7e0a361c287b279f649bc | |
parent | 3a54b21cbb30473ae1773c8ff66eacde5e07d69f (diff) | |
download | atril-662f9e950be9d3e283157f9ed965931fc449aabb.tar.bz2 atril-662f9e950be9d3e283157f9ed965931fc449aabb.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 | 45 |
2 files changed, 48 insertions, 3 deletions
diff --git a/data/org.mate.Atril.gschema.xml b/data/org.mate.Atril.gschema.xml index d73069ae..d582018e 100644 --- a/data/org.mate.Atril.gschema.xml +++ b/data/org.mate.Atril.gschema.xml @@ -17,6 +17,12 @@ <summary>Automatically reload then document</summary> <description>The document is automatically reloaded on file change.</description> </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 180ce3a5..ce19a1cc 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 SIDEBAR_DEFAULT_SIZE 132 @@ -270,7 +271,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) @@ -1377,6 +1377,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; @@ -1479,6 +1491,27 @@ lockdown_changed (GSettings *settings, ev_window_setup_action_sensitivity (ev_window); } +static GSettings * +ev_window_ensure_settings (EvWindow *ev_window) +{ + EvWindowPrivate *priv = ev_window->priv; + + if (priv->settings != NULL) + return priv->settings; + + priv->settings = g_settings_new (GS_SCHEMA_NAME); + g_signal_connect (priv->settings, + "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; +} + static gboolean ev_window_setup_document (EvWindow *ev_window) { @@ -4300,17 +4333,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); @@ -7398,6 +7433,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; @@ -7672,7 +7708,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)); |