From 158a962cee927c7b4cb9a70266681886a8895b48 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 25 Sep 2013 17:16:22 -0500 Subject: Use url-dispatcher instead of invoking system-settings directly. --- debian/control | 1 + 1 file changed, 1 insertion(+) (limited to 'debian/control') diff --git a/debian/control b/debian/control index ae07129..67938bf 100644 --- a/debian/control +++ b/debian/control @@ -22,6 +22,7 @@ Build-Depends: debhelper (>= 9), libgconf2-dev (>= 2.31), libgnome-control-center-dev, libtimezonemap1-dev, + liburl-dispatcher1-dev, Standards-Version: 3.9.3 Homepage: https://launchpad.net/indicator-datetime # If you aren't a member of ~indicator-applet-developers but need to upload -- cgit v1.2.3 From a52e3b86ee0dbce56221d1327c6c62a6d8e163e3 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 9 Oct 2013 21:33:15 -0500 Subject: preliminary implementation of snap decision --- configure.ac | 2 ++ debian/control | 1 + src/main.c | 6 +++++ src/service.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 73 insertions(+), 14 deletions(-) (limited to 'debian/control') diff --git a/configure.ac b/configure.ac index 8b95695..5b9dda6 100644 --- a/configure.ac +++ b/configure.ac @@ -51,6 +51,7 @@ GEOCLUE_REQUIRED_VERSION=0.12.0 ICAL_REQUIRED_VERSION=0.48 ECAL_REQUIRED_VERSION=3.5 EDS_REQUIRED_VERSION=3.5 +LIBNOTIFY_REQUIRED_VERSION=0.7.6 URL_DISPATCHER_1_REQUIRED_VERSION=1 GTK3_REQUIRED_VERSION=3.1.4 @@ -61,6 +62,7 @@ PKG_CHECK_MODULES(SERVICE, [glib-2.0 >= $GLIB_REQUIRED_VERSION libical >= $ICAL_REQUIRED_VERSION libecal-1.2 >= $ECAL_REQUIRED_VERSION libedataserver-1.2 >= EDS_REQUIRED_VERSION + libnotify >= $LIBNOTIFY_REQUIRED_VERSION url-dispatcher-1 >= URL_DISPATCHER_1_REQUIRED_VERSION]) ########################### diff --git a/debian/control b/debian/control index 67938bf..0815e1b 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9), libxorg-gtest-dev, libgtest-dev, libglib2.0-dev (>= 2.35.4), + libnotify-dev (>= 0.7.6), libido3-0.1-dev (>= 0.2.90), libgeoclue-dev (>= 0.12.0), libecal1.2-dev (>= 3.5), diff --git a/src/main.c b/src/main.c index 073c876..34e9b98 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include #include +#include #include "planner-eds.h" #include "planner-mock.h" @@ -52,6 +53,11 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); + /* init libnotify */ + if (!notify_init ("indicator-datetime-service")) + g_critical ("libnotify initialization failed"); + + /* get the planner */ if (g_getenv ("INDICATOR_DATETIME_USE_FAKE_PLANNER") != NULL) { diff --git a/src/service.c b/src/service.c index 57d0a7e..c76b07e 100644 --- a/src/service.c +++ b/src/service.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "dbus-shared.h" @@ -431,31 +432,80 @@ dispatch_alarm_url (const struct IndicatorDatetimeAppt * appt) url_dispatch_send (appt->url, NULL, NULL); } -/* Check for alarms that start at the current time. - If we find any, we dispatch the URL associated with them. */ +#if 0 static void -dispatch_alarm_urls (IndicatorDatetimeService * self) +on_notification_closed (NotifyNotification * nn, gpointer gself) { - GDateTime * now = indicator_datetime_service_get_localtime (self); - GSList * l; + //IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself); - for (l=self->priv->upcoming_appointments; l!=NULL; l=l->next) - { - const struct IndicatorDatetimeAppt * appt = l->data; + g_message ("hello world"); - if (appointment_has_alarm_url (appt) && datetimes_have_the_same_minute (now, appt->begin)) - dispatch_alarm_url (appt); - } + /* cleanup */ + g_signal_handlers_disconnect_by_data (nn, gself); + g_object_unref (nn); +} +#endif - g_date_time_unref (now); +static void +on_alarm_popup_ok_clicked (NotifyNotification * nn G_GNUC_UNUSED, char * action G_GNUC_UNUSED, gpointer gurl) +{ + const char * url = gurl; + url_dispatch_send (url, NULL, NULL); } +#define ALARM_ICON_NAME "alarm-symbolic" + static void update_appointment_lists (IndicatorDatetimeService * self); static gboolean -on_alarm_timer (gpointer self) +on_alarm_timer (gpointer gself) { - dispatch_alarm_urls (self); + GDateTime * now; + GSList * l; + IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself); + + /* Check for alarms that start at the current time. + * If we find one, trigger a snap decision displaying + * the appointment text and a single button to dismiss */ + now = indicator_datetime_service_get_localtime (self); + for (l=self->priv->upcoming_appointments; l!=NULL; l=l->next) + { + gchar * title; + const gchar * body; + const struct IndicatorDatetimeAppt * appt = l->data; + NotifyNotification * nn; + GError * error; + + if (!appointment_has_alarm_url (appt)) + continue; + + if (!datetimes_have_the_same_minute (now, appt->begin)) + continue; + + title = g_date_time_format (now, get_terse_time_format_string (now)); + body = appt->summary; + nn = notify_notification_new (title, body, ALARM_ICON_NAME); + + notify_notification_set_hint (nn, "x-canonical-snap-decisions", + g_variant_new_boolean(TRUE)); + notify_notification_set_hint (nn, "x-canonical-private-button-tint", + g_variant_new_boolean(TRUE)); + notify_notification_add_action (nn, "ok", _("OK"), + on_alarm_popup_ok_clicked, + g_strdup (appt->url), g_free); + //g_signal_connect (nn, "closed", G_CALLBACK(on_notification_closed), self); + + error = NULL; + notify_notification_show (nn, &error); + if (error != NULL) + { + g_warning ("Unable to show alarm '%s' popup: %s", body, error->message); + g_error_free (error); + dispatch_alarm_url (appt); + } + g_free (title); + } + g_date_time_unref (now); /* rebuild the alarm list asynchronously. when it's done, set_upcoming_appointments() will update the alarm timer */ -- cgit v1.2.3 From 50dbb636dc2078b21a7d981b1d4d3c3a25384648 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 15 Oct 2013 14:14:41 -0500 Subject: use the clock app's icon for the 'Clock' menuitem, and launch the clock app when it's clicked. --- configure.ac | 6 ++++-- debian/control | 1 + src/service.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 4 deletions(-) (limited to 'debian/control') diff --git a/configure.ac b/configure.ac index 8b95695..c41dc38 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,7 @@ ICAL_REQUIRED_VERSION=0.48 ECAL_REQUIRED_VERSION=3.5 EDS_REQUIRED_VERSION=3.5 URL_DISPATCHER_1_REQUIRED_VERSION=1 +JSON_GLIB_REQUIRED_VERSION=0.16.2 GTK3_REQUIRED_VERSION=3.1.4 @@ -60,8 +61,9 @@ PKG_CHECK_MODULES(SERVICE, [glib-2.0 >= $GLIB_REQUIRED_VERSION geoclue >= $GEOCLUE_REQUIRED_VERSION libical >= $ICAL_REQUIRED_VERSION libecal-1.2 >= $ECAL_REQUIRED_VERSION - libedataserver-1.2 >= EDS_REQUIRED_VERSION - url-dispatcher-1 >= URL_DISPATCHER_1_REQUIRED_VERSION]) + libedataserver-1.2 >= $EDS_REQUIRED_VERSION + url-dispatcher-1 >= $URL_DISPATCHER_1_REQUIRED_VERSION + json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION]) ########################### # Control Center panel diff --git a/debian/control b/debian/control index 67938bf..993d41a 100644 --- a/debian/control +++ b/debian/control @@ -40,6 +40,7 @@ Depends: ${shlibs:Depends}, systemd-shim, Recommends: indicator-applet | indicator-renderer, evolution-data-server, + click, gnome-control-center-datetime | ubuntu-system-settings, Conflicts: indicator-datetime (<< 13.10.0) Replaces: indicator-datetime (<< 13.10.0) diff --git a/src/service.c b/src/service.c index 12857bb..2516b2d 100644 --- a/src/service.c +++ b/src/service.c @@ -24,6 +24,7 @@ #include #include +#include #include #include "dbus-shared.h" @@ -783,14 +784,57 @@ add_appointments (IndicatorDatetimeService * self, GMenu * menu, gboolean terse) g_date_time_unref (now); } +static const gchar * +get_clock_app_icon_filename (void) +{ + static gboolean initialized = FALSE; + static gchar * icon_filename = NULL; + + /* try to extract the clock app's filename from click. (/$pkgdir/$icon) */ + if (!initialized) + { + gchar * pkgdir = NULL; + g_spawn_command_line_sync ("click pkgdir com.ubuntu.clock", &pkgdir, NULL, NULL, NULL); + if (pkgdir != NULL) + { + gchar * manifest = NULL; + g_strstrip (pkgdir); + g_spawn_command_line_sync ("click info com.ubuntu.clock", &manifest, NULL, NULL, NULL); + if (manifest != NULL) + { + JsonParser * parser = json_parser_new (); + if (json_parser_load_from_data (parser, manifest, -1, NULL)) + { + JsonNode * root = json_parser_get_root (parser); /* transfer-none */ + if ((root != NULL) && (JSON_NODE_TYPE(root) == JSON_NODE_OBJECT)) + { + JsonObject * o = json_node_get_object (root); /* transfer-none */ + const gchar * icon_name = json_object_get_string_member (o, "icon"); + icon_filename = g_build_filename (pkgdir, icon_name, NULL); + } + } + g_object_unref (parser); + g_free (manifest); + } + g_free (pkgdir); + } + + initialized = TRUE; + } + + return icon_filename; +} + static GMenuModel * create_phone_appointments_section (IndicatorDatetimeService * self) { GMenu * menu = g_menu_new (); GMenuItem * menu_item; + const gchar * icon_filename; - menu_item = g_menu_item_new (_("Clock"), NULL); - g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", "clock"); + menu_item = g_menu_item_new (_("Clock"), "indicator.activate-phone-clock-app"); + if ((icon_filename = get_clock_app_icon_filename ())) + g_menu_item_set_attribute (menu_item, G_MENU_ATTRIBUTE_ICON, "s", icon_filename); g_menu_append_item (menu, menu_item); g_object_unref (menu_item); @@ -1311,6 +1355,15 @@ on_phone_settings_activated (GSimpleAction * a G_GNUC_UNUSED, url_dispatch_send ("settings:///system/time-date", NULL, NULL); } +static void +on_phone_clock_activated (GSimpleAction * a G_GNUC_UNUSED, + GVariant * param G_GNUC_UNUSED, + gpointer gself G_GNUC_UNUSED) +{ + const char * url = "appid://com.ubuntu.clock/clock/current-user-version"; + url_dispatch_send (url, NULL, NULL); +} + static void on_activate_planner (GSimpleAction * a G_GNUC_UNUSED, GVariant * param, @@ -1364,6 +1417,7 @@ init_gactions (IndicatorDatetimeService * self) GActionEntry entries[] = { { "activate-desktop-settings", on_desktop_settings_activated }, { "activate-phone-settings", on_phone_settings_activated }, + { "activate-phone-clock-app", on_phone_clock_activated }, { "activate-planner", on_activate_planner, "x", NULL }, { "set-location", on_set_location, "s" } }; -- cgit v1.2.3 From a5eff35aea5fcbdd97b6d9459e5b05fcb4279676 Mon Sep 17 00:00:00 2001 From: Didier Roche Date: Wed, 16 Oct 2013 17:01:11 +0200 Subject: remove invalid click recommends and downgrade to Suggests --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debian/control') diff --git a/debian/control b/debian/control index 993d41a..22828b5 100644 --- a/debian/control +++ b/debian/control @@ -40,8 +40,8 @@ Depends: ${shlibs:Depends}, systemd-shim, Recommends: indicator-applet | indicator-renderer, evolution-data-server, - click, gnome-control-center-datetime | ubuntu-system-settings, +Suggests: click, Conflicts: indicator-datetime (<< 13.10.0) Replaces: indicator-datetime (<< 13.10.0) Description: Simple clock -- cgit v1.2.3