[Xfce4-commits] [apps/ristretto] 01/02: Fix wallpaper manager

noreply at xfce.org noreply at xfce.org
Mon Jul 1 20:22:19 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 3778e10f1a32f49a8c8a16bfe9a65626c78f2ae6
Author: Olivier Duchateau <duchateau.olivier at gmail.com>
Date:   Sat Apr 13 21:26:23 2019 +0200

    Fix wallpaper manager
    
    Bug #14571
    
    Signed-off-by: Igor <f2404 at yandex.ru>
---
 src/xfce_wallpaper_manager.c | 100 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 96 insertions(+), 4 deletions(-)

diff --git a/src/xfce_wallpaper_manager.c b/src/xfce_wallpaper_manager.c
index 160d0e4..e7f6ea6 100644
--- a/src/xfce_wallpaper_manager.c
+++ b/src/xfce_wallpaper_manager.c
@@ -76,6 +76,11 @@ static void
 configure_monitor_chooser_pixbuf (
     RsttoXfceWallpaperManager *manager );
 
+static gchar *
+get_human_monitor_name (gchar *prop_name);
+static gchar *
+retrieve_monitor_name (gint monitor_id);
+
 static void
 cb_style_combo_changed (
         GtkComboBox *style_combo,
@@ -119,6 +124,88 @@ enum
     PROP_0,
 };
 
+static gchar *
+get_human_monitor_name (gchar *prop_name)
+{
+    GRegex *regex;
+    GMatchInfo *info;
+    gchar *res = NULL;
+
+    regex = g_regex_new ("/(?P<monitor>monitor\\D+-\\d+)/", 0, 0, NULL);
+    if (regex != NULL)
+    {
+        if (g_regex_match (regex, prop_name, 0, &info))
+            res = g_match_info_fetch_named (info, "monitor");
+
+        g_match_info_free (info);
+        g_regex_unref (regex);
+    }
+
+    return res;
+}
+
+static gchar *
+retrieve_monitor_name (gint monitor_id)
+{
+    GDBusProxy *proxy;
+    GError *err;
+    GVariant *variant;
+    GVariantIter *iter;
+    gchar *key, *monitor_name, *result;
+
+    proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                           G_DBUS_PROXY_FLAGS_NONE,
+                                           NULL,
+                                           "org.xfce.Xfconf",
+                                           "/org/xfce/Xfconf",
+                                           "org.xfce.Xfconf",
+                                           NULL, &err);
+    if (proxy == NULL)
+    {
+        g_warning ("Could not access to the D-Bus interface: %s",
+                   err->message);
+        g_error_free (err);
+    }
+    else
+    {
+        variant = g_dbus_proxy_call_sync (proxy, "GetAllProperties",
+                                          g_variant_new ("(ss)",
+                                                         "xfce4-desktop",
+                                                         "/"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1, NULL, &err);
+        if (variant == NULL)
+        {
+            g_warning ("Can't invoke the method: %s", err->message);
+            g_error_free (err);
+        }
+        else
+        {
+            g_variant_get (variant, "(a{sv})", &iter);
+            /* Only keys are interesting */
+            while (g_variant_iter_loop (iter, "{&sv}", &key))
+            {
+                monitor_name = get_human_monitor_name (key);
+                if (monitor_name)
+                    break;
+            }
+            g_variant_iter_free (iter);
+            g_variant_unref (variant);
+        }
+        g_object_unref (proxy);
+    }
+
+    if (monitor_name)
+    {
+        result = g_strdup_printf ("%s", monitor_name);
+        g_free (monitor_name);
+    }
+    else
+        result = g_strdup_printf ("monitor%d", monitor_id);
+
+    return result;
+}
+
 static gint 
 rstto_xfce_wallpaper_manager_configure_dialog_run (
         RsttoWallpaperManager *self,
@@ -216,19 +303,24 @@ rstto_xfce_wallpaper_manager_set (RsttoWallpaperManager *self, RsttoFile *file)
     else
     {
         /* gdk_screen_get_monitor_plug_name can return NULL */
+        monitor_name = retrieve_monitor_name (manager->priv->monitor);
+
         image_path_prop = g_strdup_printf (
-                "/backdrop/screen%d/monitor%d/workspace%d/last-image",
+                "/backdrop/screen%d/%s/workspace%d/last-image",
                 manager->priv->screen,
-                manager->priv->monitor,
+                monitor_name,
                 workspace_nr);
 
         image_style_prop = g_strdup_printf (
-                "/backdrop/screen%d/monitor%d/workspace%d/image-style",
+                "/backdrop/screen%d/%s/workspace%d/image-style",
                 manager->priv->screen,
-                manager->priv->monitor,
+                monitor_name,
                 workspace_nr);
+
+        g_free (monitor_name);
     }
 
+
     xfconf_channel_set_string (
             manager->priv->channel,
             image_path_prop,

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


More information about the Xfce4-commits mailing list