UI:Port to blueprint

Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
Vasiliy Doylov 2025-06-17 23:43:25 +03:00
parent 3d11c03820
commit 2f1059e8a7
Signed by: NekoCWD
GPG key ID: B7BE22D44474A582
8 changed files with 107 additions and 85 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/subprojects/blueprint-compiler

View file

@ -5,4 +5,4 @@ data/io.gitlab.nekocwd.singularity.metainfo.xml.in
data/io.gitlab.nekocwd.singularity.gschema.xml
src/main.vala
src/window.vala
src/window.ui
src/window.blp

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: C_("shortcut window", "General");
ShortcutsShortcut {
title: C_("shortcut window", "Show Shortcuts");
action-name: "win.show-help-overlay";
}
ShortcutsShortcut {
title: C_("shortcut window", "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

@ -10,13 +10,33 @@ singularity_deps = [
dependency('libadwaita-1', version: '>= 1.4'),
]
singularity_sources += gnome.compile_resources('singularity-resources',
'singularity.gresource.xml',
c_name: 'singularity'
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@',
],
)
executable('singularity', singularity_sources,
singularity_sources += gnome.compile_resources(
'singularity-resources',
'singularity.gresource.xml',
c_name: 'singularity',
dependencies: blueprints,
)
executable(
'singularity',
singularity_sources,
dependencies: singularity_deps,
include_directories: config_inc,
install: true,
install: true,
)

48
src/window.blp Normal file
View file

@ -0,0 +1,48 @@
using Gtk 4.0;
using Adw 1;
template $SingularityWindow: Adw.ApplicationWindow {
title: _("Singularity");
default-width: 800;
default-height: 600;
content: Adw.ToolbarView {
[top]
Adw.HeaderBar {
[end]
MenuButton {
primary: true;
icon-name: "open-menu-symbolic";
tooltip-text: _("Main Menu");
menu-model: primary_menu;
}
}
content: Label label {
label: _("Hello, World!");
styles [
"title-1",
]
};
};
}
menu primary_menu {
section {
item {
label: _("_Preferences");
action: "app.preferences";
}
item {
label: _("_Keyboard Shortcuts");
action: "win.show-help-overlay";
}
item {
label: _("_About Singularity");
action: "app.about";
}
}
}

View file

@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="Adw" version="1.0"/>
<template class="SingularityWindow" parent="AdwApplicationWindow">
<property name="title" translatable="yes">Singularity</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="content">
<object class="AdwToolbarView">
<child type="top">
<object class="AdwHeaderBar">
<child type="end">
<object class="GtkMenuButton">
<property name="primary">True</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="tooltip-text" translatable="yes">Main Menu</property>
<property name="menu-model">primary_menu</property>
</object>
</child>
</object>
</child>
<property name="content">
<object class="GtkLabel" id="label">
<property name="label" translatable="yes">Hello, World!</property>
<style>
<class name="title-1"/>
</style>
</object>
</property>
</object>
</property>
</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 Singularity</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
</interface>

View file

@ -0,0 +1,8 @@
[wrap-git]
directory = blueprint-compiler
url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
revision = v0.16.0
depth = 1
[provide]
program_names = blueprint-compiler