From 92885b9ce200f760563f36f1cf50150fecd0bd98 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 4 Dec 2015 09:36:30 +0000 Subject: [PATCH 1/3] Add introspection check --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 537071e4..83a925e2 100644 --- a/configure.ac +++ b/configure.ac @@ -192,6 +192,8 @@ if test x$enable_documentation = xyes; then fi AM_CONDITIONAL(BUILD_DOCUMENTATION, test x$enable_documentation = xyes) +GOBJECT_INTROSPECTION_CHECK([1.40.0]) + ################################################## # Visibility handling ################################################## From 52ba7365185737841774c5f11229dcd0ba63d0e2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 4 Dec 2015 09:55:40 +0000 Subject: [PATCH 2/3] Add introspection support to libxdg-app We may want to use it from non-C languages. --- .gitignore | 2 ++ Makefile.am | 1 + lib/Makefile.am.inc | 46 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 86045e68..71068f1b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,5 @@ lib/xdg-app-version-macros.h xdg-app.pc lib/xdg-app-enum-types.c lib/xdg-app-enum-types.h +test-libxdg-app +XdgApp-1.0.* diff --git a/Makefile.am b/Makefile.am index e7f8df04..08ceaabc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,7 @@ NULL = bin_PROGRAMS = $(NULL) noinst_PROGRAMS = $(NULL) libexec_PROGRAMS = $(NULL) +CLEANFILES = $(NULL) DISTCLEANFILES= $(NULL) BUILT_SOURCES = $(NULL) diff --git a/lib/Makefile.am.inc b/lib/Makefile.am.inc index 1c1e2dbe..837eed0d 100644 --- a/lib/Makefile.am.inc +++ b/lib/Makefile.am.inc @@ -37,9 +37,7 @@ lib/xdg-app-enum-types.c: $(public_headers) lib/xdg-app-enum-types.c.template xdgappincludedir = $(includedir)/xdg-app xdgappinclude_HEADERS = $(public_headers) $(generated_public_headers) -libxdg_app_la_SOURCES = \ - $(public_headers) \ - $(generated_public_headers) \ +sources = \ lib/xdg-app.c \ lib/xdg-app-enum-types.c \ lib/xdg-app-ref.c \ @@ -50,8 +48,14 @@ libxdg_app_la_SOURCES = \ lib/xdg-app-installation.c \ $(NULL) +libxdg_app_la_SOURCES = \ + $(public_headers) \ + $(generated_public_headers) \ + $(sources) \ + $(NULL) + libxdg_app_la_CFLAGS = \ - $(HIDDEN_VISIBILITY_CFLAGS) \ + $(HIDDEN_VISIBILITY_CFLAGS) \ -DXDG_APP_COMPILATION \ -I$(top_srcdir)/lib \ -I$(top_builddir)/lib \ @@ -88,3 +92,37 @@ test_libxdg_app_LDADD = \ $(BASE_LIBS) \ libxdg-app.la \ $(NULL) + +# gobject-introspection rules +-include $(INTROSPECTION_MAKEFILE) + +INTROSPECTION_GIRS = + +if HAVE_INTROSPECTION +XdgApp-1.0.gir: libxdg-app.la Makefile + +introspected_headers = $(public_headers) +introspected_sources = $(filter-out %-private.h,$(sources)) + +XdgApp_1_0_gir_NAMESPACE = XdgApp +XdgApp_1_0_gir_VERSION = 1.0 +XdgApp_1_0_gir_LIBS = libxdg-app.la +XdgApp_1_0_gir_FILES = $(introspected_headers) $(introspected_sources) +XdgApp_1_0_gir_CFLAGS = $(libxdg_app_la_CFLAGS) +XdgApp_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 +XdgApp_1_0_gir_SCANNERFLAGS = \ + --warn-all \ + --c-include='xdg-app.h' \ + --pkg-export=xdg-app + +INTROSPECTION_GIRS += XdgApp-1.0.gir + +girdir = $(datadir)/gir-1.0 +nodist_gir_DATA = $(INTROSPECTION_GIRS) +CLEANFILES += $(nodist_gir_DATA) + +typelibdir = $(libdir)/girepository-1.0 +nodist_typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) +CLEANFILES += $(nodist_typelib_DATA) + +endif # HAVE_INTROSPECTION From c09375c8559e72c63074d449d59cfae156a46c56 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 4 Dec 2015 10:17:39 +0000 Subject: [PATCH 3/3] Annotate transfer rules for ambiguous return values This silences all the warnings from the introspection scanner. --- lib/xdg-app-installation.c | 48 ++++++++++++++++++++++++++++++++++++++ lib/xdg-app-remote.c | 11 +++++++++ 2 files changed, 59 insertions(+) diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 5ba13a94..fb434d72 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -174,6 +174,20 @@ get_ref (XdgAppInstallation *self, is_current); } +/** + * xdg_app_installation_get_installed_ref: + * @self: a #XdgAppInstallation + * @kind: ... + * @name: ... + * @arch: ... + * @version: ... + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * ... + * + * Returns: (transfer full): ... + */ XdgAppInstalledRef * xdg_app_installation_get_installed_ref (XdgAppInstallation *self, XdgAppRefKind kind, @@ -208,6 +222,17 @@ xdg_app_installation_get_installed_ref (XdgAppInstallation *self, return get_ref (self, ref, cancellable); } +/** + * xdg_app_installation_get_current_installed_app: + * @self: a #XdgAppInstallation + * @name: the name of the app + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * ... + * + * Returns: (transfer full): ... + */ XdgAppInstalledRef * xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, const char *name, @@ -233,6 +258,18 @@ xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, return get_ref (self, current, cancellable); } +/** + * xdg_app_installation_list_installed_refs: + * @self: a #XdgAppInstallation + * @kind: the kind of installation + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * Lists the installed references. + * + * Returns: (transfer full) (array zero-terminated=1): an array of + * #XdgAppInstalledRef instances + */ XdgAppInstalledRef ** xdg_app_installation_list_installed_refs (XdgAppInstallation *self, XdgAppRefKind kind, @@ -260,6 +297,17 @@ xdg_app_installation_list_installed_refs (XdgAppInstallation *self, return (XdgAppInstalledRef **)g_ptr_array_free (g_steal_pointer (&refs), FALSE); } +/** + * xdg_app_installation_list_remotes: + * @self: a #XdgAppInstallation + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * Lists the remotes. + * + * Returns: (transfer full) (array zero-terminated=1): an array of + * #XdgAppRemote instances + */ XdgAppRemote ** xdg_app_installation_list_remotes (XdgAppInstallation *self, GCancellable *cancellable, diff --git a/lib/xdg-app-remote.c b/lib/xdg-app-remote.c index f1eb98d1..85f6c559 100644 --- a/lib/xdg-app-remote.c +++ b/lib/xdg-app-remote.c @@ -193,6 +193,17 @@ get_ref (XdgAppRemote *self, NULL); } +/** + * xdg_app_remote_list_refs: + * @self: a #XdgAppRemove + * @cancellable: (nullable): a #GCancellable + * @error: return location for a #GError + * + * Lists all the refs in a #XdgAppRemote. + * + * Returns: (transfer full) (array zero-terminated=1): a %NULL-terminated array + * of #XdgAppRef instances + */ XdgAppRef ** xdg_app_remote_list_refs (XdgAppRemote *self, GCancellable *cancellable,