/* control.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from control.vala, do not modify */

/* 
 *      Copyright 2012 Julien Lavergne <gilir@ubuntu.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */
/* TODO Implement multiple request by using the inhib_cookie in a array
        and to remove the cookie when the application request it
*/

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define LXSESSION_TYPE_CONTROL_OBJECT (lxsession_control_object_get_type ())
#define LXSESSION_CONTROL_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LXSESSION_TYPE_CONTROL_OBJECT, LxsessionControlObject))
#define LXSESSION_CONTROL_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LXSESSION_TYPE_CONTROL_OBJECT, LxsessionControlObjectClass))
#define LXSESSION_IS_CONTROL_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LXSESSION_TYPE_CONTROL_OBJECT))
#define LXSESSION_IS_CONTROL_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LXSESSION_TYPE_CONTROL_OBJECT))
#define LXSESSION_CONTROL_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LXSESSION_TYPE_CONTROL_OBJECT, LxsessionControlObjectClass))

typedef struct _LxsessionControlObject LxsessionControlObject;
typedef struct _LxsessionControlObjectClass LxsessionControlObjectClass;
typedef struct _LxsessionControlObjectPrivate LxsessionControlObjectPrivate;
enum  {
	LXSESSION_CONTROL_OBJECT_0_PROPERTY,
	LXSESSION_CONTROL_OBJECT_NUM_PROPERTIES
};
static GParamSpec* lxsession_control_object_properties[LXSESSION_CONTROL_OBJECT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _LxsessionControlObject {
	GObject parent_instance;
	LxsessionControlObjectPrivate * priv;
};

struct _LxsessionControlObjectClass {
	GObjectClass parent_class;
};

static gpointer lxsession_control_object_parent_class = NULL;

VALA_EXTERN GType lxsession_control_object_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (LxsessionControlObject, g_object_unref)
VALA_EXTERN void lxsession_control_object_set_status_busy (LxsessionControlObject* self,
                                               guint toplevel_xid);
VALA_EXTERN void lxsession_control_object_inhib_screensaver (LxsessionControlObject* self,
                                                 guint toplevel_xid);
VALA_EXTERN void lxsession_control_object_exit_status_busy (LxsessionControlObject* self);
VALA_EXTERN void lxsession_control_object_uninhibit_screensaver (LxsessionControlObject* self);
VALA_EXTERN void lxsession_lxsession_spawn_command_line_async (const gchar* command_line);
VALA_EXTERN LxsessionControlObject* lxsession_control_object_new (void);
VALA_EXTERN LxsessionControlObject* lxsession_control_object_construct (GType object_type);
static GType lxsession_control_object_get_type_once (void);

void
lxsession_control_object_set_status_busy (LxsessionControlObject* self,
                                          guint toplevel_xid)
{
	g_return_if_fail (self != NULL);
	lxsession_control_object_inhib_screensaver (self, toplevel_xid);
}

void
lxsession_control_object_exit_status_busy (LxsessionControlObject* self)
{
	g_return_if_fail (self != NULL);
	lxsession_control_object_uninhibit_screensaver (self);
}

void
lxsession_control_object_inhib_screensaver (LxsessionControlObject* self,
                                            guint toplevel_xid)
{
	gchar* create_command = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup_printf ("%u", toplevel_xid);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat ("xdg-screensaver suspend" " ", _tmp1_, NULL);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	create_command = _tmp3_;
	lxsession_lxsession_spawn_command_line_async (create_command);
	g_message ("control.vala:43: Inhib Screensaver");
	_g_free0 (create_command);
}

void
lxsession_control_object_uninhibit_screensaver (LxsessionControlObject* self)
{
	g_return_if_fail (self != NULL);
	lxsession_lxsession_spawn_command_line_async ("xdg-screensaver reset");
	g_message ("control.vala:49: Disable Inhib Screensaver");
}

LxsessionControlObject*
lxsession_control_object_construct (GType object_type)
{
	LxsessionControlObject * self = NULL;
	self = (LxsessionControlObject*) g_object_new (object_type, NULL);
	return self;
}

LxsessionControlObject*
lxsession_control_object_new (void)
{
	return lxsession_control_object_construct (LXSESSION_TYPE_CONTROL_OBJECT);
}

static void
lxsession_control_object_class_init (LxsessionControlObjectClass * klass,
                                     gpointer klass_data)
{
	lxsession_control_object_parent_class = g_type_class_peek_parent (klass);
}

static void
lxsession_control_object_instance_init (LxsessionControlObject * self,
                                        gpointer klass)
{
}

static GType
lxsession_control_object_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (LxsessionControlObjectClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) lxsession_control_object_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (LxsessionControlObject), 0, (GInstanceInitFunc) lxsession_control_object_instance_init, NULL };
	GType lxsession_control_object_type_id;
	lxsession_control_object_type_id = g_type_register_static (G_TYPE_OBJECT, "LxsessionControlObject", &g_define_type_info, 0);
	return lxsession_control_object_type_id;
}

GType
lxsession_control_object_get_type (void)
{
	static volatile gsize lxsession_control_object_type_id__once = 0;
	if (g_once_init_enter (&lxsession_control_object_type_id__once)) {
		GType lxsession_control_object_type_id;
		lxsession_control_object_type_id = lxsession_control_object_get_type_once ();
		g_once_init_leave (&lxsession_control_object_type_id__once, lxsession_control_object_type_id);
	}
	return lxsession_control_object_type_id__once;
}

