gui: Port to Blueprint
This was mostly done with `blueprint-compiler port`. Since Blueprint doesn't know about custom templates, I had to manually change some values from strings to literals. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/567>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $GcalCalendarComboRowItem: Adw.PreferencesRow {
|
||||
Box {
|
||||
orientation: horizontal;
|
||||
spacing: 6;
|
||||
|
||||
Image color_image {
|
||||
styles [
|
||||
"calendar-color-image",
|
||||
]
|
||||
}
|
||||
|
||||
Label title_label {
|
||||
ellipsize: end;
|
||||
xalign: 0.0;
|
||||
label: bind template.title;
|
||||
}
|
||||
|
||||
Image visibility_image {
|
||||
halign: end;
|
||||
hexpand: true;
|
||||
icon-name: "eye-not-looking-symbolic";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GcalCalendarComboRowItem" parent="AdwPreferencesRow">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="color_image">
|
||||
<style>
|
||||
<class name="calendar-color-image"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="title_label">
|
||||
<property name="ellipsize">end</property>
|
||||
<property name="xalign">0.0</property>
|
||||
<property name="label" bind-source="GcalCalendarComboRowItem" bind-property="title" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="visibility_image">
|
||||
<property name="halign">end</property>
|
||||
<property name="hexpand">true</property>
|
||||
<property name="icon-name">eye-not-looking-symbolic</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@@ -0,0 +1,13 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $GcalCalendarComboRow: Adw.ComboRow {
|
||||
title: _("Calendar");
|
||||
title-lines: 1;
|
||||
|
||||
factory: SignalListItemFactory {
|
||||
setup => $calendar_item_setup_cb();
|
||||
bind => $calendar_item_bind_cb();
|
||||
unbind => $calendar_item_unbind_cb();
|
||||
};
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GcalCalendarComboRow" parent="AdwComboRow">
|
||||
|
||||
<property name="title" translatable="yes">Calendar</property>
|
||||
<property name="title-lines">1</property>
|
||||
<property name="factory">
|
||||
<object class="GtkSignalListItemFactory">
|
||||
<signal name="setup" handler="calendar_item_setup_cb"/>
|
||||
<signal name="bind" handler="calendar_item_bind_cb"/>
|
||||
<signal name="unbind" handler="calendar_item_unbind_cb"/>
|
||||
</object>
|
||||
</property>
|
||||
|
||||
</template>
|
||||
</interface>
|
||||
@@ -0,0 +1,46 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $GcalDateChooserDay: Button {
|
||||
halign: center;
|
||||
valign: center;
|
||||
hexpand: true;
|
||||
vexpand: true;
|
||||
|
||||
styles [
|
||||
"circular",
|
||||
"day",
|
||||
"flat",
|
||||
"text-button",
|
||||
]
|
||||
|
||||
Box {
|
||||
orientation: vertical;
|
||||
valign: center;
|
||||
|
||||
Label label {
|
||||
halign: center;
|
||||
label: "0";
|
||||
valign: center;
|
||||
width-chars: 2;
|
||||
|
||||
styles [
|
||||
"day",
|
||||
"numeric",
|
||||
]
|
||||
}
|
||||
|
||||
Revealer dot_revealer {
|
||||
halign: center;
|
||||
transition-type: crossfade;
|
||||
valign: end;
|
||||
visible: false;
|
||||
|
||||
child: Adw.Bin dot {
|
||||
css-name: "dot";
|
||||
halign: center;
|
||||
valign: center;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<template class="GcalDateChooserDay" parent="GtkButton">
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<style>
|
||||
<class name="circular"/>
|
||||
<class name="day"/>
|
||||
<class name="flat"/>
|
||||
<class name="text-button"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label">
|
||||
<property name="halign">center</property>
|
||||
<property name="label">0</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="width-chars">2</property>
|
||||
<style>
|
||||
<class name="day"/>
|
||||
<class name="numeric"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="dot_revealer">
|
||||
<property name="halign">center</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="child">
|
||||
<object class="AdwBin" id="dot">
|
||||
<property name="css-name">dot</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@@ -0,0 +1,92 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $GcalDateChooser: Adw.Bin {
|
||||
Grid {
|
||||
orientation: vertical;
|
||||
|
||||
$GcalMultiChoice month_choice {
|
||||
halign: fill;
|
||||
min-value: 0;
|
||||
max-value: 11;
|
||||
animate: false;
|
||||
value: 0;
|
||||
visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||||
notify::value => $split_multi_choice_changed() swapped;
|
||||
|
||||
layout {
|
||||
column: 0;
|
||||
row: 0;
|
||||
}
|
||||
}
|
||||
|
||||
$GcalMultiChoice year_choice {
|
||||
visible: bind $get_split_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||||
halign: fill;
|
||||
min-value: 1;
|
||||
max-value: 9999;
|
||||
animate: false;
|
||||
value: 0;
|
||||
notify::value => $split_multi_choice_changed() swapped;
|
||||
|
||||
layout {
|
||||
column: 1;
|
||||
row: 0;
|
||||
}
|
||||
}
|
||||
|
||||
$GcalMultiChoice combined_choice {
|
||||
visible: bind $get_combined_choice_visible(template.show-heading, template.split-month-year) as <bool>;
|
||||
halign: fill;
|
||||
min-value: 12;
|
||||
max-value: 119999;
|
||||
popover: popover;
|
||||
animate: false;
|
||||
value: 0;
|
||||
notify::value => $combined_multi_choice_changed() swapped;
|
||||
|
||||
layout {
|
||||
column: 0;
|
||||
column-span: 2;
|
||||
row: 0;
|
||||
}
|
||||
}
|
||||
|
||||
Grid grid {
|
||||
row-homogeneous: true;
|
||||
column-homogeneous: true;
|
||||
|
||||
layout {
|
||||
column: 0;
|
||||
column-span: 2;
|
||||
row: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Popover popover {
|
||||
Box {
|
||||
orientation: vertical;
|
||||
spacing: 12;
|
||||
|
||||
$GcalMultiChoice popover_month_choice {
|
||||
min-value: bind month_choice.min-value bidirectional;
|
||||
max-value: bind month_choice.max-value bidirectional;
|
||||
animate: bind month_choice.animate bidirectional;
|
||||
value: bind month_choice.value bidirectional;
|
||||
}
|
||||
|
||||
$GcalMultiChoice {
|
||||
min-value: bind year_choice.min-value bidirectional;
|
||||
max-value: bind year_choice.max-value bidirectional;
|
||||
animate: bind year_choice.animate bidirectional;
|
||||
value: bind year_choice.value bidirectional;
|
||||
}
|
||||
|
||||
styles [
|
||||
"activatable",
|
||||
"month",
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GcalDateChooser" parent="AdwBin">
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GcalMultiChoice" id="month_choice">
|
||||
<property name="halign">fill</property>
|
||||
<property name="min-value">0</property>
|
||||
<property name="max-value">11</property>
|
||||
<property name="animate">False</property>
|
||||
<property name="value">0</property>
|
||||
<binding name="visible">
|
||||
<closure type="gboolean" function="get_split_choice_visible">
|
||||
<lookup name="show-heading">GcalDateChooser</lookup>
|
||||
<lookup name="split-month-year">GcalDateChooser</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<signal name="notify::value" handler="split_multi_choice_changed" swapped="yes"/>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GcalMultiChoice" id="year_choice">
|
||||
<binding name="visible">
|
||||
<closure type="gboolean" function="get_split_choice_visible">
|
||||
<lookup name="show-heading">GcalDateChooser</lookup>
|
||||
<lookup name="split-month-year">GcalDateChooser</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<property name="halign">fill</property>
|
||||
<property name="min-value">1</property>
|
||||
<property name="max-value">9999</property>
|
||||
<property name="animate">False</property>
|
||||
<property name="value">0</property>
|
||||
<signal name="notify::value" handler="split_multi_choice_changed" swapped="yes"/>
|
||||
<layout>
|
||||
<property name="column">1</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GcalMultiChoice" id="combined_choice">
|
||||
<binding name="visible">
|
||||
<closure type="gboolean" function="get_combined_choice_visible">
|
||||
<lookup name="show-heading">GcalDateChooser</lookup>
|
||||
<lookup name="split-month-year">GcalDateChooser</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<property name="halign">fill</property>
|
||||
<!-- From January 1 (month 12) to December 9999 (month 119999) -->
|
||||
<property name="min-value">12</property>
|
||||
<property name="max-value">119999</property>
|
||||
<property name="popover">popover</property>
|
||||
<property name="animate">False</property>
|
||||
<property name="value">0</property>
|
||||
<signal name="notify::value" handler="combined_multi_choice_changed" swapped="yes"/>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="column-span">2</property>
|
||||
<property name="row">0</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid">
|
||||
<property name="row-homogeneous">True</property>
|
||||
<property name="column-homogeneous">True</property>
|
||||
<layout>
|
||||
<property name="column">0</property>
|
||||
<property name="column-span">2</property>
|
||||
<property name="row">1</property>
|
||||
</layout>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
||||
<object class="GtkPopover" id="popover">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GcalMultiChoice" id="popover_month_choice">
|
||||
<property name="min-value" bind-source="month_choice" bind-property="min-value" bind-flags="sync-create|bidirectional" />
|
||||
<property name="max-value" bind-source="month_choice" bind-property="max-value" bind-flags="sync-create|bidirectional" />
|
||||
<property name="animate" bind-source="month_choice" bind-property="animate" bind-flags="sync-create|bidirectional" />
|
||||
<property name="value" bind-source="month_choice" bind-property="value" bind-flags="sync-create|bidirectional" />
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GcalMultiChoice">
|
||||
<property name="min-value" bind-source="year_choice" bind-property="min-value" bind-flags="sync-create|bidirectional" />
|
||||
<property name="max-value" bind-source="year_choice" bind-property="max-value" bind-flags="sync-create|bidirectional" />
|
||||
<property name="animate" bind-source="year_choice" bind-property="animate" bind-flags="sync-create|bidirectional" />
|
||||
<property name="value" bind-source="year_choice" bind-property="value" bind-flags="sync-create|bidirectional" />
|
||||
</object>
|
||||
</child>
|
||||
<style>
|
||||
<class name="activatable"/>
|
||||
<class name="month"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
@@ -1,9 +1,28 @@
|
||||
calendar_incs += include_directories('.')
|
||||
|
||||
blueprints = custom_target(
|
||||
'blueprints',
|
||||
input: files(
|
||||
'gcal-calendar-combo-row-item.blp',
|
||||
'gcal-calendar-combo-row.blp',
|
||||
'gcal-date-chooser-day.blp',
|
||||
'gcal-date-chooser.blp',
|
||||
),
|
||||
output: '.',
|
||||
command: [
|
||||
find_program('blueprint-compiler'),
|
||||
'batch-compile',
|
||||
'@OUTPUT@',
|
||||
'@CURRENT_SOURCE_DIR@',
|
||||
'@INPUT@',
|
||||
],
|
||||
)
|
||||
|
||||
built_sources += gnome.compile_resources(
|
||||
'common-resources',
|
||||
'common.gresource.xml',
|
||||
c_name: 'common',
|
||||
dependencies: blueprints,
|
||||
)
|
||||
|
||||
sources += files(
|
||||
|
||||
Reference in New Issue
Block a user