[gnome-builder/wip/gtk4-port] plugins/meson-templates: fix GJS template with libadwaita



commit 42c9987940bd98e385876732c22cf0bd557b8f61
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 8 13:01:16 2022 -0700

    plugins/meson-templates: fix GJS template with libadwaita

 src/plugins/meson-templates/gbp-meson-template-provider.c | 1 +
 src/plugins/meson-templates/resources/src/window.js.tmpl  | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/plugins/meson-templates/gbp-meson-template-provider.c 
b/src/plugins/meson-templates/gbp-meson-template-provider.c
index 0a5afd855..9729ae59c 100644
--- a/src/plugins/meson-templates/gbp-meson-template-provider.c
+++ b/src/plugins/meson-templates/gbp-meson-template-provider.c
@@ -80,6 +80,7 @@ static GbpMesonTemplateExpansion gtk4_expansions[] = {
   { "src/hello.src.gresource.xml", "src/{{appid}}.src.gresource.xml", IDE_STRV_INIT ("JavaScript") },
   { "src/main-gtk4.js.tmpl", "src/main.js", IDE_STRV_INIT ("JavaScript") },
   { "src/meson-js.build", "src/meson.build", IDE_STRV_INIT ("JavaScript") },
+  { "src/window-gtk4.ui", "src/window.ui", IDE_STRV_INIT ("JavaScript") },
   { "src/window.js.tmpl", "src/window.js", IDE_STRV_INIT ("JavaScript") },
 
   /* Python */
diff --git a/src/plugins/meson-templates/resources/src/window.js.tmpl 
b/src/plugins/meson-templates/resources/src/window.js.tmpl
index 4d1f4020c..4d6f053fa 100644
--- a/src/plugins/meson-templates/resources/src/window.js.tmpl
+++ b/src/plugins/meson-templates/resources/src/window.js.tmpl
@@ -2,12 +2,15 @@
 
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk';
+{{if is_adwaita}}
+import Adw from 'gi://Adw';
+{{end}}
 
 export const {{PreFix}}Window = GObject.registerClass({
     GTypeName: '{{PreFix}}Window',
     Template: 'resource://{{appid_path}}/{{ui_file}}',
     InternalChildren: ['label'],
-}, class {{PreFix}}Window extends Gtk.ApplicationWindow {
+}, class {{PreFix}}Window extends {{if is_adwaita}}Adw{{else}}Gtk{{end}}.ApplicationWindow {
     _init(application) {
         super._init({ application });
     }


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