aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-01-29 12:50:59 -0600
committerCharles Kerr <charles.kerr@canonical.com>2014-01-29 12:50:59 -0600
commitf07f97ef53522abdce52cf3c7b583c0d6d47aa40 (patch)
tree6f535ea3e19a727f1de47914b4b3bfb80ecc2857 /src
parent9045a274a93bb96be458e563bebbceca1426da96 (diff)
downloadayatana-indicator-datetime-f07f97ef53522abdce52cf3c7b583c0d6d47aa40.tar.gz
ayatana-indicator-datetime-f07f97ef53522abdce52cf3c7b583c0d6d47aa40.tar.bz2
ayatana-indicator-datetime-f07f97ef53522abdce52cf3c7b583c0d6d47aa40.zip
sync with lp:~larsu/indicator-datetime/reset-date and add corresponding unit tests.
Diffstat (limited to 'src')
-rw-r--r--src/actions.cpp20
-rw-r--r--src/menu.cpp2
2 files changed, 19 insertions, 3 deletions
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<Actions*>(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>& 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" }
};
diff --git a/src/menu.cpp b/src/menu.cpp
index 390a06f..b0ba79d 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -204,6 +204,8 @@ private:
auto header = g_menu_item_new(nullptr, detailed_action.c_str());
g_menu_item_set_attribute(header, "x-canonical-type", "s",
"com.canonical.indicator.root");
+ g_menu_item_set_attribute(header, "submenu-action", "s",
+ "indicator.calendar-active");
g_menu_item_set_submenu(header, G_MENU_MODEL(m_submenu));
g_object_unref(m_submenu);