From dae4fdd39e5381083345e87759dbaffddabe14e4 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 9 Oct 2013 22:55:26 -0500 Subject: more wiring in of mock objects --- src/main.c | 38 +++++++++++++++++++++++++++----------- src/service.c | 7 +++++-- 2 files changed, 32 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 34e9b98..45ee180 100644 --- a/src/main.c +++ b/src/main.c @@ -21,6 +21,7 @@ #include #include /* exit() */ +#include #include #include @@ -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", -- cgit v1.2.3