[Xfce4-commits] [apps/ristretto] 01/01: Add support for old gtk2-style bg color settings

noreply at xfce.org noreply at xfce.org
Tue Aug 13 21:01:44 CEST 2019


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/ristretto.

commit 432336a5e5b5f3ac3d3887f059a14ffad0bb46e5
Author: Igor <f2404 at yandex.ru>
Date:   Tue Aug 13 14:57:54 2019 -0400

    Add support for old gtk2-style bg color settings
    
    gtk2 versions used GdkColor for color settings. With migration to gtk3,
    GdkColor has been replaced by GdkRGBA. This change allows to correctly
    read and apply old GdkColor settings and save them as GdkRGBA.
---
 src/settings.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/src/settings.c b/src/settings.c
index fda5b13..64c4e87 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -48,6 +48,10 @@ rstto_settings_get_property    (GObject    *object,
                                 GValue     *value,
                                 GParamSpec *pspec);
 
+static void
+rstto_xfconf_ensure_gdkrgba (XfconfChannel *channel,
+                             const gchar *property);
+
 static GObjectClass *parent_class = NULL;
 
 static RsttoSettings *settings_object;
@@ -273,11 +277,14 @@ rstto_settings_init (GObject *object)
             settings,
             "bgcolor-override");
 
+    rstto_xfconf_ensure_gdkrgba (settings->priv->channel, "/window/bgcolor");
     xfconf_g_property_bind_gdkrgba (
             settings->priv->channel,
             "/window/bgcolor",
             settings,
             "bgcolor");
+
+    rstto_xfconf_ensure_gdkrgba (settings->priv->channel, "/window/bgcolor-fullscreen");
     xfconf_g_property_bind_gdkrgba (
             settings->priv->channel,
             "/window/bgcolor-fullscreen",
@@ -686,6 +693,36 @@ rstto_settings_finalize (GObject *object)
     
 }
 
+/**
+ * rstto_xfconf_ensure_gdkrgba:
+ * This method makes sure that the property contains a GdkRGBA value rather than
+ * a GdkColor value, by converting the latter to the former if necessary.
+ */
+static void
+rstto_xfconf_ensure_gdkrgba (XfconfChannel *channel, const gchar *property)
+{
+    guint    rc, gc, bc, ac;
+    gboolean is_gdk_color = xfconf_channel_get_array (channel,
+                                                      property,
+                                                      G_TYPE_UINT, &rc,
+                                                      G_TYPE_UINT, &gc,
+                                                      G_TYPE_UINT, &bc,
+                                                      G_TYPE_UINT, &ac,
+                                                      G_TYPE_INVALID);
+
+    if (is_gdk_color)
+    {
+        GdkRGBA bg = { (gdouble) rc/65535, (gdouble) gc/65535, (gdouble) bc/65535, (gdouble) ac/65535 };
+        xfconf_channel_set_array (channel,
+                                  property,
+                                  G_TYPE_DOUBLE, &bg.red,
+                                  G_TYPE_DOUBLE, &bg.green,
+                                  G_TYPE_DOUBLE, &bg.blue,
+                                  G_TYPE_DOUBLE, &bg.alpha,
+                                  G_TYPE_INVALID);
+    }
+}
+
 
 
 /**

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list