[simple-scan/gnome-3-18: 1/6] Make PackageKit support optional



commit 41c92683a27131fd0731349f73418a0f4b98c5d4
Author: Robert Ancell <robert ancell canonical com>
Date:   Tue Sep 29 11:43:23 2015 +1300

    Make PackageKit support optional

 configure.ac    |   19 ++++++++++++++++++-
 src/Makefile.am |    6 ++++++
 src/ui.vala     |    7 +++++++
 3 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d53c561..111a285 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,7 +29,6 @@ PKG_CHECK_MODULES(SIMPLE_SCAN, [
     cairo
     gdk-pixbuf-2.0
     gusb
-    packagekit-glib2
 ])
 
 PKG_CHECK_MODULES(COLORD, [
@@ -37,6 +36,11 @@ PKG_CHECK_MODULES(COLORD, [
 ], have_colord=yes, have_colord=no)
 AM_CONDITIONAL(HAVE_COLORD, test $have_colord = yes)
 
+PKG_CHECK_MODULES(PACKAGEKIT, [
+    packagekit-glib2
+], have_packagekit=yes, have_packagekit=no)
+AM_CONDITIONAL(HAVE_PACKAGEKIT, test $have_packagekit = yes)
+
 AC_CHECK_HEADERS([sane/sane.h],[],[AC_MSG_ERROR([SANE not found])])
 AC_CHECK_HEADERS([sane/saneopts.h],[],[AC_MSG_ERROR([SANE not found])])
 
@@ -66,3 +70,16 @@ help/Makefile
 po/Makefile.in
 src/Makefile
 ])
+
+dnl ###########################################################################
+dnl Summary
+dnl ###########################################################################
+
+echo "
+                    Simple Scan $VERSION
+                    ====================
+
+        prefix:                   $prefix
+        PackageKit support:       $have_packagekit
+        Color management:         $have_colord
+"
diff --git a/src/Makefile.am b/src/Makefile.am
index 8bfb480..569f739 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,10 +33,15 @@ if HAVE_COLORD
 simple_scan_VALAFLAGS += -D HAVE_COLORD
 endif
 
+if HAVE_PACKAGEKIT
+simple_scan_VALAFLAGS += -D HAVE_PACKAGEKIT
+endif
+
 simple_scan_CFLAGS = \
        -w \
        $(SIMPLE_SCAN_CFLAGS) \
        $(COLORD_CFLAGS) \
+       $(PACKAGEKIT_CFLAGS) \    
        $(WARN_CFLAGS) \
        -DVERSION=\"$(VERSION)\" \
        -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \
@@ -50,6 +55,7 @@ simple_scan_CFLAGS = \
 simple_scan_LDADD = \
        $(SIMPLE_SCAN_LIBS) \
        $(COLORD_LIBS) \
+       $(PACKAGEKIT_LIBS) \    
        -lsane \
        -lm
 
diff --git a/src/ui.vala b/src/ui.vala
index ab1cfd4..a66db50 100644
--- a/src/ui.vala
+++ b/src/ui.vala
@@ -1639,6 +1639,7 @@ public class UserInterface : Gtk.ApplicationWindow
 
         if (packages_to_install.length > 0)
         {
+#if HAVE_PACKAGEKIT
             stack.visible = true;
             spinner.active = true;
             instructions_label.set_text (/* Label shown while installing drivers */
@@ -1671,12 +1672,17 @@ public class UserInterface : Gtk.ApplicationWindow
                 }
                 instructions_label.set_text (result_text);
             });
+#else
+            instructions_label.set_text (/* Label shown to prompt user to install packages (when PackageKit 
not available) */
+                                         _("You need to install the %s package(s).").printf (string.joinv 
(", ", packages_to_install)));
+#endif
         }
 
         dialog.run ();
         dialog.destroy ();
     }
 
+#if HAVE_PACKAGEKIT
     private async Pk.Results? install_packages (string[] packages, Pk.ProgressCallback progress_callback) 
throws GLib.Error
     {
         var task = new Pk.Task ();
@@ -1693,6 +1699,7 @@ public class UserInterface : Gtk.ApplicationWindow
 
         return yield task.install_packages_async (package_ids, null, progress_callback);
     }
+#endif
 
     [GtkCallback]
     private bool simple_scan_window_window_state_event_cb (Gtk.Widget widget, Gdk.EventWindowState event)


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