Merge lp:~charlesk/indicator-datetime/lp-1246812 into lp:indicator-datetime/14.04

Proposed by Charles Kerr on 2013-11-01
Status: Merged
Approved by: Lars Karlitski on 2013-11-02
Approved revision: 284
Merged at revision: 286
Proposed branch: lp:~charlesk/indicator-datetime/lp-1246812
Merge into: lp:indicator-datetime/14.04
Diff against target: 135 lines (+34/-58)
1 file modified
src/service.c (+34/-58)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1246812
Reviewer Review Type Date Requested Status
Lars Karlitski (community) 2013-11-01 Approve on 2013-11-02
PS Jenkins bot (community) continuous-integration Approve on 2013-11-01
Review via email: mp+193663@code.launchpad.net

Description of the change

When in the desktop-greeter mode, don't allow clicking on calendar dates to launch evolution.

To post a comment you must log in.
Lars Karlitski (larsu) wrote :

Ok.

There's something in here I don't like, but it's not related to this patch: the icon name is set without using g_icon_serialize(). That's fine in practice though, as an icon name is serialized to a string with that icon name. While it's not specified to do so and might change, I see little reason that that ever will.

review: Approve

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 2013-10-30 23:10:34 +0000
3+++ src/service.c 2013-11-01 21:20:26 +0000
4@@ -821,64 +821,40 @@
5 create_calendar_state (self));
6 }
7
8-static void
9-add_localtime_menuitem (GMenu * menu,
10- IndicatorDatetimeService * self,
11- const char * time_format,
12- const char * icon_name)
13+static GMenuModel *
14+create_calendar_section (IndicatorDatetimeService * self, int profile)
15 {
16+ const gboolean allow_activation = (profile == PROFILE_PHONE) || (profile == PROFILE_DESKTOP);
17+ GMenu * menu;
18 GDateTime * now;
19 char * label;
20- GMenuItem * menu_item;
21-
22+ GMenuItem * item;
23+
24+ menu = g_menu_new ();
25+
26+ /* add a menuitem that shows the current date & time */
27 now = indicator_datetime_service_get_localtime (self);
28- label = g_date_time_format (now, time_format);
29- menu_item = g_menu_item_new (label, NULL);
30- if (icon_name && *icon_name)
31- g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", icon_name);
32- g_menu_item_set_action_and_target_value (menu_item, "indicator.activate-planner", g_variant_new_int64(0));
33- g_menu_append_item (menu, menu_item);
34-
35- g_object_unref (menu_item);
36+ label = g_date_time_format (now, _("%A, %e %B %Y"));
37+ item = g_menu_item_new (label, NULL);
38+ g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON, "s", "calendar");
39+ if (allow_activation)
40+ g_menu_item_set_action_and_target_value (item, "indicator.activate-planner", g_variant_new_int64(0));
41+ g_menu_append_item (menu, item);
42+ g_object_unref (item);
43 g_free (label);
44 g_date_time_unref (now);
45-}
46-
47-static void
48-add_calendar_menuitem (GMenu * menu)
49-{
50- GMenuItem * menu_item;
51-
52- menu_item = g_menu_item_new ("[calendar]", NULL);
53- g_menu_item_set_action_and_target_value (menu_item, "indicator.calendar", g_variant_new_int64(0));
54- g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.calendar");
55- g_menu_item_set_attribute (menu_item, "activation-action", "s", "indicator.activate-planner");
56-
57- g_menu_append_item (menu, menu_item);
58- g_object_unref (menu_item);
59-}
60-
61-static GMenuModel *
62-create_desktop_calendar_section (IndicatorDatetimeService * self)
63-{
64- GMenu * menu = g_menu_new ();
65-
66- /* strftime(3) format string to show the day of the week and the date */
67- add_localtime_menuitem (menu, self, _("%A, %e %B %Y"), "calendar");
68-
69- if (g_settings_get_boolean (self->priv->settings, SETTINGS_SHOW_CALENDAR_S))
70- add_calendar_menuitem (menu);
71-
72- return G_MENU_MODEL (menu);
73-}
74-
75-static GMenuModel *
76-create_phone_calendar_section (IndicatorDatetimeService * self)
77-{
78- GMenu * menu = g_menu_new ();
79-
80- /* strftime(3) format string to show date */
81- add_localtime_menuitem (menu, self, _("%A, %e %B %Y"), "calendar");
82+
83+ /* add a menuitem that shows the current date & time */
84+ if ((profile == PROFILE_DESKTOP) || (profile == PROFILE_GREETER))
85+ {
86+ item = g_menu_item_new ("[calendar]", NULL);
87+ g_menu_item_set_action_and_target_value (item, "indicator.calendar", g_variant_new_int64(0));
88+ g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.calendar");
89+ if (allow_activation)
90+ g_menu_item_set_attribute (item, "activation-action", "s", "indicator.activate-planner");
91+ g_menu_append_item (menu, item);
92+ g_object_unref (item);
93+ }
94
95 return G_MENU_MODEL (menu);
96 }
97@@ -1423,14 +1399,14 @@
98 switch (profile)
99 {
100 case PROFILE_PHONE:
101- sections[n++] = create_phone_calendar_section (self);
102+ sections[n++] = create_calendar_section (self, profile);
103 sections[n++] = create_phone_appointments_section (self);
104 sections[n++] = create_phone_settings_section (self);
105 header_action = "indicator.phone-header";
106 break;
107
108 case PROFILE_DESKTOP:
109- sections[n++] = create_desktop_calendar_section (self);
110+ sections[n++] = create_calendar_section (self, profile);
111 sections[n++] = create_desktop_appointments_section (self);
112 sections[n++] = create_locations_section (self);
113 sections[n++] = create_desktop_settings_section (self);
114@@ -1438,7 +1414,7 @@
115 break;
116
117 case PROFILE_GREETER:
118- sections[n++] = create_desktop_calendar_section (self);
119+ sections[n++] = create_calendar_section (self, profile);
120 header_action = "indicator.desktop-header";
121 break;
122 }
123@@ -1673,9 +1649,9 @@
124
125 if (sections & SECTION_CALENDAR)
126 {
127- rebuild_section (phone->submenu, 0, create_phone_calendar_section (self));
128- rebuild_section (desktop->submenu, 0, create_desktop_calendar_section (self));
129- rebuild_section (greeter->submenu, 0, create_desktop_calendar_section (self));
130+ rebuild_section (phone->submenu, 0, create_calendar_section(self, PROFILE_PHONE));
131+ rebuild_section (desktop->submenu, 0, create_calendar_section(self, PROFILE_DESKTOP));
132+ rebuild_section (greeter->submenu, 0, create_calendar_section(self, PROFILE_GREETER));
133 }
134
135 if (sections & SECTION_APPOINTMENTS)

Subscribers

People subscribed via source and target branches