[Xfce4-commits] [apps/xfce4-screensaver] 01/01: Add support for Xfdesktop 4.12 color properties

noreply at xfce.org noreply at xfce.org
Fri Oct 26 12:38:44 CEST 2018


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

b   l   u   e   s   a   b   r   e       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/xfce4-screensaver.

commit 20ccbec35c9d537144712ce7a08410ff562ed6a4
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Fri Oct 26 06:37:48 2018 -0400

    Add support for Xfdesktop 4.12 color properties
---
 src/xfce-bg.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 51 insertions(+), 6 deletions(-)

diff --git a/src/xfce-bg.c b/src/xfce-bg.c
index 732422f..d2af2c2 100644
--- a/src/xfce-bg.c
+++ b/src/xfce-bg.c
@@ -196,7 +196,7 @@ static void        xfce_bg_set_placement    (XfceBG           *bg,
 static void        xfce_bg_set_filename     (XfceBG           *bg,
                                              const char       *filename);
 
-static void        color_from_array         (XfconfChannel    *channel,
+static void        color_from_rgba_array    (XfconfChannel    *channel,
                                              const gchar      *property,
                                              GdkRGBA          *colorp)
 {
@@ -222,6 +222,32 @@ static void        color_from_array         (XfconfChannel    *channel,
     colorp->alpha = a;
 }
 
+static void        color_from_color_array   (XfconfChannel    *channel,
+                                             const gchar      *property,
+                                             GdkRGBA          *colorp)
+{
+    guint   pc, rc, gc, bc;
+
+    /* If all else fails use black */
+    gdk_rgba_parse (colorp, "#000000");
+
+    if (!xfconf_channel_has_property (channel, property))
+        return;
+
+    xfconf_channel_get_array(channel,
+                             property,
+                             G_TYPE_UINT, &pc,
+                             G_TYPE_UINT, &rc,
+                             G_TYPE_UINT, &gc,
+                             G_TYPE_UINT, &bc,
+                             G_TYPE_INVALID);
+
+    colorp->red = (gdouble) rc / 65535;
+    colorp->green = (gdouble) gc / 65535;
+    colorp->blue = (gdouble) bc / 65535;
+    colorp->alpha = 1.0;
+}
+
 static gboolean
 do_changed (XfceBG *bg)
 {
@@ -387,7 +413,7 @@ xfce_bg_load_from_xfconf (XfceBG        *bg,
     GdkMonitor      *mon;
     const gchar     *monitor_name;
     gchar           *prop_prefix;
-    gchar           *property;
+    gchar           *property, *property2;
 
     g_return_if_fail(XFCE_IS_BG(bg));
 
@@ -453,11 +479,30 @@ xfce_bg_load_from_xfconf (XfceBG        *bg,
     /* Colors */
     g_free(property);
     property = g_strconcat(prop_prefix, "/rgba1", NULL);
-    color_from_array(channel, property, &c1);
+    property2 = g_strconcat(prop_prefix, "/color1", NULL);
+    if (!xfconf_channel_has_property (channel, property) && xfconf_channel_has_property (channel, property2)) {
+        // Using GdkColor properties from Xfdesktop 4.12
+        g_free(property);
+        g_free(property2);
 
-    g_free(property);
-    property = g_strconcat(prop_prefix, "/rgba2", NULL);
-    color_from_array(channel, property, &c2);
+        property = g_strconcat(prop_prefix, "/color1", NULL);
+        color_from_color_array(channel, property, &c1);
+
+        g_free(property);
+        property = g_strconcat(prop_prefix, "/color2", NULL);
+        color_from_color_array(channel, property, &c2);
+    } else {
+        // Using GdkRGBA properties from Xfdesktop 4.13
+        g_free(property);
+        g_free(property2);
+
+        property = g_strconcat(prop_prefix, "/rgba1", NULL);
+        color_from_rgba_array(channel, property, &c1);
+
+        g_free(property);
+        property = g_strconcat(prop_prefix, "/rgba2", NULL);
+        color_from_rgba_array(channel, property, &c2);
+    }
 
     /* Color type */
     g_free(property);

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


More information about the Xfce4-commits mailing list