[gnome-software/wip/hughsie/flatpak: 2/2] Make gnome-desktop optional



commit e427221eead5488ecee803554ac9b8fe4fd52e93
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jul 22 13:46:34 2016 +0100

    Make gnome-desktop optional
    
    This makes it easier to build a flatpak app in the SDK.

 configure.ac              |   24 +++++++++++++++++++++++-
 src/gs-screenshot-image.c |    6 ++++++
 src/gs-shell-updates.c    |    9 ++++++++-
 3 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c54665c..ae005bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -67,7 +67,6 @@ PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 1.1.1)
 PKG_CHECK_MODULES(SQLITE, sqlite3)
 PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.51.92)
 PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
-PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0 >= 3.17.92)
 PKG_CHECK_MODULES(LIBSECRET, libsecret-1)
 AC_PATH_PROG(APPSTREAM_UTIL, [appstream-util], [unfound])
 AC_ARG_ENABLE(man,
@@ -119,6 +118,28 @@ AS_IF([test "x$have_gtkspell" = "xyes"], [
 ])
 AM_CONDITIONAL(HAVE_GTKSPELL, test "$have_gtkspell" != no)
 
+# gnome-desktop support
+AC_ARG_ENABLE(gnome-desktop,
+              [AS_HELP_STRING([--enable-gnome-desktop],
+                              [enable gnome-desktop support [default=auto]])],,
+              enable_gnome_desktop=yes)
+AS_IF([test "x$enable_gnome_desktop" != "xno"], [
+  PKG_CHECK_MODULES(GNOME_DESKTOP,
+                    [gnome-desktop-3.0 >= 3.17.92],
+                    [have_gnome_desktop=yes],
+                    [have_gnome_desktop=no])
+], [
+    have_gnome_desktop=no
+])
+AS_IF([test "x$have_gnome_desktop" = "xyes"], [
+    AC_DEFINE(HAVE_GNOME_DESKTOP,1,[Build gnome_desktop support])
+], [
+    AS_IF([test "x$enable_gnome_desktop" = "xyes"], [
+          AC_MSG_ERROR([gnome-desktop support requested but 'gnome-desktop' was not found])
+    ])
+])
+AM_CONDITIONAL(HAVE_GNOME_DESKTOP, test "$have_gnome_desktop" != no)
+
 # PackageKit
 AC_ARG_ENABLE(packagekit,
               [AS_HELP_STRING([--enable-packagekit],
@@ -366,6 +387,7 @@ echo "
         Flatpak support:           ${have_flatpak}
         OSTree support:            ${have_ostree}
         GtkSpell support:          ${have_gtkspell}
+        GNOME desktop support:     ${have_gnome_desktop}
         RPM support:               ${have_rpm}
         Steam support:             ${enable_steam}
         GNOME Shell ext. support:  ${enable_shell_extensions}
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 71bff51..bb34bed 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -25,9 +25,11 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+#ifdef HAVE_GNOME_DESKTOP
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include <libgnome-desktop/gnome-bg.h>
 #include <libgnome-desktop/gnome-desktop-thumbnail.h>
+#endif
 
 #include "gs-screenshot-image.h"
 #include "gs-common.h"
@@ -79,6 +81,7 @@ gs_screenshot_image_set_error (GsScreenshotImage *ssimg, const gchar *message)
 static GdkPixbuf *
 gs_screenshot_image_get_desktop_pixbuf (GsScreenshotImage *ssimg)
 {
+#ifdef HAVE_GNOME_DESKTOP
        g_autoptr(GnomeBG) bg = NULL;
        g_autoptr(GnomeDesktopThumbnailFactory) factory = NULL;
        g_autoptr(GSettings) settings = NULL;
@@ -90,6 +93,9 @@ gs_screenshot_image_get_desktop_pixbuf (GsScreenshotImage *ssimg)
        return gnome_bg_create_thumbnail (bg, factory,
                                          gdk_screen_get_default (),
                                          ssimg->width, ssimg->height);
+#else
+       return NULL;
+#endif
 }
 
 static gboolean
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 4d1e5d9..1693bc9 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -36,7 +36,10 @@
 #include "gs-upgrade-banner.h"
 #include "gs-application.h"
 
+#ifdef HAVE_GNOME_DESKTOP
 #include <gdesktop-enums.h>
+#endif
+
 #include <langinfo.h>
 
 typedef enum {
@@ -164,10 +167,12 @@ time_next_midnight (void)
 static gchar *
 gs_shell_updates_last_checked_time_string (GsShellUpdates *self)
 {
+#ifdef HAVE_GNOME_DESKTOP
        GDesktopClockFormat clock_format;
+#endif
        const gchar *format_string;
        gchar *time_string;
-       gboolean use_24h_time;
+       gboolean use_24h_time = FALSE;
        gint64 tmp;
        gint days_ago;
        g_autoptr(GDateTime) last_checked = NULL;
@@ -181,8 +186,10 @@ gs_shell_updates_last_checked_time_string (GsShellUpdates *self)
        midnight = time_next_midnight ();
        days_ago = g_date_time_difference (midnight, last_checked) / G_TIME_SPAN_DAY;
 
+#ifdef HAVE_GNOME_DESKTOP
        clock_format = g_settings_get_enum (self->desktop_settings, "clock-format");
        use_24h_time = (clock_format == G_DESKTOP_CLOCK_FORMAT_24H || self->ampm_available == FALSE);
+#endif
 
        if (days_ago < 1) { // today
                if (use_24h_time) {


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