inspector: Register extension on startup
authorAlexander Mikhaylenko <alexm@gnome.org>
Tue, 28 Dec 2021 23:14:03 +0000 (04:14 +0500)
committerAlexander Mikhaylenko <alexm@gnome.org>
Tue, 28 Dec 2021 23:42:51 +0000 (04:42 +0500)
gtk/gtkmain.c
gtk/inspector/init.c
gtk/inspector/init.h

index 2ab9c68fe738f176201dc3f688bee0d714f36b48..352e32fdcd7503a038ad71d24f0165627a587685 100644 (file)
@@ -68,6 +68,7 @@
 #include "gtknative.h"
 #include "gtkpopcountprivate.h"
 
+#include "inspector/init.h"
 #include "inspector/window.h"
 
 #include "gdk/gdkeventsprivate.h"
@@ -566,6 +567,8 @@ do_post_parse_initialization (void)
   g_signal_connect (display_manager, "notify::default-display",
                     G_CALLBACK (default_display_notify_cb),
                     NULL);
+
+  gtk_inspector_register_extension ();
 }
 
 #ifdef G_PLATFORM_WIN32
index c951fe30fc9f86fe95bb6453aba2f4433e5c466f..9a80eb6c4e0cfb7d871044d45cc6cc5b2bb30cfd 100644 (file)
 
 #include "gtkmodulesprivate.h"
 
+static GIOExtensionPoint *extension_point = NULL;
+
 void
 gtk_inspector_init (void)
 {
-  static GIOExtensionPoint *extension_point = NULL;
+  GIOModuleScope *scope;
+  char **paths;
+  int i;
 
   g_type_ensure (G_TYPE_LIST_STORE);
 
@@ -89,26 +93,25 @@ gtk_inspector_init (void)
   g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL);
   g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW);
 
-  if (extension_point == NULL)
-    {
-      GIOModuleScope *scope;
-      char **paths;
-      int i;
-
-      extension_point = g_io_extension_point_register ("gtk-inspector-page");
-      g_io_extension_point_set_required_type (extension_point, GTK_TYPE_WIDGET);
+  paths = _gtk_get_module_path ("inspector");
+  scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
 
-      paths = _gtk_get_module_path ("inspector");
-      scope = g_io_module_scope_new (G_IO_MODULE_SCOPE_BLOCK_DUPLICATES);
+  for (i = 0; paths[i] != NULL; i++)
+    g_io_modules_load_all_in_directory_with_scope (paths[i], scope);
 
-      for (i = 0; paths[i] != NULL; i++)
-        g_io_modules_load_all_in_directory_with_scope (paths[i], scope);
-
-      g_strfreev (paths);
-      g_io_module_scope_free (scope);
-    }
+  g_strfreev (paths);
+  g_io_module_scope_free (scope);
 
   gtk_css_provider_set_keep_css_sections ();
 }
 
+void
+gtk_inspector_register_extension (void)
+{
+  if (extension_point == NULL) {
+    extension_point = g_io_extension_point_register ("gtk-inspector-page");
+    g_io_extension_point_set_required_type (extension_point, GTK_TYPE_WIDGET);
+  }
+}
+
 // vim: set et sw=2 ts=2:
index 7fe6745fd8f172c6357189b3bdd089be8fb56fca..04d3789bb6896a3ce65b43aee56c37dcb900154c 100644 (file)
@@ -20,7 +20,8 @@
 
 G_BEGIN_DECLS
 
-void gtk_inspector_init (void);
+void gtk_inspector_init               (void);
+void gtk_inspector_register_extension (void);
 
 G_END_DECLS