aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c57
-rw-r--r--src/service.c33
2 files changed, 50 insertions, 40 deletions
diff --git a/src/main.c b/src/main.c
index 45ee180..c7ad34a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,30 +31,55 @@
#include "planner-mock.h"
#include "service.h"
-#define TEST_MODE
-
/***
****
***/
static void
-on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
+on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop G_GNUC_UNUSED)
{
g_message ("exiting: service couldn't acquire or lost ownership of busname");
g_main_loop_quit ((GMainLoop*)loop);
}
-#ifdef TEST_MODE
static void
-log_handler (const gchar * log_domain,
- GLogLevelFlags log_level,
- const gchar * message,
- gpointer fp)
+action_ok (NotifyNotification *notification G_GNUC_UNUSED,
+ char *action,
+ gpointer gurl)
{
- fprintf (fp, "%s %d %s\n", log_domain, (int)log_level, message);
- fflush (fp);
+ const char * url = gurl;
+ g_message ("'%s' clicked for snap decision; url is '%s'", action, url);
+}
+
+static void
+show_snap_decision (void)
+{
+ const gchar * title = "Title";
+ const gchar * body = "Body";
+ const gchar * icon_name = "alarm-clock";
+ NotifyNotification * nn;
+ GError * error;
+
+ g_debug ("creating a snap decision with title '%s', body '%s', icon '%s'",
+ title, body, icon_name);
+
+ nn = notify_notification_new (title, body, 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, "action_accept", _("OK"),
+ action_ok, g_strdup("hello world"), g_free);
+
+ g_message ("showing notification %p", nn);
+ 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);
+ }
}
-#endif
int
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
@@ -74,14 +99,15 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
/* set up the planner */
#ifdef TEST_MODE
- g_warning ("Using fake appointment book for testing! Probably shouldn't merge this to trunk.");
- FILE * fp = fopen ("/tmp/indicator-datetime-log.txt", "w+");
- g_log_set_handler ("Indicator-Datetime", G_LOG_LEVEL_MASK, log_handler, fp);
+ g_warning ("Using fake appointment book for testing! "
+ "Probably shouldn't merge this to trunk.");
planner = indicator_datetime_planner_mock_new ();
#else
planner = indicator_datetime_planner_eds_new ();
#endif
+ show_snap_decision ();
+
/* run */
service = indicator_datetime_service_new (planner);
loop = g_main_loop_new (NULL, FALSE);
@@ -93,8 +119,5 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
g_main_loop_unref (loop);
g_object_unref (service);
g_object_unref (planner);
-#ifdef TEST_MODE
- fclose (fp);
-#endif
return 0;
}
diff --git a/src/service.c b/src/service.c
index 270f214..fd3d937 100644
--- a/src/service.c
+++ b/src/service.c
@@ -432,24 +432,13 @@ dispatch_alarm_url (const struct IndicatorDatetimeAppt * appt)
url_dispatch_send (appt->url, NULL, NULL);
}
-#if 0
static void
-on_notification_closed (NotifyNotification * nn, gpointer gself)
-{
- //IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself);
-
- g_message ("hello world");
-
- /* cleanup */
- g_signal_handlers_disconnect_by_data (nn, gself);
- g_object_unref (nn);
-}
-#endif
-
-static void
-on_alarm_popup_ok_clicked (NotifyNotification * nn G_GNUC_UNUSED, char * action G_GNUC_UNUSED, gpointer gurl)
+action_ok (NotifyNotification *notification G_GNUC_UNUSED,
+ char *action,
+ gpointer gurl)
{
const char * url = gurl;
+ g_debug ("'%s' clicked for snap decision %s", action, url);
url_dispatch_send (url, NULL, NULL);
}
@@ -465,17 +454,18 @@ show_snap_decision_for_alarm (const struct IndicatorDatetimeAppt * appt)
title = g_date_time_format (appt->begin,
get_terse_time_format_string (appt->begin));
body = appt->summary;
- icon_name = "alarm-symbolic";
+ icon_name = "alarm-clock";
g_debug ("creating a snap decision with title '%s', body '%s', icon '%s'",
title, body, icon_name);
+
nn = notify_notification_new (title, body, 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);
+ notify_notification_add_action (nn, "action_accept", _("OK"),
+ action_ok, g_strdup(appt->url), g_free);
+
error = NULL;
notify_notification_show (nn, &error);
if (error != NULL)
@@ -1981,14 +1971,11 @@ on_name_lost (GDBusConnection * connection G_GNUC_UNUSED,
{
IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself);
- if (connection == NULL)
- g_error ("Unable to get bus connection to own name '%s'", name);
-
g_debug ("%s %s name lost %s", G_STRLOC, G_STRFUNC, name);
unexport (self);
- g_signal_emit (self, signals[SIGNAL_NAME_LOST], 0, NULL);
+ //g_signal_emit (self, signals[SIGNAL_NAME_LOST], 0, NULL);
}