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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop Developers
 *
 * 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.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.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 BUDGIE_TYPE_POWER_APPLICATION (budgie_power_application_get_type ())
#define BUDGIE_POWER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_POWER_APPLICATION, BudgiePowerApplication))
#define BUDGIE_POWER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_POWER_APPLICATION, BudgiePowerApplicationClass))
#define BUDGIE_IS_POWER_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_POWER_APPLICATION))
#define BUDGIE_IS_POWER_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_POWER_APPLICATION))
#define BUDGIE_POWER_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_POWER_APPLICATION, BudgiePowerApplicationClass))

typedef struct _BudgiePowerApplication BudgiePowerApplication;
typedef struct _BudgiePowerApplicationClass BudgiePowerApplicationClass;
typedef struct _BudgiePowerApplicationPrivate BudgiePowerApplicationPrivate;

#define BUDGIE_TYPE_POWER_DIALOG (budgie_power_dialog_get_type ())
#define BUDGIE_POWER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_POWER_DIALOG, BudgiePowerDialog))
#define BUDGIE_POWER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_POWER_DIALOG, BudgiePowerDialogClass))
#define BUDGIE_IS_POWER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_POWER_DIALOG))
#define BUDGIE_IS_POWER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_POWER_DIALOG))
#define BUDGIE_POWER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_POWER_DIALOG, BudgiePowerDialogClass))

typedef struct _BudgiePowerDialog BudgiePowerDialog;
typedef struct _BudgiePowerDialogClass BudgiePowerDialogClass;

#define BUDGIE_TYPE_POWER_WINDOW (budgie_power_window_get_type ())
#define BUDGIE_POWER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_POWER_WINDOW, BudgiePowerWindow))
#define BUDGIE_POWER_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_POWER_WINDOW, BudgiePowerWindowClass))
#define BUDGIE_IS_POWER_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_POWER_WINDOW))
#define BUDGIE_IS_POWER_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_POWER_WINDOW))
#define BUDGIE_POWER_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_POWER_WINDOW, BudgiePowerWindowClass))

typedef struct _BudgiePowerWindow BudgiePowerWindow;
typedef struct _BudgiePowerWindowClass BudgiePowerWindowClass;

#define BUDGIE_TYPE_SHELL_SHIM (budgie_shell_shim_get_type ())
#define BUDGIE_SHELL_SHIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BUDGIE_TYPE_SHELL_SHIM, BudgieShellShim))
#define BUDGIE_SHELL_SHIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BUDGIE_TYPE_SHELL_SHIM, BudgieShellShimClass))
#define BUDGIE_IS_SHELL_SHIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BUDGIE_TYPE_SHELL_SHIM))
#define BUDGIE_IS_SHELL_SHIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BUDGIE_TYPE_SHELL_SHIM))
#define BUDGIE_SHELL_SHIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BUDGIE_TYPE_SHELL_SHIM, BudgieShellShimClass))

typedef struct _BudgieShellShim BudgieShellShim;
typedef struct _BudgieShellShimClass BudgieShellShimClass;
enum  {
	BUDGIE_POWER_APPLICATION_0_PROPERTY,
	BUDGIE_POWER_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* budgie_power_application_properties[BUDGIE_POWER_APPLICATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BudgiePowerApplication {
	GtkApplication parent_instance;
	BudgiePowerApplicationPrivate * priv;
};

struct _BudgiePowerApplicationClass {
	GtkApplicationClass parent_class;
};

struct _BudgiePowerApplicationPrivate {
	BudgiePowerDialog* power_dbus;
	BudgiePowerWindow* window;
	gboolean grabbed;
	BudgieShellShim* shim;
};

static gint BudgiePowerApplication_private_offset;
static gpointer budgie_power_application_parent_class = NULL;

VALA_EXTERN GType budgie_power_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BudgiePowerApplication, g_object_unref)
VALA_EXTERN GType budgie_power_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BudgiePowerDialog, g_object_unref)
VALA_EXTERN guint budgie_power_dialog_register_object (void* object,
                                           GDBusConnection* connection,
                                           const gchar* path,
                                           GError** error);
