diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-10-09 22:55:26 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-10-09 22:55:26 -0500 |
commit | dae4fdd39e5381083345e87759dbaffddabe14e4 (patch) | |
tree | c68345f54911053be886be9fe3231385bd37599d | |
parent | a52e3b86ee0dbce56221d1327c6c62a6d8e163e3 (diff) | |
download | ayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.tar.gz ayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.tar.bz2 ayatana-indicator-datetime-dae4fdd39e5381083345e87759dbaffddabe14e4.zip |
more wiring in of mock objects
-rw-r--r-- | src/main.c | 38 | ||||
-rw-r--r-- | src/service.c | 7 |
2 files changed, 32 insertions, 13 deletions
@@ -21,6 +21,7 @@ #include <locale.h> #include <stdlib.h> /* exit() */ +#include <stdio.h> #include <glib/gi18n.h> #include <gio/gio.h> @@ -30,6 +31,8 @@ #include "planner-mock.h" #include "service.h" +#define TEST_MODE + /*** **** ***/ @@ -41,6 +44,18 @@ on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop) 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) +{ + fprintf (fp, "%s %d %s\n", log_domain, (int)log_level, message); + fflush (fp); +} +#endif + int main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) { @@ -57,17 +72,15 @@ main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED) if (!notify_init ("indicator-datetime-service")) g_critical ("libnotify initialization failed"); - - /* get the planner */ - if (g_getenv ("INDICATOR_DATETIME_USE_FAKE_PLANNER") != NULL) - { - g_message ("Using fake appointment book for testing"); - planner = indicator_datetime_planner_mock_new (); - } - else - { - planner = indicator_datetime_planner_eds_new (); - } + /* 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); + planner = indicator_datetime_planner_mock_new (); +#else + planner = indicator_datetime_planner_eds_new (); +#endif /* run */ service = indicator_datetime_service_new (planner); @@ -80,5 +93,8 @@ 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 c76b07e..61d50aa 100644 --- a/src/service.c +++ b/src/service.c @@ -472,6 +472,7 @@ on_alarm_timer (gpointer gself) { gchar * title; const gchar * body; + const gchar * icon_name; const struct IndicatorDatetimeAppt * appt = l->data; NotifyNotification * nn; GError * error; @@ -484,8 +485,10 @@ on_alarm_timer (gpointer gself) title = g_date_time_format (now, get_terse_time_format_string (now)); body = appt->summary; - nn = notify_notification_new (title, body, ALARM_ICON_NAME); - + icon_name = ALARM_ICON_NAME; + 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", |