[PATCH] Add Basic Support for Other Platforms v2



From 315f31321916055aa717981875467b4517295204 Mon Sep 17 00:00:00 2001
From: canatan <unixman archlinux info>
Date: Sun, 5 Jul 2015 16:49:05 +0000
Subject: [PATCH] Add basic support for platforms v2

there are no big thinks here.i just move x11 stuff into ifdefs
according to gdk defines(gdkconfig.h) which is GDK_WINDOWING_X11
as you know
from here https://bugzilla.gnome.org/show_bug.cgi?id=751625
gtk is able to build platforms that it has not x11 libs other than
win32 or quartz. eg. a wayland platform that hasn't x11 stuff.
i tested it on an x11-less wayland.it is work but some issues
that complains:
gtk_widget_size_allocate():attempt to allocate widget with width -14
and many of dbus-launch fails because of its x11 dependency.
also it is need a patch for gnome-desktop for works which i have.
it is based commit 76c63eb3ee13affac097d6258a8fcc79ce92a321

Best reviews.

Changes from v1

* move x11 stuff into ifdefs which is missing in v1

* also move them into if(GDK_IS_X11_DISPLAY()){} block,needed to work
---
 eel/eel-gdk-extensions.c                        | 52 +++++++-------
libnautilus-private/nautilus-canvas-container.c | 86 ++++++++++++-----------
 libnautilus-private/nautilus-canvas-dnd.c       |  3 +
 libnautilus-private/nautilus-program-choosing.c |  2 +
 src/nautilus-application.c                      |  3 +
src/nautilus-desktop-canvas-view.c | 92 +++++++++++++------------
 src/nautilus-desktop-window.c                   | 62 +++++++++--------
 src/nautilus-mime-actions.c                     | 37 ++++++----
 src/nautilus-shell-search-provider.c            |  3 +
 src/nautilus-view.c                             | 18 ++---
 src/nautilus-window.c                           | 34 ++++-----
 11 files changed, 213 insertions(+), 179 deletions(-)

diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index d288fc9..3171216 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -44,35 +44,37 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
 {
        EelGdkGeometryFlags gdk_flags = EEL_GDK_NO_VALUE;
 #ifdef GDK_WINDOWING_X11
-       int x11_flags;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               int x11_flags;

-       g_return_val_if_fail (string != NULL, EEL_GDK_NO_VALUE);
-       g_return_val_if_fail (x_return != NULL, EEL_GDK_NO_VALUE);
-       g_return_val_if_fail (y_return != NULL, EEL_GDK_NO_VALUE);
-       g_return_val_if_fail (width_return != NULL, EEL_GDK_NO_VALUE);
-       g_return_val_if_fail (height_return != NULL, EEL_GDK_NO_VALUE);
+               g_return_val_if_fail (string != NULL, EEL_GDK_NO_VALUE);
+               g_return_val_if_fail (x_return != NULL, EEL_GDK_NO_VALUE);
+               g_return_val_if_fail (y_return != NULL, EEL_GDK_NO_VALUE);
+               g_return_val_if_fail (width_return != NULL, EEL_GDK_NO_VALUE);
+               g_return_val_if_fail (height_return != NULL, EEL_GDK_NO_VALUE);

-       x11_flags = XParseGeometry (string, x_return, y_return,
+               x11_flags = XParseGeometry (string, x_return, y_return,
                                    width_return, height_return);

-       gdk_flags = EEL_GDK_NO_VALUE;
-       if (x11_flags & XValue) {
-               gdk_flags |= EEL_GDK_X_VALUE;
-       }
-       if (x11_flags & YValue) {
-               gdk_flags |= EEL_GDK_Y_VALUE;
-       }
-       if (x11_flags & WidthValue) {
-               gdk_flags |= EEL_GDK_WIDTH_VALUE;
-       }
-       if (x11_flags & HeightValue) {
-               gdk_flags |= EEL_GDK_HEIGHT_VALUE;
-       }
-       if (x11_flags & XNegative) {
-               gdk_flags |= EEL_GDK_X_NEGATIVE;
-       }
-       if (x11_flags & YNegative) {
-               gdk_flags |= EEL_GDK_Y_NEGATIVE;
+               gdk_flags = EEL_GDK_NO_VALUE;
+               if (x11_flags & XValue) {
+                       gdk_flags |= EEL_GDK_X_VALUE;
+               }
+               if (x11_flags & YValue) {
+                       gdk_flags |= EEL_GDK_Y_VALUE;
+               }
+               if (x11_flags & WidthValue) {
+                       gdk_flags |= EEL_GDK_WIDTH_VALUE;
+               }
+               if (x11_flags & HeightValue) {
+                       gdk_flags |= EEL_GDK_HEIGHT_VALUE;
+               }
+               if (x11_flags & XNegative) {
+                       gdk_flags |= EEL_GDK_X_NEGATIVE;
+               }
+               if (x11_flags & YNegative) {
+                       gdk_flags |= EEL_GDK_Y_NEGATIVE;
+               }
        }
 #endif
        return gdk_flags;
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index c578b3b..3800367 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -2342,20 +2342,21 @@ get_rubber_color (NautilusCanvasContainer *container,
                   GdkRGBA *bordercolor)
 {
 #ifdef GDK_WINDOWING_X11
-       Atom         representative_colors_atom,real_type;
-       Display     *display;
-       gint         result = -1;
-       gint         real_format;
-       gulong       items_read = 0;
-       gulong       items_left = 0;
-       gchar       *colors;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               Atom         representative_colors_atom,real_type;
+               Display     *display;
+               gint         result = -1;
+               gint         real_format;
+               gulong       items_read = 0;
+               gulong       items_left = 0;
+               gchar       *colors;

-       if (nautilus_canvas_container_get_is_desktop (container)) {
- representative_colors_atom = gdk_x11_get_xatom_by_name ("_GNOME_BACKGROUND_REPRESENTATIVE_COLORS");
-               display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());
+               if (nautilus_canvas_container_get_is_desktop (container)) {
+ representative_colors_atom = gdk_x11_get_xatom_by_name ("_GNOME_BACKGROUND_REPRESENTATIVE_COLORS");
+                       display = gdk_x11_display_get_xdisplay (gdk_display_get_default ());

-               gdk_error_trap_push ();
-               result = XGetWindowProperty (display,
+                       gdk_error_trap_push ();
+                       result = XGetWindowProperty (display,
                                             GDK_ROOT_WINDOW (),
                                             representative_colors_atom,
                                             0L,
@@ -2367,45 +2368,46 @@ get_rubber_color (NautilusCanvasContainer *container,
                                             &items_read,
                                             &items_left,
                                             (guchar **) &colors);
-               gdk_error_trap_pop_ignored ();
-       }
+                       gdk_error_trap_pop_ignored ();
+               }

-       if (result == Success && items_read) {
+               if (result == Success && items_read) {
                /* by treating the result as a nul-terminated string, we
                 * select the first colour in the list.
                 */
-               GdkRGBA read;
-               gdouble shade;
+                       GdkRGBA read;
+                       gdouble shade;

-               gdk_rgba_parse (&read, colors);
-               XFree (colors);
+                       gdk_rgba_parse (&read, colors);
+                       XFree (colors);

-               /* Border
-                *
-                * We shade darker colours to be slightly lighter and
-                * lighter ones to be slightly darker.
-                */
-               shade = read.green < 0.5 ? 1.1 : 0.9;
-               bordercolor->red = read.red * shade;
-               bordercolor->green = read.green * shade;
-               bordercolor->blue = read.blue * shade;
-               bordercolor->alpha = 1.0;
-
-               /* Background */
-               *bgcolor = read;
-               bgcolor->alpha = 0.6;
-       } else {
-               /* Fallback to the style context if we can't get the Atom */
-               GtkStyleContext *context;
+                       /* Border
+                        *
+                        * We shade darker colours to be slightly lighter and
+                        * lighter ones to be slightly darker.
+                        */
+                       shade = read.green < 0.5 ? 1.1 : 0.9;
+                       bordercolor->red = read.red * shade;
+                       bordercolor->green = read.green * shade;
+                       bordercolor->blue = read.blue * shade;
+                       bordercolor->alpha = 1.0;
+
+                       /* Background */
+                       *bgcolor = read;
+                       bgcolor->alpha = 0.6;
+               } else {
+                       /* Fallback to the style context if we can't get the Atom */
+                       GtkStyleContext *context;

-               context = gtk_widget_get_style_context (GTK_WIDGET (container));
-               gtk_style_context_save (context);
-               gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
+                       context = gtk_widget_get_style_context (GTK_WIDGET (container));
+                       gtk_style_context_save (context);
+                       gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);

- gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, bgcolor); - gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, bordercolor); + gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, bgcolor); + gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, bordercolor);

-               gtk_style_context_restore (context);
+                       gtk_style_context_restore (context);
+               }
        }
 #endif

