date-chooser-day: Add .non-workday class to the current day

This will help making the non worked days let prominent.
This commit is contained in:
Adrien Plazas
2022-06-16 08:15:51 -03:00
committed by Georges Basile Stavracas Neto
parent 21895416f3
commit 54e0a5784c
@@ -23,6 +23,7 @@
#include "gcal-date-chooser-day.h"
#include "gcal-date-time-utils.h"
#include "gcal-utils.h"
#include <stdlib.h>
#include <langinfo.h>
@@ -171,18 +172,27 @@ gcal_date_chooser_day_set_date (GcalDateChooserDay *self,
g_autoptr (GDateTime) now = NULL;
g_autofree gchar *text = NULL;
gboolean today;
gint weekday;
g_assert (date != NULL);
g_clear_pointer (&self->date, g_date_time_unref);
self->date = g_date_time_ref (date);
now = g_date_time_new_now (g_date_time_get_timezone (date));
today = gcal_date_time_compare_date (date, now) == 0;
weekday = g_date_time_get_day_of_week (date) % 7;
if (G_UNLIKELY (today))
gtk_widget_add_css_class (widget, "today");
else
gtk_widget_remove_css_class (widget, "today");
if (G_LIKELY (is_workday (weekday)))
gtk_widget_remove_css_class (widget, "non-workday");
else
gtk_widget_add_css_class (widget, "non-workday");
text = g_strdup_printf ("%d", g_date_time_get_day_of_month (date));
gtk_label_set_label (GTK_LABEL (self->label), text);
}