[gnome-calendar] date-chooser-day: Use a template
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] date-chooser-day: Use a template
- Date: Thu, 16 Jun 2022 11:44:35 +0000 (UTC)
commit a58fa3deb8983040afa986af8917d2723ee3d980
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Apr 6 13:24:37 2022 +0200
date-chooser-day: Use a template
This makes the widget easier to maintain.
src/gui/event-editor/event-editor.gresource.xml | 1 +
src/gui/event-editor/gcal-date-chooser-day.c | 23 ++++++-----------------
src/gui/event-editor/gcal-date-chooser-day.ui | 20 ++++++++++++++++++++
3 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/src/gui/event-editor/event-editor.gresource.xml b/src/gui/event-editor/event-editor.gresource.xml
index cec9f0ff..38165c51 100644
--- a/src/gui/event-editor/event-editor.gresource.xml
+++ b/src/gui/event-editor/event-editor.gresource.xml
@@ -3,6 +3,7 @@
<gresource prefix="/org/gnome/calendar/ui/event-editor">
<file compressed="true">gcal-alarm-row.ui</file>
<file compressed="true">gcal-date-chooser.ui</file>
+ <file compressed="true">gcal-date-chooser-day.ui</file>
<file compressed="true">gcal-date-selector.ui</file>
<file compressed="true">gcal-event-editor-dialog.ui</file>
<file compressed="true">gcal-multi-choice.ui</file>
diff --git a/src/gui/event-editor/gcal-date-chooser-day.c b/src/gui/event-editor/gcal-date-chooser-day.c
index e4f4dbb4..fd0b45f4 100644
--- a/src/gui/event-editor/gcal-date-chooser-day.c
+++ b/src/gui/event-editor/gcal-date-chooser-day.c
@@ -50,30 +50,19 @@ static void
gcal_date_chooser_day_class_init (GcalDateChooserDayClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
object_class->dispose = gcal_date_chooser_day_dispose;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/calendar/ui/event-editor/gcal-date-chooser-day.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, GcalDateChooserDay, label);
}
static void
gcal_date_chooser_day_init (GcalDateChooserDay *self)
{
- GtkWidget *widget = GTK_WIDGET (self);
-
- gtk_widget_set_halign (widget, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_widget_add_css_class (widget, "circular");
- gtk_widget_add_css_class (widget, "day");
- gtk_widget_add_css_class (widget, "flat");
-
- self->label = gtk_label_new ("");
- gtk_widget_set_halign (self->label, GTK_ALIGN_CENTER);
- gtk_widget_set_valign (self->label, GTK_ALIGN_CENTER);
- gtk_widget_set_hexpand (self->label, TRUE);
- gtk_widget_set_vexpand (self->label, TRUE);
-
- gtk_button_set_child (GTK_BUTTON (self), self->label);
+ gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget*
diff --git a/src/gui/event-editor/gcal-date-chooser-day.ui b/src/gui/event-editor/gcal-date-chooser-day.ui
new file mode 100644
index 00000000..b18db55f
--- /dev/null
+++ b/src/gui/event-editor/gcal-date-chooser-day.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<interface>
+ <template class="GcalDateChooserDay" parent="GtkButton">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="circular"/>
+ <class name="day"/>
+ <class name="flat"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="halign">center</property>
+ <property name="hexpand">True</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ </template>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]