[gnome-builder] main: cleanup initialization for GTK 4 port



commit bae25b8a16cff452e4249c8de1d6e86c80350038
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 11 22:05:36 2022 -0700

    main: cleanup initialization for GTK 4 port
    
     - Load external libraries at startup
     - Fix application instance creation
     - Remove worker modes
     - Guess shell early at startup
     - Use .Devel for development builds
     - Remove G_MESSAGES_DEBUG early to avoid passing to subprocesses

 src/main.c | 49 +++++++++++++++++++++++++++++--------------------
 1 file changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index 31aad183a..771610f6c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,8 +27,6 @@
 #include <gtksourceview/gtksource.h>
 #include <libide-core.h>
 #include <libide-code.h>
-#include <libide-editor.h>
-#include <libide-greeter.h>
 #include <libide-gui.h>
 #include <libide-threading.h>
 #include <locale.h>
@@ -36,13 +34,18 @@
 # include <sysprof-capture.h>
 #endif
 #include <sched.h>
+#include <stdlib.h>
 #include <unistd.h>
 
 #include "ide-application-private.h"
 #include "ide-build-ident.h"
-#include "ide-thread-private.h"
+#include "ide-editor-private.h"
+#include "ide-gtk-private.h"
 #include "ide-log-private.h"
+#include "ide-search-private.h"
+#include "ide-shell-private.h"
 #include "ide-terminal-private.h"
+#include "ide-thread-private.h"
 #include "ide-private.h"
 
 #include "bug-buddy.h"
@@ -138,19 +141,13 @@ verbose_cb (const gchar  *option_name,
 static void
 early_params_check (gint       *argc,
                     gchar    ***argv,
-                    gboolean   *standalone,
-                    gchar     **type,
-                    gchar     **plugin,
-                    gchar     **dbus_address)
+                    gboolean   *standalone)
 {
   g_autoptr(GOptionContext) context = NULL;
   g_autoptr(GOptionGroup) gir_group = NULL;
   GOptionEntry entries[] = {
     { "standalone", 's', 0, G_OPTION_ARG_NONE, standalone, N_("Run a new instance of Builder") },
     { "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, verbose_cb },
-    { "plugin", 0, 0, G_OPTION_ARG_STRING, plugin },
-    { "type", 0, 0, G_OPTION_ARG_STRING, type },
-    { "dbus-address", 0, 0, G_OPTION_ARG_STRING, dbus_address },
     { NULL }
   };
 
@@ -210,14 +207,18 @@ gint
 main (gint   argc,
       gchar *argv[])
 {
-  g_autofree gchar *plugin = NULL;
-  g_autofree gchar *type = NULL;
-  g_autofree gchar *dbus_address = NULL;
+  g_autofree char *messages_debug = NULL;
   IdeApplication *app;
   const gchar *desktop;
   gboolean standalone = FALSE;
   int ret;
 
+  /* Get environment variable early and clear it from GLib. We want to be
+   * certain we don't pass this on to child processes so we clear it upfront.
+   */
+  messages_debug = g_strdup (getenv ("G_MESSAGES_DEBUG"));
+  unsetenv ("G_MESSAGES_DEBUG");
+
   /* Setup our gdb fork()/exec() helper if we're in a terminal */
   if (is_running_in_shell ())
     bug_buddy_init ();
@@ -235,11 +236,8 @@ main (gint   argc,
   g_set_prgname (ide_get_program_name ());
   g_set_application_name (_("Builder"));
 
-#if 0
-  /* TODO: allow support for parallel nightly install */
 #ifdef DEVELOPMENT_BUILD
-  ide_set_application_id ("org.gnome.Builder-Devel");
-#endif
+  ide_set_application_id ("org.gnome.Builder.Devel");
 #endif
 
   /* Early init of logging so that we get messages in a consistent
@@ -249,7 +247,7 @@ main (gint   argc,
   ide_log_init (TRUE, NULL, messages_debug);
 
   /* Extract options like -vvvv */
-  early_params_check (&argc, &argv, &standalone, &type, &plugin, &dbus_address);
+  early_params_check (&argc, &argv, &standalone);
 
   /* Log some info so it shows up in logs */
   g_message ("GNOME Builder %s (%s) from channel \"%s\" starting with ABI %s",
@@ -285,15 +283,26 @@ main (gint   argc,
              gtk_get_minor_version (),
              gtk_get_micro_version ());
 
+  /* Init libraries with initializers */
+  gtk_init ();
   gtk_source_init ();
+  adw_init ();
+  panel_init ();
 
   /* Initialize thread pools */
   _ide_thread_pool_init (FALSE);
 
-  /* Guess the user shell early */
+  /* Guess the user $SHELL and $PATH early */
   _ide_guess_shell ();
+  _ide_guess_user_path ();
+
+  /* Ensure availability of some symbols possibly dropped in link */
+  _ide_gtk_init ();
+  _ide_search_init ();
+  _ide_editor_init ();
+  _ide_terminal_init ();
 
-  app = _ide_application_new (standalone, type, plugin, dbus_address);
+  app = _ide_application_new (standalone);
   g_application_add_option_group (G_APPLICATION (app), g_irepository_get_option_group ());
   ret = g_application_run (G_APPLICATION (app), argc, argv);
   /* Force disposal of the application (to help catch cleanup


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