aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-01-29 15:52:13 +0000
committerTarmac <Unknown>2014-01-29 15:52:13 +0000
commitc0a0b35591a62b6150f0e478e4dee72b429d6eb5 (patch)
tree62dabb77119a32d0fb656b9d379df8e1bd0d1ccf
parente099f058ad7e1d026fcf7e2bf125edb95b0a438c (diff)
parent4272a3e74b1f7aeec22e852c32a06eae3a69a980 (diff)
downloadayatana-indicator-datetime-c0a0b35591a62b6150f0e478e4dee72b429d6eb5.tar.gz
ayatana-indicator-datetime-c0a0b35591a62b6150f0e478e4dee72b429d6eb5.tar.bz2
ayatana-indicator-datetime-c0a0b35591a62b6150f0e478e4dee72b429d6eb5.zip
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. Charles, if your big refactoring-branch should land before this, do you mind adapting this patch for that? Thanks . Fixes: https://bugs.launchpad.net/bugs/793450. Approved by Charles Kerr, PS Jenkins bot.
-rw-r--r--src/service.c19
1 files changed, 18 insertions, 1 deletions
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 ();