[gnome-autoar] Enable GObject Introspection support



commit 59c84e185087814de13582af27dee4c099d83def
Author: Ting-Wei Lan <lantw44 gmail com>
Date:   Wed Jan 22 14:34:38 2014 +0800

    Enable GObject Introspection support
    
    Most GObject things work, but some non-GObject things need API change to work.

 Makefile.am                         |   40 ++++++++++++++++++++++++++++++----
 configure.ac                        |    4 +++
 gnome-autoar/autoar-create.c        |   19 ++++++++-------
 gnome-autoar/autoar-create.h        |    4 +-
 gnome-autoar/autoar-format-filter.c |   12 +++++-----
 gnome-autoar/autoar-format-filter.h |    4 +-
 gnome-autoar/autoar-gtk.c           |    4 +-
 tests/test-create.c                 |    2 +-
 8 files changed, 62 insertions(+), 27 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 496d11a..cb46bfb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST =
 BUILT_SOURCES =
-DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
 
 
 # Top-level directory
@@ -71,12 +71,46 @@ gnome_autoar_libgnome_autoar_la_CFLAGS = \
        -I$(top_builddir)/gnome-autoar          \
        $(AM_CFLAGS)                            \
        $(NULL)
+gnome_autoar_libgnome_autoar_la_LIBADD = \
+       $(DEPENDENCIES_LIBS)                    \
+       $(NULL)
 
 gnome-autoar/autoar-enum-types.h: gnome-autoar/autoar-enum-types.h.template $(libgnome_autoar_la_headers)
        $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gnome-autoar/autoar-enum-types.h.template 
$(libgnome_autoar_la_headers) ) > $@
 gnome-autoar/autoar-enum-types.c: gnome-autoar/autoar-enum-types.c.template $(libgnome_autoar_la_headers)
        $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gnome-autoar/autoar-enum-types.c.template 
$(libgnome_autoar_la_headers) ) > $@
 
+CLEANFILES = $(BUILT_SOURCES)
+DISTCLEANFILES = $(BUILT_SOURCES)
+MAINTAINERCLEANFILES = $(BUILT_SOURCES)
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS = gnome-autoar/GnomeAutoar-0.1.gir
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) --warn-all
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+gnome-autoar/GnomeAutoar-0.1.gir: gnome-autoar/libgnome-autoar.la
+gnome_autoar_GnomeAutoar_0_1_gir_SCANNERFLAGS = --identifier-prefix=Autoar
+gnome_autoar_GnomeAutoar_0_1_gir_CFLAGS = -I$(top_srcdir) $(AM_CFLAGS)
+gnome_autoar_GnomeAutoar_0_1_gir_INCLUDES = GLib-2.0 GObject-2.0 Gio-2.0 Gtk-3.0
+gnome_autoar_GnomeAutoar_0_1_gir_LIBS = gnome-autoar/libgnome-autoar.la
+gnome_autoar_GnomeAutoar_0_1_gir_FILES = \
+       $(libgnome_autoar_la_headers)           \
+       $(libgnome_autoar_la_sources)           \
+       $(NULL)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+
+endif
+
 
 # Directory: data
 gsettings_ENUM_NAMESPACE = org.gnome.desktop.archives
@@ -123,8 +157,4 @@ tests_test_ui_SOURCES = tests/test-ui.c
 tests_test_ui_CFLAGS = $(test_cflags)
 tests_test_ui_LDADD = $(test_libs)
 
-CLEANFILES = $(BUILT_SOURCES)
-DISTCLEANFILES = $(BUILT_SOURCES)
-MAINTAINERCLEANFILES = $(BUILT_SOURCES)
-
 SUBDIRS = . docs
diff --git a/configure.ac b/configure.ac
index aa348db..4b076b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,6 +30,9 @@ AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
 # check for gtk-doc
 GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
 
+# check for gobject-introspection
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
 # Checks for libraries.
 GLIB_REQUIRED=2.35.6
 GTK_REQUIRED=3.2
@@ -62,6 +65,7 @@ AC_CONFIG_FILES([Makefile
                  docs/Makefile
                  docs/reference/Makefile
                  gnome-autoar/gnome-autoar.pc])
+AS_MKDIR_P([data])
 AC_OUTPUT
 
 echo "
