summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-09-04 01:18:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-09-04 01:33:28 -0400
commitde10f4a6402e8f92e7221384887b91b8e602ca13 (patch)
tree7ab67dcf3a5897d6eaea0b7abb1546f36fed2fff
parentd21ec4ce9dc606d43e2dc9a35b08c5dd6cb56e17 (diff)
downloadgtk+-wip/matthiasc/calendar.tar.gz
Add marked days to the date chooser testwip/matthiasc/calendar
-rw-r--r--tests/testdatechooser.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/testdatechooser.c b/tests/testdatechooser.c
index 732a877160..3588381854 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);