[libadwaita/wip/exalm/inspector-v2] Rework GtkInspector page




commit 328b2d646eeb5a98f5eaba403fecaacb1b2d2952
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Thu Oct 7 12:54:18 2021 +0500

    Rework GtkInspector page
    
    Drop the module, hook to gtk_inspector_init() instead.
    
    See https://gitlab.gnome.org/GNOME/gtk/-/commit/3f5107cea56edb6c339345b2432a1a481f7f3dd1

 meson.build                                       |  1 +
 meson_options.txt                                 |  4 ---
 src/{inspector => }/adw-inspector-page-private.h  |  0
 src/{inspector => }/adw-inspector-page.c          | 33 +++++++++++++++--
 src/{inspector => }/adw-inspector-page.ui         |  0
 src/adwaita.gresources.xml                        |  1 +
 src/inspector/adw-inspector-module.c              | 43 -----------------------
 src/inspector/adw-inspector-module.gresources.xml |  6 ----
 src/inspector/meson.build                         | 23 ------------
 src/meson.build                                   |  4 +--
 10 files changed, 35 insertions(+), 80 deletions(-)
---
diff --git a/meson.build b/meson.build
index 30171e68..1dcbd794 100644
--- a/meson.build
+++ b/meson.build
@@ -28,6 +28,7 @@ libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
 add_project_arguments([
   '-DHAVE_CONFIG_H',
   '-DADWAITA_COMPILATION',
+  '-D_GNU_SOURCE',
   '-I' + meson.build_root(),
 ], language: 'c')
 
diff --git a/meson_options.txt b/meson_options.txt
index 78a8c6a6..a136a963 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,7 +20,3 @@ option('tests',
 option('examples',
        type: 'boolean', value: true,
        description: 'Build and install the examples and demo applications')
-
-option('inspector',
-       type: 'boolean', value: true,
-       description: 'Build and install the libadwaita GtkInspector module')
diff --git a/src/inspector/adw-inspector-page-private.h b/src/adw-inspector-page-private.h
similarity index 100%
rename from src/inspector/adw-inspector-page-private.h
rename to src/adw-inspector-page-private.h
diff --git a/src/inspector/adw-inspector-page.c b/src/adw-inspector-page.c
similarity index 89%
rename from src/inspector/adw-inspector-page.c
rename to src/adw-inspector-page.c
index c953b0a1..916001bf 100644
--- a/src/inspector/adw-inspector-page.c
+++ b/src/adw-inspector-page.c
@@ -11,8 +11,13 @@
 
 #include "adw-inspector-page-private.h"
 
-#include <adwaita.h>
+#include <dlfcn.h>
+#include "adw-bin.h"
+#include "adw-combo-row.h"
+#include "adw-enum-list-model.h"
+#include "adw-main.h"
 #include "adw-settings-private.h"
+#include "adw-style-manager.h"
 
 struct _AdwInspectorPage
 {
@@ -162,7 +167,7 @@ adw_inspector_page_class_init (AdwInspectorPageClass *klass)
   g_object_class_install_properties (object_class, LAST_PROP, props);
 
   gtk_widget_class_set_template_from_resource (widget_class,
-                                               "/org/gnome/Adwaita/inspector/ui/adw-inspector-page.ui");
+                                               "/org/gnome/Adwaita/ui/adw-inspector-page.ui");
 
   gtk_widget_class_bind_template_child (widget_class, AdwInspectorPage, support_color_schemes_switch);
   gtk_widget_class_bind_template_child (widget_class, AdwInspectorPage, color_scheme_row);
@@ -195,3 +200,27 @@ adw_inspector_page_init (AdwInspectorPage *self)
   hc = adw_settings_get_high_contrast (self->settings);
   gtk_switch_set_active (self->high_contrast_switch, hc);
 }
+
+extern void gtk_inspector_init (void);
+
+void
+gtk_inspector_init (void)
+{
+  static void (*original) (void) = NULL;
+
+  if (!original)
+    original = dlsym (RTLD_NEXT, "gtk_inspector_init");
+
+  if (!original)
+    return;
+
+  original ();
+
+  if (!adw_is_initialized ())
+    return;
+
+  g_io_extension_point_implement ("gtk-inspector-page",
+                                  ADW_TYPE_INSPECTOR_PAGE,
+                                  "libadwaita",
+                                  10);
+}
diff --git a/src/inspector/adw-inspector-page.ui b/src/adw-inspector-page.ui
similarity index 100%
rename from src/inspector/adw-inspector-page.ui
rename to src/adw-inspector-page.ui
diff --git a/src/adwaita.gresources.xml b/src/adwaita.gresources.xml
index 69f5f483..e31f86c0 100644
--- a/src/adwaita.gresources.xml
+++ b/src/adwaita.gresources.xml
@@ -11,6 +11,7 @@
     <file preprocess="xml-stripblanks">adw-action-row.ui</file>
     <file preprocess="xml-stripblanks">adw-combo-row.ui</file>
     <file preprocess="xml-stripblanks">adw-expander-row.ui</file>
+    <file preprocess="xml-stripblanks">adw-inspector-page.ui</file>
     <file preprocess="xml-stripblanks">adw-preferences-group.ui</file>
     <file preprocess="xml-stripblanks">adw-preferences-page.ui</file>
     <file preprocess="xml-stripblanks">adw-preferences-window.ui</file>
diff --git a/src/meson.build b/src/meson.build
index fd4e2784..6ae0b66e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -149,6 +149,7 @@ src_sources = [
   'adw-gizmo.c',
   'adw-header-bar.c',
   'adw-indicator-bin.c',
+  'adw-inspector-page.c',
   'adw-leaflet.c',
   'adw-main.c',
   'adw-navigation-direction.c',
@@ -206,6 +207,7 @@ libadwaita_deps = [
   dependency('fribidi'),
   gio_dep,
   gtk_dep,
+  cc.find_library('dl', required: false),
   cc.find_library('m', required: false),
   cc.find_library('rt', required: false),
 ]
@@ -325,5 +327,3 @@ pkgg.generate(
      requires: 'gtk4',
   install_dir: libdir / 'pkgconfig',
 )
-
-subdir('inspector')


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