Port to blueprint

This commit is contained in:
Elias Projahn 2023-06-18 14:33:53 +02:00
parent 9969ebcfd7
commit 4d436eaaf5
6 changed files with 85 additions and 78 deletions

24
src/gtk/help-overlay.blp Normal file
View file

@ -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";
}
}
}
}

View file

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkShortcutsWindow" id="help_overlay">
<property name="modal">True</property>
<child>
<object class="GtkShortcutsSection">
<property name="section-name">shortcuts</property>
<property name="max-height">10</property>
<child>
<object class="GtkShortcutsGroup">
<property name="title" translatable="yes" context="shortcut window">General</property>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Show Shortcuts</property>
<property name="action-name">win.show-help-overlay</property>
</object>
</child>
<child>
<object class="GtkShortcutsShortcut">
<property name="title" translatable="yes" context="shortcut window">Quit</property>
<property name="action-name">app.quit</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>

View file

@ -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,

40
src/window.blp Normal file
View file

@ -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";
}
}

View file

@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="Adw" version="1.0"/>
<template class="MusicusWindow" parent="AdwApplicationWindow">
<property name="default-width">600</property>
<property name="default-height">300</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkHeaderBar" id="header_bar">
<child type="end">
<object class="GtkMenuButton">
<property name="icon-name">open-menu-symbolic</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="label">
<property name="label">Hello, World!</property>
<property name="vexpand">true</property>
<style>
<class name="title-1"/>
</style>
</object>
</child>
</object>
</child>
</template>
<menu id="primary_menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.preferences</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
<attribute name="action">win.show-help-overlay</attribute>
</item>
<item>
<attribute name="label" translatable="yes">_About Musicus</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
</interface>