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

/*
 * Copyright 2011-2020 elementary, Inc. (https://elementary.io)
 *
 * 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.
 */

#include "power.h"
#include <glib.h>
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <granite.h>
#include <glib/gi18n-lib.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

enum  {
	POWER_WIDGETS_POPOVER_WIDGET_0_PROPERTY,
	POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY,
	POWER_WIDGETS_POPOVER_WIDGET_NUM_PROPERTIES
};
static GParamSpec* power_widgets_popover_widget_properties[POWER_WIDGETS_POPOVER_WIDGET_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block3Data Block3Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _PowerWidgetsPopoverWidgetPrivate {
	gboolean _is_in_session;
	GtkRevealer* device_separator_revealer;
	PowerWidgetsPowerModeList* power_mode_list;
};

struct _Block3Data {
	int _ref_count_;
	PowerWidgetsPopoverWidget* self;
	GtkRevealer* last_separator_revealer;
};

static gint PowerWidgetsPopoverWidget_private_offset;
static gpointer power_widgets_popover_widget_parent_class = NULL;
static PowerServicesDeviceManager* power_widgets_popover_widget_dm;
static PowerServicesDeviceManager* power_widgets_popover_widget_dm = NULL;

static void power_widgets_popover_widget_update_device_separator_revealer (PowerWidgetsPopoverWidget* self);
static GObject * power_widgets_popover_widget_constructor (GType type,
                                                    guint n_construct_properties,
                                                    GObjectConstructParam * construct_properties);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void _power_widgets_popover_widget___lambda18_ (PowerWidgetsPopoverWidget* self,
                                                GObject* s,
                                                GParamSpec* p);
static void __power_widgets_popover_widget___lambda18__g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self);
static void _power_widgets_popover_widget___lambda19_ (PowerWidgetsPopoverWidget* self);
static void __power_widgets_popover_widget___lambda19__gtk_button_clicked (GtkButton* _sender,
                                                                    gpointer self);
static void _power_widgets_popover_widget___lambda20_ (Block3Data* _data3_,
                                                gint brightness);
static void __power_widgets_popover_widget___lambda20__power_services_device_manager_brightness_changed (PowerServicesDeviceManager* _sender,
                                                                                                  gint brightness,
                                                                                                  gpointer self);
static void power_widgets_popover_widget_finalize (GObject * obj);
static GType power_widgets_popover_widget_get_type_once (void);
static void _vala_power_widgets_popover_widget_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_power_widgets_popover_widget_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);

static inline gpointer
power_widgets_popover_widget_get_instance_private (PowerWidgetsPopoverWidget* self)
{
	return G_STRUCT_MEMBER_P (self, PowerWidgetsPopoverWidget_private_offset);
}

PowerWidgetsPopoverWidget*
power_widgets_popover_widget_construct (GType object_type,
                                        gboolean is_in_session)
{
	PowerWidgetsPopoverWidget * self = NULL;
	self = (PowerWidgetsPopoverWidget*) g_object_new (object_type, "is-in-session", is_in_session, NULL);
	return self;
}

PowerWidgetsPopoverWidget*
power_widgets_popover_widget_new (gboolean is_in_session)
{
	return power_widgets_popover_widget_construct (POWER_WIDGETS_TYPE_POPOVER_WIDGET, is_in_session);
}

