[Xfce4-commits] <ristretto:ristretto-0.0> Implement bgcolor settings

Stephan Arts noreply at xfce.org
Sun Oct 23 19:12:44 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to be4b10beab50a7a9e3ceb6e84fbfd65cd223395f (commit)
       from c2a9945bcada416a23698705f6402560405c756c (commit)

commit be4b10beab50a7a9e3ceb6e84fbfd65cd223395f
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Apr 22 00:40:08 2009 +0200

    Implement bgcolor settings

 src/picture_viewer.c     |   14 ++++-
 src/preferences_dialog.c |   71 ++++++++++++++++++++++----
 src/settings.c           |  127 ++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 184 insertions(+), 28 deletions(-)

diff --git a/src/picture_viewer.c b/src/picture_viewer.c
index 1d5d0b1..9b803a1 100644
--- a/src/picture_viewer.c
+++ b/src/picture_viewer.c
@@ -27,6 +27,7 @@
 
 #include "image.h"
 #include "picture_viewer.h"
+#include "settings.h"
 
 typedef enum
 {
@@ -389,10 +390,18 @@ rstto_picture_viewer_expose(GtkWidget *widget, GdkEventExpose *event)
 static void
 rstto_picture_viewer_paint (GtkWidget *widget)
 {
+    RsttoSettings *settings_manager = rstto_settings_new();
     RsttoPictureViewer *viewer = RSTTO_PICTURE_VIEWER(widget);
     GdkPixbuf *pixbuf = viewer->priv->dst_pixbuf;
     GdkColor color;
     GdkColor line_color;
+    GValue bg_color = {0, }, bg_color_override = {0, };
+    g_value_init (&bg_color, GDK_TYPE_COLOR);
+    g_value_init (&bg_color_override, G_TYPE_BOOLEAN);
+
+    g_object_get_property (G_OBJECT(settings_manager), "bgcolor", &bg_color);
+    g_object_get_property (G_OBJECT(settings_manager), "bgcolor-override", &bg_color_override);
+
 
     color.pixel = 0x0;
     line_color.pixel = 0x0;
@@ -405,9 +414,9 @@ rstto_picture_viewer_paint (GtkWidget *widget)
         GdkPixmap *buffer = gdk_pixmap_new(NULL, widget->allocation.width, widget->allocation.height, gdk_drawable_get_depth(widget->window));
         GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(buffer));
 
-        if (viewer->priv->bg_color)
+        if (g_value_get_boxed (&bg_color) && g_value_get_boolean (&bg_color_override))
         {
-            gdk_gc_set_foreground(gc, viewer->priv->bg_color);
+            gdk_gc_set_foreground(gc, g_value_get_boxed (&bg_color));
         }
         else
         {
@@ -561,6 +570,7 @@ rstto_picture_viewer_paint (GtkWidget *widget)
                         widget->allocation.height);
         g_object_unref(buffer);
    }
+   g_object_unref (settings_manager);
 }
 
 static void
diff --git a/src/preferences_dialog.c b/src/preferences_dialog.c
index 62559b7..917c89f 100644
--- a/src/preferences_dialog.c
+++ b/src/preferences_dialog.c
@@ -29,6 +29,12 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *);
 static void
 rstto_preferences_dialog_class_init(RsttoPreferencesDialogClass *);
 
+
+static void
+cb_rstto_preferences_dialog_bgcolor_override_toggled (GtkToggleButton *, gpointer);
+static void
+cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *, gpointer);
+
 static GtkWidgetClass *parent_class = NULL;
 
 GType
@@ -68,7 +74,7 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
     GtkWidget *bgcolor_frame, *bgcolor_vbox, *bgcolor_hbox, *bgcolor_button;
     GtkWidget *cache_frame, *cache_vbox;
     GtkWidget *scaling_frame, *scaling_vbox;
-    GtkObject *cache_hbox, *cache_adjustment, *cache_spin_button, *cache_preload_check_button;
+    GtkWidget *cache_hbox, *cache_adjustment, *cache_spin_button, *cache_preload_check_button;
     GtkWidget *toolbar_vbox, *toolbar_frame;
 
     GtkWidget *widget;
@@ -85,9 +91,13 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
     widget = gtk_check_button_new_with_label (_("Override background color:"));
     bgcolor_hbox = gtk_hbox_new(FALSE, 4);
     bgcolor_button = gtk_color_button_new();
