diff options
author | Ted Gould <ted@gould.cx> | 2011-04-12 22:18:26 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-04-12 22:18:26 -0500 |
commit | bf82669e3caf6e5f9f08e25039539634ace12db2 (patch) | |
tree | e918f0e076de0bd33eb87bc06b8bbae40c5ae6d0 /src/indicator-datetime.c | |
parent | 6d42bccac27b7214e5e650f698c2b117231e3f77 (diff) | |
parent | ea0c8c5ef4d8c790304d6c4f3c791b3e56244027 (diff) | |
download | ayatana-indicator-datetime-bf82669e3caf6e5f9f08e25039539634ace12db2.tar.gz ayatana-indicator-datetime-bf82669e3caf6e5f9f08e25039539634ace12db2.tar.bz2 ayatana-indicator-datetime-bf82669e3caf6e5f9f08e25039539634ace12db2.zip |
Work around libindicator not sending a close event by looking for it directly in the indicator
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r-- | src/indicator-datetime.c | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index a999f42..b322cc6 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -269,6 +269,35 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) } static void +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"); + + // 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"); + + 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 (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); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp);*/ +} + +static void indicator_datetime_init (IndicatorDatetime *self) { self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); @@ -348,6 +377,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 +1264,6 @@ calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, I } else { g_debug("\tMarks: <cleared>"); } - } 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; } @@ -1418,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; } |