[Xfce4-commits] [xfce/thunar] 01/01: Use xfconf and handle xfdesktop's single workspace (Bug #11047)
noreply at xfce.org
noreply at xfce.org
Mon Feb 2 22:59:52 CET 2015
This is an automated email from the git hooks/post-receive script.
andrzejr pushed a commit to branch master
in repository xfce/thunar.
commit 378c9bcae2afa0c723142e67bc9d47af33f8d323
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Mon Feb 2 10:28:39 2015 +0300
Use xfconf and handle xfdesktop's single workspace (Bug #11047)
Use xfconf since Thunar requires it anyway and handle xfdesktop's
single workspace mode.
---
plugins/thunar-wallpaper/Makefile.am | 2 +
plugins/thunar-wallpaper/twp-provider.c | 62 ++++++++++++++++++-------------
2 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/plugins/thunar-wallpaper/Makefile.am b/plugins/thunar-wallpaper/Makefile.am
index 8946622..70b92d5 100644
--- a/plugins/thunar-wallpaper/Makefile.am
+++ b/plugins/thunar-wallpaper/Makefile.am
@@ -20,6 +20,7 @@ thunar_wallpaper_plugin_la_CFLAGS = \
$(GLIB_CFLAGS) \
$(GTK_CFLAGS) \
$(LIBX11_CFLAGS) \
+ $(XFCONF_CFLAGS) \
$(PLATFORM_CFLAGS)
thunar_wallpaper_plugin_la_LDFLAGS = \
@@ -35,6 +36,7 @@ thunar_wallpaper_plugin_la_LIBADD = \
$(EXO_LIBS) \
$(GLIB_LIBS) \
$(GTK_LIBS) \
+ $(XFCONF_LIBS) \
$(LIBX11_LIBS)
thunar_wallpaper_plugin_la_DEPENDENCIES = \
diff --git a/plugins/thunar-wallpaper/twp-provider.c b/plugins/thunar-wallpaper/twp-provider.c
index 8551801..feaf445 100644
--- a/plugins/thunar-wallpaper/twp-provider.c
+++ b/plugins/thunar-wallpaper/twp-provider.c
@@ -31,6 +31,8 @@
#include <glib/gi18n.h>
+#include <xfconf/xfconf.h>
+
#include "twp-provider.h"
@@ -59,7 +61,6 @@ typedef enum
static DesktopType desktop_type = DESKTOP_TYPE_NONE;
-static gboolean _has_xfconf_query = FALSE;
static gboolean _has_gconftool = FALSE;
@@ -105,13 +106,6 @@ twp_provider_init (TwpProvider *twp_provider)
{
gchar *program;
- program = g_find_program_in_path ("xfconf-query");
- if (G_LIKELY (program != NULL))
- {
- _has_xfconf_query = TRUE;
- g_free (program);
- }
-
program = g_find_program_in_path ("gconftool-2");
if (G_LIKELY (program != NULL))
{
@@ -186,8 +180,7 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
if ((XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
{
- if (_has_xfconf_query)
- desktop_type = DESKTOP_TYPE_XFCE;
+ desktop_type = DESKTOP_TYPE_XFCE;
}
else
{
@@ -230,6 +223,9 @@ twp_action_set_wallpaper (GtkAction *action,
gchar *file_name = NULL;
gchar *hostname = NULL;
gchar *command;
+ XfconfChannel *channel;
+ gboolean is_single_workspace;
+ gint current_image_style;
if (n_screens > 1)
screen = gdk_display_get_default_screen (display);
@@ -267,27 +263,40 @@ twp_action_set_wallpaper (GtkAction *action,
{
case DESKTOP_TYPE_XFCE:
g_debug ("set on xfce");
+
+ channel = xfconf_channel_get ("xfce4-desktop");
+
/* This is the format for xfdesktop before 4.11 */
image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path", screen_nr, monitor_nr);
image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show", screen_nr, monitor_nr);
image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style", screen_nr, monitor_nr);
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s %s", image_path_prop, escaped_file_name);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ /* Set the wallpaper and ensure that it's set to show */
+ xfconf_channel_set_string (channel, image_path_prop, escaped_file_name);
+ xfconf_channel_set_bool (channel, image_show_prop, TRUE);
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t bool -s true", image_show_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 0", image_style_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ /* If there isn't a wallpaper style set, then set one */
+ current_image_style = xfconf_channel_get_int (channel, image_style_prop, -1);
+ if (current_image_style == -1)
+ {
+ xfconf_channel_set_int (channel, image_style_prop, 0);
+ }
g_free(image_path_prop);
g_free(image_show_prop);
g_free(image_style_prop);
+
+ /* Xfdesktop 4.11+ has a concept of a single-workspace-mode where
+ * the same workspace is used for everything but additionally allows
+ * the user to use any current workspace as the single active
+ * workspace, we'll need to check if it is enabled and use that. */
+ is_single_workspace = xfconf_channel_get_bool (channel, "/backdrop/single-workspace-mode", FALSE);
+ if (is_single_workspace)
+ {
+ workspace = xfconf_channel_get_int (channel, "/backdrop/single-workspace-number", 0);
+ }
+
/* This is the format for xfdesktop post 4.11. A workspace number is
* added and the monitor is referred to name. We set both formats so
* that it works as the user expects. */
@@ -305,13 +314,14 @@ twp_action_set_wallpaper (GtkAction *action,
image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/workspace%d/image-style", screen_nr, monitor_nr, workspace);
}
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s %s", image_path_prop, escaped_file_name);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ xfconf_channel_set_string (channel, image_path_prop, escaped_file_name);
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 5", image_style_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
+ /* If there isn't a wallpaper style set, then set one */
+ current_image_style = xfconf_channel_get_int (channel, image_style_prop, -1);
+ if (current_image_style == -1)
+ {
+ xfconf_channel_set_int (channel, image_style_prop, 5);
+ }
g_free(image_path_prop);
g_free(image_style_prop);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list