~ubuntu-branches/ubuntu/saucy/indicator-session/saucy-proposed

« back to all changes in this revision

Viewing changes to src/session-service.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Charles Kerr, Lars Uebernickel, Łukasz 'sil2100' Zemczak, Ubuntu daily release
  • Date: 2013-07-16 02:02:05 UTC
  • mfrom: (1.1.64)
  • Revision ID: package-import@ubuntu.com-20130716020205-84ig434y92hxi2g8
Tags: 12.10.5+13.10.20130716-0ubuntu1
[ Charles Kerr ]
* This is the GMenu, login1 version of indicator-session. This
  resubmission removes the prerequisite branch because the entire diff
  is contained in this ng-login1 branch.

[ Lars Uebernickel ]
* This is the GMenu, login1 version of indicator-session. This
  resubmission removes the prerequisite branch because the entire diff
  is contained in this ng-login1 branch.

[ Łukasz 'sil2100' Zemczak ]
* Add the python build-dep, as gdbus-codegen needs it to work
  properly.

[ Ubuntu daily release ]
* Automatic snapshot from revision 400

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
A small wrapper utility to load indicators and put them as menu items
3
 
into the gnome-panel using it's applet interface.
4
 
 
5
 
Copyright 2009 Canonical Ltd.
6
 
 
7
 
Authors:
8
 
    Ted Gould <ted@canonical.com>
9
 
    Christoph Korn <c_korn@gmx.de>
10
 
    Cody Russell <crussell@canonical.com>
11
 
    Conor Curran <conor.curran@canonical.com>
12
 
    Charles Kerr <charles.kerr@canonical.com>
13
 
 
14
 
This program is free software: you can redistribute it and/or modify it
15
 
under the terms of the GNU General Public License version 3, as published
16
 
by the Free Software Foundation.
17
 
 
18
 
This program is distributed in the hope that it will be useful, but
19
 
WITHOUT ANY WARRANTY; without even the implied warranties of
20
 
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
21
 
PURPOSE.  See the GNU General Public License for more details.
22
 
 
23
 
You should have received a copy of the GNU General Public License along
24
 
with this program.  If not, see <http://www.gnu.org/licenses/>.
25
 
*/
26
 
 
27
 
#include "config.h"
28
 
 
29
 
#include <unistd.h>
30
 
#include <locale.h>
31
 
 
32
 
#include <glib/gi18n.h>
33
 
#include <gio/gio.h>
34
 
#include <gio/gdesktopappinfo.h>
35
 
 
36
 
#include <libdbusmenu-glib/server.h>
37
 
 
38
 
#include <gtk/gtk.h>
39
 
 
40
 
#include <libindicator/indicator-service.h>
41
 
 
42
 
#include "session-dbus.h"
43
 
#include "session-menu-mgr.h"
44
 
#include "shared-names.h"
45
 
#include "users-service-dbus.h"
46
 
 
47
 
static SessionDbus * session_dbus = NULL;
48
 
static GMainLoop * mainloop = NULL;
49
 
 
50
 
 
51
 
/* When the service interface starts to shutdown,
52
 
   we should follow it. */
53
 
void
54
 
service_shutdown (IndicatorService * service, gpointer user_data)
55
 
{
56
 
  if (mainloop != NULL)
57
 
    {
58
 
      g_debug ("Service shutdown");
59
 
      g_main_loop_quit (mainloop);
60
 
    }
61
 
}
62
 
 
63
 
static inline gboolean
64
 
is_greeter_mode (void)
65
 
{
66
 
  return !g_strcmp0 (g_getenv ("INDICATOR_GREETER_MODE"), "1");
67
 
}
68
 
 
69
 
/* Main, is well, main.  It brings everything up and throws
70
 
   us into the mainloop of no return. */
71
 
int
72
 
main (int argc, char ** argv)
73
 
{
74
 
  /* Setting up i18n and gettext.
75
 
     Apparently we need all of these. */
76
 
  setlocale (LC_ALL, "");
77
 
  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
78
 
  textdomain (GETTEXT_PACKAGE);
79
 
 
80
 
  IndicatorService * service = indicator_service_new_version (INDICATOR_SESSION_DBUS_NAME,
81
 
                                                              INDICATOR_SESSION_DBUS_VERSION);
82
 
  g_signal_connect (G_OBJECT(service), INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
83
 
                    G_CALLBACK(service_shutdown), NULL);
84
 
 
85
 
  session_dbus = session_dbus_new();
86
 
 
87
 
  SessionMenuMgr * menu_mgr = session_menu_mgr_new (session_dbus, is_greeter_mode());
88
 
  DbusmenuServer* server = dbusmenu_server_new (INDICATOR_SESSION_DBUS_OBJECT);
89
 
  dbusmenu_server_set_root (server, session_menu_mgr_get_menu (menu_mgr));
90
 
 
91
 
  mainloop = g_main_loop_new(NULL, FALSE);
92
 
  g_main_loop_run(mainloop);
93
 
 
94
 
  return 0;
95
 
}
96