Merge lp:~larsu/indicator-datetime/reset-date into lp:indicator-datetime/14.04

Proposed by Lars Karlitski on 2014-01-29
Status: Merged
Approved by: Charles Kerr on 2014-01-29
Approved revision: 296
Merged at revision: 296
Proposed branch: lp:~larsu/indicator-datetime/reset-date
Merge into: lp:indicator-datetime/14.04
Diff against target: 43 lines (+18/-1)
1 file modified
src/service.c (+18/-1)
To merge this branch: bzr merge lp:~larsu/indicator-datetime/reset-date
Reviewer Review Type Date Requested Status
Sebastien Bacher Needs Information on 2014-01-29
Charles Kerr (community) 2014-01-29 Approve on 2014-01-29
PS Jenkins bot (community) continuous-integration Approve on 2014-01-29
Review via email: mp+203736@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Charles Kerr (charlesk) wrote :

The code looks fine and it works. Thanks larsu :)

review: Approve
Sebastien Bacher (seb128) wrote :

What happens if you run that code without the new libindicator version? (or asked differently, should we update the depends on libindicator?)

review: Needs Information
Lars Karlitski (larsu) wrote :

The old libindicator will simply ignore the new menu item attribute. I don't think we need to bump the dependency.

Sebastien Bacher (seb128) wrote :

Great, I just wanted to make sure, thanks

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/service.c'
2--- src/service.c 2014-01-21 21:47:02 +0000
3+++ src/service.c 2014-01-29 13:32:47 +0000
4@@ -1359,6 +1359,21 @@
5 g_free (zone);
6 }
7
8+static void
9+on_calendar_active_changed (GSimpleAction *action G_GNUC_UNUSED,
10+ GVariant *state,
11+ gpointer user_data)
12+{
13+ IndicatorDatetimeService *self = user_data;
14+
15+ /* reset the date when the menu is shown */
16+ if (g_variant_get_boolean (state) && self->priv->calendar_date)
17+ {
18+ g_clear_pointer (&self->priv->calendar_date, g_date_time_unref);
19+ update_calendar_action_state (self);
20+ }
21+}
22+
23 /***
24 ****
25 ***/
26@@ -1431,6 +1446,7 @@
27 g_menu_item_set_attribute (header, "x-canonical-type",
28 "s", "com.canonical.indicator.root");
29 g_menu_item_set_submenu (header, G_MENU_MODEL (submenu));
30+ g_menu_item_set_attribute (header, "submenu-action", "s", "indicator.calendar-active");
31 g_object_unref (submenu);
32
33 /* add header to the menu */
34@@ -1586,7 +1602,8 @@
35 { "activate-phone-clock-app", on_phone_clock_activated },
36 { "activate-planner", on_activate_planner, "x", NULL },
37 { "activate-appointment", on_activate_appointment, "s", NULL },
38- { "set-location", on_set_location, "s" }
39+ { "set-location", on_set_location, "s" },
40+ { "calendar-active", NULL, NULL, "false", on_calendar_active_changed }
41 };
42
43 p->actions = g_simple_action_group_new ();

Subscribers

People subscribed via source and target branches