~ps-jenkins/indicator-datetime/latestsnapshot-13.10.0+13.10.20131023.2-0ubuntu1

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Tarmac
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2013-10-22 22:35:31 UTC
  • mfrom: (278.1.1 indicator-datetime)
  • Revision ID: tarmac-20131022223531-rn7zr7smbnlki2ak
Revert revision 277 which appears to be more feature than bugfix applicable for SRU.

Approved by PS Jenkins bot, Ted Gould.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include <glib/gi18n.h>
26
26
#include <gio/gio.h>
27
 
#include <libnotify/notify.h> 
28
27
 
29
 
#include "planner-eds.h"
30
 
#include "planner-mock.h"
31
28
#include "service.h"
32
29
 
33
30
/***
34
31
****
35
32
***/
36
33
 
37
 
/* When enabled, new alarms will show up every minute to test snap decisions */
38
 
static gboolean test_alarms = FALSE;
39
 
 
40
 
static GOptionEntry entries[] = {
41
 
  { "test-alarms", '\0', 0, G_OPTION_ARG_NONE, &test_alarms, "Test Alarms", NULL },
42
 
  { NULL }
43
 
};
44
 
 
45
34
static void
46
35
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
47
36
{
48
37
  g_message ("exiting: service couldn't acquire or lost ownership of busname");
49
 
 
50
 
  if (!test_alarms)
51
 
    g_main_loop_quit ((GMainLoop*)loop);
 
38
  g_main_loop_quit ((GMainLoop*)loop);
52
39
}
53
40
 
54
41
int
55
42
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
56
43
{
57
 
  GOptionContext * context;
58
 
  GError * error;
59
 
  IndicatorDatetimePlanner * planner;
 
44
  GMainLoop * loop;
60
45
  IndicatorDatetimeService * service;
61
 
  GMainLoop * loop;
62
46
 
63
47
  /* Work around a deadlock in glib's type initialization. It can be
64
48
   * removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is
71
55
  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
72
56
  textdomain (GETTEXT_PACKAGE);
73
57
 
74
 
  /* init libnotify */
75
 
  if (!notify_init ("indicator-datetime-service"))
76
 
    g_critical ("libnotify initialization failed");
77
 
 
78
 
  /* parse command-line options */
79
 
  context = g_option_context_new (NULL);
80
 
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
81
 
  if (!g_option_context_parse (context, &argc, &argv, &error))
82
 
    {
83
 
      g_print("option parsing failed: %s\n", error->message);
84
 
      return EXIT_FAILURE;
85
 
    }
86
 
 
87
 
  /* set up the planner */
88
 
  if (test_alarms)
89
 
    {
90
 
      g_message ("Using fake appointment book for testing alarms.");
91
 
      planner = indicator_datetime_planner_mock_new ();
92
 
    }
93
 
  else
94
 
    {
95
 
      planner = indicator_datetime_planner_eds_new ();
96
 
    }
97
 
 
98
58
  /* run */
99
 
  service = indicator_datetime_service_new (planner);
 
59
  service = indicator_datetime_service_new ();
100
60
  loop = g_main_loop_new (NULL, FALSE);
101
61
  g_signal_connect (service, INDICATOR_DATETIME_SERVICE_SIGNAL_NAME_LOST,
102
62
                    G_CALLBACK(on_name_lost), loop);
103
63
  g_main_loop_run (loop);
104
64
 
105
65
  /* cleanup */
 
66
  g_clear_object (&service);
106
67
  g_main_loop_unref (loop);
107
 
  g_object_unref (service);
108
 
  g_object_unref (planner);
109
68
  return 0;
110
69
}