diff --git a/gnome-autoar/autoar-create.c b/gnome-autoar/autoar-create.c
index 26137c4..c98f262 100644
--- a/gnome-autoar/autoar-create.c
+++ b/gnome-autoar/autoar-create.c
@@ -82,7 +82,7 @@ G_DEFINE_QUARK (autoar-create, autoar_create)
 
 struct _AutoarCreatePrivate
 {
-  char **source;
+  GStrv  source;
   char  *output;
 
   GPtrArray *source_file; /* An array of GFile, not terminated by NULL */
@@ -246,7 +246,7 @@ autoar_create_set_property (GObject      *object,
  *
  * Returns: (transfer none): a %NULL-terminated array of strings
  **/
-char**
+GStrv
 autoar_create_get_source (AutoarCreate *arcreate)
 {
   g_return_val_if_fail (AUTOAR_IS_CREATE (arcreate), NULL);
@@ -260,7 +260,8 @@ autoar_create_get_source (AutoarCreate *arcreate)
  * This function is similar to autoar_create_get_source(), except for the return
  * value is an array of #GFile.
  *
- * Returns: (transfer none): a #GPtrArray, which is an array of #GFile
+ * Returns: (element-type GLib.PtrArray) (transfer none): a #GPtrArray,
+ * which is an array of #GFile
  **/
 GPtrArray*
 autoar_create_get_source_file (AutoarCreate *arcreate)
@@ -1238,14 +1239,14 @@ autoar_create_init (AutoarCreate *arcreate)
 }
 
 static AutoarCreate*
-autoar_create_new_full (const char **source,
+autoar_create_new_full (const GStrv  source,
                         GFile **source_file,
                         const char *output,
                         GFile *output_file,
                         AutoarPref *arpref)
 {
   AutoarCreate *arcreate;
-  const char **gen_source;
+  GStrv gen_source;
   char *gen_output;
   GPtrArray *gen_source_file;
   GFile *gen_output_file;
@@ -1262,7 +1263,7 @@ autoar_create_new_full (const char **source,
     for (i = 0; source_file[i] != NULL; i++)
       g_ptr_array_add (strv, autoar_common_g_file_get_name (source_file[i]));
     g_ptr_array_add (strv, NULL);
-    gen_source = (const char**) g_ptr_array_free (strv, FALSE);
+    gen_source = (const GStrv) g_ptr_array_free (strv, FALSE);
   }
 
   gen_source_file = g_ptr_array_new_with_free_func (g_object_unref);
@@ -1288,7 +1289,7 @@ autoar_create_new_full (const char **source,
                   NULL);
   arcreate->priv->arpref = g_object_ref (arpref);
 
-  g_strfreev ((char**)gen_source);
+  g_strfreev (gen_source);
   g_free (gen_output);
 
   if (gen_source_file != NULL)
@@ -1329,7 +1330,7 @@ autoar_create_new (AutoarPref *arpref,
   g_ptr_array_add (strv, NULL);
   va_end (ap);
 
-  arcreate = autoar_create_new_full ((const char**) strv->pdata, NULL,
+  arcreate = autoar_create_new_full ((const GStrv) strv->pdata, NULL,
                                      output, NULL, arpref);
   g_ptr_array_unref (strv);
   return arcreate;
@@ -1385,7 +1386,7 @@ autoar_create_new_file (AutoarPref *arpref,
 AutoarCreate*
 autoar_create_newv (AutoarPref  *arpref,
                     const char  *output,
-                    const char **source)
+                    const GStrv  source)
 {
   g_return_val_if_fail (source != NULL, NULL);
   g_return_val_if_fail (*source != NULL, NULL);
diff --git a/gnome-autoar/autoar-create.h b/gnome-autoar/autoar-create.h
index 9c953d8..0202111 100644
--- a/gnome-autoar/autoar-create.h
+++ b/gnome-autoar/autoar-create.h
@@ -87,7 +87,7 @@ AutoarCreate*   autoar_create_new_file            (AutoarPref *arpref,
                                                    ...);
 AutoarCreate*   autoar_create_newv                (AutoarPref  *arpref,
                                                    const char  *output,
-                                                   const char **source);
+                                                   const GStrv  source);
 AutoarCreate*   autoar_create_new_filev           (AutoarPref  *arpref,
                                                    GFile       *output_file,
                                                    GFile      **source_file);
@@ -97,7 +97,7 @@ void            autoar_create_start               (AutoarCreate *arcreate,
 void            autoar_create_start_async         (AutoarCreate *arcreate,
                                                    GCancellable *cancellable);
 
-char          **autoar_create_get_source          (AutoarCreate *arcreate);
+GStrv           autoar_create_get_source          (AutoarCreate *arcreate);
 GPtrArray      *autoar_create_get_source_file     (AutoarCreate *arcreate);
 char           *autoar_create_get_output          (AutoarCreate *arcreate);
 GFile          *autoar_create_get_output_file     (AutoarCreate *arcreate);
diff --git a/gnome-autoar/autoar-format-filter.c b/gnome-autoar/autoar-format-filter.c
index f2e1fd9..08ae094 100644
--- a/gnome-autoar/autoar-format-filter.c
+++ b/gnome-autoar/autoar-format-filter.c
@@ -189,7 +189,7 @@ static AutoarFilterDescription autoar_filter_description[] = {
  *
  * Returns: maximal allowed values of #AutoarFormat
  **/
-AutoarFormat
+int
 autoar_format_last (void)
 {
   return AUTOAR_FORMAT_LAST;
@@ -302,7 +302,7 @@ autoar_format_get_description_libarchive (AutoarFormat format)
 }
 
 /**
- * autoar_format_get_libarchive_read:
+ * autoar_format_get_libarchive_read: (skip)
  * @format: an #AutoarFormat
  *
  * Gets the function used to set format on the object returned by
@@ -318,7 +318,7 @@ autoar_format_get_libarchive_read (AutoarFormat format)
 }
 
 /**
- * autoar_format_get_libarchive_write:
+ * autoar_format_get_libarchive_write: (skip)
  * @format: an #AutoarFormat
  *
  * Gets the function used to set format on the object returned by
@@ -340,7 +340,7 @@ autoar_format_get_libarchive_write (AutoarFormat format)
  *
  * Returns: maximal allowed values of #AutoarFilter
  **/
-AutoarFilter
+int
 autoar_filter_last (void)
 {
   return AUTOAR_FILTER_LAST;
@@ -448,7 +448,7 @@ autoar_filter_get_description_libarchive (AutoarFilter filter)
 }
 
 /**
- * autoar_filter_get_libarchive_read:
+ * autoar_filter_get_libarchive_read: (skip)
  * @filter: an #AutoarFilter
  *
  * Gets the function used to add filter on the object returned by
@@ -464,7 +464,7 @@ autoar_filter_get_libarchive_read (AutoarFilter filter)
 }
 
 /**
- * autoar_filter_get_libarchive_write:
+ * autoar_filter_get_libarchive_write: (skip)
  * @filter: an #AutoarFilter
  *
  * Gets the function used to add filter on the object returned by
diff --git a/gnome-autoar/autoar-format-filter.h b/gnome-autoar/autoar-format-filter.h
index f55ce55..6242c43 100644
--- a/gnome-autoar/autoar-format-filter.h
+++ b/gnome-autoar/autoar-format-filter.h
@@ -118,7 +118,7 @@ typedef enum {
 typedef int (*AutoarFormatFunc) (struct archive *a);
 typedef int (*AutoarFilterFunc) (struct archive *a);
 
-AutoarFormat  autoar_format_last                        (void);
+int           autoar_format_last                        (void);
 gboolean      autoar_format_is_valid                    (AutoarFormat format);
 const char   *autoar_format_get_mime_type               (AutoarFormat format);
 const char   *autoar_format_get_extension               (AutoarFormat format);
@@ -128,7 +128,7 @@ int           autoar_format_get_format_libarchive       (AutoarFormat format);
 AutoarFormatFunc autoar_format_get_libarchive_read      (AutoarFormat format);
 AutoarFormatFunc autoar_format_get_libarchive_write     (AutoarFormat format);
 
-AutoarFilter  autoar_filter_last                        (void);
+int           autoar_filter_last                        (void);
 gboolean      autoar_filter_is_valid                    (AutoarFilter filter);
 const char   *autoar_filter_get_mime_type               (AutoarFilter filter);
 const char   *autoar_filter_get_extension               (AutoarFilter filter);
diff --git a/gnome-autoar/autoar-gtk.c b/gnome-autoar/autoar-gtk.c
index f2403fc..939bd24 100644
--- a/gnome-autoar/autoar-gtk.c
+++ b/gnome-autoar/autoar-gtk.c
@@ -245,7 +245,7 @@ simple_changed_cb (GtkComboBox *simple,
  * autoar_pref_get_default_filter(), or just set them to 1 to select
  * the default archive format.
  *
- * Returns: a new #GtkComboBox widget
+ * Returns: (transfer full): a new #GtkComboBox widget
  **/
 GtkWidget*
 autoar_gtk_format_filter_simple_new (AutoarFormat default_format,
@@ -445,7 +445,7 @@ advanced_filter_store (void)
  * Create a #GtkGrid with two lists. One list shows all available formats,
  * and the other list shows all available filters.
  *
- * Returns: a new #GtkGrid widget
+ * Returns: (transfer full): a new #GtkGrid widget
  **/
 GtkWidget*
 autoar_gtk_format_filter_advanced_new (AutoarFormat default_format,
diff --git a/tests/test-create.c b/tests/test-create.c
index 6364ef7..bd06122 100644
--- a/tests/test-create.c
+++ b/tests/test-create.c
@@ -62,7 +62,7 @@ main (int argc,
   autoar_pref_set_default_format (arpref, atoi (argv[1]));
   autoar_pref_set_default_filter (arpref, atoi (argv[2]));
 
-  arcreate = autoar_create_newv (arpref, argv[3], (const char**)argv + 4);
+  arcreate = autoar_create_newv (arpref, argv[3], (const GStrv)argv + 4);
   g_signal_connect (arcreate, "decide-dest", G_CALLBACK (my_handler_decide_dest), NULL);
   g_signal_connect (arcreate, "progress", G_CALLBACK (my_handler_progress), NULL);
   g_signal_connect (arcreate, "error", G_CALLBACK (my_handler_error), NULL);


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