VALA_EXTERN GType budgie_power_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BudgiePowerWindow, g_object_unref)
VALA_EXTERN GType budgie_shell_shim_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BudgieShellShim, g_object_unref)
VALA_EXTERN guint budgie_shell_shim_register_object (void* object,
                                         GDBusConnection* connection,
                                         const gchar* path,
                                         GError** error);
VALA_EXTERN BudgiePowerApplication* budgie_power_application_new (void);
VALA_EXTERN BudgiePowerApplication* budgie_power_application_construct (GType object_type);
VALA_EXTERN BudgieShellShim* budgie_shell_shim_new (void);
VALA_EXTERN BudgieShellShim* budgie_shell_shim_construct (GType object_type);
VALA_EXTERN void budgie_shell_shim_serve (BudgieShellShim* self);
static void budgie_power_application_real_activate (GApplication* base);
VALA_EXTERN BudgiePowerWindow* budgie_power_window_new (GtkApplication* app);
VALA_EXTERN BudgiePowerWindow* budgie_power_window_construct (GType object_type,
                                                  GtkApplication* app);
static void budgie_power_application_on_hide (BudgiePowerApplication* self);
static void _budgie_power_application_on_hide_gtk_widget_hide (GtkWidget* _sender,
                                                        gpointer self);
static void budgie_power_application_on_dbus_acquired (BudgiePowerApplication* self,
                                                GDBusConnection* conn);
static void _budgie_power_application_on_dbus_acquired_gbus_acquired_callback (GDBusConnection* connection,
                                                                        const gchar* name,
                                                                        gpointer self);
VALA_EXTERN BudgiePowerDialog* budgie_power_dialog_new (void);
VALA_EXTERN BudgiePowerDialog* budgie_power_dialog_construct (GType object_type);
static void budgie_power_application_on_toggle (BudgiePowerApplication* self,
                                         gboolean show);
static void _budgie_power_application_on_toggle_budgie_power_dialog_toggle (BudgiePowerDialog* _sender,
                                                                     gboolean show,
                                                                     gpointer self);
VALA_EXTERN void budgie_power_dialog_set_is_showing (BudgiePowerDialog* self,
                                         gboolean value);
static void budgie_power_application_ungrab_seat (BudgiePowerApplication* self);
VALA_EXTERN void budgie_power_window_reset_focus (BudgiePowerWindow* self);
static gboolean budgie_power_application_on_mapped_grab (BudgiePowerApplication* self,
                                                  GdkEventAny* event);
static gboolean _budgie_power_application_on_mapped_grab_gtk_widget_map_event (GtkWidget* _sender,
                                                                        GdkEventAny* event,
                                                                        gpointer self);
static gboolean ___lambda22_ (BudgiePowerApplication* self);
static void budgie_power_application_grab_seat (BudgiePowerApplication* self);
static gboolean ____lambda22__gsource_func (gpointer self);
static void budgie_power_application_finalize (GObject * obj);
static GType budgie_power_application_get_type_once (void);

static inline gpointer
budgie_power_application_get_instance_private (BudgiePowerApplication* self)
{
	return G_STRUCT_MEMBER_P (self, BudgiePowerApplication_private_offset);
}

BudgiePowerApplication*
budgie_power_application_construct (GType object_type)
{
	BudgiePowerApplication * self = NULL;
	BudgieShellShim* _tmp0_;
	BudgieShellShim* _tmp1_;
	self = (BudgiePowerApplication*) g_object_new (object_type, "application-id", "org.buddiesofbudgie.PowerDialog", "flags", 0, NULL);
	_tmp0_ = budgie_shell_shim_new ();
	_g_object_unref0 (self->priv->shim);
	self->priv->shim = _tmp0_;
	_tmp1_ = self->priv->shim;
	budgie_shell_shim_serve (_tmp1_);
	return self;
}

