From 4272a3e74b1f7aeec22e852c32a06eae3a69a980 Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 29 Jan 2014 14:24:03 +0100 Subject: Set calendar to the current date when the menu is popped up This makes use of the "submenu-action" attribute to get notified when the menu is popped up. --- src/service.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index 746ced9..7176ef1 100644 --- a/src/service.c +++ b/src/service.c @@ -1359,6 +1359,21 @@ on_set_location (GSimpleAction * a G_GNUC_UNUSED, g_free (zone); } +static void +on_calendar_active_changed (GSimpleAction *action G_GNUC_UNUSED, + GVariant *state, + gpointer user_data) +{ + IndicatorDatetimeService *self = user_data; + + /* reset the date when the menu is shown */ + if (g_variant_get_boolean (state) && self->priv->calendar_date) + { + g_clear_pointer (&self->priv->calendar_date, g_date_time_unref); + update_calendar_action_state (self); + } +} + /*** **** ***/ @@ -1431,6 +1446,7 @@ create_menu (IndicatorDatetimeService * self, int profile) g_menu_item_set_attribute (header, "x-canonical-type", "s", "com.canonical.indicator.root"); g_menu_item_set_submenu (header, G_MENU_MODEL (submenu)); + g_menu_item_set_attribute (header, "submenu-action", "s", "indicator.calendar-active"); g_object_unref (submenu); /* add header to the menu */ @@ -1586,7 +1602,8 @@ init_gactions (IndicatorDatetimeService * self) { "activate-phone-clock-app", on_phone_clock_activated }, { "activate-planner", on_activate_planner, "x", NULL }, { "activate-appointment", on_activate_appointment, "s", NULL }, - { "set-location", on_set_location, "s" } + { "set-location", on_set_location, "s" }, + { "calendar-active", NULL, NULL, "false", on_calendar_active_changed } }; p->actions = g_simple_action_group_new (); -- cgit v1.2.3