-    gtk_container_add (GTK_CONTAINER (bgcolor_hbox), widget);
-    gtk_container_add (GTK_CONTAINER (bgcolor_hbox), bgcolor_button);
-    gtk_container_add (GTK_CONTAINER (bgcolor_vbox), bgcolor_hbox);
+    gtk_box_pack_start (GTK_BOX (bgcolor_hbox), widget, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (bgcolor_hbox), bgcolor_button, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (bgcolor_vbox), bgcolor_hbox, FALSE, FALSE, 0);
+    
+    /* connect signals */
+    g_signal_connect (G_OBJECT (widget), "toggled", (GCallback)cb_rstto_preferences_dialog_bgcolor_override_toggled, bgcolor_button);
+    g_signal_connect (G_OBJECT (bgcolor_button), "color-set", G_CALLBACK (cb_rstto_preferences_dialog_bgcolor_color_set), NULL);
 
     cache_vbox = gtk_vbox_new(FALSE, 0);
     cache_frame = xfce_create_framebox_with_content (_("Image cache"), cache_vbox);
@@ -98,8 +108,8 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
     cache_hbox = gtk_hbox_new(FALSE, 4);
     cache_spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(cache_adjustment), 1.0, 0);
     cache_preload_check_button = gtk_check_button_new_with_label (_("Preload images"));
-    gtk_container_add (GTK_CONTAINER (cache_hbox), widget);
-    gtk_container_add (GTK_CONTAINER (cache_hbox), cache_spin_button);
+    gtk_box_pack_start (GTK_BOX (cache_hbox), widget, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (cache_hbox), cache_spin_button, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (cache_vbox), cache_hbox, FALSE, FALSE, 0);
     gtk_box_pack_start (GTK_BOX (cache_vbox), cache_preload_check_button, FALSE, FALSE, 0);
 
@@ -113,16 +123,16 @@ rstto_preferences_dialog_init(RsttoPreferencesDialog *dialog)
     gtk_box_pack_start (GTK_BOX (slideshow_main_vbox), slideshow_bgcolor_frame, FALSE, FALSE, 0);
     
     widget = gtk_radio_button_new_with_label (NULL, _("Black"));
-    gtk_container_add (GTK_CONTAINER (slideshow_bgcolor_vbox), widget);
+    gtk_box_pack_start (GTK_BOX (slideshow_bgcolor_vbox), widget, FALSE, FALSE, 0);
     widget = gtk_radio_button_new_with_label_from_widget (widget, _("Colorify (no idea how to call this feature)"));
-    gtk_container_add (GTK_CONTAINER (slideshow_bgcolor_vbox), widget);
+    gtk_box_pack_start (GTK_BOX (slideshow_bgcolor_vbox), widget, FALSE, FALSE, 0);
 
     widget = gtk_radio_button_new_with_label_from_widget (widget, _("Custom:"));
     slideshow_bgcolor_hbox = gtk_hbox_new(FALSE, 4);
     slideshow_bgcolor_button = gtk_color_button_new();
-    gtk_container_add (GTK_CONTAINER (slideshow_bgcolor_hbox), widget);
-    gtk_container_add (GTK_CONTAINER (slideshow_bgcolor_hbox), slideshow_bgcolor_button);
-    gtk_container_add (GTK_CONTAINER (slideshow_bgcolor_vbox), slideshow_bgcolor_hbox);
+    gtk_box_pack_start (GTK_BOX (slideshow_bgcolor_hbox), widget, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (slideshow_bgcolor_hbox), slideshow_bgcolor_button, FALSE, FALSE, 0);
+    gtk_box_pack_start (GTK_BOX (slideshow_bgcolor_vbox), slideshow_bgcolor_hbox, FALSE, FALSE, 0);
 
     timeout_vbox = gtk_vbox_new(FALSE, 0);
     timeout_frame = xfce_create_framebox_with_content (_("Timeout"), timeout_vbox);
@@ -199,3 +209,42 @@ rstto_preferences_dialog_new (GtkWindow *parent)
 
     return dialog;
 }
