Merge lp:~noskcaj/ubuntu/trusty/thunar/lp-1277149 into lp:ubuntu/trusty/thunar

Proposed by Jackson Doak
Status: Merged
Merge reported by: Martin Pitt
Merged at revision: not available
Proposed branch: lp:~noskcaj/ubuntu/trusty/thunar/lp-1277149
Merge into: lp:ubuntu/trusty/thunar
Diff against target: 267 lines (+244/-0)
4 files modified
debian/changelog (+7/-0)
debian/patches/git-xfdesktop-4.11.patch (+188/-0)
debian/patches/gtk3-bookmarks.patch (+47/-0)
debian/patches/series (+2/-0)
To merge this branch: bzr merge lp:~noskcaj/ubuntu/trusty/thunar/lp-1277149
Reviewer Review Type Date Requested Status
Martin Pitt Approve
Review via email: mp+205288@code.launchpad.net

Description of the change

Allow thunar to change wallpapers with xfdesktop4 4.11

To post a comment you must log in.
96. By Jackson Doak

Add gtk3-bookmarks.patch, use new gtk3 bookmark location

Revision history for this message
Martin Pitt (pitti) wrote :

Thanks, looks fine! (Well-written patch headers)

Uploaded.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-12-26 22:09:24 +0000
+++ debian/changelog 2014-02-07 20:28:18 +0000
@@ -1,3 +1,10 @@
1thunar (1.6.3-1ubuntu3) trusty; urgency=medium
2
3 * Add git-xfdesktop-4.11.patch. LP: #1277149
4 * Add gtk3-bookmarks.patch, use new gtk3 bookmark location
5
6 -- Jackson Doak <noskcaj@ubuntu.com> Fri, 07 Feb 2014 16:54:48 +1100
7
1thunar (1.6.3-1ubuntu2) trusty; urgency=medium8thunar (1.6.3-1ubuntu2) trusty; urgency=medium
29
3 * Use dh-autoreconf and xdt-autogen to update libtool.m4 for new ports.10 * Use dh-autoreconf and xdt-autogen to update libtool.m4 for new ports.
411
=== added file 'debian/patches/git-xfdesktop-4.11.patch'
--- debian/patches/git-xfdesktop-4.11.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/git-xfdesktop-4.11.patch 2014-02-07 20:28:18 +0000
@@ -0,0 +1,188 @@
1Author: Eric Koegel <eric.koegel@gmail.com>
2Date: Tue, 26 Nov 2013 10:16:21 +0300
3Description: [PATCH] Update xfconf setting for thunar-wallpaper plugin
4 Xfdesktop uses a new xfconf format starting with version 4.11.
5 This patch updates the thunar-wallpaper plugin to set the image
6 in the new format while continuing to set the old format.
7Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/thunar/+bug/1277149
8---
9 plugins/thunar-wallpaper/twp-provider.c | 111 ++++++++++++++++++++++++++++++--
10 1 file changed, 106 insertions(+), 5 deletions(-)
11
12--- a/plugins/thunar-wallpaper/twp-provider.c
13+++ b/plugins/thunar-wallpaper/twp-provider.c
14@@ -27,6 +27,7 @@
15
16 #include <gdk/gdkx.h>
17 #include <X11/Xlib.h>
18+#include <X11/Xatom.h>
19
20 #include <glib/gi18n.h>
21
22@@ -45,6 +46,7 @@ static GList *twp_provider_get_file_acti
23 GList *files);
24 static void twp_action_set_wallpaper (GtkAction *action,
25 gpointer user_data);
26+static gint twp_get_active_workspace_number (GdkScreen *screen);
27
28
29 typedef enum
30@@ -217,16 +219,23 @@ twp_action_set_wallpaper (GtkAction *act
31 gint screen_nr = 0;
32 gint n_monitors;
33 gint monitor_nr = 0;
34+ gint workspace;
35 GdkScreen *screen;
36 gchar *image_path_prop;
37 gchar *image_show_prop;
38 gchar *image_style_prop;
39+ gchar *monitor_name;
40 gchar *file_uri;
41 gchar *escaped_file_name;
42 gchar *file_name = NULL;
43 gchar *hostname = NULL;
44 gchar *command;
45
46+ if (n_screens > 1)
47+ screen = gdk_display_get_default_screen (display);
48+ else
49+ screen = gdk_display_get_screen (display, 0);
50+
51 if (desktop_type != DESKTOP_TYPE_NONE)
52 {
53 file_uri = thunarx_file_info_get_uri (file_info);
54@@ -239,10 +248,6 @@ twp_action_set_wallpaper (GtkAction *act
55
56 return;
57 }
58- if (n_screens > 1)
59- screen = gdk_display_get_default_screen (display);
60- else
61- screen = gdk_display_get_screen (display, 0);
62
63 n_monitors = gdk_screen_get_n_monitors (screen);
64 if (n_monitors > 1)
65@@ -252,12 +257,17 @@ twp_action_set_wallpaper (GtkAction *act
66 g_free(file_uri);
67 }
68
69+ workspace = twp_get_active_workspace_number (screen);
70+
71+ monitor_name = gdk_screen_get_monitor_plug_name (screen, monitor_nr);
72+
73 escaped_file_name = g_shell_quote (file_name);
74
75 switch (desktop_type)
76 {
77 case DESKTOP_TYPE_XFCE:
78 g_debug ("set on xfce");
79+ /* This is the format for xfdesktop before 4.11 */
80 image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path", screen_nr, monitor_nr);
81 image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show", screen_nr, monitor_nr);
82 image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style", screen_nr, monitor_nr);
83@@ -277,6 +287,34 @@ twp_action_set_wallpaper (GtkAction *act
84 g_free(image_path_prop);
85 g_free(image_show_prop);
86 g_free(image_style_prop);
87+
88+ /* This is the format for xfdesktop post 4.11. A workspace number is
89+ * added and the monitor is referred to name. We set both formats so
90+ * that it works as the user expects. */
91+ if (monitor_name)
92+ {
93+ image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%s/workspace%d/last-image", screen_nr, monitor_name, workspace);
94+ image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%s/workspace%d/image-style", screen_nr, monitor_name, workspace);
95+ }
96+ else
97+ {
98+ /* gdk_screen_get_monitor_plug_name can return NULL, in those
99+ * instances we fallback to monitor number but still include the
100+ * workspace number */
101+ image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/workspace%d/last-image", screen_nr, monitor_nr, workspace);
102+ image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/workspace%d/image-style", screen_nr, monitor_nr, workspace);
103+ }
104+
105+ command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s %s", image_path_prop, escaped_file_name);
106+ g_spawn_command_line_async (command, NULL);
107+ g_free (command);
108+
109+ command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 3", image_style_prop);
110+ g_spawn_command_line_async (command, NULL);
111+ g_free (command);
112+
113+ g_free(image_path_prop);
114+ g_free(image_style_prop);
115 break;
116
117 case DESKTOP_TYPE_NAUTILUS:
118@@ -302,6 +340,69 @@ twp_action_set_wallpaper (GtkAction *act
119 break;
120 }
121
122+ g_free (monitor_name);
123 g_free (escaped_file_name);
124- g_free(file_name);
125+ g_free (file_name);
126+}
127+
128+/* Taken from xfce_spawn_get_active_workspace_number in xfce-spawn.c apart of
129+ * the libxfce4ui library.
130+ * http://git.xfce.org/xfce/libxfce4ui/tree/libxfce4ui/xfce-spawn.c#n193
131+ */
132+static gint
133+twp_get_active_workspace_number (GdkScreen *screen)
134+{
135+ GdkWindow *root;
136+ gulong bytes_after_ret = 0;
137+ gulong nitems_ret = 0;
138+ guint *prop_ret = NULL;
139+ Atom _NET_CURRENT_DESKTOP;
140+ Atom _WIN_WORKSPACE;
141+ Atom type_ret = None;
142+ gint format_ret;
143+ gint ws_num = 0;
144+
145+ gdk_error_trap_push ();
146+
147+ root = gdk_screen_get_root_window (screen);
148+
149+ /* determine the X atom values */
150+ _NET_CURRENT_DESKTOP = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_NET_CURRENT_DESKTOP", False);
151+ _WIN_WORKSPACE = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_WIN_WORKSPACE", False);
152+
153+ if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root),
154+ gdk_x11_get_default_root_xwindow(),
155+ _NET_CURRENT_DESKTOP, 0, 32, False, XA_CARDINAL,
156+ &type_ret, &format_ret, &nitems_ret, &bytes_after_ret,
157+ (gpointer) &prop_ret) != Success)
158+ {
159+ if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root),
160+ gdk_x11_get_default_root_xwindow(),
161+ _WIN_WORKSPACE, 0, 32, False, XA_CARDINAL,
162+ &type_ret, &format_ret, &nitems_ret, &bytes_after_ret,
163+ (gpointer) &prop_ret) != Success)
164+ {
165+ if (G_UNLIKELY (prop_ret != NULL))
166+ {
167+ XFree (prop_ret);
168+ prop_ret = NULL;
169+ }
170+ }
171+ }
172+
173+ if (G_LIKELY (prop_ret != NULL))
174+ {
175+ if (G_LIKELY (type_ret != None && format_ret != 0))
176+ ws_num = *prop_ret;
177+ XFree (prop_ret);
178+ }
179+
180+#if GTK_CHECK_VERSION (3, 0, 0)
181+ gdk_error_trap_pop_ignored ();
182+#else
183+ if (gdk_error_trap_pop () != 0)
184+ return 0;
185+#endif
186+
187+ return ws_num;
188 }
0189
=== added file 'debian/patches/gtk3-bookmarks.patch'
--- debian/patches/gtk3-bookmarks.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/gtk3-bookmarks.patch 2014-02-07 20:28:18 +0000
@@ -0,0 +1,47 @@
1Author: Alistair Buxton <a.j.buxton@gmail.com>
2Date: Sun, 12 Jan 2014 17:27:30 +0000
3Description: [PATCH] Use the new Gtk bookmarks location.
4Bug: https://bugzilla.xfce.org/show_bug.cgi?id=10627
5
6---
7 thunar/thunar-gio-extensions.c | 2 +-
8 thunar/thunar-util.c | 10 +++++++++-
9 2 files changed, 10 insertions(+), 2 deletions(-)
10
11--- a/thunar/thunar-gio-extensions.c
12+++ b/thunar/thunar-gio-extensions.c
13@@ -77,7 +77,7 @@ thunar_g_file_new_for_bookmarks (void)
14 gchar *filename;
15 GFile *bookmarks;
16
17- filename = g_build_filename (xfce_get_homedir (), ".gtk-bookmarks", NULL);
18+ filename = g_build_filename (g_get_user_config_dir (), "gtk-3.0", "bookmarks", NULL);
19 bookmarks = g_file_new_for_path (filename);
20 g_free (filename);
21
22--- a/thunar/thunar-util.c
23+++ b/thunar/thunar-util.c
24@@ -84,6 +84,15 @@ thunar_util_load_bookmarks (GFile
25
26 /* append the GTK+ bookmarks (if any) */
27 fp = fopen (bookmarks_path, "r");
28+ g_free (bookmarks_path);
29+
30+ if (G_UNLIKELY (fp == NULL))
31+ {
32+ bookmarks_path = g_build_filename (g_get_home_dir (), ".gtk-bookmarks", NULL);
33+ fp = fopen(bookmarks_path, "r");
34+ g_free(bookmarks_path);
35+ }
36+
37 if (G_LIKELY (fp != NULL))
38 {
39 while (fgets (line, sizeof (line), fp) != NULL)
40@@ -119,7 +128,6 @@ thunar_util_load_bookmarks (GFile
41 fclose (fp);
42 }
43
44- g_free (bookmarks_path);
45 }
46
47
048
=== modified file 'debian/patches/series'
--- debian/patches/series 2013-08-15 21:37:17 +0000
+++ debian/patches/series 2014-02-07 20:28:18 +0000
@@ -1,1 +1,3 @@
101_support-non-multiarch-modules.patch101_support-non-multiarch-modules.patch
2git-xfdesktop-4.11.patch
3gtk3-bookmarks.patch

Subscribers

People subscribed via source and target branches

to all changes: