~codygarver/+junk/ind-sess

« back to all changes in this revision

Viewing changes to src/main.c

  • Committer: Cody Garver
  • Date: 2014-04-03 17:08:08 UTC
  • Revision ID: cody@elementaryos.org-20140403170808-z56s93rorb1dzvmk
Initial import, version 12.10.5+14.04.20140324-0ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * Authors:
 
5
 *   Charles Kerr <charles.kerr@canonical.com>
 
6
 *
 
7
 * This program is free software: you can redistribute it and/or modify it
 
8
 * under the terms of the GNU General Public License version 3, as published
 
9
 * by the Free Software Foundation.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful, but
 
12
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
13
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
14
 * PURPOSE.  See the GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License along
 
17
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <locale.h>
 
21
#include <stdlib.h> /* exit() */
 
22
 
 
23
#include <glib/gi18n.h>
 
24
#include <gio/gio.h>
 
25
 
 
26
#include "service.h"
 
27
 
 
28
/***
 
29
****
 
30
***/
 
31
 
 
32
static void
 
33
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
 
34
{
 
35
  g_warning ("exiting: service couldn't acquire, or lost ownership of, busname");
 
36
 
 
37
  g_main_loop_quit (loop);
 
38
}
 
39
 
 
40
int
 
41
main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
 
42
{
 
43
  GMainLoop * loop;
 
44
  IndicatorSessionService * service;
 
45
 
 
46
  /* Work around a deadlock in glib's type initialization. It can be
 
47
   * removed when https://bugzilla.gnome.org/show_bug.cgi?id=674885 is
 
48
   * fixed.
 
49
   */
 
50
  g_type_ensure (G_TYPE_DBUS_CONNECTION);
 
51
 
 
52
  /* boilerplate i18n */
 
53
  setlocale (LC_ALL, "");
 
54
  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
 
55
  textdomain (GETTEXT_PACKAGE);
 
56
 
 
57
  /* run */
 
58
  service = indicator_session_service_new ();
 
59
  loop = g_main_loop_new (NULL, FALSE);
 
60
  g_signal_connect (service, INDICATOR_SESSION_SERVICE_SIGNAL_NAME_LOST,
 
61
                    G_CALLBACK(on_name_lost), loop);
 
62
  g_main_loop_run (loop);
 
63
 
 
64
  /* cleanup */
 
65
  g_clear_object (&service);
 
66
  g_main_loop_unref (loop);
 
67
  return 0;
 
68
}