[solang/gsettings] Zoom factor is now saved and restored



commit 62ee612bcec364f066bd208ad7254a322f43dee6
Author: Florent Thévenet <feuloren free fr>
Date:   Tue Jun 22 12:15:30 2010 +0200

    Zoom factor is now saved and restored

 data/solang.gschema.xml           |    9 ++++++++
 src/renderer/browser-renderer.cpp |   38 ++++++++++++++++++++++--------------
 src/renderer/browser-renderer.h   |    2 +
 3 files changed, 34 insertions(+), 15 deletions(-)
---
diff --git a/data/solang.gschema.xml b/data/solang.gschema.xml
index bb6dd13..f08ba98 100644
--- a/data/solang.gschema.xml
+++ b/data/solang.gschema.xml
@@ -2,6 +2,10 @@
   <schema id="org.gnome.solang" path="/org/gnome/solang/">
     <child name="uistate" schema="org.gnome.solang.uistate" />
     <child name="keys" schema="org.gnome.solang.keys" />
+    <child name="browser" schema="org.gnome.solang.browser" />
+  </schema>
+
+  <schema id="org.gnome.solang.browser" path="/org/gnome/solang/browser/">
     <key name="background-color" type="s">
       <default>""</default>
       <summary>Background color</summary>
@@ -12,6 +16,11 @@
       <summary>Use Background color</summary>
       <description>If True, the icon view will use the specified background-color instead of the gtk theme color.</description>
     </key>
+    <key name="zoom-value" type="d">
+      <default>-1</default>
+      <summary>Zoom factor</summary>
+      <description>Zoom factor for the thumbnails.</description>
+    </key>
   </schema>
     
   <schema id="org.gnome.solang.uistate" path="/org/gnome/solang/uistate/">
diff --git a/src/renderer/browser-renderer.cpp b/src/renderer/browser-renderer.cpp
index f6042ea..30b975c 100644
--- a/src/renderer/browser-renderer.cpp
+++ b/src/renderer/browser-renderer.cpp
@@ -153,6 +153,7 @@ BrowserRenderer::BrowserRenderer() throw() :
     zoomValue_(initialZoomValue),
     pageNum_(-1),
     contextID_(),
+    settings_(g_settings_new("org.gnome.solang.browser")),
     signalInitEnd_(),
     signalListStoreChangeBegin_(),
     signalListStoreChangeEnd_(),
@@ -249,11 +250,19 @@ BrowserRenderer::BrowserRenderer() throw() :
                       &BrowserRenderer::on_action_view_slideshow));
 
     {
+        double saved_value = g_settings_get_double(settings_, "zoom-value");
+        if (saved_value >= lowerZoomValue && saved_value <= higherZoomValue)
+        {
+            zoomValue_ = saved_value;
+            set_thumbnail_size();
+        }
+
+
         const Glib::RefPtr<ScaleAction> scale_action
             = ScaleAction::create(
                   "ActionViewBrowserZoom",
                   _("Enlarge or shrink the thumbnails"),
-                  Gtk::Adjustment(initialZoomValue,
+                  Gtk::Adjustment(zoomValue_,
                                   lowerZoomValue,
                                   higherZoomValue,
                                   stepZoomValue,
@@ -352,6 +361,12 @@ BrowserRenderer::BrowserRenderer() throw() :
         Gtk::AccelKey("<alt>End"),
         sigc::mem_fun(*this, &BrowserRenderer::on_action_go_last));
 
+    //we set the background color of the thumbnailView from GSettings
+    if (g_settings_get_boolean(settings_, "use-background-color")) {
+        Glib::ustring color = g_settings_get_string(settings_, "background-color");
+        thumbnailView_.set_base_color(color);
+    }
+
     vBox_.pack_start(hBox_, Gtk::PACK_SHRINK, 0);
 
     scrolledWindow_.set_policy(Gtk::POLICY_AUTOMATIC,
@@ -411,13 +426,6 @@ BrowserRenderer::init(Application & application) throw()
         = application.get_renderer_registry();
     renderer_registry.add(this);
 
-    //we set the background color of the thumbnailView from GSettings
-    GSettings * settings = application.get_settings();
-    if (g_settings_get_boolean(settings, "use-background-color")) {
-        Glib::ustring color = g_settings_get_string(settings, "background-color");
-        thumbnailView_.set_base_color(color);
-    }
-
     const ListStorePtr & list_store = application.get_list_store();
 
     treeModelFilter_ = Gtk::TreeModelFilter::create(list_store);
@@ -471,6 +479,8 @@ BrowserRenderer::init(Application & application) throw()
 void
 BrowserRenderer::final(Application & application) throw()
 {
+    g_settings_set_double(settings_, "zoom-value", zoomValue_);
+
     signalItemActivated_.disconnect();
     signalListStoreChangeBegin_.disconnect();
     signalListStoreChangeEnd_.disconnect();
@@ -626,9 +636,8 @@ BrowserRenderer::on_action_change_background_color(
     thumbnailView_.set_base_color(color_code);
 
     //then we store it with GSettings
-    GSettings * settings = application_->get_settings();
-    g_settings_set_boolean(settings, "use-background-color", TRUE);
-    g_settings_set_string(settings, "background-color", color_code.data());
+    g_settings_set_boolean(settings_, "use-background-color", TRUE);
+    g_settings_set_string(settings_, "background-color", color_code.data());
 }
 
 void
@@ -636,8 +645,7 @@ BrowserRenderer::on_action_unset_background_color() throw()
 {
     thumbnailView_.unset_base_color();
 
-    GSettings * settings = application_->get_settings();
-    g_settings_set_boolean(settings, "use-background-color", FALSE);
+    g_settings_set_boolean(settings_, "use-background-color", FALSE);
 }
 
 void
@@ -825,11 +833,11 @@ BrowserRenderer::on_action_view_zoom_changed(
 
     connection.disconnect();
     connection
-        = Glib::signal_timeout().connect_seconds(
+        = Glib::signal_timeout().connect(
               sigc::bind_return(
                   sigc::mem_fun(*this,
                                 &BrowserRenderer::reload), false),
-              1, Glib::PRIORITY_DEFAULT);
+              300, Glib::PRIORITY_DEFAULT);
 }
 
 void
diff --git a/src/renderer/browser-renderer.h b/src/renderer/browser-renderer.h
index a73954e..2257fae 100644
--- a/src/renderer/browser-renderer.h
+++ b/src/renderer/browser-renderer.h
@@ -201,6 +201,8 @@ class BrowserRenderer :
 
         guint contextID_;
 
+        GSettings * settings_;
+
         sigc::connection signalInitEnd_;
 
         sigc::connection signalItemActivated_;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]