+
+
+static void
+cb_rstto_preferences_dialog_bgcolor_override_toggled (GtkToggleButton *button, 
+                                                      gpointer user_data)
+{
+    GtkWidget *color_button = GTK_WIDGET (user_data);
+    RsttoSettings *settings = rstto_settings_new();
+    
+    GValue bgcolor_override_val = {0, };
+    g_value_init (&bgcolor_override_val, G_TYPE_BOOLEAN);
+
+    if (gtk_toggle_button_get_active (button))
+    {
+        g_value_set_boolean (&bgcolor_override_val, TRUE);
+        gtk_widget_set_sensitive (color_button, TRUE);
+    }
+    else
+    {
+        g_value_set_boolean (&bgcolor_override_val, FALSE);
+        gtk_widget_set_sensitive (color_button, FALSE);
+    }
+
+    g_object_set_property (G_OBJECT (settings), "bgcolor-override", &bgcolor_override_val);
+    
+}
+
+static void
+cb_rstto_preferences_dialog_bgcolor_color_set (GtkColorButton *button, gpointer user_data)
+{
+    RsttoSettings *settings = rstto_settings_new();
+
+    GValue bgcolor_val = {0, };
+    g_value_init (&bgcolor_val, GDK_TYPE_COLOR);
+
+    g_object_get_property (G_OBJECT(button), "color", &bgcolor_val);
+    g_object_set_property (G_OBJECT(settings), "bgcolor", &bgcolor_val);
+    
+}
diff --git a/src/settings.c b/src/settings.c
index c6380d0..03abe00 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -54,12 +54,17 @@ enum
 {
     PROP_0,
     PROP_SHOW_TOOLBAR,
+    PROP_TOOLBAR_OPEN_FOLDER,
+    PROP_PRELOAD_IMAGE,
     PROP_WINDOW_WIDTH,
     PROP_WINDOW_HEIGHT,
     PROP_BGCOLOR,
+    PROP_BGCOLOR_OVERRIDE,
     PROP_CURRENT_URI,
     PROP_SLIDESHOW_TIMEOUT,
     PROP_SLIDESHOW_BGCOLOR,
+    PROP_SLIDESHOW_BGCOLOR_STYLE,
+    PROP_SCROLLWHEEL_ACTION,
 };
 
 GType
@@ -92,13 +97,18 @@ struct _RsttoSettingsPriv
 {
     XfconfChannel *channel;
 
-    gboolean show_toolbar;
-    guint    window_width;
-    guint    window_height;
-    gchar   *last_file_path;
-    guint    slideshow_timeout;
+    gboolean  show_toolbar;
+    gboolean  toolbar_open_folder;
+    gboolean  preload_image;
+    guint     window_width;
+    guint     window_height;
+    gchar    *last_file_path;
+    guint     slideshow_timeout;
     GdkColor *bgcolor;
+    gboolean  bgcolor_override;
     GdkColor *slideshow_bgcolor;
+    gchar    *scrollwheel_action;
+    guint     slideshow_bgcolor_style;
 };
 
 
@@ -121,14 +131,24 @@ rstto_settings_init (GObject *object)
     }
     
     settings->priv->slideshow_timeout = 5000;
+    settings->priv->bgcolor = g_new0 (GdkColor, 1);
 
     xfconf_g_property_bind (settings->priv->channel, "/window/width", G_TYPE_UINT, settings, "window-width");
     xfconf_g_property_bind (settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height");
-    xfconf_g_property_bind (settings->priv->channel, "/window/show-toolbar", G_TYPE_BOOLEAN, settings, "show-toolbar");
+
     xfconf_g_property_bind (settings->priv->channel, "/file/current-uri", G_TYPE_STRING, settings, "current-uri");
+
+    xfconf_g_property_bind (settings->priv->channel, "/window/show-toolbar", G_TYPE_BOOLEAN, settings, "show-toolbar");
+    xfconf_g_property_bind (settings->priv->channel, "/window/scrollwheel-action", G_TYPE_STRING, settings, "scrollwheel-action");
+    xfconf_g_property_bind (settings->priv->channel, "/window/toolbar-open-folder", G_TYPE_BOOLEAN, settings, "toolbar-open-folder");
+
     xfconf_g_property_bind (settings->priv->channel, "/slideshow/timeout", G_TYPE_UINT, settings, "slideshow-timeout");
+    xfconf_g_property_bind (settings->priv->channel, "/slideshow/bgcolor-style", G_TYPE_UINT, settings, "slideshow-bgcolor-style");
     xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/slideshow/bgcolor", settings, "slideshow-bgcolor");
+
     xfconf_g_property_bind_gdkcolor (settings->priv->channel, "/window/bgcolor", settings, "bgcolor");
+    xfconf_g_property_bind (settings->priv->channel, "/window/bgcolor-override", G_TYPE_BOOLEAN, settings, "bgcolor-override");
+    xfconf_g_property_bind (settings->priv->channel, "/image/preload", G_TYPE_BOOLEAN, settings, "preload-image");
 }
 
 
@@ -147,15 +167,6 @@ rstto_settings_class_init (GObjectClass *object_class)
     object_class->set_property = rstto_settings_set_property;
     object_class->get_property = rstto_settings_get_property;
 
-    pspec = g_param_spec_boolean ("show-toolbar",
-                                  "",
-                                  "",
-                                  TRUE,
-                                  G_PARAM_READWRITE);
-    g_object_class_install_property (object_class,
-                                     PROP_SHOW_TOOLBAR,
-                                     pspec);
-
     pspec = g_param_spec_uint    ("window-width",
                                   "",
                                   "",
@@ -178,6 +189,34 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_WINDOW_HEIGHT,
                                      pspec);
 
