[gnome-todo/wip/gbsneto/plugins] project: enable introspection



commit cafe4cd6103c4ffa876287dfd786c1ca971542c0
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Jan 15 22:20:27 2016 -0200

    project: enable introspection
    
    From this point, we'll start support plugins
    written in Python. Yay!

 Makefile.am                     |    3 +-
 configure.ac                    |    6 +++
 m4/introspection.m4             |   96 +++++++++++++++++++++++++++++++++++++++
 src/Makefile.am                 |   60 ++++++++++++++++++++++++
 src/gtd-application.c           |   16 ++++++-
 src/plugin/gtd-plugin-manager.c |    1 +
 6 files changed, 180 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 9851c4b..5a2523c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,8 @@ DISTCLEANFILES = \
        po/.intltool-merge-cache
 
 DISTCHECK_CONFIGURE_FLAGS = \
-       --enable-appstream-util
+       --enable-appstream-util \
+       --enable-introspection
 
 # Remove doc directory on uninstall
 uninstall-local:
diff --git a/configure.ac b/configure.ac
index c9a5e7f..077dc7c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,12 @@ AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [GETTEXT package name])
 
 dnl ================================================================
+dnl GObject introspection support
+dnl ================================================================
+GOBJECT_INTROSPECTION_CHECK([1.42.0])
+
+
+dnl ================================================================
 dnl Misc
 dnl ================================================================
 AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..d89c3d9
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,96 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build 
AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+       dnl Canonicalize enable_introspection
+       enable_introspection=$found_introspection
+    ],dnl
+    [dnl       
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of 
@<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir 
gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 29ff8e2..ad87dc2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,3 +133,63 @@ EXTRA_DIST = \
     gtd-enum-types.c.template
 
 -include $(top_srcdir)/git.mk
+
+
+#==================================
+# GObject introspection
+#==================================
+if HAVE_INTROSPECTION
+-include $(INTROSPECTION_MAKEFILE)
+
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = \
+       --add-include-path=$(srcdir) --warn-all
+INTROSPECTION_COMPILER_ARGS = \
+       --includedir=$(srcdir)
+
+introspection_sources = \
+       interfaces/gtd-activatable.c \
+       interfaces/gtd-activatable.h \
+       interfaces/gtd-panel.c \
+       interfaces/gtd-panel.h \
+       interfaces/gtd-provider.c \
+       interfaces/gtd-provider.h \
+       notification/gtd-notification.c \
+       notification/gtd-notification.h \
+       gtd-enums.h \
+       gtd-manager.c \
+       gtd-manager.h \
+       gtd-object.c \
+       gtd-object.h \
+       gtd-task.c \
+       gtd-task.h \
+       gtd-task-list.c \
+       gtd-task-list.h \
+       gtd-task-list-view.c \
+       gtd-task-list-view.h \
+       gtd-window.c \
+       gtd-window.h \
+       gtd-types.h \
+       $(NULL)
+
+Todo-1.0.gir: gnome-todo
+Todo_1_0_gir_INCLUDES = Gio-2.0 GObject-2.0 Gtk-3.0
+Todo_1_0_gir_CFLAGS = $(gnome_todo_CFLAGS)
+Todo_1_0_gir_PROGRAM = $(builddir)/gnome-todo
+Todo_1_0_gir_SCANNERFLAGS = \
+       -n Todo \
+       --identifier-prefix Gtd  \
+       --symbol-prefix gtd
+Todo_1_0_gir_FILES = $(introspection_sources)
+INTROSPECTION_GIRS += Todo-1.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += \
+       $(gir_DATA) \
+       $(typelib_DATA)
+endif
diff --git a/src/gtd-application.c b/src/gtd-application.c
index f4a5861..dab22f2 100644
--- a/src/gtd-application.c
+++ b/src/gtd-application.c
@@ -30,6 +30,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <gio/gio.h>
+#include <girepository.h>
 #include <glib/gi18n.h>
 
 typedef struct
@@ -146,7 +147,7 @@ gtd_application_new (void)
 
   return g_object_new (GTD_TYPE_APPLICATION,
                        "application-id", "org.gnome.Todo",
-                       "flags", G_APPLICATION_FLAGS_NONE,
+                       "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
                        "resource-base-path", "/org/gnome/todo",
                        NULL);
 }
@@ -280,6 +281,18 @@ gtd_application_startup (GApplication *application)
   gtd_manager_load_plugins (priv->manager);
 }
 
+static gboolean
+gtd_application_local_command_line (GApplication   *application,
+                                    gchar        ***arguments,
+                                    gint           *exit_status)
+{
+  g_application_add_option_group (application, g_irepository_get_option_group());
+
+  return G_APPLICATION_CLASS (gtd_application_parent_class)->local_command_line (application,
+                                                                                 arguments,
+                                                                                 exit_status);
+}
+
 static void
 gtd_application_class_init (GtdApplicationClass *klass)
 {
@@ -290,6 +303,7 @@ gtd_application_class_init (GtdApplicationClass *klass)
 
   application_class->activate = gtd_application_activate;
   application_class->startup = gtd_application_startup;
+  application_class->local_command_line = gtd_application_local_command_line;
 }
 
 static void
diff --git a/src/plugin/gtd-plugin-manager.c b/src/plugin/gtd-plugin-manager.c
index ac62d63..2f85072 100644
--- a/src/plugin/gtd-plugin-manager.c
+++ b/src/plugin/gtd-plugin-manager.c
@@ -275,6 +275,7 @@ setup_plugins (GtdPluginManager *self)
   const GList *l;
 
   engine = peas_engine_get_default ();
+  peas_engine_enable_loader (engine, "python3");
 
   /* Load plugins */
   plugins = peas_engine_get_plugin_list (engine);


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