[gnome-software/wip/hughsie/GsAppList2: 4/4] Export a set of headers to allow external plugins to be built



commit f0b6c86973c073d9bfc75668588552f4ded30272
Author: Richard Hughes <richard hughsie com>
Date:   Thu May 19 09:32:29 2016 +0100

    Export a set of headers to allow external plugins to be built
    
    This isn't something that I think is a very good idea; the API and ABI inside
    gnome-software is still changing and there's a huge benefit to getting plugins
    upstream where they can undergo review. However, when we're shipping
    gnome-software in enterprise-class distros we might want to allow customers to
    ship thier own plugins to make various business-specific changes that don't
    make sense upstream.
    
    This might involve querying a custom LDAP server and changing the suggested apps
    to reflect what groups the user is in, or might involve showing a whole new
    class of applications that does not conform to the Linux-specific "application
    is a desktop-file" paradigm.

 configure.ac                   |    5 ++-
 contrib/gnome-software.spec.in |   14 ++++++++++
 contrib/gs-plugin-example.c    |   55 ++++++++++++++++++++++++++++++++++++++++
 src/Makefile.am                |   15 +++++++++++
 src/gnome-software.h           |    4 +++
 src/gnome-software.pc.in       |   13 +++++++++
 src/gs-screenshot-image.c      |    4 +-
 src/gs-shell-details.c         |    1 -
 src/plugins/Makefile.am        |    1 +
 9 files changed, 107 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index efc7cf7..45fb6b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,9 +15,9 @@ AC_PROG_INSTALL
 LT_INIT
 AM_PROG_CC_C_O
 IT_PROG_INTLTOOL([0.35.0])
-#YELP_HELP_INIT
 
-#GNOME_DOC_INIT
+# set up gtk-doc
+GTK_DOC_CHECK([1.11],[--flavour no-tmpl])
 
 dnl ---------------------------------------------------------------------------
 dnl - Extra verbose warning switches
@@ -334,6 +334,7 @@ data/icons/hicolor/48x48/Makefile
 data/icons/hicolor/256x256/Makefile
 data/icons/hicolor/scalable/Makefile
 data/tests/Makefile
+src/gnome-software.pc
 src/Makefile
 src/plugins/Makefile
 tests/Makefile
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
index e7656be..833bb6e 100644
--- a/contrib/gnome-software.spec.in
+++ b/contrib/gnome-software.spec.in
@@ -61,6 +61,14 @@ BuildRequires: flatpak-devel >= %{flatpak_version}
 gnome-software is an application that makes it easy to add, remove
 and update software in the GNOME desktop.
 
+%package devel
+Summary: Headers for building external gnome-software plugins
+Requires: libappstream-glib-devel%{?_isa}
+
+%description devel
+These development files are for building gnome-software plugins outside
+the source tree. Most users do not need this subpackage installed.
+
 %prep
 %setup -q
 
@@ -126,6 +134,12 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
 %{_datadir}/glib-2.0/schemas/org.gnome.software.gschema.xml
 %{_datadir}/glib-2.0/schemas/org.gnome.software-fedora.gschema.override
 
