[gtk+/wip/matthiasc/calendar] Add marked days to the date chooser test
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/calendar] Add marked days to the date chooser test
- Date: Fri, 4 Sep 2015 05:34:42 +0000 (UTC)
commit de10f4a6402e8f92e7221384887b91b8e602ca13
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 4 01:18:46 2015 -0400
Add marked days to the date chooser test
tests/testdatechooser.c | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/tests/testdatechooser.c b/tests/testdatechooser.c
index 732a877..3588381 100644
--- a/tests/testdatechooser.c
+++ b/tests/testdatechooser.c
@@ -14,6 +14,37 @@ date_changed (GObject *calendar,
g_free (text);
}
+static GtkDateChooserDayOptions
+get_day_options (GtkDateChooserWidget *calendar,
+ GDateTime *date,
+ gpointer data)
+{
+ GtkDateChooserDayOptions options;
+
+ options = GTK_DATE_CHOOSER_DAY_NONE;
+
+ if (g_date_time_get_day_of_week (date) == 6 ||
+ g_date_time_get_day_of_week (date) == 7)
+ options |= GTK_DATE_CHOOSER_DAY_WEEKEND;
+
+ /* 4th of July */
+ if (g_date_time_get_month (date) == 7 &&
+ g_date_time_get_day_of_month (date) == 4)
+ options |= GTK_DATE_CHOOSER_DAY_HOLIDAY;
+
+ /* Bastille day */
+ if (g_date_time_get_month (date) == 7 &&
+ g_date_time_get_day_of_month (date) == 14)
+ options |= GTK_DATE_CHOOSER_DAY_HOLIDAY;
+
+ /* my birthday */
+ if (g_date_time_get_month (date) == 3 &&
+ g_date_time_get_day_of_month (date) == 1)
+ options |= GTK_DATE_CHOOSER_DAY_MARKED;
+
+ return options;
+}
+
int
main (int argc, char *argv[])
{
@@ -26,6 +57,10 @@ main (int argc, char *argv[])
calendar = gtk_date_chooser_widget_new ();
g_signal_connect (calendar, "notify::date",
G_CALLBACK (date_changed), NULL);
+ gtk_date_chooser_widget_set_day_options_callback (GTK_DATE_CHOOSER_WIDGET (calendar),
+ get_day_options,
+ NULL,
+ NULL);
gtk_container_add (GTK_CONTAINER (window), calendar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]