98
99
/* cached GTimeZone for use by indicator_datetime_service_get_localtime() */
99
100
GTimeZone * internal_timezone;
102
/* the clock app's icon filename */
103
gchar * clock_app_icon_filename;
105
/* Whether or not we've tried to load the clock app's icon.
106
This way we don't keep trying to reload it on the desktop */
107
gboolean clock_app_icon_initialized;
102
110
guint actions_export_id;
103
111
GDBusConnection * conn;
783
791
g_date_time_unref (now);
795
/* try to extract the clock app's filename from click. (/$pkgdir/$icon) */
797
get_clock_app_icon_filename (void)
799
gchar * icon_filename = NULL;
803
g_spawn_command_line_sync ("click pkgdir com.ubuntu.clock", &pkgdir, NULL, NULL, NULL);
806
gchar * manifest = NULL;
808
g_spawn_command_line_sync ("click info com.ubuntu.clock", &manifest, NULL, NULL, NULL);
809
if (manifest != NULL)
811
JsonParser * parser = json_parser_new ();
812
if (json_parser_load_from_data (parser, manifest, -1, NULL))
814
JsonNode * root = json_parser_get_root (parser); /* transfer-none */
815
if ((root != NULL) && (JSON_NODE_TYPE(root) == JSON_NODE_OBJECT))
817
JsonObject * o = json_node_get_object (root); /* transfer-none */
818
const gchar * icon_name = json_object_get_string_member (o, "icon");
819
if (icon_name != NULL)
820
icon_filename = g_build_filename (pkgdir, icon_name, NULL);
823
g_object_unref (parser);
829
return icon_filename;
786
832
static GMenuModel *
787
833
create_phone_appointments_section (IndicatorDatetimeService * self)
835
priv_t * p = self->priv;
789
836
GMenu * menu = g_menu_new ();
790
837
GMenuItem * menu_item;
792
menu_item = g_menu_item_new (_("Clock"), NULL);
793
g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", "clock");
839
if (G_UNLIKELY (!p->clock_app_icon_initialized))
841
p->clock_app_icon_initialized = TRUE;
842
p->clock_app_icon_filename = get_clock_app_icon_filename ();
845
menu_item = g_menu_item_new (_("Clock"), "indicator.activate-phone-clock-app");
846
if (p->clock_app_icon_filename != NULL)
847
g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", p->clock_app_icon_filename);
794
848
g_menu_append_item (menu, menu_item);
795
849
g_object_unref (menu_item);
1369
on_phone_clock_activated (GSimpleAction * a G_GNUC_UNUSED,
1370
GVariant * param G_GNUC_UNUSED,
1371
gpointer gself G_GNUC_UNUSED)
1373
const char * url = "appid://com.ubuntu.clock/clock/current-user-version";
1374
url_dispatch_send (url, NULL, NULL);
1315
1378
on_activate_planner (GSimpleAction * a G_GNUC_UNUSED,
1316
1379
GVariant * param,
1317
1380
gpointer gself)
1364
1427
GActionEntry entries[] = {
1365
1428
{ "activate-desktop-settings", on_desktop_settings_activated },
1366
1429
{ "activate-phone-settings", on_phone_settings_activated },
1430
{ "activate-phone-clock-app", on_phone_clock_activated },
1367
1431
{ "activate-planner", on_activate_planner, "x", NULL },
1368
1432
{ "set-location", on_set_location, "s" }
1834
1898
IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE(o);
1835
1899
priv_t * p = self->priv;
1901
g_free (p->clock_app_icon_filename);
1837
1902
g_clear_pointer (&p->skew_time, g_date_time_unref);
1838
1903
g_clear_pointer (&p->calendar_date, g_date_time_unref);