+%files devel
+%{_libdir}/pkgconfig/gnome-software.pc
+%dir %{_includedir}/gnome-software
+%{_includedir}/gnome-software/*.h
+%{_datadir}/gtk-doc/html/gnome-software
+
 %changelog
 * #LONGDATE# Richard Hughes <richard hughsie com> #VERSION#-0.#BUILD##ALPHATAG#
 - Update from GIT
diff --git a/contrib/gs-plugin-example.c b/contrib/gs-plugin-example.c
new file mode 100644
index 0000000..fb57a36
--- /dev/null
+++ b/contrib/gs-plugin-example.c
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2016 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <gnome-software.h>
+
+/*
+ * Compile and install with:
+ *
+ * gcc -shared -o libgs_plugin_example.so gs-plugin-example.c -fPIC \
+ *  `pkg-config --libs --cflags gnome-software` &&
+ *  cp gs_plugin_example.so `pkg-config gnome-software --variable=plugindir`
+ */
+
+const gchar **
+gs_plugin_order_before (GsPlugin *plugin)
+{
+       const gchar *deps[] = { "appstream", NULL };
+       return deps;
+}
+
+gboolean
+gs_plugin_add_search (GsPlugin *plugin,
+                     gchar **values,
+                     GsAppList *list,
+                     GCancellable *cancellable,
+                     GError **error)
+{
+       guint i;
+       for (i = 0; values[i] != NULL; i++) {
+               if (g_strcmp0 (values[i], "photoshop") == 0) {
+                       g_autoptr(GsApp) app = gs_app_new ("gimp.desktop");
+                       gs_app_add_quirk (app, AS_APP_QUIRK_MATCH_ANY_PREFIX);
+                       gs_app_list_add (list, app);
+               }
+       }
+       return TRUE;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 2675a8e..93a2f2c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,20 @@ AM_CPPFLAGS =                                                \
        -DTESTDATADIR=\""$(top_srcdir)/data"\"          \
        -DGS_DATA=\"$(pkgdatadir)\"
 
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = gnome-software.pc
+
+gnomesoftware_includedir = $(includedir)/gnome-software
+gnomesoftware_include_HEADERS =                                \
+       gnome-software.h                                \
+       gs-app.h                                        \
+       gs-app-list.h                                   \
+       gs-category.h                                   \
+       gs-os-release.h                                 \
+       gs-plugin.h                                     \
+       gs-review.h                                     \
+       gs-utils.h
+
 @INTLTOOL_DESKTOP_RULE@
 desktopdir = $(datadir)/applications
 desktop_in_files =                                     \
@@ -330,6 +344,7 @@ EXTRA_DIST =                                                \
        org.freedesktop.PackageKit.xml                  \
        org.freedesktop.PackageKit.Modify2.xml          \
        gnome-software.gresource.xml                    \
+       gnome-software.pc.in                            \
        gnome-software.xml                              \
        gtk-style.css                                   \
        gtk-style-hc.css                                \
diff --git a/src/gnome-software.h b/src/gnome-software.h
index 7e4c041..be10cc4 100644
--- a/src/gnome-software.h
+++ b/src/gnome-software.h
@@ -22,6 +22,10 @@
 #ifndef __GNOME_SOFTWARE_H__
 #define __GNOME_SOFTWARE_H__
 
+#ifndef I_KNOW_THE_GNOME_SOFTWARE_API_IS_SUBJECT_TO_CHANGE
+#error You have to define I_KNOW_THE_GNOME_SOFTWARE_API_IS_SUBJECT_TO_CHANGE
+#endif
+
 #include <gs-app.h>
 #include <gs-app-list.h>
 #include <gs-category.h>
diff --git a/src/gnome-software.pc.in b/src/gnome-software.pc.in
new file mode 100644
index 0000000..2c22d4b
--- /dev/null
+++ b/src/gnome-software.pc.in
@@ -0,0 +1,13 @@
+prefix= prefix@
+exec_prefix= exec_prefix@
+libdir= libdir@
+includedir= includedir@
+plugindir= libdir@/gs-plugins- GS_PLUGIN_API_VERSION@
+
+Name: gnome-software
+Description: GNOME Software is a software center for GNOME
+Version: @VERSION@
+Requires.private: gthread-2.0 atk
+Requires: gobject-2.0 gdk-3.0 appstream-glib libsoup-2.4 gio-unix-2.0
+Libs: -L${libdir}
+Cflags: -I${includedir}/gnome-software
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 8d17636..f56731d 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -1,6 +1,6 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  *
- * Copyright (C) 2013 Richard Hughes <richard hughsie com>
+ * Copyright (C) 2013-2016 Richard Hughes <richard hughsie com>
  * Copyright (C) 2013 Matthias Clasen <mclasen redhat com>
  *
  * Licensed under the GNU General Public License Version 2
@@ -24,7 +24,6 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gnome-software.h>
 
 #define GNOME_DESKTOP_USE_UNSTABLE_API
 #include <libgnome-desktop/gnome-bg.h>
@@ -32,6 +31,7 @@
 
 #include "gs-screenshot-image.h"
 #include "gs-common.h"
+#include "gs-utils.h"
 
 struct _GsScreenshotImage
 {
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index d92282f..ec48830 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -24,7 +24,6 @@
 
 #include <string.h>
 #include <glib/gi18n.h>
-#include <gnome-software.h>
 
 #include "gs-common.h"
 
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 0237315..756d706 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -16,6 +16,7 @@ AM_CPPFLAGS =                                         \
        $(XDG_APP_CFLAGS)                               \
        $(FLATPAK_CFLAGS)                               \
        $(RPM_CFLAGS)                                   \
+       -DI_KNOW_THE_GNOME_SOFTWARE_API_IS_SUBJECT_TO_CHANGE    \
        -DBINDIR=\"$(bindir)\"                          \
        -DDATADIR=\"$(datadir)\"                        \
        -DG_LOG_DOMAIN=\"GsPlugin\"                     \


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