[solang/gsettings: 2/4] User can choose the background color of the IconView



commit 4409f2d57fcf58c296b510f97caa466261a5eac4
Author: Florent Thévenet <feuloren free fr>
Date:   Sat May 15 08:56:00 2010 +0200

    User can choose the background color of the IconView

 src/renderer/browser-renderer.cpp |   65 +++++++++++++++++++++++++++++++++++++
 src/renderer/browser-renderer.h   |    6 +++
 src/renderer/thumbnail-view.cpp   |   23 +++++++++++++
 src/renderer/thumbnail-view.h     |    6 +++
 4 files changed, 100 insertions(+), 0 deletions(-)
---
diff --git a/src/renderer/browser-renderer.cpp b/src/renderer/browser-renderer.cpp
index 5d644a9..27d26bc 100644
--- a/src/renderer/browser-renderer.cpp
+++ b/src/renderer/browser-renderer.cpp
@@ -195,6 +195,43 @@ BrowserRenderer::BrowserRenderer() throw() :
 
     actionGroup_->add(
         Gtk::Action::create(
+            "ActionViewColorMenu", _("Background _Color")));
+
+    {
+        actionGroup_->add(
+            Gtk::Action::create(
+                "ActionViewBrowserColorUnset", _("Use _Theme Color"),
+                _("Set the background color to theme color.")),
+            sigc::mem_fun(*this, 
+                &BrowserRenderer::on_action_unset_background_color));
+
+        actionGroup_->add(
+            Gtk::Action::create(
+                "ActionViewBrowserColorLG", _("_Light Gray"),
+                _("Set the background color to Light Gray.")),
+            sigc::bind<Glib::ustring>( sigc::mem_fun(
+                    *this, &BrowserRenderer::on_action_change_background_color),
+                "#A9A9A9"));
+
+        actionGroup_->add(
+            Gtk::Action::create(
+                "ActionViewBrowserColorG", _("_Gray"),
+                _("Set the background color to Gray.")),
+            sigc::bind<Glib::ustring>( sigc::mem_fun(
+                    *this, &BrowserRenderer::on_action_change_background_color),
+                "#6B6B6B"));
+
+        actionGroup_->add(
+            Gtk::Action::create(
+                "ActionViewBrowserColorDG", _("_Dark Gray"),
+                _("Set the background color to Dark Gray.")),
+            sigc::bind<Glib::ustring>( sigc::mem_fun(
+                    *this, &BrowserRenderer::on_action_change_background_color),
+                "#333333"));
+    }
+
+    actionGroup_->add(
+        Gtk::Action::create(
             "ActionEditAddToExportQueue", Gtk::Stock::ADD,
             _("_Add to Export Queue")),
         sigc::mem_fun(*this,
@@ -372,6 +409,13 @@ BrowserRenderer::init(Application & application) throw()
     RendererRegistry & renderer_registry
         = 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();
 
@@ -575,6 +619,27 @@ BrowserRenderer::on_action_go_last() throw()
 }
 
 void
+BrowserRenderer::on_action_change_background_color(
+                    Glib::ustring color_code) throw()
+{
+    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());
+}
+
+void
+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);
+}
+
+void
 BrowserRenderer::on_action_view_slideshow() throw()
 {
     RendererRegistry & renderer_registry
diff --git a/src/renderer/browser-renderer.h b/src/renderer/browser-renderer.h
index 9c4fd48..73e18a8 100644
--- a/src/renderer/browser-renderer.h
+++ b/src/renderer/browser-renderer.h
@@ -121,6 +121,12 @@ class BrowserRenderer :
         on_action_go_last() throw();
 
         void
+        on_action_change_background_color(Glib::ustring color_code) throw();
+
+        void
+        on_action_unset_background_color() throw();
+
+        void
         on_dock_item_parent_changed(Gtk::Widget * previous_parent)
                                     throw();
 
diff --git a/src/renderer/thumbnail-view.cpp b/src/renderer/thumbnail-view.cpp
index d85330d..fd4a365 100644
--- a/src/renderer/thumbnail-view.cpp
+++ b/src/renderer/thumbnail-view.cpp
@@ -153,6 +153,8 @@ ThumbnailView::configure(gint thumbnail_renderer_width,
     show_all_children();
 }
 
+
+
 PhotoPtr
 ThumbnailView::get_photo_from_path(const Gtk::TreeModel::Path & path)
                                    throw()
@@ -274,6 +276,27 @@ ThumbnailView::popup_menu(GdkEventButton * event) throw()
 }
 
 void
+ThumbnailView::set_base_color(Glib::ustring color_code) throw()
+{
+    const Gdk::Color color(color_code);
+    modify_base(Gtk::STATE_ACTIVE, color);
+    modify_base(Gtk::STATE_NORMAL, color);
+    modify_base(Gtk::STATE_PRELIGHT, color);
+    modify_base(Gtk::STATE_SELECTED, color);
+    modify_base(Gtk::STATE_INSENSITIVE, color);
+}
+
+void
+ThumbnailView::unset_base_color() throw()
+{
+    unset_base(Gtk::STATE_ACTIVE);
+    unset_base(Gtk::STATE_NORMAL);
+    unset_base(Gtk::STATE_PRELIGHT);
+    unset_base(Gtk::STATE_SELECTED);
+    unset_base(Gtk::STATE_INSENSITIVE);
+}
+
+void
 ThumbnailView::set_thumbnail_width(gint width) throw()
 {
     rendererThumbnail_.property_width().set_value(width);
diff --git a/src/renderer/thumbnail-view.h b/src/renderer/thumbnail-view.h
index 643b912..c30598c 100644
--- a/src/renderer/thumbnail-view.h
+++ b/src/renderer/thumbnail-view.h
@@ -60,6 +60,12 @@ class ThumbnailView :
         const UIManagerPtr &
         get_ui_manager() throw();
 
+        void
+        set_base_color(Glib::ustring color_code) throw();
+
+        void
+        unset_base_color() throw();
+
     protected:
         PhotoPtr
         get_photo_from_path(const Gtk::TreeModel::Path & path) throw();



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