BudgiePowerApplication*
budgie_power_application_new (void)
{
	return budgie_power_application_construct (BUDGIE_TYPE_POWER_APPLICATION);
}

static void
_budgie_power_application_on_hide_gtk_widget_hide (GtkWidget* _sender,
                                                   gpointer self)
{
	budgie_power_application_on_hide ((BudgiePowerApplication*) self);
}

static void
_budgie_power_application_on_dbus_acquired_gbus_acquired_callback (GDBusConnection* connection,
                                                                   const gchar* name,
                                                                   gpointer self)
{
	budgie_power_application_on_dbus_acquired ((BudgiePowerApplication*) self, connection);
}

static void
budgie_power_application_real_activate (GApplication* base)
{
	BudgiePowerApplication * self;
	BudgiePowerWindow* _tmp0_;
	BudgiePowerDialog* _tmp3_;
	self = (BudgiePowerApplication*) base;
	_tmp0_ = self->priv->window;
	if (_tmp0_ == NULL) {
		BudgiePowerWindow* _tmp1_;
		BudgiePowerWindow* _tmp2_;
		_tmp1_ = budgie_power_window_new ((GtkApplication*) self);
		g_object_ref_sink (_tmp1_);
		_g_object_unref0 (self->priv->window);
		self->priv->window = _tmp1_;
		_tmp2_ = self->priv->window;
		g_signal_connect_object ((GtkWidget*) _tmp2_, "hide", (GCallback) _budgie_power_application_on_hide_gtk_widget_hide, self, 0);
	}
	_tmp3_ = self->priv->power_dbus;
	if (_tmp3_ == NULL) {
		g_bus_own_name_with_closures (G_BUS_TYPE_SESSION, "org.buddiesofbudgie.PowerDialog", G_BUS_NAME_OWNER_FLAGS_NONE, (GClosure*) ((_budgie_power_application_on_dbus_acquired_gbus_acquired_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _budgie_power_application_on_dbus_acquired_gbus_acquired_callback, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	}
}

static void
_budgie_power_application_on_toggle_budgie_power_dialog_toggle (BudgiePowerDialog* _sender,
                                                                gboolean show,
                                                                gpointer self)
{
	budgie_power_application_on_toggle ((BudgiePowerApplication*) self, show);
}

static void
budgie_power_application_on_dbus_acquired (BudgiePowerApplication* self,
                                           GDBusConnection* conn)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conn != NULL);
	{
		BudgiePowerDialog* _tmp0_;
		BudgiePowerDialog* _tmp1_;
		BudgiePowerDialog* _tmp2_;
		_tmp0_ = budgie_power_dialog_new ();
		_g_object_unref0 (self->priv->power_dbus);
		self->priv->power_dbus = _tmp0_;
		_tmp1_ = self->priv->power_dbus;
		budgie_power_dialog_register_object (_tmp1_, conn, "/org/buddiesofbudgie/PowerDialog", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = self->priv->power_dbus;
		g_signal_connect_object (_tmp2_, "toggle", (GCallback) _budgie_power_application_on_toggle_budgie_power_dialog_toggle, self, 0);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("application.vala:59: Unable to register PowerDialog DBus: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
budgie_power_application_on_hide (BudgiePowerApplication* self)
{
	BudgiePowerDialog* _tmp0_;
	BudgiePowerDialog* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->power_dbus;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->power_dbus;
	budgie_power_dialog_set_is_showing (_tmp1_, FALSE);
}

static gboolean
_budgie_power_application_on_mapped_grab_gtk_widget_map_event (GtkWidget* _sender,
                                                               GdkEventAny* event,
                                                               gpointer self)
{
	gboolean result;
	result = budgie_power_application_on_mapped_grab ((BudgiePowerApplication*) self, event);
	return result;
}

static gboolean
___lambda22_ (BudgiePowerApplication* self)
{
	gboolean result;
	budgie_power_application_grab_seat (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
____lambda22__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda22_ ((BudgiePowerApplication*) self);
	return result;
}

static void
budgie_power_application_on_toggle (BudgiePowerApplication* self,
                                    gboolean show)
{
	BudgiePowerWindow* _tmp0_;
	BudgiePowerWindow* _tmp2_;
	BudgiePowerWindow* _tmp3_;
	BudgiePowerWindow* _tmp4_;
	GSettings* wm_settings = NULL;
	GSettings* _tmp5_;
	gchar* focus_mode = NULL;
	GSettings* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	if (_tmp0_ == NULL) {
		g_critical ("application.vala:71: Tried to toggle visibility of PowerDialog, but th" \
"e window hasn't been initialized");
		return;
	}
	if (!show) {
		BudgiePowerWindow* _tmp1_;
		budgie_power_application_ungrab_seat (self);
		_tmp1_ = self->priv->window;
		gtk_widget_hide ((GtkWidget*) _tmp1_);
		return;
	}
	_tmp2_ = self->priv->window;
	gtk_window_present_with_time ((GtkWindow*) _tmp2_, (guint32) GDK_CURRENT_TIME);
	_tmp3_ = self->priv->window;
	gtk_widget_show_all ((GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->window;
	budgie_power_window_reset_focus (_tmp4_);
	_tmp5_ = g_settings_new ("com.solus-project.budgie-wm");
	wm_settings = _tmp5_;
	_tmp6_ = wm_settings;
	_tmp7_ = g_settings_get_string (_tmp6_, "window-focus-mode");
	focus_mode = _tmp7_;
	_tmp8_ = focus_mode;
	if (g_strcmp0 (_tmp8_, "mouse") == 0) {
		BudgiePowerWindow* _tmp9_;
		_tmp9_ = self->priv->window;
		g_signal_connect_object ((GtkWidget*) _tmp9_, "map-event", (GCallback) _budgie_power_application_on_mapped_grab_gtk_widget_map_event, self, 0);
	} else {
		g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 250, ____lambda22__gsource_func, g_object_ref (self), g_object_unref);
	}
	_g_free0 (focus_mode);
	_g_object_unref0 (wm_settings);
}

/**
 * Grabs the seat as soon as the window surface is mapped and visible,
 * then disconnects itself so it only fires once per show.
 */
static gboolean
budgie_power_application_on_mapped_grab (BudgiePowerApplication* self,
                                         GdkEventAny* event)
{
	BudgiePowerWindow* _tmp0_;
	guint _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = self->priv->window;
	g_signal_parse_name ("map-event", gtk_widget_get_type (), &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched ((GtkWidget*) _tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _budgie_power_application_on_mapped_grab_gtk_widget_map_event, self);
	budgie_power_application_grab_seat (self);
	result = FALSE;
	return result;
}

/**
 * Attempts to grab device input and send it to our dialog window.
 */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
budgie_power_application_grab_seat (BudgiePowerApplication* self)
{
	BudgiePowerWindow* _tmp0_;
	GdkDisplay* display = NULL;
	BudgiePowerWindow* _tmp1_;
	GdkDisplay* _tmp2_;
	GdkDisplay* _tmp3_;
	GdkSeat* seat = NULL;
	GdkDisplay* _tmp4_;
	GdkSeat* _tmp5_;
	GdkSeat* _tmp6_;
	GdkGrabStatus status = 0;
	GdkSeat* _tmp7_;
	BudgiePowerWindow* _tmp8_;
	GdkWindow* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->window;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->window;
	_tmp2_ = gtk_widget_get_display ((GtkWidget*) _tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	display = _tmp3_;
	_tmp4_ = display;
	_tmp5_ = gdk_display_get_default_seat (_tmp4_);
	_tmp6_ = _g_object_ref0 (_tmp5_);
	seat = _tmp6_;
	_tmp7_ = seat;
	_tmp8_ = self->priv->window;
	_tmp9_ = gtk_widget_get_window ((GtkWidget*) _tmp8_);
	status = gdk_seat_grab (_tmp7_, _tmp9_, GDK_SEAT_CAPABILITY_ALL, TRUE, NULL, NULL, NULL, NULL);
	if (status != GDK_GRAB_SUCCESS) {
		GEnumValue* _tmp10_;
		_tmp10_ = g_enum_get_value (g_type_class_ref (gdk_grab_status_get_type ()), status);
		g_warning ("application.vala:124: Tried to grab seat, but failed: %s", (_tmp10_ != NULL) ? _tmp10_->value_name : NULL);
	}
	self->priv->grabbed = TRUE;
	_g_object_unref0 (seat);
	_g_object_unref0 (display);
}

/**
 * Releases a seat grab. If the seat hasn't been grabbed, this function
 * does nothing.
 */
static void
budgie_power_application_ungrab_seat (BudgiePowerApplication* self)
{
	gboolean _tmp0_ = FALSE;
	GdkDisplay* display = NULL;
	BudgiePowerWindow* _tmp2_;
	GdkDisplay* _tmp3_;
	GdkDisplay* _tmp4_;
	GdkSeat* seat = NULL;
	GdkDisplay* _tmp5_;
	GdkSeat* _tmp6_;
	GdkSeat* _tmp7_;
	GdkSeat* _tmp8_;
	g_return_if_fail (self != NULL);
	if (!self->priv->grabbed) {
		_tmp0_ = TRUE;
	} else {
		BudgiePowerWindow* _tmp1_;
		_tmp1_ = self->priv->window;
		_tmp0_ = _tmp1_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = self->priv->window;
	_tmp3_ = gtk_widget_get_display ((GtkWidget*) _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	display = _tmp4_;
	_tmp5_ = display;
	_tmp6_ = gdk_display_get_default_seat (_tmp5_);
	_tmp7_ = _g_object_ref0 (_tmp6_);
	seat = _tmp7_;
	_tmp8_ = seat;
	gdk_seat_ungrab (_tmp8_);
	self->priv->grabbed = FALSE;
	_g_object_unref0 (seat);
	_g_object_unref0 (display);
}

static void
budgie_power_application_class_init (BudgiePowerApplicationClass * klass,
                                     gpointer klass_data)
{
	budgie_power_application_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BudgiePowerApplication_private_offset);
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) budgie_power_application_real_activate;
	G_OBJECT_CLASS (klass)->finalize = budgie_power_application_finalize;
}

static void
budgie_power_application_instance_init (BudgiePowerApplication * self,
                                        gpointer klass)
{
	self->priv = budgie_power_application_get_instance_private (self);
	self->priv->power_dbus = NULL;
	self->priv->window = NULL;
	self->priv->grabbed = FALSE;
}

static void
budgie_power_application_finalize (GObject * obj)
{
	BudgiePowerApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BUDGIE_TYPE_POWER_APPLICATION, BudgiePowerApplication);
	_g_object_unref0 (self->priv->power_dbus);
	_g_object_unref0 (self->priv->window);
	_g_object_unref0 (self->priv->shim);
	G_OBJECT_CLASS (budgie_power_application_parent_class)->finalize (obj);
}

static GType
budgie_power_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BudgiePowerApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) budgie_power_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BudgiePowerApplication), 0, (GInstanceInitFunc) budgie_power_application_instance_init, NULL };
	GType budgie_power_application_type_id;
	budgie_power_application_type_id = g_type_register_static (gtk_application_get_type (), "BudgiePowerApplication", &g_define_type_info, 0);
	BudgiePowerApplication_private_offset = g_type_add_instance_private (budgie_power_application_type_id, sizeof (BudgiePowerApplicationPrivate));
	return budgie_power_application_type_id;
}

GType
budgie_power_application_get_type (void)
{
	static volatile gsize budgie_power_application_type_id__once = 0;
	if (g_once_init_enter (&budgie_power_application_type_id__once)) {
		GType budgie_power_application_type_id;
		budgie_power_application_type_id = budgie_power_application_get_type_once ();
		g_once_init_leave (&budgie_power_application_type_id__once, budgie_power_application_type_id);
	}
	return budgie_power_application_type_id__once;
}

