[Xfce4-commits] <ristretto:ristretto-0.0> Add check for nautilus to set the wallpaper under gnome

Stephan Arts noreply at xfce.org
Sun Oct 23 19:26:42 CEST 2011


Updating branch refs/heads/ristretto-0.0
         to bfe534260e0229c1f927179de22ee93c73ddd71d (commit)
       from c75e15a27427188fbd1e0a8bbaa308ad3fd74372 (commit)

commit bfe534260e0229c1f927179de22ee93c73ddd71d
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Jul 14 00:25:52 2010 +0200

    Add check for nautilus to set the wallpaper under gnome

 ChangeLog                     |    5 +++++
 src/gnome_wallpaper_manager.c |   25 +++++++++++++++++++++++++
 src/main_window.c             |   22 ++++++++++++++++++----
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8e3f70e..33025e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-07-14 Stephan Arts <stephan at xfce.org>
+
+	* src/main_window.c,
+	  src/gnome_wallpaper_manager.c: Add check for nautilus - to set the wallpaper under gnome
+
 2010-07-13 Stephan Arts <stephan at xfce.org>
 
 	* src/image_list.c: Fix reference-count bug.
diff --git a/src/gnome_wallpaper_manager.c b/src/gnome_wallpaper_manager.c
index b33105b..1213ccf 100644
--- a/src/gnome_wallpaper_manager.c
+++ b/src/gnome_wallpaper_manager.c
@@ -22,6 +22,8 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
 #include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xproto.h>
 #include <gio/gio.h>
 
 #include "image.h"
@@ -74,6 +76,29 @@ rstto_gnome_wallpaper_manager_configure_dialog_run (RsttoWallpaperManager *self,
 static gboolean
 rstto_gnome_wallpaper_manager_check_running (RsttoWallpaperManager *self)
 {
+    GdkScreen *gdk_screen = gdk_screen_get_default();
+    GdkAtom gnome_selection_atom;
+    GdkAtom actual_type;
+    gint actual_format;
+    gint actual_length;
+    guchar *data;
+
+    gnome_selection_atom = gdk_atom_intern("NAUTILUS_DESKTOP_WINDOW_ID", FALSE);
+
+    if (gdk_property_get(gdk_screen_get_root_window(gdk_screen),
+                         gnome_selection_atom,
+                         GDK_NONE,
+                         0,
+                         1,
+                         FALSE,
+                         &actual_type,
+                         &actual_format,
+                         &actual_length,
+                         &data))
+    {
+        return TRUE;
+    }
+
     return FALSE;
 }
 
diff --git a/src/main_window.c b/src/main_window.c
index d98dc56..332a069 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -381,6 +381,7 @@ rstto_main_window_init (RsttoMainWindow *window)
     GtkWidget       *main_vbox = gtk_vbox_new (FALSE, 0);
     GtkRecentFilter *recent_filter;
     guint            window_width, window_height;
+    RsttoWallpaperManager *wallpaper_manager = NULL;
 
     GClosure        *leave_fullscreen_closure = g_cclosure_new_swap ((GCallback)gtk_window_unfullscreen, window, NULL);
     GClosure        *next_image_closure = g_cclosure_new ((GCallback)cb_rstto_main_window_next_image, window, NULL);
@@ -391,7 +392,20 @@ rstto_main_window_init (RsttoMainWindow *window)
     gtk_window_set_title (GTK_WINDOW (window), RISTRETTO_APP_TITLE);
 
     window->priv = g_new0(RsttoMainWindowPriv, 1);
-    window->priv->wallpaper_manager = RSTTO_WALLPAPER_MANAGER (rstto_xfce_wallpaper_manager_new());
+    wallpaper_manager = RSTTO_WALLPAPER_MANAGER (rstto_gnome_wallpaper_manager_new());
+    if (rstto_wallpaper_manager_check_running (wallpaper_manager) == FALSE)
+    {
+        g_object_unref (wallpaper_manager);
+        wallpaper_manager = NULL;
+    }
+
+    wallpaper_manager = RSTTO_WALLPAPER_MANAGER (rstto_xfce_wallpaper_manager_new());
+    if (rstto_wallpaper_manager_check_running (wallpaper_manager) == FALSE)
+    {
+        g_object_unref (wallpaper_manager);
+        wallpaper_manager = NULL;
+    }
+    window->priv->wallpaper_manager = wallpaper_manager;
 
     window->priv->iter = NULL;
 
@@ -930,7 +944,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             
 
             /* View Menu */
-            if (rstto_wallpaper_manager_check_running (window->priv->wallpaper_manager))
+            if (window->priv->wallpaper_manager)
             {
                 gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/set-as-wallpaper"), TRUE);
             }
@@ -978,7 +992,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             
 
             /* View Menu */
-            if (rstto_wallpaper_manager_check_running (window->priv->wallpaper_manager))
+            if (window->priv->wallpaper_manager)
             {
                 gtk_widget_set_sensitive (gtk_ui_manager_get_widget (window->priv->ui_manager, "/main-menu/view-menu/set-as-wallpaper"), TRUE);
             }
@@ -1262,7 +1276,7 @@ cb_rstto_main_window_set_as_wallpaper (GtkWidget *widget, RsttoMainWindow *windo
         image = rstto_image_list_iter_get_image (window->priv->iter);
     g_return_if_fail (image);
 
-    if (rstto_wallpaper_manager_check_running (window->priv->wallpaper_manager))
+    if (window->priv->wallpaper_manager)
     {
         if (rstto_wallpaper_manager_configure_dialog_run (window->priv->wallpaper_manager, image) == GTK_RESPONSE_OK)
         {


More information about the Xfce4-commits mailing list