static void
power_widgets_popover_widget_update_device_separator_revealer (PowerWidgetsPopoverWidget* self)
{
	gboolean _tmp0_ = FALSE;
	PowerServicesDeviceManager* _tmp1_;
	PowerServicesBacklight* _tmp2_;
	PowerServicesBacklight* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	GtkRevealer* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp1_ = power_widgets_popover_widget_dm;
	_tmp2_ = power_services_device_manager_get_backlight (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = power_services_backlight_get_present (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		PowerServicesDeviceManager* _tmp6_;
		gboolean _tmp7_;
		gboolean _tmp8_;
		_tmp6_ = power_widgets_popover_widget_dm;
		_tmp7_ = power_services_device_manager_get_has_battery (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp0_ = _tmp8_;
	} else {
		_tmp0_ = FALSE;
	}
	_tmp9_ = self->priv->device_separator_revealer;
	gtk_revealer_set_reveal_child (_tmp9_, _tmp0_);
}

void
power_widgets_popover_widget_update_power_mode (PowerWidgetsPopoverWidget* self)
{
	PowerWidgetsPowerModeList* _tmp0_ = NULL;
	PowerWidgetsPowerModeList* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->power_mode_list;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		power_widgets_power_mode_list_update_active_profile (_tmp0_);
	}
}

gboolean
power_widgets_popover_widget_get_is_in_session (PowerWidgetsPopoverWidget* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_in_session;
	return result;
}

static void
power_widgets_popover_widget_set_is_in_session (PowerWidgetsPopoverWidget* self,
                                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = power_widgets_popover_widget_get_is_in_session (self);
	if (old_value != value) {
		self->priv->_is_in_session = value;
		g_object_notify_by_pspec ((GObject *) self, power_widgets_popover_widget_properties[POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY]);
	}
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		PowerWidgetsPopoverWidget* self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->last_separator_revealer);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
_power_widgets_popover_widget___lambda18_ (PowerWidgetsPopoverWidget* self,
                                           GObject* s,
                                           GParamSpec* p)
{
	g_return_if_fail (s != NULL);
	g_return_if_fail (p != NULL);
	power_widgets_popover_widget_update_device_separator_revealer (self);
}

static void
__power_widgets_popover_widget___lambda18__g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self)
{
	_power_widgets_popover_widget___lambda18_ ((PowerWidgetsPopoverWidget*) self, _sender, pspec);
}

