month-cell: Show month name on the 1st day

This helps differentiate when the month change happens.
This commit is contained in:
Georges Basile Stavracas Neto
2023-08-16 21:21:47 -03:00
parent b8b1db7bcd
commit dabbc597d9
2 changed files with 16 additions and 0 deletions
+12
View File
@@ -36,6 +36,7 @@ struct _GcalMonthCell
GtkLabel *day_label;
GtkWidget *header_box;
GtkLabel *month_name_label;
GtkImage *weather_icon;
GtkLabel *temp_label;
@@ -321,6 +322,7 @@ gcal_month_cell_class_init (GcalMonthCellClass *klass)
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);
@@ -365,6 +367,7 @@ 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));
@@ -379,6 +382,15 @@ gcal_month_cell_set_date (GcalMonthCell *self,
gtk_label_set_text (self->day_label, text);
update_style_flags (self);
/* Month name */
day_of_month = g_date_time_get_day_of_month (date);
gtk_widget_set_visible (GTK_WIDGET (self->month_name_label), day_of_month == 1);
if (g_date_time_get_day_of_month (date) == 1)
{
g_autofree gchar *month_name = g_date_time_format (date, "%b");
gtk_label_set_text (self->month_name_label, month_name);
}
}
/**
+4
View File
@@ -24,6 +24,10 @@
</object>
</child>
<child>
<object class="GtkLabel" id="month_name_label" />
</child>
<!-- Weather forecast -->
<child>
<object class="GtkImage" id="weather_icon">