From f07f97ef53522abdce52cf3c7b583c0d6d47aa40 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 29 Jan 2014 12:50:59 -0600 Subject: sync with lp:~larsu/indicator-datetime/reset-date and add corresponding unit tests. --- src/actions.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/actions.cpp') diff --git a/src/actions.cpp b/src/actions.cpp index a6a7c0b..acf8fd4 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -108,9 +108,22 @@ void on_set_location(GSimpleAction * /*action*/, g_free(zone); } -static void on_calendar_activated(GSimpleAction * /*action*/, - GVariant * state, - gpointer gself) +void on_calendar_active_changed(GSimpleAction * /*action*/, + GVariant * state, + gpointer gself) +{ + // reset the date when the menu is shown + if (g_variant_get_boolean(state)) + { + auto self = static_cast(gself); + + self->set_calendar_date(self->state()->clock->localtime()); + } +} + +void on_calendar_activated(GSimpleAction * /*action*/, + GVariant * state, + gpointer gself) { const time_t t = g_variant_get_int64(state); @@ -175,6 +188,7 @@ Actions::Actions(const std::shared_ptr& state): { "activate-phone-clock-app", on_phone_clock_activated }, { "activate-appointment", on_activate_appointment, "s", nullptr }, { "activate-planner", on_activate_planner, "x", nullptr }, + { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed }, { "set-location", on_set_location, "s" } }; -- cgit v1.2.3