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

Proposed by Charles Kerr
Status: Merged
Approved by: Lars Karlitski
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) Approve
PS Jenkins bot (community) continuous-integration Approve
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.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
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
=== modified file 'src/service.c'
--- src/service.c 2013-10-30 23:10:34 +0000
+++ src/service.c 2013-11-01 21:20:26 +0000
@@ -821,64 +821,40 @@
821 create_calendar_state (self));821 create_calendar_state (self));
822}822}
823823
824static void824static GMenuModel *
825add_localtime_menuitem (GMenu * menu,825create_calendar_section (IndicatorDatetimeService * self, int profile)
826 IndicatorDatetimeService * self,
827 const char * time_format,
828 const char * icon_name)
829{826{
827 const gboolean allow_activation = (profile == PROFILE_PHONE) || (profile == PROFILE_DESKTOP);
828 GMenu * menu;
830 GDateTime * now;829 GDateTime * now;
831 char * label;830 char * label;
832 GMenuItem * menu_item;831 GMenuItem * item;
833832
833 menu = g_menu_new ();
834
835 /* add a menuitem that shows the current date & time */
834 now = indicator_datetime_service_get_localtime (self);836 now = indicator_datetime_service_get_localtime (self);
835 label = g_date_time_format (now, time_format);837 label = g_date_time_format (now, _("%A, %e %B %Y"));
836 menu_item = g_menu_item_new (label, NULL);838 item = g_menu_item_new (label, NULL);
837 if (icon_name && *icon_name)839 g_menu_item_set_attribute (item, G_MENU_ATTRIBUTE_ICON, "s", "calendar");
838 g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", icon_name);840 if (allow_activation)
839 g_menu_item_set_action_and_target_value (menu_item, "indicator.activate-planner", g_variant_new_int64(0));841 g_menu_item_set_action_and_target_value (item, "indicator.activate-planner", g_variant_new_int64(0));
840 g_menu_append_item (menu, menu_item);842 g_menu_append_item (menu, item);
841843 g_object_unref (item);
842 g_object_unref (menu_item);
843 g_free (label);844 g_free (label);
844 g_date_time_unref (now);845 g_date_time_unref (now);
845}846
846847 /* add a menuitem that shows the current date & time */
847static void848 if ((profile == PROFILE_DESKTOP) || (profile == PROFILE_GREETER))
848add_calendar_menuitem (GMenu * menu)849 {
849{850 item = g_menu_item_new ("[calendar]", NULL);
850 GMenuItem * menu_item;851 g_menu_item_set_action_and_target_value (item, "indicator.calendar", g_variant_new_int64(0));
851852 g_menu_item_set_attribute (item, "x-canonical-type", "s", "com.canonical.indicator.calendar");
852 menu_item = g_menu_item_new ("[calendar]", NULL);853 if (allow_activation)
853 g_menu_item_set_action_and_target_value (menu_item, "indicator.calendar", g_variant_new_int64(0));854 g_menu_item_set_attribute (item, "activation-action", "s", "indicator.activate-planner");
854 g_menu_item_set_attribute (menu_item, "x-canonical-type", "s", "com.canonical.indicator.calendar");855 g_menu_append_item (menu, item);
855 g_menu_item_set_attribute (menu_item, "activation-action", "s", "indicator.activate-planner");856 g_object_unref (item);
856857 }
857 g_menu_append_item (menu, menu_item);
858 g_object_unref (menu_item);
859}
860
861static GMenuModel *
862create_desktop_calendar_section (IndicatorDatetimeService * self)
863{
864 GMenu * menu = g_menu_new ();
865
866 /* strftime(3) format string to show the day of the week and the date */
867 add_localtime_menuitem (menu, self, _("%A, %e %B %Y"), "calendar");
868
869 if (g_settings_get_boolean (self->priv->settings, SETTINGS_SHOW_CALENDAR_S))
870 add_calendar_menuitem (menu);
871
872 return G_MENU_MODEL (menu);
873}
874
875static GMenuModel *
876create_phone_calendar_section (IndicatorDatetimeService * self)
877{
878 GMenu * menu = g_menu_new ();
879
880 /* strftime(3) format string to show date */
881 add_localtime_menuitem (menu, self, _("%A, %e %B %Y"), "calendar");
882858
883 return G_MENU_MODEL (menu);859 return G_MENU_MODEL (menu);
884}860}
@@ -1423,14 +1399,14 @@
1423 switch (profile)1399 switch (profile)
1424 {1400 {
1425 case PROFILE_PHONE:1401 case PROFILE_PHONE:
1426 sections[n++] = create_phone_calendar_section (self);1402 sections[n++] = create_calendar_section (self, profile);
1427 sections[n++] = create_phone_appointments_section (self);1403 sections[n++] = create_phone_appointments_section (self);
1428 sections[n++] = create_phone_settings_section (self);1404 sections[n++] = create_phone_settings_section (self);
1429 header_action = "indicator.phone-header";1405 header_action = "indicator.phone-header";
1430 break;1406 break;
14311407
1432 case PROFILE_DESKTOP:1408 case PROFILE_DESKTOP:
1433 sections[n++] = create_desktop_calendar_section (self);1409 sections[n++] = create_calendar_section (self, profile);
1434 sections[n++] = create_desktop_appointments_section (self);1410 sections[n++] = create_desktop_appointments_section (self);
1435 sections[n++] = create_locations_section (self);1411 sections[n++] = create_locations_section (self);
1436 sections[n++] = create_desktop_settings_section (self);1412 sections[n++] = create_desktop_settings_section (self);
@@ -1438,7 +1414,7 @@
1438 break;1414 break;
14391415
1440 case PROFILE_GREETER:1416 case PROFILE_GREETER:
1441 sections[n++] = create_desktop_calendar_section (self);1417 sections[n++] = create_calendar_section (self, profile);
1442 header_action = "indicator.desktop-header";1418 header_action = "indicator.desktop-header";
1443 break;1419 break;
1444 }1420 }
@@ -1673,9 +1649,9 @@
16731649
1674 if (sections & SECTION_CALENDAR)1650 if (sections & SECTION_CALENDAR)
1675 {1651 {
1676 rebuild_section (phone->submenu, 0, create_phone_calendar_section (self));1652 rebuild_section (phone->submenu, 0, create_calendar_section(self, PROFILE_PHONE));
1677 rebuild_section (desktop->submenu, 0, create_desktop_calendar_section (self));1653 rebuild_section (desktop->submenu, 0, create_calendar_section(self, PROFILE_DESKTOP));
1678 rebuild_section (greeter->submenu, 0, create_desktop_calendar_section (self));1654 rebuild_section (greeter->submenu, 0, create_calendar_section(self, PROFILE_GREETER));
1679 }1655 }
16801656
1681 if (sections & SECTION_APPOINTMENTS)1657 if (sections & SECTION_APPOINTMENTS)

Subscribers

People subscribed via source and target branches