diff --git a/libnautilus-private/nautilus-canvas-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c
index b4da369..6b514bc 100644
--- a/libnautilus-private/nautilus-canvas-dnd.c
+++ b/libnautilus-private/nautilus-canvas-dnd.c
@@ -48,7 +48,10 @@
 #include <eel/eel-string.h>
 #include <eel/eel-vfs-extensions.h>
 #include <gdk/gdkkeysyms.h>
+#include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>

diff --git a/libnautilus-private/nautilus-program-choosing.c b/libnautilus-private/nautilus-program-choosing.c
index 7160214..32212a7 100644
--- a/libnautilus-private/nautilus-program-choosing.c
+++ b/libnautilus-private/nautilus-program-choosing.c
@@ -38,7 +38,9 @@
 #include <stdlib.h>

 #include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif

 void
 nautilus_launch_application_for_mount (GAppInfo *app_info,
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index bde2330..5a6b9cd 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -64,7 +64,10 @@
 #include <gio/gio.h>
 #include <eel/eel-gtk-extensions.h>
 #include <eel/eel-stock-dialogs.h>
+#include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 #include <gtk/gtk.h>

G_DEFINE_TYPE (NautilusApplication, nautilus_application, GTK_TYPE_APPLICATION); diff --git a/src/nautilus-desktop-canvas-view.c b/src/nautilus-desktop-canvas-view.c
index 251fe9a..8c87f97 100644
--- a/src/nautilus-desktop-canvas-view.c
+++ b/src/nautilus-desktop-canvas-view.c
@@ -135,19 +135,20 @@ net_workarea_changed (NautilusDesktopCanvasView *canvas_view,
        long *nworkareas = NULL;

 #ifdef GDK_WINDOWING_X11
-       GdkAtom type_returned;
-       int format_returned;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               GdkAtom type_returned;
+               int format_returned;

-       g_return_if_fail (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (canvas_view));
+               g_return_if_fail (NAUTILUS_IS_DESKTOP_CANVAS_VIEW (canvas_view));

-       canvas_container = get_canvas_container (canvas_view);
+               canvas_container = get_canvas_container (canvas_view);

-       /* Find the number of desktops so we know how long the
-        * workareas array is going to be (each desktop will have four
-        * elements in the workareas array describing
-        * x,y,width,height) */
-       gdk_error_trap_push ();
-       if (!gdk_property_get (window,
+               /* Find the number of desktops so we know how long the
+                * workareas array is going to be (each desktop will have four
+                * elements in the workareas array describing
+                * x,y,width,height) */
+               gdk_error_trap_push ();
+               if (!gdk_property_get (window,
                               gdk_atom_intern ("_NET_NUMBER_OF_DESKTOPS", FALSE),
                               gdk_x11_xatom_to_atom (XA_CARDINAL),
                               0, 4, FALSE,
@@ -155,13 +156,13 @@ net_workarea_changed (NautilusDesktopCanvasView *canvas_view,
                               &format_returned,
                               &length_returned,
                               (guchar **) &nworkareas)) {
-               g_warning("Can not calculate _NET_NUMBER_OF_DESKTOPS");
-       }
-       if (gdk_error_trap_pop()
-           || nworkareas == NULL
-           || type_returned != gdk_x11_xatom_to_atom (XA_CARDINAL)
-           || format_returned != 32)
-               g_warning("Can not calculate _NET_NUMBER_OF_DESKTOPS");
+                       g_warning("Can not calculate _NET_NUMBER_OF_DESKTOPS");
+               }
+               if (gdk_error_trap_pop()
+               || nworkareas == NULL
+               || type_returned != gdk_x11_xatom_to_atom (XA_CARDINAL)
+               || format_returned != 32)
+                       g_warning("Can not calculate _NET_NUMBER_OF_DESKTOPS");

        /* Note : gdk_property_get() is broken (API documents admit
         * this).  As a length argument, it expects the number of
@@ -173,9 +174,9 @@ net_workarea_changed (NautilusDesktopCanvasView *canvas_view,
         * request does not correspond to the number of bytes you get
         * back, and is the reason for the workaround below.
         */
-       gdk_error_trap_push ();
-       if (nworkareas == NULL || (*nworkareas < 1)
-           || !gdk_property_get (window,
+               gdk_error_trap_push ();
+               if (nworkareas == NULL || (*nworkareas < 1)
+               || !gdk_property_get (window,
                                  gdk_atom_intern ("_NET_WORKAREA", FALSE),
                                  gdk_x11_xatom_to_atom (XA_CARDINAL),
                                  0, ((*nworkareas) * 4 * 4), FALSE,
@@ -183,23 +184,24 @@ net_workarea_changed (NautilusDesktopCanvasView *canvas_view,
                                  &format_returned,
                                  &length_returned,
                                  (guchar **) &workareas)) {
-               g_warning("Can not get _NET_WORKAREA");
-               workareas = NULL;
-       }
+                       g_warning("Can not get _NET_WORKAREA");
+                       workareas = NULL;
+               }

-       if (gdk_error_trap_pop ()
-           || workareas == NULL
-           || type_returned != gdk_x11_xatom_to_atom (XA_CARDINAL)
-           || ((*nworkareas) * 4 * sizeof(long)) != length_returned
-           || format_returned != 32) {
-               g_warning("Can not determine workarea, guessing at layout");
-               nautilus_canvas_container_set_margins (canvas_container,
+               if (gdk_error_trap_pop ()
+                       || workareas == NULL
+               || type_returned != gdk_x11_xatom_to_atom (XA_CARDINAL)
+               || ((*nworkareas) * 4 * sizeof(long)) != length_returned
+               || format_returned != 32) {
+                       g_warning("Can not determine workarea, guessing at layout");
+                       nautilus_canvas_container_set_margins (canvas_container,
                                                     0, 0, 0, 0);
-       } else {
-               screen = gdk_window_get_screen (window);
+               } else {
+                       screen = gdk_window_get_screen (window);

-               canvas_container_set_workarea
- (canvas_container, screen, workareas, length_returned / sizeof (long));
+                       canvas_container_set_workarea
+ (canvas_container, screen, workareas, length_returned / sizeof (long));
+               }
        }
 #endif

@@ -221,18 +223,20 @@ desktop_canvas_view_property_filter (GdkXEvent *gdk_xevent,
                                   gpointer data)
 {
 #ifdef GDK_WINDOWING_X11
-       XEvent *xevent = gdk_xevent;
-       NautilusDesktopCanvasView *canvas_view;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               XEvent *xevent = gdk_xevent;
+               NautilusDesktopCanvasView *canvas_view;

-       canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (data);
+               canvas_view = NAUTILUS_DESKTOP_CANVAS_VIEW (data);

-       switch (xevent->type) {
-       case PropertyNotify:
- if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WORKAREA"))
-                       net_workarea_changed (canvas_view, event->any.window);
-               break;
-       default:
-               break;
+               switch (xevent->type) {
+               case PropertyNotify:
+ if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WORKAREA"))
+                               net_workarea_changed (canvas_view, event->any.window);
+                       break;
+               default:
+                       break;
+               }
        }
 #endif
        return GDK_FILTER_CONTINUE;
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 7c95314..4a83b89 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -118,48 +118,50 @@ static void
 nautilus_desktop_window_init_selection (NautilusDesktopWindow *window)
 {
 #ifdef GDK_WINDOWING_X11
-       char selection_name[32];
-       GdkAtom selection_atom;
-       Window selection_owner;
-       GdkDisplay *display;
-       GtkWidget *selection_widget;
-       GdkScreen *screen;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               char selection_name[32];
+               GdkAtom selection_atom;
+               Window selection_owner;
+               GdkDisplay *display;
+               GtkWidget *selection_widget;
+               GdkScreen *screen;

-       screen = gdk_screen_get_default ();
+               screen = gdk_screen_get_default ();

-       g_snprintf (selection_name, sizeof (selection_name),
+               g_snprintf (selection_name, sizeof (selection_name),
                    "_NET_DESKTOP_MANAGER_S%d", gdk_screen_get_number (screen));
-       selection_atom = gdk_atom_intern (selection_name, FALSE);
-       display = gdk_screen_get_display (screen);
+               selection_atom = gdk_atom_intern (selection_name, FALSE);
+               display = gdk_screen_get_display (screen);

-       selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
+               selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
                                              gdk_x11_atom_to_xatom_for_display (display,
                                                                                 selection_atom));
-       if (selection_owner != None) {
- g_critical ("Another desktop manager in use; desktop window won't be created");
-               return;
-       }
+               if (selection_owner != None) {
+ g_critical ("Another desktop manager in use; desktop window won't be created");
+                       return;
+               }

-       selection_widget = gtk_invisible_new_for_screen (screen);
-       /* We need this for gdk_x11_get_server_time() */
-       gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
+               selection_widget = gtk_invisible_new_for_screen (screen);
+               /* We need this for gdk_x11_get_server_time() */
+               gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);

-       if (!gtk_selection_owner_set_for_display (display,
+               if (!gtk_selection_owner_set_for_display (display,
                                                  selection_widget,
                                                  selection_atom,
gdk_x11_get_server_time (gtk_widget_get_window (selection_widget)))) {
-               gtk_widget_destroy (selection_widget);
- g_critical ("Can't set ourselves as selection owner for desktop manager; "
+                       gtk_widget_destroy (selection_widget);
+ g_critical ("Can't set ourselves as selection owner for desktop manager; "
                            "desktop window won't be created");
-               return;
-       }
+                       return;
+               }

-       g_signal_connect (selection_widget, "selection-get",
+               g_signal_connect (selection_widget, "selection-get",
                          G_CALLBACK (selection_get_cb), window);
-       g_signal_connect (selection_widget, "selection-clear-event",
+               g_signal_connect (selection_widget, "selection-clear-event",
                          G_CALLBACK (selection_clear_event_cb), window);

-       window->details->desktop_selection = selection_widget;
+               window->details->desktop_selection = selection_widget;
+       }
 #endif
 }

@@ -321,14 +323,16 @@ static void
 set_wmspec_desktop_hint (GdkWindow *window)
 {
 #ifdef GDK_WINDOWING_X11
-       GdkAtom atom;
+       if(GDK_IS_X11_WINDOW(window)){
+               GdkAtom atom;

-       atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE);
+               atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE);

-       gdk_property_change (window,
+               gdk_property_change (window,
                             gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
                             gdk_x11_xatom_to_atom (XA_ATOM), 32,
                             GDK_PROP_MODE_REPLACE, (guchar *) &atom, 1);
+       }
 #endif
 }

diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 2251383..a5288ee 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -33,7 +33,10 @@
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
 #include <string.h>
+#include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif

 #include <libnautilus-private/nautilus-file-attributes.h>
 #include <libnautilus-private/nautilus-file.h>
@@ -1093,22 +1096,24 @@ search_for_application_dbus_call_notify_cb (GDBusProxy *proxy,
 static void
search_for_application_mime_type (ActivateParametersInstall *parameters_install, const gchar *mime_type)
 {
-       GdkWindow *window;
-       guint xid = 0;
-       const char *mime_types[2];
-
-       g_assert (parameters_install->proxy != NULL);
-
-       /* get XID from parent window */
- window = gtk_widget_get_window (GTK_WIDGET (parameters_install->parent_window));
-       if (window != NULL) {
-               xid = GDK_WINDOW_XID (window);
-       }
+#ifdef GDK_WINDOWING_X11
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               GdkWindow *window;
+               guint xid = 0;
+               const char *mime_types[2];
+
+               g_assert (parameters_install->proxy != NULL);
+
+               /* get XID from parent window */
+ window = gtk_widget_get_window (GTK_WIDGET (parameters_install->parent_window));
+               if (window != NULL) {
+                       xid = GDK_WINDOW_XID (window);
+               }

-       mime_types[0] = mime_type;
-       mime_types[1] = NULL;
+               mime_types[0] = mime_type;
+               mime_types[1] = NULL;

-       g_dbus_proxy_call (parameters_install->proxy,
+               g_dbus_proxy_call (parameters_install->proxy,
                           "InstallMimeTypes",
                           g_variant_new ("(u^ass)",
                                          xid,
@@ -1120,7 +1125,9 @@ search_for_application_mime_type (ActivateParametersInstall *parameters_install,
                           (GAsyncReadyCallback) search_for_application_dbus_call_notify_cb,
                           parameters_install);

-       DEBUG ("InstallMimeType method invoked for %s", mime_type);
+               DEBUG ("InstallMimeType method invoked for %s", mime_type);
+       }
+#endif
 }

 static void
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index 78cfb83..1683754 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -26,7 +26,10 @@
 #include <gio/gio.h>
 #include <string.h>
 #include <glib/gi18n.h>
+#include <gdk/gdk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif

 #include <libnautilus-private/nautilus-file.h>
 #include <libnautilus-private/nautilus-file-utilities.h>
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index df6046f..65d04e3 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -820,17 +820,19 @@ nautilus_view_preview_files (NautilusView *view,
                             GArray *locations)
 {
 #ifdef GDK_WINDOWING_X11
-       gchar *uri;
-       guint xid;
-       GtkWidget *toplevel;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               gchar *uri;
+               guint xid;
+               GtkWidget *toplevel;

-       uri = nautilus_file_get_uri (files->data);
-       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+               uri = nautilus_file_get_uri (files->data);
+               toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));

-       xid = gdk_x11_window_get_xid (gtk_widget_get_window (toplevel));
-       nautilus_previewer_call_show_file (uri, xid, TRUE);
+               xid = gdk_x11_window_get_xid (gtk_widget_get_window (toplevel));
+               nautilus_previewer_call_show_file (uri, xid, TRUE);

-       g_free (uri);
+               g_free (uri);
+       }
 #endif
 }

diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index b156e65..0317b60 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1238,33 +1238,35 @@ format_cb (GtkMenuItem *item,
           gpointer     user_data)
 {
 #ifdef GDK_WINDOWING_X11
-       NautilusWindow *window = NAUTILUS_WINDOW (user_data);
-       GAppInfo *app_info;
-       gchar *cmdline, *device_identifier, *xid_string;
-       GVolume *volume;
+       if(GDK_IS_X11_DISPLAY(gdk_display_get_default())){
+               NautilusWindow *window = NAUTILUS_WINDOW (user_data);
+               GAppInfo *app_info;
+               gchar *cmdline, *device_identifier, *xid_string;
+               GVolume *volume;

-       volume = g_object_get_data (G_OBJECT (item), "nautilus-volume");
+               volume = g_object_get_data (G_OBJECT (item), "nautilus-volume");

-       g_assert (volume != NULL && G_IS_VOLUME (volume));
+               g_assert (volume != NULL && G_IS_VOLUME (volume));

- device_identifier = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); + device_identifier = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);

- xid = (gint) gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window)));
-       xid_string = g_strdup_printf ("%d", xid);
+ xid = (gint) gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (window)));
+               xid_string = g_strdup_printf ("%d", xid);

-       cmdline = g_strconcat ("gnome-disks ",
+               cmdline = g_strconcat ("gnome-disks ",
                               "--block-device ", device_identifier, " ",
                               "--format-device ",
                               "--xid ", xid_string,
                               NULL);

- app_info = g_app_info_create_from_commandline (cmdline, NULL, 0, NULL);
-       g_app_info_launch (app_info, NULL, NULL, NULL);
+ app_info = g_app_info_create_from_commandline (cmdline, NULL, 0, NULL);
+               g_app_info_launch (app_info, NULL, NULL, NULL);

-       g_free (cmdline);
-       g_free (device_identifier);
-       g_free (xid_string);
-       g_clear_object (&app_info);
+               g_free (cmdline);
+               g_free (device_identifier);
+               g_free (xid_string);
+               g_clear_object (&app_info);
+       }
 #endif
 }

--
2.4.5



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]