From 4d436eaaf559a01aa87871a98cd272e7ccbadade Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 18 Jun 2023 14:33:53 +0200 Subject: [PATCH] Port to blueprint --- de.johrpan.musicus.json | 11 +++++++++ src/gtk/help-overlay.blp | 24 ++++++++++++++++++++ src/gtk/help-overlay.ui | 29 ------------------------ src/meson.build | 10 ++++++++ src/window.blp | 40 ++++++++++++++++++++++++++++++++ src/window.ui | 49 ---------------------------------------- 6 files changed, 85 insertions(+), 78 deletions(-) create mode 100644 src/gtk/help-overlay.blp delete mode 100644 src/gtk/help-overlay.ui create mode 100644 src/window.blp delete mode 100644 src/window.ui diff --git a/de.johrpan.musicus.json b/de.johrpan.musicus.json index a6f78f0..ee65873 100644 --- a/de.johrpan.musicus.json +++ b/de.johrpan.musicus.json @@ -36,6 +36,17 @@ "*.a" ], "modules" : [ + { + "name": "blueprint-compiler", + "buildsystem": "meson", + "sources": [ + { + "type": "git", + "url": "https://gitlab.gnome.org/jwestman/blueprint-compiler", + "tag": "v0.8.1" + } + ] + }, { "name" : "musicus", "builddir" : true, diff --git a/src/gtk/help-overlay.blp b/src/gtk/help-overlay.blp new file mode 100644 index 0000000..ede23d8 --- /dev/null +++ b/src/gtk/help-overlay.blp @@ -0,0 +1,24 @@ +using Gtk 4.0; + +ShortcutsWindow help_overlay { + modal: true; + + ShortcutsSection { + section-name: "shortcuts"; + max-height: 10; + + ShortcutsGroup { + title: "General"; + + ShortcutsShortcut { + title: "Show Shortcuts"; + action-name: "win.show-help-overlay"; + } + + ShortcutsShortcut { + title: "Quit"; + action-name: "app.quit"; + } + } + } +} diff --git a/src/gtk/help-overlay.ui b/src/gtk/help-overlay.ui deleted file mode 100644 index ef12f02..0000000 --- a/src/gtk/help-overlay.ui +++ /dev/null @@ -1,29 +0,0 @@ - - - - True - - - shortcuts - 10 - - - General - - - Show Shortcuts - win.show-help-overlay - - - - - Quit - app.quit - - - - - - - - diff --git a/src/meson.build b/src/meson.build index a07fa38..fa55c8e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,8 +1,18 @@ pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) gnome = import('gnome') +blueprints = custom_target('blueprints', + input: files( + 'gtk/help-overlay.blp', + 'window.blp' + ), + output: '.', + command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], +) + gnome.compile_resources('musicus', 'musicus.gresource.xml', + dependencies: blueprints, gresource_bundle: true, install: true, install_dir: pkgdatadir, diff --git a/src/window.blp b/src/window.blp new file mode 100644 index 0000000..f1a93f1 --- /dev/null +++ b/src/window.blp @@ -0,0 +1,40 @@ +using Gtk 4.0; +using Adw 1; + +template $MusicusWindow : Adw.ApplicationWindow { + default-width: 600; + default-height: 300; + + Box { + orientation: vertical; + + HeaderBar header_bar { + [end] + MenuButton { + icon-name: "open-menu-symbolic"; + menu-model: primary_menu; + } + } + + Label label { + label: "Hello, World!"; + vexpand: true; + styles ["title-1"] + } + } +} + +menu primary_menu { + item { + label: "_Preferences"; + action: "app.preferences"; + } + item { + label: "_Keyboard Shortcuts"; + action: "app.help-overlay"; + } + item { + label: "_About Musicus"; + action: "app.about"; + } +} \ No newline at end of file diff --git a/src/window.ui b/src/window.ui deleted file mode 100644 index 2a94d08..0000000 --- a/src/window.ui +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - -
- - _Preferences - app.preferences - - - _Keyboard Shortcuts - win.show-help-overlay - - - _About Musicus - app.about - -
-
-