diff options
author | karl-qdh <karl@qdh.org.uk> | 2011-03-06 13:01:20 +0000 |
---|---|---|
committer | karl-qdh <karl@qdh.org.uk> | 2011-03-06 13:01:20 +0000 |
commit | 368393bf30ff81a02a800441ddef5640c4b0d207 (patch) | |
tree | 100573a5ba9b34eb3d0b6a0c28802ab36354a5c3 /src/idocalendarmenuitem.c | |
parent | acbbf01f8ad7b09e618227449a041cc4d0b9e267 (diff) | |
download | ayatana-ido-368393bf30ff81a02a800441ddef5640c4b0d207.tar.gz ayatana-ido-368393bf30ff81a02a800441ddef5640c4b0d207.tar.bz2 ayatana-ido-368393bf30ff81a02a800441ddef5640c4b0d207.zip |
Added new API to the calendar menu item so we can change the selected day/date.
Also added new signals for selecting days and selecting with double click. In indicator-datetime
these signals will be connected to either launching evolution (double), or invoking a re-building of the
appointments menu (single) from the selected day forward.
In this case we should also set the date of the calendar to today by default when opening the menu.
Diffstat (limited to 'src/idocalendarmenuitem.c')
-rw-r--r-- | src/idocalendarmenuitem.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c index ba46ae2..d49aacf 100644 --- a/src/idocalendarmenuitem.c +++ b/src/idocalendarmenuitem.c @@ -83,6 +83,15 @@ ido_calendar_menu_item_class_init (IdoCalendarMenuItemClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + + g_signal_new("day-selected", G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 1, G_TYPE_UINT); + g_signal_new("day-selected-double-click", G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 1, G_TYPE_UINT); } static void @@ -246,7 +255,15 @@ calendar_realized_cb (GtkWidget *widget, "month-changed", G_CALLBACK (calendar_month_changed_cb), item); - + g_signal_connect (item->priv->calendar, + "day-selected", + G_CALLBACK (calendar_day_selected_cb), + item); + g_signal_connect (item->priv->calendar, + "day-selected-double-click", + G_CALLBACK (calendar_day_selected_double_click_cb), + item); + ido_calendar_menu_item_send_focus_change (widget, TRUE); } @@ -270,6 +287,26 @@ calendar_month_changed_cb (GtkWidget *widget, g_signal_emit_by_name (item, "month-changed", NULL); } +static void +calendar_day_selected_cb (GtkWidget *widget, + gpointer user_data) +{ + IdoCalendarMenuItem *item = (IdoCalendarMenuItem *)user_data; + guint day, month, year; + gtk_calendar_get_date (GTK_CALENDAR (menuitem->priv->calendar), &year, &month, &day); + g_signal_emit_by_name (item, "day-selected", day, NULL); +} + +static void +calendar_day_selected_double_click_cb (GtkWidget *widget, + gpointer user_data) +{ + IdoCalendarMenuItem *item = (IdoCalendarMenuItem *)user_data; + guint day, month, year; + gtk_calendar_get_date (GTK_CALENDAR (menuitem->priv->calendar), &year, &month, &day); + g_signal_emit_by_name (item, "day-selected-double-click", day, NULL); +} + /* Public API */ GtkWidget * ido_calendar_menu_item_new (void) @@ -327,3 +364,18 @@ ido_calendar_menu_item_get_date (IdoCalendarMenuItem *menuitem, g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem)); gtk_calendar_get_date (GTK_CALENDAR (menuitem->priv->calendar), year, month, day); } + +gboolean +ido_calendar_menu_item_set_date (IdoCalendarMenuItem *menuitem, + guint year, + guint month, + guint day) +{ + g_return_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem)); + gtk_calendar_select_month (GTK_CALENDAR (menuitem->priv->calendar), month, year); + gtk_calendar_select_day (GTK_CALENDAR (menuitem->priv->calendar), day); + return TRUE; +} + + + |