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 */
19
20/* TODO Implement multiple request by using the inhib_cookie in a array
21        and to remove the cookie when the application request it
22*/
23
24namespace Lxsession
25{
26    public class ControlObject: GLib.Object
27    {
28        public void set_status_busy (uint toplevel_xid)
29        /* Status : Busy doing something, disable idle behavior of application */
30        {
31            inhib_screensaver (toplevel_xid);
32        }
33
34        public void exit_status_busy ()
35        {
36            uninhibit_screensaver ();
37        }
38
39        public void inhib_screensaver (uint toplevel_xid)
40        {
41            string create_command = "xdg-screensaver suspend" + " " + toplevel_xid.to_string();
42            lxsession_spawn_command_line_async(create_command);
43            message("Inhib Screensaver");
44        }
45
46        public void uninhibit_screensaver ()
47        {
48            lxsession_spawn_command_line_async("xdg-screensaver reset");
49            message("Disable Inhib Screensaver");
50        }
51    }
52}
53