From 9485b01a79c5a7ebe563986295acf24f6ce7df1a Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Sun, 6 Mar 2011 14:28:05 +0000 Subject: Hooking up the signals from the calendar and getting it working on service side --- src/datetime-service.c | 2 +- src/dbus-shared.h | 1 + src/indicator-datetime.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 6f38004..ffaafb0 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -279,7 +279,7 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) static gboolean month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) { - // BLOCKED: We're not getting the signal from calendar the ido calendar menuitem + // BLOCKED: Get string from the variant causes segfault in glib // TODO: * Decode the month/year from the string we received // * Check what our current month/year are // * Set some globals so when we-re-run update appointment menu items it gets the right start date diff --git a/src/dbus-shared.h b/src/dbus-shared.h index fa6de7b..8b1a20b 100644 --- a/src/dbus-shared.h +++ b/src/dbus-shared.h @@ -34,6 +34,7 @@ with this program. If not, see . #define CALENDAR_MENUITEM_PROP_MARK "calendar-mark" #define CALENDAR_MENUITEM_PROP_UNMARK "calendar-unmark" #define CALENDAR_MENUITEM_PROP_CLEAR_MARKS "calendar-clear-marks" +#define CALENDAR_MENUITEM_PROP_SET_DATE "calendar-set-date" #define APPOINTMENT_MENUITEM_TYPE "appointment-item" diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 7953883..0d10579 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1102,6 +1102,9 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value)); } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) { ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data)); + } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { + // TODO This needs to be an array of 3 ints + //ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), ); } else { g_warning("Indicator Item property '%s' unknown", prop); } @@ -1196,10 +1199,42 @@ month_changed_cb (IdoCalendarMenuItem *ido, g_sprintf(datestring, "%d-%d-%d", y, m, d); GVariant *variant = g_variant_new_string(datestring); guint timestamp = (guint)time(NULL); - dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "event::month-changed", variant, timestamp); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "month-changed", variant, timestamp); g_debug("Got month changed signal: %s", datestring); } +static void +day_selected_cb (IdoCalendarMenuItem *ido, + guint day, + gpointer user_data) +{ + gchar datestring[20]; + guint d,m,y; + DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data); + ido_calendar_menu_item_get_date(ido, &y, &m, &d); + g_sprintf(datestring, "%d-%d-%d", y, m, d); + GVariant *variant = g_variant_new_string(datestring); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected", variant, timestamp); + g_debug("Got day-selected signal: %s", datestring); +} + +static void +day_selected_double_click_cb (IdoCalendarMenuItem *ido, + guint day, + gpointer user_data) +{ + gchar datestring[20]; + guint d,m,y; + DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data); + ido_calendar_menu_item_get_date(ido, &y, &m, &d); + g_sprintf(datestring, "%d-%d-%d", y, m, d); + GVariant *variant = g_variant_new_string(datestring); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected-double-click", variant, timestamp); + g_debug("Got day-selected-double-click signal: %s", datestring); +} + static gboolean new_calendar_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, @@ -1231,6 +1266,11 @@ new_calendar_item (DbusmenuMenuitem * newitem, dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); g_signal_connect_after(ido, "month-changed", G_CALLBACK(month_changed_cb), (gpointer)newitem); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + g_signal_connect_after(ido, "day-selected", G_CALLBACK(day_selected_cb), (gpointer)newitem); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + g_signal_connect_after(ido, "day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem); + return TRUE; } -- cgit v1.2.3