[file-roller/wip/jtojnar/gtk4: 1/2] Add support for introspection




commit 796c18fd27fc9ed68b3432e1a98e068a755023cf
Author: Jan Tojnar <jtojnar gmail com>
Date:   Tue Dec 21 02:46:29 2021 +0100

    Add support for introspection
    
    It is required for Tartan to properly analyze our types.

 meson.build          |  5 +++++
 src/fr-application.c | 24 +++++++++++++++++++++
 src/fr-gir.h         | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/meson.build      | 17 ++++++++++++++-
 4 files changed, 104 insertions(+), 1 deletion(-)
---
diff --git a/meson.build b/meson.build
index dd2ed956..06b7ad23 100644
--- a/meson.build
+++ b/meson.build
@@ -31,6 +31,8 @@ gthread_dep = dependency('gthread-2.0')
 gtk_dep = dependency('gtk+-3.0', version : gtk_version)
 
 # Optional dependencies
+gobject_introspection_dep = dependency('gobject-introspection-1.0', required : false)
+use_gobject_introspection = gobject_introspection_dep.found()
 
 libnautilus_extension_dep = dependency('libnautilus-extension', version : nautilus_version, required : 
get_option('nautilus-actions'))
 build_nautilus_actions = libnautilus_extension_dep.found()
@@ -73,6 +75,9 @@ else
   config_data.set_quoted('UIDIR', join_paths(datadir, meson.project_name(), 'ui'))
   config_data.set_quoted('SHDIR', join_paths(prefix, get_option('libexecdir'), meson.project_name()))  
 endif
+if use_gobject_introspection
+  config_data.set('ENABLE_INTROSPECTION', 1)
+endif
 if use_json_glib
   config_data.set('HAVE_JSON_GLIB', 1)
 endif
diff --git a/src/fr-application.c b/src/fr-application.c
index 39b8ff44..2721955b 100644
--- a/src/fr-application.c
+++ b/src/fr-application.c
@@ -31,6 +31,9 @@
 #ifdef ENABLE_NOTIFICATION
 #  include <libnotify/notify.h>
 #endif
+#ifdef ENABLE_INTROSPECTION
+#  include <girepository.h>
+#endif
 #include "file-utils.h"
 #include "fr-application.h"
 #include "fr-application-menu.h"
@@ -54,6 +57,9 @@ static gboolean     arg_version = FALSE;
 static gboolean     arg_service = FALSE;
 static gboolean     arg_notify = FALSE;
 static const char  *program_argv0 = NULL; /* argv[0] from main(); used as the command to restart the program 
*/
+#ifdef ENABLE_INTROSPECTION
+static char        *introspection_dump = NULL;
+#endif
 
 
 static const GOptionEntry options[] = {
@@ -94,6 +100,12 @@ static const GOptionEntry options[] = {
        { "version", 'v', 0, G_OPTION_ARG_NONE, &arg_version,
          N_("Show version"), NULL },
 
+#ifdef ENABLE_INTROSPECTION
+       { "introspect-dump", '\0', 0, G_OPTION_ARG_STRING, &introspection_dump,
+         N_("Dump gobject introspection file"),
+         N_("input.txt,output.xml") },
+#endif
+
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
          NULL,
          NULL },
@@ -548,6 +560,18 @@ fr_application_command_line (GApplication            *application,
        g_strfreev (argv);
        g_option_context_free (context);
 
+#ifdef ENABLE_INTROSPECTION
+       if (introspection_dump) {
+               if (!g_irepository_dump (introspection_dump, &error)) {
+                       g_critical ("Failed to dump introspection data: %s", error->message);
+                       g_error_free (error);
+                       return fr_application_command_line_finished (application, EXIT_FAILURE);
+               }
+
+               return fr_application_command_line_finished (application, EXIT_SUCCESS);
+       }
+#endif
+
        if (remaining_args == NULL) { /* No archive specified. */
                if (! arg_service)
                        gtk_widget_show (fr_window_new ());
diff --git a/src/fr-gir.h b/src/fr-gir.h
new file mode 100644
index 00000000..441dbb13
--- /dev/null
+++ b/src/fr-gir.h
@@ -0,0 +1,59 @@
+#include "dlg-add.h"
+#include "dlg-ask-password.h"
+#include "dlg-batch-add.h"
+#include "dlg-delete.h"
+#include "dlg-extract.h"
+#include "dlg-open-with.h"
+#include "dlg-package-installer.h"
+#include "dlg-password.h"
+#include "dlg-prop.h"
+#include "dlg-update.h"
+#include "egg-macros.h"
+#include "eggtreemultidnd.h"
+#include "file-data.h"
+#include "file-utils.h"
+#include "fr-application-menu.h"
+#include "fr-application.h"
+#include "fr-archive-libarchive.h"
+#include "fr-archive.h"
+#include "fr-command-7z.h"
+#include "fr-command-ace.h"
+#include "fr-command-alz.h"
+#include "fr-command-ar.h"
+#include "fr-command-arj.h"
+#include "fr-command-cfile.h"
+#include "fr-command-cpio.h"
+#include "fr-command-dpkg.h"
+#include "fr-command-iso.h"
+#include "fr-command-jar.h"
+#include "fr-command-lha.h"
+#include "fr-command-lrzip.h"
+#include "fr-command-rar.h"
+#include "fr-command-rpm.h"
+#include "fr-command-tar.h"
+#include "fr-command-unarchiver.h"
+#include "fr-command-unsquashfs.h"
+#include "fr-command-unstuff.h"
+#include "fr-command-zip.h"
+#include "fr-command-zoo.h"
+#include "fr-command.h"
+#include "fr-error.h"
+#include "fr-file-selector-dialog.h"
+#include "fr-init.h"
+#include "fr-list-model.h"
+#include "fr-location-bar.h"
+#include "fr-new-archive-dialog.h"
+#include "fr-process.h"
+#include "fr-window-actions-callbacks.h"
+#include "fr-window-actions-entries.h"
+#include "fr-window.h"
+#include "gio-utils.h"
+#include "glib-utils.h"
+#include "gth-icon-cache.h"
+#include "gtk-utils.h"
+#include "java-utils.h"
+#include "mkdtemp.h"
+#include "open-file.h"
+#include "preferences.h"
+#include "rar-utils.h"
+#include "typedefs.h"
diff --git a/src/meson.build b/src/meson.build
index 8083aacc..9862491e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -76,7 +76,7 @@ enum_files = gnome.mkenums_simple('fr-enum-types',
 
 # Build targets
 
-executable('file-roller', 
+fr_exe = executable('file-roller',
   sources : [ 
     config_file, 
     source_files, 
@@ -90,15 +90,30 @@ executable('file-roller',
     glib_dep, 
     gthread_dep, 
     gtk_dep, 
+    use_gobject_introspection ? gobject_introspection_dep : [],
     use_json_glib ? libjson_glib_dep : [],
     use_libnotify ? libnotify_dep : [],
     use_libarchive ? libarchive_dep : []
   ],
+  link_args: [
+    # Required for GIRepository to be able to dump symbols.
+    use_gobject_introspection ? '-Wl,--export-dynamic' : [],
+  ],
   include_directories : config_inc,
   c_args : c_args,
   install : true
 )
 
+if use_gobject_introspection
+  fr_gir = gnome.generate_gir(
+    fr_exe,
+    namespace: 'FileRoller',
+    nsversion: '1.0',
+    identifier_prefix: 'Fr',
+    header: 'fr-gir.h',
+  )
+endif
+
 executable('test-server', 'test-server.c',
   dependencies : [ 
     libm_dep, 


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