/* UserIndicator.c generated by valac 0.32.1, the Vala compiler
 * generated from UserIndicator.vala, do not modify */

/*
 * This file is part of budgie-desktop
 * 
 * Copyright (C) 2015-2016 Solus Project
 *
 * 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 <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <libpeas/peas.h>
#include <plugin.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>


#define TYPE_USER_INDICATOR (user_indicator_get_type ())
#define USER_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_USER_INDICATOR, UserIndicator))
#define USER_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_USER_INDICATOR, UserIndicatorClass))
#define IS_USER_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_USER_INDICATOR))
#define IS_USER_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_USER_INDICATOR))
#define USER_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_USER_INDICATOR, UserIndicatorClass))

typedef struct _UserIndicator UserIndicator;
typedef struct _UserIndicatorClass UserIndicatorClass;
typedef struct _UserIndicatorPrivate UserIndicatorPrivate;

#define TYPE_USER_INDICATOR_APPLET (user_indicator_applet_get_type ())
#define USER_INDICATOR_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_USER_INDICATOR_APPLET, UserIndicatorApplet))
#define USER_INDICATOR_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_USER_INDICATOR_APPLET, UserIndicatorAppletClass))
#define IS_USER_INDICATOR_APPLET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_USER_INDICATOR_APPLET))
#define IS_USER_INDICATOR_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_USER_INDICATOR_APPLET))
#define USER_INDICATOR_APPLET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_USER_INDICATOR_APPLET, UserIndicatorAppletClass))

typedef struct _UserIndicatorApplet UserIndicatorApplet;
typedef struct _UserIndicatorAppletClass UserIndicatorAppletClass;
typedef struct _UserIndicatorAppletPrivate UserIndicatorAppletPrivate;

#define TYPE_USER_INDICATOR_WINDOW (user_indicator_window_get_type ())
#define USER_INDICATOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_USER_INDICATOR_WINDOW, UserIndicatorWindow))
#define USER_INDICATOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_USER_INDICATOR_WINDOW, UserIndicatorWindowClass))
#define IS_USER_INDICATOR_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_USER_INDICATOR_WINDOW))
#define IS_USER_INDICATOR_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_USER_INDICATOR_WINDOW))
#define USER_INDICATOR_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_USER_INDICATOR_WINDOW, UserIndicatorWindowClass))

typedef struct _UserIndicatorWindow UserIndicatorWindow;
typedef struct _UserIndicatorWindowClass UserIndicatorWindowClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _UserIndicator {
	PeasExtensionBase parent_instance;
	UserIndicatorPrivate * priv;
};

struct _UserIndicatorClass {
	PeasExtensionBaseClass parent_class;
};

struct _UserIndicatorApplet {
	BudgieApplet parent_instance;
	UserIndicatorAppletPrivate * priv;
	GtkEventBox* ebox;
	UserIndicatorWindow* popover;
};

struct _UserIndicatorAppletClass {
	BudgieAppletClass parent_class;
};

struct _UserIndicatorAppletPrivate {
	GtkImage* image;
	BudgiePopoverManager* manager;
	gchar* _uuid;
};


static gpointer user_indicator_parent_class = NULL;
static BudgiePluginIface* user_indicator_budgie_plugin_parent_iface = NULL;
static GType user_indicator_type_id = 0;
static gpointer user_indicator_applet_parent_class = NULL;
static GType user_indicator_applet_type_id = 0;

#define USER_SYMBOLIC_ICON "system-shutdown-symbolic"
GType user_indicator_get_type (void) G_GNUC_CONST;
GType user_indicator_register_type (GTypeModule * module);
enum  {
	USER_INDICATOR_DUMMY_PROPERTY
};
static BudgieApplet* user_indicator_real_get_panel_widget (BudgiePlugin* base, const gchar* uuid);
UserIndicatorApplet* user_indicator_applet_new (const gchar* uuid);
UserIndicatorApplet* user_indicator_applet_construct (GType object_type, const gchar* uuid);
GType user_indicator_applet_get_type (void) G_GNUC_CONST;
GType user_indicator_applet_register_type (GTypeModule * module);
UserIndicator* user_indicator_new (void);
UserIndicator* user_indicator_construct (GType object_type);
GType user_indicator_window_get_type (void) G_GNUC_CONST;
GType user_indicator_window_register_type (GTypeModule * module);
#define USER_INDICATOR_APPLET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_USER_INDICATOR_APPLET, UserIndicatorAppletPrivate))
enum  {
	USER_INDICATOR_APPLET_DUMMY_PROPERTY,
	USER_INDICATOR_APPLET_UUID
};
UserIndicatorWindow* user_indicator_window_new (GtkWidget* window_parent);
UserIndicatorWindow* user_indicator_window_construct (GType object_type, GtkWidget* window_parent);
static gboolean __lambda17_ (UserIndicatorApplet* self, GdkEventButton* e);
void user_indicator_applet_Toggle (UserIndicatorApplet* self);
static gboolean ___lambda17__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self);
static void user_indicator_applet_real_invoke_action (BudgieApplet* base, BudgiePanelAction action);
static void user_indicator_applet_real_update_popovers (BudgieApplet* base, BudgiePopoverManager* manager);
const gchar* user_indicator_applet_get_uuid (UserIndicatorApplet* self);
void user_indicator_applet_set_uuid (UserIndicatorApplet* self, const gchar* value);
static void user_indicator_applet_finalize (GObject* obj);
static void _vala_user_indicator_applet_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_user_indicator_applet_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
void peas_register_types (GTypeModule* module);


static BudgieApplet* user_indicator_real_get_panel_widget (BudgiePlugin* base, const gchar* uuid) {
	UserIndicator * self;
	BudgieApplet* result = NULL;
	const gchar* _tmp0_ = NULL;
	UserIndicatorApplet* _tmp1_ = NULL;
	self = (UserIndicator*) base;
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = uuid;
	_tmp1_ = user_indicator_applet_new (_tmp0_);
	g_object_ref_sink (_tmp1_);
	result = (BudgieApplet*) _tmp1_;
	return result;
}


UserIndicator* user_indicator_construct (GType object_type) {
	UserIndicator * self = NULL;
	self = (UserIndicator*) g_object_new (object_type, NULL);
	return self;
}


UserIndicator* user_indicator_new (void) {
	return user_indicator_construct (TYPE_USER_INDICATOR);
}


static void user_indicator_class_init (UserIndicatorClass * klass) {
	user_indicator_parent_class = g_type_class_peek_parent (klass);
}


static void user_indicator_budgie_plugin_interface_init (BudgiePluginIface * iface) {
	user_indicator_budgie_plugin_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_panel_widget = (BudgieApplet* (*)(BudgiePlugin*, const gchar*)) user_indicator_real_get_panel_widget;
}


static void user_indicator_instance_init (UserIndicator * self) {
}


GType user_indicator_get_type (void) {
	return user_indicator_type_id;
}


GType user_indicator_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (UserIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) user_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UserIndicator), 0, (GInstanceInitFunc) user_indicator_instance_init, NULL };
	static const GInterfaceInfo budgie_plugin_info = { (GInterfaceInitFunc) user_indicator_budgie_plugin_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	user_indicator_type_id = g_type_module_register_type (module, peas_extension_base_get_type (), "UserIndicator", &g_define_type_info, 0);
	g_type_module_add_interface (module, user_indicator_type_id, budgie_plugin_get_type (), &budgie_plugin_info);
	return user_indicator_type_id;
}


static gboolean __lambda17_ (UserIndicatorApplet* self, GdkEventButton* e) {
	gboolean result = FALSE;
	GdkEventButton* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	g_return_val_if_fail (e != NULL, FALSE);
	_tmp0_ = e;
	_tmp1_ = _tmp0_->button;
	if (_tmp1_ != ((guint) 1)) {
		result = GDK_EVENT_PROPAGATE;
		return result;
	}
	user_indicator_applet_Toggle (self);
	result = GDK_EVENT_STOP;
	return result;
}


static gboolean ___lambda17__gtk_widget_button_press_event (GtkWidget* _sender, GdkEventButton* event, gpointer self) {
	gboolean result;
	result = __lambda17_ ((UserIndicatorApplet*) self, event);
	return result;
}


UserIndicatorApplet* user_indicator_applet_construct (GType object_type, const gchar* uuid) {
	UserIndicatorApplet * self = NULL;
	const gchar* _tmp0_ = NULL;
	GtkEventBox* _tmp1_ = NULL;
	GtkImage* _tmp2_ = NULL;
	GtkEventBox* _tmp3_ = NULL;
	GtkImage* _tmp4_ = NULL;
	GtkImage* _tmp5_ = NULL;
	UserIndicatorWindow* _tmp6_ = NULL;
	GtkEventBox* _tmp7_ = NULL;
	UserIndicatorWindow* _tmp8_ = NULL;
	GtkWidget* _tmp9_ = NULL;
	GtkEventBox* _tmp10_ = NULL;
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = uuid;
	self = (UserIndicatorApplet*) g_object_new (object_type, "uuid", _tmp0_, NULL);
	_tmp1_ = (GtkEventBox*) gtk_event_box_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->ebox);
	self->ebox = _tmp1_;
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name (USER_SYMBOLIC_ICON, GTK_ICON_SIZE_MENU);
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->image);
	self->priv->image = _tmp2_;
	_tmp3_ = self->ebox;
	_tmp4_ = self->priv->image;
	gtk_container_add ((GtkContainer*) _tmp3_, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->image;
	_tmp6_ = user_indicator_window_new ((GtkWidget*) _tmp5_);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->popover);
	self->popover = _tmp6_;
	_tmp7_ = self->ebox;
	g_signal_connect_object ((GtkWidget*) _tmp7_, "button-press-event", (GCallback) ___lambda17__gtk_widget_button_press_event, self, 0);
	_tmp8_ = self->popover;
	_tmp9_ = gtk_bin_get_child ((GtkBin*) _tmp8_);
	gtk_widget_show_all (_tmp9_);
	_tmp10_ = self->ebox;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp10_);
	gtk_widget_show_all ((GtkWidget*) self);
	return self;
}


UserIndicatorApplet* user_indicator_applet_new (const gchar* uuid) {
	return user_indicator_applet_construct (TYPE_USER_INDICATOR_APPLET, uuid);
}


void user_indicator_applet_Toggle (UserIndicatorApplet* self) {
	UserIndicatorWindow* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->popover;
	_tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
	if (_tmp1_) {
		UserIndicatorWindow* _tmp2_ = NULL;
		_tmp2_ = self->popover;
		gtk_widget_hide ((GtkWidget*) _tmp2_);
	} else {
		UserIndicatorWindow* _tmp3_ = NULL;
		GtkWidget* _tmp4_ = NULL;
		BudgiePopoverManager* _tmp5_ = NULL;
		GtkEventBox* _tmp6_ = NULL;
		_tmp3_ = self->popover;
		_tmp4_ = gtk_bin_get_child ((GtkBin*) _tmp3_);
		gtk_widget_show_all (_tmp4_);
		_tmp5_ = self->priv->manager;
		_tmp6_ = self->ebox;
		budgie_popover_manager_show_popover (_tmp5_, (GtkWidget*) _tmp6_);
	}
}


static void user_indicator_applet_real_invoke_action (BudgieApplet* base, BudgiePanelAction action) {
	UserIndicatorApplet * self;
	self = (UserIndicatorApplet*) base;
	user_indicator_applet_Toggle (self);
}


static void user_indicator_applet_real_update_popovers (BudgieApplet* base, BudgiePopoverManager* manager) {
	UserIndicatorApplet * self;
	BudgiePopoverManager* _tmp0_ = NULL;
	BudgiePopoverManager* _tmp1_ = NULL;
	GtkEventBox* _tmp2_ = NULL;
	UserIndicatorWindow* _tmp3_ = NULL;
	self = (UserIndicatorApplet*) base;
	_tmp0_ = manager;
	self->priv->manager = _tmp0_;
	_tmp1_ = manager;
	_tmp2_ = self->ebox;
	_tmp3_ = self->popover;
	budgie_popover_manager_register_popover (_tmp1_, (GtkWidget*) _tmp2_, (GtkPopover*) _tmp3_);
}


const gchar* user_indicator_applet_get_uuid (UserIndicatorApplet* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_uuid;
	result = _tmp0_;
	return result;
}


void user_indicator_applet_set_uuid (UserIndicatorApplet* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_uuid);
	self->priv->_uuid = _tmp1_;
	g_object_notify ((GObject *) self, "uuid");
}


static void user_indicator_applet_class_init (UserIndicatorAppletClass * klass) {
	user_indicator_applet_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (UserIndicatorAppletPrivate));
	((BudgieAppletClass *) klass)->invoke_action = user_indicator_applet_real_invoke_action;
	((BudgieAppletClass *) klass)->update_popovers = user_indicator_applet_real_update_popovers;
	G_OBJECT_CLASS (klass)->get_property = _vala_user_indicator_applet_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_user_indicator_applet_set_property;
	G_OBJECT_CLASS (klass)->finalize = user_indicator_applet_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), USER_INDICATOR_APPLET_UUID, g_param_spec_string ("uuid", "uuid", "uuid", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
}


static void user_indicator_applet_instance_init (UserIndicatorApplet * self) {
	self->priv = USER_INDICATOR_APPLET_GET_PRIVATE (self);
	self->priv->manager = NULL;
}


static void user_indicator_applet_finalize (GObject* obj) {
	UserIndicatorApplet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_USER_INDICATOR_APPLET, UserIndicatorApplet);
	_g_object_unref0 (self->ebox);
	_g_object_unref0 (self->popover);
	_g_object_unref0 (self->priv->image);
	_g_free0 (self->priv->_uuid);
	G_OBJECT_CLASS (user_indicator_applet_parent_class)->finalize (obj);
}


GType user_indicator_applet_get_type (void) {
	return user_indicator_applet_type_id;
}


GType user_indicator_applet_register_type (GTypeModule * module) {
	static const GTypeInfo g_define_type_info = { sizeof (UserIndicatorAppletClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) user_indicator_applet_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UserIndicatorApplet), 0, (GInstanceInitFunc) user_indicator_applet_instance_init, NULL };
	user_indicator_applet_type_id = g_type_module_register_type (module, budgie_applet_get_type (), "UserIndicatorApplet", &g_define_type_info, 0);
	return user_indicator_applet_type_id;
}


static void _vala_user_indicator_applet_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	UserIndicatorApplet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_USER_INDICATOR_APPLET, UserIndicatorApplet);
	switch (property_id) {
		case USER_INDICATOR_APPLET_UUID:
		g_value_set_string (value, user_indicator_applet_get_uuid (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_user_indicator_applet_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	UserIndicatorApplet * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_USER_INDICATOR_APPLET, UserIndicatorApplet);
	switch (property_id) {
		case USER_INDICATOR_APPLET_UUID:
		user_indicator_applet_set_uuid (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void peas_register_types (GTypeModule* module) {
	PeasObjectModule* objmodule = NULL;
	GTypeModule* _tmp0_ = NULL;
	PeasObjectModule* _tmp1_ = NULL;
	g_return_if_fail (module != NULL);
	user_indicator_register_type (module);
	user_indicator_applet_register_type (module);
	user_indicator_window_register_type (module);
	indicator_item_register_type (module);
	accounts_interface_register_type (module);
	accounts_interface_proxy_register_dynamic_type (module);
	account_user_interface_register_type (module);
	account_user_interface_proxy_register_dynamic_type (module);
	properties_interface_register_type (module);
	properties_interface_proxy_register_dynamic_type (module);
	logind_interface_register_type (module);
	logind_interface_proxy_register_dynamic_type (module);
	session_manager_register_type (module);
	session_manager_proxy_register_dynamic_type (module);
	screen_saver_register_type (module);
	screen_saver_proxy_register_dynamic_type (module);
	_tmp0_ = module;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, peas_object_module_get_type ()) ? ((PeasObjectModule*) _tmp0_) : NULL);
	objmodule = _tmp1_;
	peas_object_module_register_extension_type (objmodule, budgie_plugin_get_type (), TYPE_USER_INDICATOR);
	_g_object_unref0 (objmodule);
}



