[file-roller/wip/jtojnar/api_docs: 1/2] introspection: Allow building without schemas installed and outside X server
- From: Jan Tojnar <jtojnar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller/wip/jtojnar/api_docs: 1/2] introspection: Allow building without schemas installed and outside X server
- Date: Sat, 21 May 2022 21:51:42 +0000 (UTC)
commit 3db0b8dfbe78cfff9352f6a471a6a1bbc8394bf0
Author: Jan Tojnar <jtojnar gmail com>
Date: Mon May 16 01:18:32 2022 +0200
introspection: Allow building without schemas installed and outside X server
Previously, we handled the `--introspection-dump` CLI flag inside GApplication
but that initialized bunch of classes that bind GSettings in their constructors
so they need access to schemas, which are not yet available when building
in a sandbox. The option parser itself adds GTK options, which triggers
GTK to check for display server.
Let’s move handling the `--introspection-dump` to the beginning of the main
program entry point before GApplication is even created to prevent this.
src/fr-application.c | 24 ------------------------
src/main.c | 16 ++++++++++++++++
2 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/src/fr-application.c b/src/fr-application.c
index b0e5f21e..98ffe335 100644
--- a/src/fr-application.c
+++ b/src/fr-application.c
@@ -29,9 +29,6 @@
#include <gtk/gtk.h>
#include <glib/gprintf.h>
#include <handy.h>
-#ifdef ENABLE_INTROSPECTION
-# include <girepository.h>
-#endif
#include "file-utils.h"
#include "fr-application.h"
#include "fr-application-menu.h"
@@ -55,9 +52,6 @@ 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[] = {
@@ -98,12 +92,6 @@ 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 },
@@ -583,18 +571,6 @@ 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/main.c b/src/main.c
index 043f604c..1bf136aa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,6 +22,9 @@
#include <config.h>
#include <glib.h>
#include <glib/gi18n.h>
+#ifdef ENABLE_INTROSPECTION
+# include <girepository.h>
+#endif
#include "fr-application.h"
int
@@ -29,6 +32,19 @@ main (int argc, char **argv)
{
GtkApplication *app;
int status;
+#ifdef ENABLE_INTROSPECTION
+ const char *introspect_dump_prefix = "--introspect-dump=";
+
+ if (argc == 2 && g_str_has_prefix (argv[1], introspect_dump_prefix)) {
+ g_autoptr (GError) error = NULL;
+ if (!g_irepository_dump (argv[1] + strlen(introspect_dump_prefix), &error)) {
+ g_critical ("Failed to dump introspection data: %s", error->message);
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+ }
+#endif
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]