[Goodies-commits] r5675 - in thunar-wallpaper-plugin/trunk: . thunar-wallpaper-plugin

Stephan Arts stephan at xfce.org
Sat Oct 18 09:41:00 CEST 2008


Author: stephan
Date: 2008-10-18 07:40:59 +0000 (Sat, 18 Oct 2008)
New Revision: 5675

Modified:
   thunar-wallpaper-plugin/trunk/ChangeLog
   thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/Makefile.am
   thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/twp-provider.c
Log:
* Fix linking error with xfconf
* Check if xfdesktop is actually running before setting the wallpaper
* Retrieve the filename from the ThunarxFileInfo object and pass that to xfconf.



Modified: thunar-wallpaper-plugin/trunk/ChangeLog
===================================================================
--- thunar-wallpaper-plugin/trunk/ChangeLog	2008-10-18 01:10:31 UTC (rev 5674)
+++ thunar-wallpaper-plugin/trunk/ChangeLog	2008-10-18 07:40:59 UTC (rev 5675)
@@ -1,3 +1,10 @@
+2008-10-18  Stephan Arts <stephan at xfce.org>
+
+	* Fix linking error with xfconf
+	* Check if xfdesktop is actually running before setting the wallpaper
+	* Retrieve the filename from the ThunarxFileInfo object and pass that to
+	  xfconf.
+
 2008-10-18	Stephan Arts <stephan at xfce.org>
 
 	* Initial import in SVN

Modified: thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/Makefile.am
===================================================================
--- thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/Makefile.am	2008-10-18 01:10:31 UTC (rev 5674)
+++ thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/Makefile.am	2008-10-18 07:40:59 UTC (rev 5675)
@@ -12,9 +12,9 @@
 	thunar-wallpaper-plugin.la
 
 thunar_wallpaper_plugin_la_SOURCES =		\
-	thunar-wallpaper-plugin.c				\
 	twp-provider.h							\
-	twp-provider.c
+	twp-provider.c							\
+	thunar-wallpaper-plugin.c
 
 thunar_wallpaper_plugin_la_CFLAGS =			\
 	$(PLATFORM_CFLAGS)						\
@@ -28,7 +28,5 @@
 	-module									\
 	$(PLATFORM_LDFLAGS)						\
 	$(THUNARX_LDFLAGS)						\
+	$(XFCONF_LIBS)							\
 	$(THUNAR_VFS_LDFLAGS)
-
-thunar_wallpaper_plugin_la_LIBADD =		\
-	$(XFCONF_LDFLAGS)

Modified: thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/twp-provider.c
===================================================================
--- thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/twp-provider.c	2008-10-18 01:10:31 UTC (rev 5674)
+++ thunar-wallpaper-plugin/trunk/thunar-wallpaper-plugin/twp-provider.c	2008-10-18 07:40:59 UTC (rev 5675)
@@ -31,9 +31,13 @@
 
 #include <xfconf/xfconf.h>
 #include <thunar-vfs/thunar-vfs.h>
+#include <gdk/gdkx.h>
+#include <X11/Xlib.h>
 
 #include <thunar-wallpaper-plugin/twp-provider.h>
 
+#define XFDESKTOP_SELECTION_FMT "XFDESKTOP_SELECTION_%d"
+
 static void   twp_provider_class_init           (TwpProviderClass         *klass);
 static void   twp_provider_menu_provider_init   (ThunarxMenuProviderIface *iface);
 static void   twp_provider_property_page_provider_init (ThunarxPropertyPageProviderIface *iface);
@@ -133,7 +137,20 @@
 	GtkWidget          *action;
 	GList              *actions = NULL;
     gint                n_files = 0;
+    gchar               selection_name[100];
 
+    GdkScreen *gdk_screen = gdk_screen_get_default();
+    gint xscreen = gdk_screen_get_number(gdk_screen);
+
+    g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
+
+    Window root_window = GDK_ROOT_WINDOW();
+    Atom xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
+    if(!(XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
+    {
+        return NULL;
+    }
+
     /* we can only set a single wallpaper */
 	if (files->next == NULL)
 	{
@@ -154,7 +171,8 @@
                             "name", "Twp::setwallpaper",
                             "label", _("Set as Wallpaper"),
                             NULL);
-                g_signal_connect (action, "activate", G_CALLBACK (twp_action_set_wallpaper), files);
+                g_signal_connect (action, "activate", G_CALLBACK (twp_action_set_wallpaper), files->data);
+
                 actions = g_list_append (actions, action);
             }
 		}
@@ -165,7 +183,7 @@
 
 
 static GList*
-twp_provider_get_pages (ThunarxPropertyPageProvider *page_provider, GList *files)
+twp_Provider_get_pages (ThunarxPropertyPageProvider *page_provider, GList *files)
 {
   GList *pages = NULL;
   return pages;
@@ -174,7 +192,7 @@
 static
 twp_action_set_wallpaper (GtkAction *action, gpointer user_data)
 {
-    GList *files = user_data;
+    ThunarxFileInfo *file_info = user_data;
     GdkDisplay *display = gdk_display_get_default();
     gint n_screens = gdk_display_get_n_screens (display);
     gint screen_nr = 0;
@@ -184,39 +202,50 @@
     gchar *image_path_prop;
     gchar *image_show_prop;
     gchar *image_style_prop;
+    gchar *file_uri;
+    gchar *file_name;
+    gchar *hostname = NULL;
 
     XfconfChannel *xfdesktop_channel = xfconf_channel_new("xfce4-desktop");
 
-
-    if (n_screens > 1)
+    file_uri = thunarx_file_info_get_uri (file_info);
+    file_name = g_filename_from_uri (file_uri, &hostname, NULL);
+    if (hostname == NULL)
     {
-        screen = gdk_display_get_default_screen (display);
-    }
-    else
-    {
-        screen = gdk_display_get_screen (display, 0);
-    }
+        if (n_screens > 1)
+        {
+            screen = gdk_display_get_default_screen (display);
+        }
+        else
+        {
+            screen = gdk_display_get_screen (display, 0);
+        }
 
-    n_monitors = gdk_screen_get_n_monitors (screen);
+        n_monitors = gdk_screen_get_n_monitors (screen);
 
-    if (n_monitors > 1)
-    {
+        if (n_monitors > 1)
+        {
 
-    }
-    
-    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);
+        }
+        
+        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);
 
-    if(xfconf_channel_set_string(xfdesktop_channel, image_path_prop, files->data) == TRUE)
-    {
-        xfconf_channel_set_bool(xfdesktop_channel, image_show_prop, TRUE);
-        xfconf_channel_set_int(xfdesktop_channel, image_style_prop, 4);
+
+        if(xfconf_channel_set_string(xfdesktop_channel, image_path_prop, file_name) == TRUE)
+        {
+            xfconf_channel_set_bool(xfdesktop_channel, image_show_prop, TRUE);
+            xfconf_channel_set_int(xfdesktop_channel, image_style_prop, 4);
+        }
+
+        g_free(image_path_prop);
+        g_free(image_show_prop);
+        g_free(image_style_prop);
+
     }
-
-    g_free(image_path_prop);
-    g_free(image_show_prop);
-    g_free(image_style_prop);
+    g_free(file_uri);
+    g_free(file_name);
     g_object_unref(xfdesktop_channel);
 
     




More information about the Goodies-commits mailing list