Merge lp:~charlesk/indicator-datetime/lp-1227106 into lp:~indicator-applet-developers/indicator-datetime/trunk.13.10

Proposed by Charles Kerr on 2013-10-15
Status: Merged
Approved by: Ted Gould on 2013-10-15
Approved revision: 272
Merged at revision: 271
Proposed branch: lp:~charlesk/indicator-datetime/lp-1227106
Merge into: lp:~indicator-applet-developers/indicator-datetime/trunk.13.10
Diff against target: 155 lines (+72/-4)
3 files modified
configure.ac (+4/-2)
debian/control (+1/-0)
src/service.c (+67/-2)
To merge this branch: bzr merge lp:~charlesk/indicator-datetime/lp-1227106
Reviewer Review Type Date Requested Status
Ted Gould (community) 2013-10-15 Approve on 2013-10-15
PS Jenkins bot (community) continuous-integration Approve on 2013-10-15
Review via email: mp+191280@code.launchpad.net

Description of the change

Changes the phone profile's "Clock" menuitem in two ways:

 1. instead of using a stock icon, try to use the clock app's icon.

 2. when clicked, launch the clock app.

To post a comment you must log in.
272. By Charles Kerr on 2013-10-15

make clock_app_icon_filename a field of IndicatorDatetimeServicePriv

Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2013-09-25 22:16:22 +0000
3+++ configure.ac 2013-10-15 19:44:44 +0000
4@@ -52,6 +52,7 @@
5 ECAL_REQUIRED_VERSION=3.5
6 EDS_REQUIRED_VERSION=3.5
7 URL_DISPATCHER_1_REQUIRED_VERSION=1
8+JSON_GLIB_REQUIRED_VERSION=0.16.2
9
10 GTK3_REQUIRED_VERSION=3.1.4
11
12@@ -60,8 +61,9 @@
13 geoclue >= $GEOCLUE_REQUIRED_VERSION
14 libical >= $ICAL_REQUIRED_VERSION
15 libecal-1.2 >= $ECAL_REQUIRED_VERSION
16- libedataserver-1.2 >= EDS_REQUIRED_VERSION
17- url-dispatcher-1 >= URL_DISPATCHER_1_REQUIRED_VERSION])
18+ libedataserver-1.2 >= $EDS_REQUIRED_VERSION
19+ url-dispatcher-1 >= $URL_DISPATCHER_1_REQUIRED_VERSION
20+ json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION])
21
22 ###########################
23 # Control Center panel
24
25=== modified file 'debian/control'
26--- debian/control 2013-09-25 22:16:22 +0000
27+++ debian/control 2013-10-15 19:44:44 +0000
28@@ -40,6 +40,7 @@
29 systemd-shim,
30 Recommends: indicator-applet | indicator-renderer,
31 evolution-data-server,
32+ click,
33 gnome-control-center-datetime | ubuntu-system-settings,
34 Conflicts: indicator-datetime (<< 13.10.0)
35 Replaces: indicator-datetime (<< 13.10.0)
36
37=== modified file 'src/service.c'
38--- src/service.c 2013-10-15 16:20:41 +0000
39+++ src/service.c 2013-10-15 19:44:44 +0000
40@@ -24,6 +24,7 @@
41
42 #include <glib/gi18n.h>
43 #include <gio/gio.h>
44+#include <json-glib/json-glib.h>
45 #include <url-dispatcher.h>
46
47 #include "dbus-shared.h"
48@@ -98,6 +99,13 @@
49 /* cached GTimeZone for use by indicator_datetime_service_get_localtime() */
50 GTimeZone * internal_timezone;
51
52+ /* the clock app's icon filename */
53+ gchar * clock_app_icon_filename;
54+
55+ /* Whether or not we've tried to load the clock app's icon.
56+ This way we don't keep trying to reload it on the desktop */
57+ gboolean clock_app_icon_initialized;
58+
59 guint own_id;
60 guint actions_export_id;
61 GDBusConnection * conn;
62@@ -783,14 +791,60 @@
63 g_date_time_unref (now);
64 }
65
66+
67+/* try to extract the clock app's filename from click. (/$pkgdir/$icon) */
68+static gchar *
69+get_clock_app_icon_filename (void)
70+{
71+ gchar * icon_filename = NULL;
72+ gchar * pkgdir;
73+
74+ pkgdir = NULL;
75+ g_spawn_command_line_sync ("click pkgdir com.ubuntu.clock", &pkgdir, NULL, NULL, NULL);
76+ if (pkgdir != NULL)
77+ {
78+ gchar * manifest = NULL;
79+ g_strstrip (pkgdir);
80+ g_spawn_command_line_sync ("click info com.ubuntu.clock", &manifest, NULL, NULL, NULL);
81+ if (manifest != NULL)
82+ {
83+ JsonParser * parser = json_parser_new ();
84+ if (json_parser_load_from_data (parser, manifest, -1, NULL))
85+ {
86+ JsonNode * root = json_parser_get_root (parser); /* transfer-none */
87+ if ((root != NULL) && (JSON_NODE_TYPE(root) == JSON_NODE_OBJECT))
88+ {
89+ JsonObject * o = json_node_get_object (root); /* transfer-none */
90+ const gchar * icon_name = json_object_get_string_member (o, "icon");
91+ if (icon_name != NULL)
92+ icon_filename = g_build_filename (pkgdir, icon_name, NULL);
93+ }
94+ }
95+ g_object_unref (parser);
96+ g_free (manifest);
97+ }
98+ g_free (pkgdir);
99+ }
100+
101+ return icon_filename;
102+}
103+
104 static GMenuModel *
105 create_phone_appointments_section (IndicatorDatetimeService * self)
106 {
107+ priv_t * p = self->priv;
108 GMenu * menu = g_menu_new ();
109 GMenuItem * menu_item;
110
111- menu_item = g_menu_item_new (_("Clock"), NULL);
112- g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", "clock");
113+ if (G_UNLIKELY (!p->clock_app_icon_initialized))
114+ {
115+ p->clock_app_icon_initialized = TRUE;
116+ p->clock_app_icon_filename = get_clock_app_icon_filename ();
117+ }
118+
119+ menu_item = g_menu_item_new (_("Clock"), "indicator.activate-phone-clock-app");
120+ if (p->clock_app_icon_filename != NULL)
121+ g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", p->clock_app_icon_filename);
122 g_menu_append_item (menu, menu_item);
123 g_object_unref (menu_item);
124
125@@ -1312,6 +1366,15 @@
126 }
127
128 static void
129+on_phone_clock_activated (GSimpleAction * a G_GNUC_UNUSED,
130+ GVariant * param G_GNUC_UNUSED,
131+ gpointer gself G_GNUC_UNUSED)
132+{
133+ const char * url = "appid://com.ubuntu.clock/clock/current-user-version";
134+ url_dispatch_send (url, NULL, NULL);
135+}
136+
137+static void
138 on_activate_planner (GSimpleAction * a G_GNUC_UNUSED,
139 GVariant * param,
140 gpointer gself)
141@@ -1364,6 +1427,7 @@
142 GActionEntry entries[] = {
143 { "activate-desktop-settings", on_desktop_settings_activated },
144 { "activate-phone-settings", on_phone_settings_activated },
145+ { "activate-phone-clock-app", on_phone_clock_activated },
146 { "activate-planner", on_activate_planner, "x", NULL },
147 { "set-location", on_set_location, "s" }
148 };
149@@ -1834,6 +1898,7 @@
150 IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE(o);
151 priv_t * p = self->priv;
152
153+ g_free (p->clock_app_icon_filename);
154 g_clear_pointer (&p->skew_time, g_date_time_unref);
155 g_clear_pointer (&p->calendar_date, g_date_time_unref);
156

Subscribers

People subscribed via source and target branches