static void
_power_widgets_popover_widget___lambda19_ (PowerWidgetsPopoverWidget* self)
{
	GError* _inner_error0_ = NULL;
	{
		g_app_info_launch_default_for_uri ("settings://power", NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_warning ("PopoverWidget.vala:131: Failed to open power settings: %s", _tmp1_);
		_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
__power_widgets_popover_widget___lambda19__gtk_button_clicked (GtkButton* _sender,
                                                               gpointer self)
{
	_power_widgets_popover_widget___lambda19_ ((PowerWidgetsPopoverWidget*) self);
}

static void
_power_widgets_popover_widget___lambda20_ (Block3Data* _data3_,
                                           gint brightness)
{
	PowerWidgetsPopoverWidget* self;
	self = _data3_->self;
	if (brightness != -1) {
		GtkRevealer* _tmp0_;
		_tmp0_ = _data3_->last_separator_revealer;
		gtk_revealer_set_reveal_child (_tmp0_, TRUE);
	} else {
		GtkRevealer* _tmp1_;
		_tmp1_ = _data3_->last_separator_revealer;
		gtk_revealer_set_reveal_child (_tmp1_, FALSE);
	}
}

static void
__power_widgets_popover_widget___lambda20__power_services_device_manager_brightness_changed (PowerServicesDeviceManager* _sender,
                                                                                             gint brightness,
                                                                                             gpointer self)
{
	_power_widgets_popover_widget___lambda20_ (self, brightness);
}

static GObject *
power_widgets_popover_widget_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PowerWidgetsPopoverWidget * self;
	Block3Data* _data3_;
	GSettings* settings = NULL;
	GSettings* _tmp0_;
	PowerWidgetsDeviceList* device_list = NULL;
	PowerWidgetsDeviceList* _tmp1_;
	GtkRevealer* device_list_revealer = NULL;
	GtkRevealer* _tmp2_;
	GtkRevealer* _tmp3_;
	PowerWidgetsDeviceList* _tmp4_;
	GtkSeparator* device_separator = NULL;
	GtkSeparator* _tmp5_ = NULL;
	GtkRevealer* _tmp6_;
	GtkRevealer* _tmp7_;
	GtkSeparator* _tmp8_;
	GtkSeparator* last_separator = NULL;
	GtkSeparator* _tmp9_ = NULL;
	PowerServicesDeviceManager* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GtkRevealer* _tmp13_ = NULL;
	GtkRevealer* _tmp14_;
	GtkSeparator* _tmp15_;
	GraniteSwitchModelButton* show_percent_switch = NULL;
	GraniteSwitchModelButton* _tmp16_;
	GraniteSwitchModelButton* _tmp17_;
	GtkStyleContext* _tmp18_;
	GtkSeparator* show_percent_sep = NULL;
	GtkSeparator* _tmp19_ = NULL;
	GtkBox* show_percent_box = NULL;
	GtkBox* _tmp20_;
	GtkBox* _tmp21_;
	GraniteSwitchModelButton* _tmp22_;
	GtkBox* _tmp23_;
	GtkSeparator* _tmp24_;
	GtkRevealer* show_percent_revealer = NULL;
	GtkRevealer* _tmp25_;
	GtkRevealer* _tmp26_;
	GtkBox* _tmp27_;
	PowerWidgetsPowerModeList* _tmp28_;
	GtkSeparator* power_mode_separator = NULL;
	GtkSeparator* _tmp29_ = NULL;
	GtkModelButton* show_settings_button = NULL;
	gchar* _tmp30_;
	GtkModelButton* _tmp31_ = NULL;
	GtkRevealer* _tmp32_;
	GtkRevealer* _tmp33_;
	GtkRevealer* _tmp34_;
	PowerServicesDeviceManager* _tmp35_;
	PowerServicesBacklight* _tmp36_;
	PowerServicesBacklight* _tmp37_;
	gboolean _tmp38_;
	gboolean _tmp39_;
	gboolean _tmp42_;
	gboolean _tmp43_;
	gboolean _tmp46_;
	PowerServicesDeviceManager* _tmp49_;
	GSettings* _tmp50_;
	GraniteSwitchModelButton* _tmp51_;
	PowerServicesDeviceManager* _tmp52_;
	GtkRevealer* _tmp53_;
	gboolean _tmp54_ = FALSE;
	PowerServicesDeviceManager* _tmp55_;
	gboolean _tmp56_;
	gboolean _tmp57_;
	GtkModelButton* _tmp64_;
	PowerServicesDeviceManager* _tmp65_;
	parent_class = G_OBJECT_CLASS (power_widgets_popover_widget_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, POWER_WIDGETS_TYPE_POPOVER_WIDGET, PowerWidgetsPopoverWidget);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = g_settings_new ("io.elementary.desktop.wingpanel.power");
	settings = _tmp0_;
	_tmp1_ = power_widgets_device_list_new ();
	g_object_ref_sink (_tmp1_);
	device_list = _tmp1_;
	_tmp2_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp2_);
	device_list_revealer = _tmp2_;
	_tmp3_ = device_list_revealer;
	_tmp4_ = device_list;
	gtk_container_add ((GtkContainer*) _tmp3_, (GtkWidget*) _tmp4_);
	_tmp5_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp5_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp5_, 3);
	g_object_ref_sink (_tmp5_);
	device_separator = _tmp5_;
	_tmp6_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->priv->device_separator_revealer);
	self->priv->device_separator_revealer = _tmp6_;
	_tmp7_ = self->priv->device_separator_revealer;
	_tmp8_ = device_separator;
	gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp9_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp9_, 3);
	g_object_ref_sink (_tmp9_);
	last_separator = _tmp9_;
	_tmp10_ = power_widgets_popover_widget_dm;
	_tmp11_ = power_services_device_manager_get_brightness (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_reveal_child (_tmp13_, _tmp12_ != -1);
	g_object_ref_sink (_tmp13_);
	_data3_->last_separator_revealer = _tmp13_;
	_tmp14_ = _data3_->last_separator_revealer;
	_tmp15_ = last_separator;
	gtk_container_add ((GtkContainer*) _tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = granite_switch_model_button_new (_ ("Show Percentage"));
	g_object_ref_sink (_tmp16_);
	show_percent_switch = _tmp16_;
	_tmp17_ = show_percent_switch;
	_tmp18_ = gtk_widget_get_style_context ((GtkWidget*) _tmp17_);
	gtk_style_context_add_class (_tmp18_, GRANITE_STYLE_CLASS_H4_LABEL);
	_tmp19_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp19_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp19_, 3);
	g_object_ref_sink (_tmp19_);
	show_percent_sep = _tmp19_;
	_tmp20_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp20_);
	show_percent_box = _tmp20_;
	_tmp21_ = show_percent_box;
	_tmp22_ = show_percent_switch;
	gtk_container_add ((GtkContainer*) _tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = show_percent_box;
	_tmp24_ = show_percent_sep;
	gtk_container_add ((GtkContainer*) _tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = (GtkRevealer*) gtk_revealer_new ();
	g_object_ref_sink (_tmp25_);
	show_percent_revealer = _tmp25_;
	_tmp26_ = show_percent_revealer;
	_tmp27_ = show_percent_box;
	gtk_container_add ((GtkContainer*) _tmp26_, (GtkWidget*) _tmp27_);
	_tmp28_ = power_widgets_power_mode_list_new ();
	g_object_ref_sink (_tmp28_);
	_g_object_unref0 (self->priv->power_mode_list);
	self->priv->power_mode_list = _tmp28_;
	_tmp29_ = (GtkSeparator*) gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp29_, 3);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp29_, 3);
	g_object_ref_sink (_tmp29_);
	power_mode_separator = _tmp29_;
	_tmp30_ = g_strdup (_ ("Power Settings…"));
	_tmp31_ = (GtkModelButton*) gtk_model_button_new ();
	g_object_set (_tmp31_, "text", _tmp30_, NULL);
	_g_free0 (_tmp30_);
	g_object_ref_sink (_tmp31_);
	show_settings_button = _tmp31_;
	_tmp32_ = show_percent_revealer;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp32_, 0, 0, 1, 1);
	_tmp33_ = device_list_revealer;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp33_, 0, 1, 1, 1);
	_tmp34_ = self->priv->device_separator_revealer;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp34_, 0, 3, 1, 1);
	_tmp35_ = power_widgets_popover_widget_dm;
	_tmp36_ = power_services_device_manager_get_backlight (_tmp35_);
	_tmp37_ = _tmp36_;
	_tmp38_ = power_services_backlight_get_present (_tmp37_);
	_tmp39_ = _tmp38_;
	if (_tmp39_) {
		PowerWidgetsScreenBrightness* screen_brightness = NULL;
		PowerWidgetsScreenBrightness* _tmp40_;
		PowerWidgetsScreenBrightness* _tmp41_;
		_tmp40_ = power_widgets_screen_brightness_new ();
		g_object_ref_sink (_tmp40_);
		screen_brightness = _tmp40_;
		_tmp41_ = screen_brightness;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp41_, 0, 4, 1, 1);
		_g_object_unref0 (screen_brightness);
	}
	_tmp42_ = power_widgets_power_mode_list_get_successfully_initialized ();
	_tmp43_ = _tmp42_;
	if (_tmp43_) {
		GtkSeparator* _tmp44_;
		PowerWidgetsPowerModeList* _tmp45_;
		_tmp44_ = power_mode_separator;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp44_, 0, 5, 1, 1);
		_tmp45_ = self->priv->power_mode_list;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp45_, 0, 6, 1, 1);
	}
	_tmp46_ = self->priv->_is_in_session;
	if (_tmp46_) {
		GtkRevealer* _tmp47_;
		GtkModelButton* _tmp48_;
		_tmp47_ = _data3_->last_separator_revealer;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp47_, 0, 7, 1, 1);
		_tmp48_ = show_settings_button;
		gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp48_, 0, 8, 1, 1);
	}
	power_widgets_popover_widget_update_device_separator_revealer (self);
	_tmp49_ = power_widgets_popover_widget_dm;
	g_signal_connect_object ((GObject*) _tmp49_, "notify::has-battery", (GCallback) __power_widgets_popover_widget___lambda18__g_object_notify, self, 0);
	_tmp50_ = settings;
	_tmp51_ = show_percent_switch;
	g_settings_bind (_tmp50_, "show-percentage", (GObject*) _tmp51_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp52_ = power_widgets_popover_widget_dm;
	_tmp53_ = device_list_revealer;
	g_object_bind_property_with_closures ((GObject*) _tmp52_, "has-battery", (GObject*) _tmp53_, "reveal-child", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp55_ = power_widgets_popover_widget_dm;
	_tmp56_ = power_services_device_manager_get_has_battery (_tmp55_);
	_tmp57_ = _tmp56_;
	if (_tmp57_) {
		PowerServicesDeviceManager* _tmp58_;
		PowerServicesDevice* _tmp59_;
		PowerServicesDevice* _tmp60_;
		gboolean _tmp61_;
		gboolean _tmp62_;
		_tmp58_ = power_widgets_popover_widget_dm;
		_tmp59_ = power_services_device_manager_get_display_device (_tmp58_);
		_tmp60_ = _tmp59_;
		_tmp61_ = power_services_device_get_is_a_battery (_tmp60_);
		_tmp62_ = _tmp61_;
		_tmp54_ = _tmp62_;
	} else {
		_tmp54_ = FALSE;
	}
	if (_tmp54_) {
		GtkRevealer* _tmp63_;
		_tmp63_ = show_percent_revealer;
		gtk_revealer_set_reveal_child (_tmp63_, TRUE);
	}
	_tmp64_ = show_settings_button;
	g_signal_connect_object ((GtkButton*) _tmp64_, "clicked", (GCallback) __power_widgets_popover_widget___lambda19__gtk_button_clicked, self, 0);
	_tmp65_ = power_widgets_popover_widget_dm;
	g_signal_connect_data (_tmp65_, "brightness-changed", (GCallback) __power_widgets_popover_widget___lambda20__power_services_device_manager_brightness_changed, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	_g_object_unref0 (show_settings_button);
	_g_object_unref0 (power_mode_separator);
	_g_object_unref0 (show_percent_revealer);
	_g_object_unref0 (show_percent_box);
	_g_object_unref0 (show_percent_sep);
	_g_object_unref0 (show_percent_switch);
	_g_object_unref0 (last_separator);
	_g_object_unref0 (device_separator);
	_g_object_unref0 (device_list_revealer);
	_g_object_unref0 (device_list);
	_g_object_unref0 (settings);
	block3_data_unref (_data3_);
	_data3_ = NULL;
	return obj;
}

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

static void
power_widgets_popover_widget_class_init (PowerWidgetsPopoverWidgetClass * klass,
                                         gpointer klass_data)
{
	PowerServicesDeviceManager* _tmp0_;
	PowerServicesDeviceManager* _tmp1_;
	power_widgets_popover_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PowerWidgetsPopoverWidget_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_power_widgets_popover_widget_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_power_widgets_popover_widget_set_property;
	G_OBJECT_CLASS (klass)->constructor = power_widgets_popover_widget_constructor;
	G_OBJECT_CLASS (klass)->finalize = power_widgets_popover_widget_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY, power_widgets_popover_widget_properties[POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY] = g_param_spec_boolean ("is-in-session", "is-in-session", "is-in-session", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	_tmp0_ = power_services_device_manager_get_default ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (power_widgets_popover_widget_dm);
	power_widgets_popover_widget_dm = _tmp1_;
}

static void
power_widgets_popover_widget_instance_init (PowerWidgetsPopoverWidget * self,
                                            gpointer klass)
{
	self->priv = power_widgets_popover_widget_get_instance_private (self);
	self->priv->_is_in_session = FALSE;
}

static void
power_widgets_popover_widget_finalize (GObject * obj)
{
	PowerWidgetsPopoverWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, POWER_WIDGETS_TYPE_POPOVER_WIDGET, PowerWidgetsPopoverWidget);
	_g_object_unref0 (self->priv->device_separator_revealer);
	_g_object_unref0 (self->priv->power_mode_list);
	G_OBJECT_CLASS (power_widgets_popover_widget_parent_class)->finalize (obj);
}

static GType
power_widgets_popover_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PowerWidgetsPopoverWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) power_widgets_popover_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PowerWidgetsPopoverWidget), 0, (GInstanceInitFunc) power_widgets_popover_widget_instance_init, NULL };
	GType power_widgets_popover_widget_type_id;
	power_widgets_popover_widget_type_id = g_type_register_static (gtk_grid_get_type (), "PowerWidgetsPopoverWidget", &g_define_type_info, 0);
	PowerWidgetsPopoverWidget_private_offset = g_type_add_instance_private (power_widgets_popover_widget_type_id, sizeof (PowerWidgetsPopoverWidgetPrivate));
	return power_widgets_popover_widget_type_id;
}

GType
power_widgets_popover_widget_get_type (void)
{
	static volatile gsize power_widgets_popover_widget_type_id__once = 0;
	if (g_once_init_enter (&power_widgets_popover_widget_type_id__once)) {
		GType power_widgets_popover_widget_type_id;
		power_widgets_popover_widget_type_id = power_widgets_popover_widget_get_type_once ();
		g_once_init_leave (&power_widgets_popover_widget_type_id__once, power_widgets_popover_widget_type_id);
	}
	return power_widgets_popover_widget_type_id__once;
}

static void
_vala_power_widgets_popover_widget_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	PowerWidgetsPopoverWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, POWER_WIDGETS_TYPE_POPOVER_WIDGET, PowerWidgetsPopoverWidget);
	switch (property_id) {
		case POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY:
		g_value_set_boolean (value, power_widgets_popover_widget_get_is_in_session (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_power_widgets_popover_widget_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	PowerWidgetsPopoverWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, POWER_WIDGETS_TYPE_POPOVER_WIDGET, PowerWidgetsPopoverWidget);
	switch (property_id) {
		case POWER_WIDGETS_POPOVER_WIDGET_IS_IN_SESSION_PROPERTY:
		power_widgets_popover_widget_set_is_in_session (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

