[gnome-calendar/date-selector] date-selector: allow calendar to select the date
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar/date-selector] date-selector: allow calendar to select the date
- Date: Sun, 21 Dec 2014 14:48:18 +0000 (UTC)
commit 8a9426081fc61d512566c1963b3294018ae9447a
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sun Dec 21 12:48:09 2014 -0200
date-selector: allow calendar to select the date
For testing reasons, we don't fire MODIFIED signal yet.
src/gcal-date-selector.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-date-selector.c b/src/gcal-date-selector.c
index 5a79474..01118b0 100644
--- a/src/gcal-date-selector.c
+++ b/src/gcal-date-selector.c
@@ -62,6 +62,9 @@ enum
static guint signals[NUM_SIGNALS] = { 0, };
+static void calendar_day_selected (GtkCalendar *calendar,
+ gpointer user_data);
+
static void text_inserted (GtkEditable *editable,
gchar *new_text,
gint new_text_length,
@@ -78,6 +81,30 @@ static void gcal_date_selector_constructed (GObject
G_DEFINE_TYPE_WITH_PRIVATE (GcalDateSelector, gcal_date_selector, GTK_TYPE_TOGGLE_BUTTON);
static void
+calendar_day_selected (GtkCalendar *calendar,
+ gpointer user_data)
+{
+ GcalDateSelectorPrivate *priv;
+ guint day, month, year;
+
+ priv = gcal_date_selector_get_instance_private (GCAL_DATE_SELECTOR (user_data));
+ gtk_calendar_get_date (calendar, &year, &month, &day);
+
+ /**
+ * Block signal handler to avoid an infinite
+ * recursion, exploding the proccess stack.
+ */
+ g_signal_handlers_block_by_func (priv->calendar,
+ calendar_day_selected,
+ user_data);
+ set_date (GCAL_DATE_SELECTOR (user_data), day, month + 1, year);
+
+ g_signal_handlers_unblock_by_func (priv->calendar,
+ calendar_day_selected,
+ user_data);
+}
+
+static void
text_inserted (GtkEditable *editable,
gchar *new_text,
gint new_text_length,
@@ -359,6 +386,8 @@ gcal_date_selector_constructed (GObject *object)
g_signal_connect (priv->entries[MONTH], "insert-text", G_CALLBACK (text_inserted), object);
g_signal_connect (priv->entries[YEAR], "insert-text", G_CALLBACK (text_inserted), object);
+ g_signal_connect (priv->calendar, "day-selected", G_CALLBACK (calendar_day_selected), object);
+
g_object_unref (builder);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]