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



commit d88813e122edf28862e1bcaa8d29e2f0731fb12e
Author: Richard Hughes <richard hughsie com>
Date:   Fri Jul 22 13:45:57 2016 +0100

    Make gtkspell optional
    
    This makes it easier to build a flatpak app in the SDK.

 configure.ac           |   25 ++++++++++++++++++++++++-
 src/Makefile.am        |    2 ++
 src/gs-review-dialog.c |    7 +++++++
 3 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index af9b547..c54665c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,7 +60,7 @@ GLIB_GSETTINGS
 dnl ---------------------------------------------------------------------------
 dnl - Check library dependencies
 dnl ---------------------------------------------------------------------------
-PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.18.2 gio-unix-2.0 gtkspell3-3.0)
+PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.18.2 gio-unix-2.0)
 PKG_CHECK_MODULES(APPSTREAM, appstream-glib >= 0.5.15)
 PKG_CHECK_MODULES(GDK_PIXBUF, gdk-pixbuf-2.0 >= 2.31.5)
 PKG_CHECK_MODULES(JSON_GLIB, json-glib-1.0 >= 1.1.1)
@@ -97,6 +97,28 @@ AC_ARG_ENABLE(tests,
               enable_tests=yes)
 AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" != no)
 
+# spell checking
+AC_ARG_ENABLE(gtkspell,
+              [AS_HELP_STRING([--enable-gtkspell],
+                              [enable gtkspell support [default=auto]])],,
+              enable_gtkspell=yes)
+AS_IF([test "x$enable_gtkspell" != "xno"], [
+  PKG_CHECK_MODULES(GTKSPELL,
+                    [gtkspell3-3.0],
+                    [have_gtkspell=yes],
+                    [have_gtkspell=no])
+], [
+    have_gtkspell=no
+])
+AS_IF([test "x$have_gtkspell" = "xyes"], [
+    AC_DEFINE(HAVE_GTKSPELL,1,[Build gtkspell support])
+], [
+    AS_IF([test "x$enable_gtkspell" = "xyes"], [
+          AC_MSG_ERROR([gtkspell support requested but 'gtkspell3' was not found])
+    ])
+])
+AM_CONDITIONAL(HAVE_GTKSPELL, test "$have_gtkspell" != no)
+
 # PackageKit
 AC_ARG_ENABLE(packagekit,
               [AS_HELP_STRING([--enable-packagekit],
@@ -343,6 +365,7 @@ echo "
         Limba support:             ${have_limba}
         Flatpak support:           ${have_flatpak}
         OSTree support:            ${have_ostree}
+        GtkSpell support:          ${have_gtkspell}
         RPM support:               ${have_rpm}
         Steam support:             ${enable_steam}
         GNOME Shell ext. support:  ${enable_shell_extensions}
diff --git a/src/Makefile.am b/src/Makefile.am
index ae71985..9a2b4a5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -5,6 +5,7 @@ AM_CPPFLAGS =                                           \
        $(APPSTREAM_CFLAGS)                             \
        $(GLIB_CFLAGS)                                  \
        $(GTK_CFLAGS)                                   \
+       $(GTKSPELL_CFLAGS)                              \
        $(SOUP_CFLAGS)                                  \
        $(PACKAGEKIT_CFLAGS)                            \
        $(GNOME_DESKTOP_CFLAGS)                         \
@@ -276,6 +277,7 @@ gnome_software_LDADD =                                      \
        $(APPSTREAM_LIBS)                               \
        $(GLIB_LIBS)                                    \
        $(GTK_LIBS)                                     \
+       $(GTKSPELL_LIBS)                                \
        $(SOUP_LIBS)                                    \
        $(LIBSECRET_LIBS)                               \
        $(PACKAGEKIT_LIBS)                              \
diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c
index 9f41dc1..f81bf28 100644
--- a/src/gs-review-dialog.c
+++ b/src/gs-review-dialog.c
@@ -23,7 +23,10 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+
+#ifdef HAVE_GTKSPELL
 #include <gtkspell/gtkspell.h>
+#endif
 
 #include "gs-review-dialog.h"
 #include "gs-star-widget.h"
@@ -43,7 +46,9 @@ struct _GsReviewDialog
        GtkWidget       *summary_entry;
        GtkWidget       *post_button;
        GtkWidget       *text_view;
+#ifdef HAVE_GTKSPELL
        GtkSpellChecker *spell_checker;
+#endif
        guint            timer_id;
 };
 
@@ -175,10 +180,12 @@ gs_review_dialog_init (GsReviewDialog *dialog)
        gtk_widget_init_template (GTK_WIDGET (dialog));
        gs_star_widget_set_icon_size (GS_STAR_WIDGET (dialog->star), 32);
 
+#ifdef HAVE_GTKSPELL
        /* allow checking spelling */
        dialog->spell_checker = gtk_spell_checker_new ();
        gtk_spell_checker_attach (dialog->spell_checker,
                                  GTK_TEXT_VIEW (dialog->text_view));
+#endif
 
        /* require the user to spend at least 30 seconds on writing a review */
        dialog->timer_id = g_timeout_add_seconds (WRITING_TIME_MIN,


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