From 9e768e9751cd1705146f245d61dedc5d9f6147d5 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 11 Apr 2011 14:40:57 +0100 Subject: Calendar reset, should work for mike --- src/indicator-datetime.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index a999f42..7d1222e 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -268,6 +268,28 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) return; } +static void +menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) +{ + IndicatorDatetime * self = INDICATOR_DATETIME(user_data); + int y,m,d; + time_t curtime; + + time(&curtime); + struct tm *today = localtime(&curtime); + int y = today->tm_year; + int m = today->tm_mon; + int d = today->tm_mday; + + // Set the calendar to todays date + ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), y, m, d); + + // Make sure the day-selected signal is sent so the menu updates - may duplicate + GVariant *variant = g_variant_new_uint32((guint)curtime); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected", variant, timestamp); +} + static void indicator_datetime_init (IndicatorDatetime *self) { @@ -348,6 +370,8 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ); + g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notfy_cb), self); + DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu); dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL); dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL); @@ -1233,13 +1257,6 @@ calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, I } else { g_debug("\tMarks: "); } - } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { - if (value != NULL) { - gsize size = 3; - const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint)); - g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]); - ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]); - } } return; } -- cgit v1.2.3 From 22a5e34ec75727861c77488aa62d606d64c95271 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 11 Apr 2011 14:45:47 +0100 Subject: Improve debug messages and only react when hiding --- src/indicator-datetime.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 7d1222e..a6d7ef2 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -272,6 +272,14 @@ static void menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) { IndicatorDatetime * self = INDICATOR_DATETIME(user_data); + g_debug("notify visible signal recieved"); + + // we should only react if we're currently visible + gboolean visible; + g_object_get(G_OBJECT(menu), "visible", &visible, NULL); + if (visible) return; + g_debug("notify visible menu hidden, resetting date"); + int y,m,d; time_t curtime; -- cgit v1.2.3 From 54a4bf27e26fbdbcd02618250dbabd2b880ca447 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 11 Apr 2011 14:56:07 +0100 Subject: syntax fail --- src/indicator-datetime.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index a6d7ef2..a69e728 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -280,7 +280,6 @@ menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) if (visible) return; g_debug("notify visible menu hidden, resetting date"); - int y,m,d; time_t curtime; time(&curtime); @@ -290,12 +289,12 @@ menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) int d = today->tm_mday; // Set the calendar to todays date - ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), y, m, d); + ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (self->priv->ido_calendar), y, m, d); // Make sure the day-selected signal is sent so the menu updates - may duplicate GVariant *variant = g_variant_new_uint32((guint)curtime); guint timestamp = (guint)time(NULL); - dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected", variant, timestamp); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp); } static void @@ -1443,11 +1442,6 @@ new_calendar_item (DbusmenuMenuitem * newitem, calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_MARKS, propval, ido); } - propval = dbusmenu_menuitem_property_get_variant(newitem, CALENDAR_MENUITEM_PROP_SET_DATE); - if (propval != NULL) { - calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_SET_DATE, propval, ido); - } - return TRUE; } -- cgit v1.2.3 From ea0c8c5ef4d8c790304d6c4f3c791b3e56244027 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 11 Apr 2011 15:15:16 +0100 Subject: Fixed niggles --- src/indicator-datetime.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index a69e728..b322cc6 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -269,7 +269,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) } static void -menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) +menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data) { IndicatorDatetime * self = INDICATOR_DATETIME(user_data); g_debug("notify visible signal recieved"); @@ -289,12 +289,12 @@ menu_visible_notfy_cb(GtkWidget * menu, gpointer user_data) int d = today->tm_mday; // Set the calendar to todays date - ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (self->priv->ido_calendar), y, m, d); + ido_calendar_menu_item_set_date (self->priv->ido_calendar, y+1900, m, d); // Make sure the day-selected signal is sent so the menu updates - may duplicate - GVariant *variant = g_variant_new_uint32((guint)curtime); + /*GVariant *variant = g_variant_new_uint32((guint)curtime); guint timestamp = (guint)time(NULL); - dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp);*/ } static void -- cgit v1.2.3