~noskcaj/gnome-settings-daemon/3.14

« back to all changes in this revision

Viewing changes to debian/patches/52_sync_background_to_accountsservice.patch

  • Committer: Daniel Holbach
  • Date: 2014-05-28 12:42:05 UTC
  • Revision ID: daniel.holbach@canonical.com-20140528124205-nsl4atink1jsxtq9
* Drop all Unity patches and legacy features (LP: #1318539)
  - Keep schemas for background plugin, since they are used by u-s-d
* debian/patches: Refreshed
  - git_new_screencast_keybinding.patch
  - git_xsettings_segfaults.patch
* debian/control.in: Fix lintian warnings
  - gnome-settings-daemon-schemas add ${misc:Depends}
  - gnome-settings-daemon fix binNMUable error for gnome-settings-daemon-schemas
* Bump standards to 3.9.5 (No changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: gnome-settings-daemon-3.6.1/plugins/background/gsd-background-manager.c
2
 
===================================================================
3
 
--- gnome-settings-daemon-3.6.1.orig/plugins/background/gsd-background-manager.c        2012-05-24 11:50:44.000000000 +0200
4
 
+++ gnome-settings-daemon-3.6.1/plugins/background/gsd-background-manager.c     2012-10-26 10:19:49.567004179 +0200
5
 
@@ -412,6 +412,98 @@
6
 
                 setup_bg_and_draw_background (manager);
7
 
 }
8
 
 
9
 
+static void
10
 
+set_accountsservice_background (const gchar *background)
11
 
+{
12
 
+  GDBusProxy *proxy = NULL;
13
 
+  GDBusProxy *user = NULL;
14
 
+  GVariant *variant = NULL;
15
 
+  GError *error = NULL;
16
 
+  gchar *object_path = NULL;
17
 
+
18
 
+  proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
19
 
+                                         G_DBUS_PROXY_FLAGS_NONE,
20
 
+                                         NULL,
21
 
+                                         "org.freedesktop.Accounts",
22
 
+                                         "/org/freedesktop/Accounts",
23
 
+                                         "org.freedesktop.Accounts",
24
 
+                                         NULL,
25
 
+                                         &error);
26
 
+
27
 
+  if (proxy == NULL) {
28
 
+    g_warning ("Failed to contact accounts service: %s", error->message);
29
 
+    g_error_free (error);
30
 
+    return;
31
 
+  }
32
 
+
33
 
+  variant = g_dbus_proxy_call_sync (proxy,
34
 
+                                    "FindUserByName",
35
 
+                                    g_variant_new ("(s)", g_get_user_name ()),
36
 
+                                    G_DBUS_CALL_FLAGS_NONE,
37
 
+                                    -1,
38
 
+                                    NULL,
39
 
+                                    &error);
40
 
+
41
 
+  if (variant == NULL) {
42
 
+    g_warning ("Could not contact accounts service to look up '%s': %s",
43
 
+               g_get_user_name (), error->message);
44
 
+    g_error_free (error);
45
 
+    goto bail;
46
 
+  }
47
 
+
48
 
+  g_variant_get (variant, "(o)", &object_path);
49
 
+  user = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
50
 
+                                        G_DBUS_PROXY_FLAGS_NONE,
51
 
+                                        NULL,
52
 
+                                        "org.freedesktop.Accounts",
53
 
+                                        object_path,
54
 
+                                        "org.freedesktop.Accounts.User",
55
 
+                                        NULL,
56
 
+                                        &error);
57
 
+  g_free (object_path);
58
 
+
59
 
+  if (user == NULL) {
60
 
+    g_warning ("Could not create proxy for user '%s': %s",
61
 
+               g_variant_get_string (variant, NULL), error->message);
62
 
+    g_error_free (error);
63
 
+    goto bail;
64
 
+  }
65
 
+  g_variant_unref (variant);
66
 
+
67
 
+  variant = g_dbus_proxy_call_sync (user,
68
 
+                                    "SetBackgroundFile",
69
 
+                                    g_variant_new ("(s)", background ? background : ""),
70
 
+                                    G_DBUS_CALL_FLAGS_NONE,
71
 
+                                    -1,
72
 
+                                    NULL,
73
 
+                                    &error);
74
 
+
75
 
+  if (variant == NULL) {
76
 
+    g_warning ("Failed to set the background '%s': %s", background, error->message);
77
 
+    g_error_free (error);
78
 
+    goto bail;
79
 
+  }
80
 
+
81
 
+bail:
82
 
+  if (proxy != NULL)
83
 
+    g_object_unref (proxy);
84
 
+  if (variant != NULL)
85
 
+    g_variant_unref (variant);
86
 
+}
87
 
+
88
 
+static void
89
 
+picture_uri_changed (GSettings            *settings,
90
 
+                     const char           *key,
91
 
+                     GsdBackgroundManager *manager)
92
 
+{
93
 
+        const char *picture_uri = g_settings_get_string (settings, key);
94
 
+        GFile *picture_file = g_file_new_for_uri (picture_uri);
95
 
+        char *picture_path = g_file_get_path (picture_file);
96
 
+        set_accountsservice_background (picture_path);
97
 
+        g_free (picture_path);
98
 
+        g_object_unref (picture_file);
99
 
+}
100
 
+
101
 
 gboolean
102
 
 gsd_background_manager_start (GsdBackgroundManager *manager,
103
 
                               GError              **error)
104
 
@@ -424,6 +516,8 @@
105
 
         manager->priv->settings = g_settings_new ("org.gnome.desktop.background");
106
 
         g_signal_connect (manager->priv->settings, "changed::draw-background",
107
 
                           G_CALLBACK (draw_background_changed), manager);
108
 
+        g_signal_connect (manager->priv->settings, "changed::picture-uri",
109
 
+                          G_CALLBACK (picture_uri_changed), manager);
110
 
 
111
 
         /* If this is set, nautilus will draw the background and is
112
 
         * almost definitely in our session.  however, it may not be