aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-14 21:45:26 -0500
committerTed Gould <ted@gould.cx>2011-03-14 21:45:26 -0500
commit9b651a1251a134e2c5ea38d954fdac22d7ade0ac (patch)
treeb6bf157f0a0bd86acd59932a2cd69194a215ded2 /src
parenta38ef76289761495301c80b2473cbf3089b6a8e6 (diff)
parent3a78f4ca394856de3e7d46bdd7cca0d234b1980f (diff)
downloadayatana-ido-9b651a1251a134e2c5ea38d954fdac22d7ade0ac.tar.gz
ayatana-ido-9b651a1251a134e2c5ea38d954fdac22d7ade0ac.tar.bz2
ayatana-ido-9b651a1251a134e2c5ea38d954fdac22d7ade0ac.zip
Be able to set active date and signal when it changes
Diffstat (limited to 'src')
-rw-r--r--src/idocalendarmenuitem.c59
-rw-r--r--src/idocalendarmenuitem.h4
2 files changed, 61 insertions, 2 deletions
diff --git a/src/idocalendarmenuitem.c b/src/idocalendarmenuitem.c
index ec52f13..346b3d6 100644
--- a/src/idocalendarmenuitem.c
+++ b/src/idocalendarmenuitem.c
@@ -44,7 +44,10 @@ static void calendar_move_focus_cb (GtkWidget *widg
IdoCalendarMenuItem *item);
static void calendar_month_changed_cb (GtkWidget *widget,
gpointer user_data);
-
+static void calendar_day_selected_double_click_cb (GtkWidget *widget,
+ gpointer user_data);
+static void calendar_day_selected_cb (GtkWidget *widget,
+ gpointer user_data);
struct _IdoCalendarMenuItemPrivate
{
GtkWidget *box;
@@ -83,6 +86,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 +258,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 +290,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 (widget), &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 (widget), &year, &month, &day);
+ g_signal_emit_by_name (item, "day-selected-double-click", day, NULL);
+}
+
/* Public API */
GtkWidget *
ido_calendar_menu_item_new (void)
@@ -334,3 +374,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_val_if_fail(IDO_IS_CALENDAR_MENU_ITEM(menuitem), FALSE);
+ gtk_calendar_select_month (GTK_CALENDAR (menuitem->priv->calendar), month, year);
+ gtk_calendar_select_day (GTK_CALENDAR (menuitem->priv->calendar), day);
+ return TRUE;
+}
+
+
+
diff --git a/src/idocalendarmenuitem.h b/src/idocalendarmenuitem.h
index 7fe899a..c4833fb 100644
--- a/src/idocalendarmenuitem.h
+++ b/src/idocalendarmenuitem.h
@@ -66,6 +66,10 @@ void ido_calendar_menu_item_get_date (IdoCalendarMenuItem *menu
guint *year,
guint *month,
guint *day);
+gboolean ido_calendar_menu_item_set_date (IdoCalendarMenuItem *menuitem,
+ guint year,
+ guint month,
+ guint day);
G_END_DECLS
#endif /* __IDO_CALENDAR_MENU_ITEM_H__ */