+    pspec = g_param_spec_boolean ("show-toolbar",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_SHOW_TOOLBAR,
+                                     pspec);
+
+    pspec = g_param_spec_boolean ("toolbar-open-folder",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_TOOLBAR_OPEN_FOLDER,
+                                     pspec);
+
+
+    pspec = g_param_spec_boolean ("preload-image",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_PRELOAD_IMAGE,
+                                     pspec);
+
     pspec = g_param_spec_string  ("current-uri",
                                   "",
                                   "",
@@ -187,6 +226,15 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_CURRENT_URI,
                                      pspec);
 
+    pspec = g_param_spec_string  ("scrollwheel-action",
+                                  "",
+                                  "",
+                                  "zoom",
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_CURRENT_URI,
+                                     pspec);
+
     pspec = g_param_spec_uint    ("slideshow-timeout",
                                   "",
                                   "",
@@ -207,6 +255,15 @@ rstto_settings_class_init (GObjectClass *object_class)
                                      PROP_BGCOLOR,
                                      pspec);
 
+    pspec = g_param_spec_boolean ("bgcolor-override",
+                                  "",
+                                  "",
+                                  TRUE,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_BGCOLOR_OVERRIDE,
+                                     pspec);
+
     pspec = g_param_spec_boxed   ("slideshow-bgcolor",
                                   "",
                                   "",
@@ -215,6 +272,17 @@ rstto_settings_class_init (GObjectClass *object_class)
     g_object_class_install_property (object_class,
                                      PROP_SLIDESHOW_BGCOLOR,
                                      pspec);
+
+    pspec = g_param_spec_uint    ("slideshow-bgcolor-style",
+                                  "",
+                                  "",
+                                  0,
+                                  2,
+                                  0,
+                                  G_PARAM_READWRITE);
+    g_object_class_install_property (object_class,
+                                     PROP_SLIDESHOW_BGCOLOR_STYLE,
+                                     pspec);
 }
 
 /**
@@ -292,6 +360,12 @@ rstto_settings_set_property    (GObject      *object,
         case PROP_SHOW_TOOLBAR:
             settings->priv->show_toolbar = g_value_get_boolean (value);
             break;
+        case PROP_TOOLBAR_OPEN_FOLDER:
+            settings->priv->toolbar_open_folder = g_value_get_boolean (value);
+            break;
+        case PROP_PRELOAD_IMAGE:
+            settings->priv->preload_image = g_value_get_boolean (value);
+            break;
         case PROP_WINDOW_WIDTH:
             settings->priv->window_width = g_value_get_uint (value);
             break;
@@ -301,6 +375,9 @@ rstto_settings_set_property    (GObject      *object,
         case PROP_BGCOLOR:
             settings->priv->bgcolor = g_value_get_boxed (value);
             break;
+        case PROP_BGCOLOR_OVERRIDE:
+            settings->priv->bgcolor_override = g_value_get_boolean (value);
+            break;
         case PROP_CURRENT_URI:
             if (settings->priv->last_file_path)
                 g_free (settings->priv->last_file_path);
@@ -312,6 +389,11 @@ rstto_settings_set_property    (GObject      *object,
         case PROP_SLIDESHOW_BGCOLOR:
             settings->priv->slideshow_bgcolor = g_value_get_boxed (value);
             break;
+        case PROP_SCROLLWHEEL_ACTION:
+            if (settings->priv->scrollwheel_action)
+                g_free (settings->priv->scrollwheel_action);
+            settings->priv->scrollwheel_action = g_value_dup_string (value);
+            break;
         default:
             break;
     }
@@ -331,6 +413,12 @@ rstto_settings_get_property    (GObject    *object,
         case PROP_SHOW_TOOLBAR:
             g_value_set_boolean (value, settings->priv->show_toolbar);
             break;
+        case PROP_TOOLBAR_OPEN_FOLDER:
+            g_value_set_boolean (value, settings->priv->toolbar_open_folder);
+            break;
+        case PROP_PRELOAD_IMAGE:
+            g_value_set_boolean (value, settings->priv->preload_image);
+            break;
         case PROP_WINDOW_WIDTH:
             g_value_set_uint (value, settings->priv->window_width);
             break;
@@ -343,6 +431,15 @@ rstto_settings_get_property    (GObject    *object,
         case PROP_SLIDESHOW_TIMEOUT:
             g_value_set_uint (value, settings->priv->slideshow_timeout);
             break;
+        case PROP_BGCOLOR:
+            g_value_set_boxed (value, settings->priv->bgcolor);
+            break;
+        case PROP_BGCOLOR_OVERRIDE:
+            g_value_set_boolean (value, settings->priv->bgcolor_override);
+            break;
+        case PROP_SCROLLWHEEL_ACTION:
+            g_value_set_string (value, settings->priv->scrollwheel_action);
+            break;
         default:
             break;
 


More information about the Xfce4-commits mailing list