1/*
2 *      Copyright 2012 Julien Lavergne <gilir@ubuntu.com>
3 *
4 *      This program is free software; you can redistribute it and/or modify
5 *      it under the terms of the GNU General Public License as published by
6 *      the Free Software Foundation; either version 2 of the License, or
7 *      (at your option) any later version.
8 *
9 *      This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *      You should have received a copy of the GNU General Public License
15 *      along with this program; if not, write to the Free Software
16 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 *      MA 02110-1301, USA.
18 */
19using Gtk;
20#if USE_GTK2
21using Unique;
22#endif
23
24namespace Lxsession
25{
26    public class Main: GLib.Object
27    {
28        public static int main(string[] args)
29        {
30            Gtk.init (ref args);
31#if USE_GTK2
32            Unique.App app = new Unique.App("org.lxde.lxclipboard", null);
33
34            if(app.is_running)
35            {
36                message("lxclipboard is already running. Existing");
37                return 0;
38            }
39#endif
40# if USE_GTK3
41            Gtk.Application app = new Gtk.Application (
42                "org.lxde.lxclipboard",
43                GLib.ApplicationFlags.FLAGS_NONE);
44            app.register ();
45
46            if(app.is_remote)
47            {
48                message("lxclipboard is already running. Existing");
49                return 0;
50            }
51#endif
52
53            clipboard_start ();
54
55            /* start main loop */
56            new MainLoop().run();
57
58            /* Stop clipboard */
59            clipboard_stop ();
60
61            return 0;
62        }
63    }
64}
65