From 6e97c05a1439302a49592284f58b9220cb1a072e Mon Sep 17 00:00:00 2001 From: Philipp Sauberzweig Date: Mon, 13 Oct 2025 19:59:19 +0200 Subject: [PATCH] views: Merge month name and date number into a single label. Part-of: --- src/gui/views/gcal-month-cell.blp | 2 -- src/gui/views/gcal-month-cell.c | 19 +++++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/gui/views/gcal-month-cell.blp b/src/gui/views/gcal-month-cell.blp index 35a13a68..d544083f 100644 --- a/src/gui/views/gcal-month-cell.blp +++ b/src/gui/views/gcal-month-cell.blp @@ -36,8 +36,6 @@ template $GcalMonthCell: Adw.BreakpointBin { ] } - Label month_name_label {} - Image weather_icon { pixel-size: 16; margin-start: 12; diff --git a/src/gui/views/gcal-month-cell.c b/src/gui/views/gcal-month-cell.c index 72203632..f4e3a31a 100644 --- a/src/gui/views/gcal-month-cell.c +++ b/src/gui/views/gcal-month-cell.c @@ -39,7 +39,6 @@ struct _GcalMonthCell GtkLabel *day_label; GtkWidget *header_box; - GtkLabel *month_name_label; GtkImage *weather_icon; GtkLabel *temp_label; @@ -219,7 +218,7 @@ update_weather (GcalMonthCell *self) if (day_of_month == 1) { g_autofree gchar *month_name = g_date_time_format (self->date, "%b"); - gtk_label_set_text (self->month_name_label, month_name); + gtk_label_set_text (self->day_label, month_name); } } else @@ -231,7 +230,7 @@ update_weather (GcalMonthCell *self) if (day_of_month == 1) { g_autofree gchar *month_name = g_date_time_format (self->date, "%B"); - gtk_label_set_text (self->month_name_label, month_name); + gtk_label_set_text (self->day_label, month_name); } } } @@ -434,7 +433,6 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass) gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, breakpoint_narrow); gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, day_label); gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, header_box); - gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, month_name_label); gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_button); gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overflow_inscription); gtk_widget_class_bind_template_child (widget_class, GcalMonthCell, overlay); @@ -480,7 +478,6 @@ void gcal_month_cell_set_date (GcalMonthCell *self, GDateTime *date) { - g_autofree gchar *text = NULL; gint day_of_month; g_return_if_fail (GCAL_IS_MONTH_CELL (self)); @@ -492,25 +489,19 @@ gcal_month_cell_set_date (GcalMonthCell *self, self->date = g_date_time_ref (date); day_of_month = g_date_time_get_day_of_month (date); - /* Day label */ - text = g_strdup_printf ("%d", day_of_month); - - gtk_label_set_text (self->day_label, text); update_style_flags (self); add_month_separators (self); - /* Month name */ - gtk_widget_set_visible (GTK_WIDGET (self->month_name_label), day_of_month == 1); if (day_of_month == 1) { g_autofree gchar *month_name = g_date_time_format (date, "%B"); - gtk_label_set_text (self->month_name_label, month_name); - gtk_widget_add_css_class (GTK_WIDGET (self->month_name_label), "heading"); + gtk_label_set_text (self->day_label, month_name); gtk_widget_add_css_class (GTK_WIDGET (self->day_label), "heading"); } else { - gtk_widget_remove_css_class (GTK_WIDGET (self->month_name_label), "heading"); + g_autofree gchar *date_number = g_strdup_printf ("%d", day_of_month); + gtk_label_set_text (self->day_label, date_number); gtk_widget_remove_css_class (GTK_WIDGET (self->day_label), "heading"); }