Skip to content
Snippets Groups Projects
Verified Commit 6c0b23d2 authored by Bruce Cowan's avatar Bruce Cowan :airplane:
Browse files

Use blueprint

parent 0cf284cf
No related branches found
No related tags found
No related merge requests found
...@@ -3,3 +3,5 @@ ...@@ -3,3 +3,5 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
.flatpak* .flatpak*
/subprojects/blueprint-compiler
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2012-2022 Bruce Cowan <bruce@bcowan.me.uk>
SPDX-License-Identifier: GPL-3.0-or-later
-->
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<menu id="menu">
<section>
<item>
<attribute name="label" translatable="yes">_Preferences</attribute>
<attribute name="action">app.prefs</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">_About Rugby</attribute>
<attribute name="action">app.about</attribute>
</item>
</section>
</menu>
<template class="RugbyAppWindow" parent="GtkApplicationWindow">
<property name="title" translatable="yes">Rugby</property>
<property name="default-height">600</property>
<property name="default-width">400</property>
<style>
<class name="devel"/>
</style>
<child>
<object class="GtkScrolledWindow">
<child>
<object class="AdwClampScrollable">
<property name="maximum-size">600</property>
<child>
<object class="GtkListView" id="listview">
<property name="model">
<object class="GtkNoSelection">
<property name="model">
<object class="RugbyListStore">
<binding name="score">
<lookup name="value">scorespin</lookup>
</binding>
</object>
</property>
</object>
</property>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/uk/me/bcowan/rugby/score-item.ui</property>
</object>
</property>
<style>
<class name="rich-list"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar">
<child>
<object class="GtkSpinButton" id="scorespin">
<property name="adjustment">
<object class="GtkAdjustment">
<property name="step-increment">1</property>
<property name="upper">200</property>
</object>
</property>
<property name="focusable">1</property>
<property name="tooltip-text">Score</property>
</object>
</child>
<child type="title">
<object class="GtkLabel">
<property name="label">Rugby</property>
<style>
<class name="title"/>
</style>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="menu_button">
<property name="direction">none</property>
<property name="menu_model">menu</property>
</object>
</child>
</object>
</child>
</template>
</interface>
...@@ -2,9 +2,19 @@ ...@@ -2,9 +2,19 @@
# #
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
blueprints = custom_target('blueprints',
input: files(
'prefs.blp',
'window.blp'
),
output: '.',
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
)
resources = gnome.compile_resources('gen-resources', resources = gnome.compile_resources('gen-resources',
'rugby.gresource.xml', 'rugby.gresource.xml',
source_dir: 'data') source_dir: 'data',
dependencies: blueprints)
desktop_file = 'uk.me.bcowan.Rugby.desktop' desktop_file = 'uk.me.bcowan.Rugby.desktop'
install_data(desktop_file, install_data(desktop_file,
......
// SPDX-FileCopyrightText: 2022 Bruce Cowan <bruce@bcowan.me.uk>
//
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;
template RugbyPrefWindow : Adw.PreferencesWindow {
default-height: 300;
default-width: 400;
title: "Preferences";
modal: true;
Adw.PreferencesPage {
Adw.PreferencesGroup {
title: "Scoring";
Adw.ActionRow {
title: "Points for a converted tries";
SpinButton try_spin {
adjustment: Adjustment {
lower: 1;
upper: 7;
step-increment: 1;
};
max-width-chars: 3;
valign: center;
}
}
Adw.ActionRow {
title: "Points for an unconverted try";
SpinButton utry_spin {
adjustment: Adjustment {
lower: 1;
upper: 5;
step-increment: 1;
};
max-width-chars: 3;
valign: center;
}
}
Adw.ActionRow {
title: "Points for a kick";
SpinButton kick_spin {
adjustment: Adjustment {
lower: 1;
upper: 3;
step-increment: 1;
};
max-width-chars: 3;
valign: center;
}
}
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
SPDX-FileCopyrightText: 2020-2022 Bruce Cowan <bruce@bcowan.me.uk>
SPDX-License-Identifier: GPL-3.0-or-later
-->
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0"/>
<template class="RugbyPrefWindow" parent="AdwPreferencesWindow">
<property name="default-height">300</property>
<property name="default-width">400</property>
<property name="title">Preferences</property>
<property name="modal">True</property>
<child>
<object class="AdwPreferencesPage">
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Scoring</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Points for a converted try</property>
<child>
<object class="GtkSpinButton" id="try_spin">
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">1</property>
<property name="upper">7</property>
<property name="step_increment">1</property>
</object>
</property>
<property name="max-width-chars">3</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Points for a unconverted try</property>
<child>
<object class="GtkSpinButton" id="utry_spin">
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">1</property>
<property name="upper">5</property>
<property name="step_increment">1</property>
</object>
</property>
<property name="max-width-chars">3</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Points for a kick</property>
<child>
<object class="GtkSpinButton" id="kick_spin">
<property name="adjustment">
<object class="GtkAdjustment">
<property name="lower">1</property>
<property name="upper">3</property>
<property name="step_increment">1</property>
</object>
</property>
<property name="max-width-chars">3</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
SPDX-FileCopyrightText: 2012-2021 Bruce Cowan <bruce@bcowan.me.uk> SPDX-FileCopyrightText: 2012-2022 Bruce Cowan <bruce@bcowan.me.uk>
SPDX-License-Identifier: GPL-3.0-or-later SPDX-License-Identifier: GPL-3.0-or-later
--> -->
<gresources> <gresources>
<gresource prefix="/uk/me/bcowan/rugby"> <gresource prefix="/uk/me/bcowan/rugby">
<file preprocess="xml-stripblanks" compressed="true">interface.ui</file>
<file preprocess="xml-stripblanks" compressed="true">prefs.ui</file> <file preprocess="xml-stripblanks" compressed="true">prefs.ui</file>
<file preprocess="xml-stripblanks" compressed="true">score-item.ui</file> <file preprocess="xml-stripblanks" compressed="true">score-item.ui</file>
<file preprocess="xml-stripblanks" compressed="true">window.ui</file>
</gresource> </gresource>
</gresources> </gresources>
// SPDX-FileCopyrightText: 2022 Bruce Cowan <bruce@bcowan.me.uk>
//
// SPDX-License-Identifier: GPL-3.0-or-later
using Gtk 4.0;
using Adw 1;
template RugbyAppWindow : ApplicationWindow {
title: "Rugby";
default-height: 600;
default-width: 400;
styles ["devel"]
[titlebar]
HeaderBar {
SpinButton scorespin {
adjustment: Adjustment {
step-increment: 1;
upper: 200;
};
focusable: true;
tooltip-text: "Score";
}
[title]
Label {
styles ["title"]
label: "Rugby";
}
[end]
MenuButton menu_button {
direction: none;
menu-model: app_menu;
}
}
ScrolledWindow {
Adw.ClampScrollable {
maximum-size: 600;
ListView listview {
styles ["rich-list"]
model: NoSelection {
model: .RugbyListStore {
score: bind scorespin.value;
};
};
factory: BuilderListItemFactory {
resource: "/uk/me/bcowan/rugby/score-item.ui";
};
}
}
}
}
menu app_menu {
section {
item ("_Preferences", "app.prefs")
}
section {
item ("_About Rugby", "app.about")
}
}
...@@ -85,7 +85,7 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass) ...@@ -85,7 +85,7 @@ rugby_app_window_class_init (RugbyAppWindowClass *klass)
g_type_ensure (RUGBY_TYPE_LIST_STORE); g_type_ensure (RUGBY_TYPE_LIST_STORE);
gtk_widget_class_set_template_from_resource (widget_class, gtk_widget_class_set_template_from_resource (widget_class,
"/uk/me/bcowan/rugby/interface.ui"); "/uk/me/bcowan/rugby/window.ui");
gtk_widget_class_bind_template_callback (widget_class, item_tooltip_cb); gtk_widget_class_bind_template_callback (widget_class, item_tooltip_cb);
} }
......
[wrap-git]
directory = blueprint-compiler
url = https://gitlab.gnome.org/jwestman/blueprint-compiler.git
revision = v0.2.0
depth = 1
[provide]
program_names = blueprint-compiler
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment