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

/*
 * Copyright 2021-2022 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.
 *
 * Authored by: Subhadeep Jasu <subhajasu@gmail.com>
 */

#include "power.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <granite-7.h>
#include <glib/gi18n-lib.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_POWER_MODE_BUTTON_0_PROPERTY,
	POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY,
	POWER_POWER_MODE_BUTTON_NUM_PROPERTIES
};
static GParamSpec* power_power_mode_button_properties[POWER_POWER_MODE_BUTTON_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#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_settings_schema_unref0(var) ((var == NULL) ? NULL : (var = (g_settings_schema_unref (var), NULL)))

struct _PowerPowerModeButtonPrivate {
	gchar* _settings_key;
	GtkCheckButton* saver_radio;
	GtkCheckButton* balanced_radio;
	GtkCheckButton* performance_radio;
};

static gint PowerPowerModeButton_private_offset;
static gpointer power_power_mode_button_parent_class = NULL;
static gboolean power_power_mode_button__successfully_initialized;
static gboolean power_power_mode_button__successfully_initialized = TRUE;
static PowerPowerProfile* power_power_mode_button_pprofile;
static PowerPowerProfile* power_power_mode_button_pprofile = NULL;
static GSettings* power_power_mode_button_settings;
static GSettings* power_power_mode_button_settings = NULL;

static void power_power_mode_button_update_active_profile (PowerPowerModeButton* self);
static void power_power_mode_button_set_successfully_initialized (gboolean value);
static GObject * power_power_mode_button_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
static void _power_power_mode_button___lambda12_ (PowerPowerModeButton* self);
static void __power_power_mode_button___lambda12__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                     gpointer self);
static void _power_power_mode_button___lambda13_ (PowerPowerModeButton* self);
static void __power_power_mode_button___lambda13__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                     gpointer self);
static void _power_power_mode_button___lambda14_ (PowerPowerModeButton* self);
static void __power_power_mode_button___lambda14__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                     gpointer self);
static void power_power_mode_button_finalize (GObject * obj);
static GType power_power_mode_button_get_type_once (void);
static void _vala_power_power_mode_button_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_power_power_mode_button_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
power_power_mode_button_get_instance_private (PowerPowerModeButton* self)
{
	return G_STRUCT_MEMBER_P (self, PowerPowerModeButton_private_offset);
}

PowerPowerModeButton*
power_power_mode_button_construct (GType object_type,
                                   gboolean on_battery)
{
	PowerPowerModeButton * self = NULL;
	const gchar* _tmp0_ = NULL;
	if (on_battery) {
		_tmp0_ = "profile-on-good-battery";
	} else {
		_tmp0_ = "profile-plugged-in";
	}
	self = (PowerPowerModeButton*) g_object_new (object_type, "settings-key", _tmp0_, NULL);
	return self;
}

PowerPowerModeButton*
power_power_mode_button_new (gboolean on_battery)
{
	return power_power_mode_button_construct (POWER_TYPE_POWER_MODE_BUTTON, on_battery);
}

static void
power_power_mode_button_update_active_profile (PowerPowerModeButton* self)
{
	GSettings* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GQuark _tmp5_ = 0U;
	static GQuark _tmp4_label0 = 0;
	static GQuark _tmp4_label1 = 0;
	static GQuark _tmp4_label2 = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = power_power_mode_button_settings;
	_tmp1_ = self->priv->_settings_key;
	_tmp2_ = g_settings_get_string (_tmp0_, _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp5_ = (NULL == _tmp3_) ? 0 : g_quark_from_string (_tmp3_);
	g_free (_tmp3_);
	if (_tmp5_ == ((0 != _tmp4_label0) ? _tmp4_label0 : (_tmp4_label0 = g_quark_from_static_string ("power-saver")))) {
		switch (0) {
			default:
			{
				GtkCheckButton* _tmp6_;
				_tmp6_ = self->priv->saver_radio;
				gtk_check_button_set_active (_tmp6_, TRUE);
				break;
			}
		}
	} else if (_tmp5_ == ((0 != _tmp4_label1) ? _tmp4_label1 : (_tmp4_label1 = g_quark_from_static_string ("balanced")))) {
		switch (0) {
			default:
			{
				GtkCheckButton* _tmp7_;
				_tmp7_ = self->priv->balanced_radio;
				gtk_check_button_set_active (_tmp7_, TRUE);
				break;
			}
		}
	} else if (_tmp5_ == ((0 != _tmp4_label2) ? _tmp4_label2 : (_tmp4_label2 = g_quark_from_static_string ("performance")))) {
		switch (0) {
			default:
			{
				GtkCheckButton* _tmp8_;
				_tmp8_ = self->priv->performance_radio;
				gtk_check_button_set_active (_tmp8_, TRUE);
				break;
			}
		}
	}
}

gboolean
power_power_mode_button_get_successfully_initialized (void)
{
	gboolean result;
	result = power_power_mode_button__successfully_initialized;
	return result;
}

static void
power_power_mode_button_set_successfully_initialized (gboolean value)
{
	power_power_mode_button__successfully_initialized = value;
}

const gchar*
power_power_mode_button_get_settings_key (PowerPowerModeButton* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_settings_key;
	result = _tmp0_;
	return result;
}

static void
power_power_mode_button_set_settings_key (PowerPowerModeButton* self,
                                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = power_power_mode_button_get_settings_key (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_settings_key);
		self->priv->_settings_key = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, power_power_mode_button_properties[POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY]);
	}
}

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

static void
_power_power_mode_button___lambda12_ (PowerPowerModeButton* self)
{
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->saver_radio;
	_tmp1_ = gtk_check_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GSettings* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = power_power_mode_button_settings;
		_tmp4_ = self->priv->_settings_key;
		g_settings_set_string (_tmp3_, _tmp4_, "power-saver");
	}
}

static void
__power_power_mode_button___lambda12__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                gpointer self)
{
	_power_power_mode_button___lambda12_ ((PowerPowerModeButton*) self);
}

static void
_power_power_mode_button___lambda13_ (PowerPowerModeButton* self)
{
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->balanced_radio;
	_tmp1_ = gtk_check_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GSettings* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = power_power_mode_button_settings;
		_tmp4_ = self->priv->_settings_key;
		g_settings_set_string (_tmp3_, _tmp4_, "balanced");
	}
}

static void
__power_power_mode_button___lambda13__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                gpointer self)
{
	_power_power_mode_button___lambda13_ ((PowerPowerModeButton*) self);
}

static void
_power_power_mode_button___lambda14_ (PowerPowerModeButton* self)
{
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->performance_radio;
	_tmp1_ = gtk_check_button_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		GSettings* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = power_power_mode_button_settings;
		_tmp4_ = self->priv->_settings_key;
		g_settings_set_string (_tmp3_, _tmp4_, "performance");
	}
}

static void
__power_power_mode_button___lambda14__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                gpointer self)
{
	_power_power_mode_button___lambda14_ ((PowerPowerModeButton*) self);
}

static GObject *
power_power_mode_button_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PowerPowerModeButton * self;
	gboolean _tmp0_ = FALSE;
	GSettings* _tmp1_;
	GraniteHeaderLabel* header = NULL;
	GraniteHeaderLabel* _tmp3_ = NULL;
	GtkImage* saver_icon = NULL;
	GtkImage* _tmp4_ = NULL;
	GtkLabel* saver_label = NULL;
	GtkLabel* _tmp5_;
	GtkBox* saver_button_box = NULL;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkImage* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkCheckButton* _tmp11_;
	GtkCheckButton* _tmp12_;
	GtkBox* _tmp13_;
	GtkCheckButton* _tmp14_;
	GtkImage* balanced_icon = NULL;
	GtkImage* _tmp15_ = NULL;
	GtkLabel* balanced_label = NULL;
	GtkLabel* _tmp16_;
	GtkBox* balanced_button_box = NULL;
	GtkBox* _tmp17_;
	GtkBox* _tmp18_;
	GtkImage* _tmp19_;
	GtkBox* _tmp20_;
	GtkLabel* _tmp21_;
	GtkCheckButton* _tmp22_;
	GtkCheckButton* _tmp23_;
	GtkCheckButton* _tmp24_ = NULL;
	GtkCheckButton* _tmp25_;
	GtkBox* _tmp26_;
	GtkCheckButton* _tmp27_;
	GtkImage* performance_icon = NULL;
	GtkImage* _tmp28_ = NULL;
	GtkLabel* performance_label = NULL;
	GtkLabel* _tmp29_;
	GtkBox* performance_button_box = NULL;
	GtkBox* _tmp30_;
	GtkBox* _tmp31_;
	GtkImage* _tmp32_;
	GtkBox* _tmp33_;
	GtkLabel* _tmp34_;
	GtkCheckButton* _tmp35_;
	GtkCheckButton* _tmp36_;
	GtkCheckButton* _tmp37_ = NULL;
	GtkCheckButton* _tmp38_;
	GtkBox* _tmp39_;
	GtkCheckButton* _tmp40_;
	GraniteHeaderLabel* _tmp41_;
	PowerPowerProfile* _tmp42_;
	GHashTable** _tmp43_;
	gint _tmp43__length1;
	gint _tmp44_ = 0;
	GHashTable** _tmp45_;
	gint _tmp45__length1;
	GtkCheckButton* _tmp55_;
	GtkCheckButton* _tmp56_;
	GtkCheckButton* _tmp57_;
	parent_class = G_OBJECT_CLASS (power_power_mode_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, POWER_TYPE_POWER_MODE_BUTTON, PowerPowerModeButton);
	_tmp1_ = power_power_mode_button_settings;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		PowerPowerProfile* _tmp2_;
		_tmp2_ = power_power_mode_button_pprofile;
		_tmp0_ = _tmp2_ == NULL;
	}
	if (_tmp0_) {
		return obj;
	}
	_tmp3_ = granite_header_label_new (_ ("Power Mode"));
	gtk_widget_set_hexpand ((GtkWidget*) _tmp3_, TRUE);
	g_object_ref_sink (_tmp3_);
	header = _tmp3_;
	_tmp4_ = (GtkImage*) gtk_image_new_from_icon_name ("power-mode-powersaver-symbolic");
	gtk_image_set_icon_size (_tmp4_, GTK_ICON_SIZE_LARGE);
	g_object_ref_sink (_tmp4_);
	saver_icon = _tmp4_;
	_tmp5_ = (GtkLabel*) gtk_label_new (_ ("Power Saver"));
	g_object_ref_sink (_tmp5_);
	saver_label = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp6_);
	saver_button_box = _tmp6_;
	_tmp7_ = saver_button_box;
	_tmp8_ = saver_icon;
	gtk_box_append (_tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = saver_button_box;
	_tmp10_ = saver_label;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->saver_radio);
	self->priv->saver_radio = _tmp11_;
	_tmp12_ = self->priv->saver_radio;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "image-button");
	_tmp13_ = saver_button_box;
	_tmp14_ = self->priv->saver_radio;
	gtk_widget_set_parent ((GtkWidget*) _tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = (GtkImage*) gtk_image_new_from_icon_name ("power-mode-balanced-symbolic");
	gtk_image_set_icon_size (_tmp15_, GTK_ICON_SIZE_LARGE);
	g_object_ref_sink (_tmp15_);
	balanced_icon = _tmp15_;
	_tmp16_ = (GtkLabel*) gtk_label_new (_ ("Balanced"));
	g_object_ref_sink (_tmp16_);
	balanced_label = _tmp16_;
	_tmp17_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp17_);
	balanced_button_box = _tmp17_;
	_tmp18_ = balanced_button_box;
	_tmp19_ = balanced_icon;
	gtk_box_append (_tmp18_, (GtkWidget*) _tmp19_);
	_tmp20_ = balanced_button_box;
	_tmp21_ = balanced_label;
	gtk_box_append (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = self->priv->saver_radio;
	_tmp23_ = _g_object_ref0 (_tmp22_);
	_tmp24_ = (GtkCheckButton*) gtk_check_button_new ();
	gtk_check_button_set_group (_tmp24_, _tmp23_);
	_g_object_unref0 (_tmp23_);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->balanced_radio);
	self->priv->balanced_radio = _tmp24_;
	_tmp25_ = self->priv->balanced_radio;
	gtk_widget_add_css_class ((GtkWidget*) _tmp25_, "image-button");
	_tmp26_ = balanced_button_box;
	_tmp27_ = self->priv->balanced_radio;
	gtk_widget_set_parent ((GtkWidget*) _tmp26_, (GtkWidget*) _tmp27_);
	_tmp28_ = (GtkImage*) gtk_image_new_from_icon_name ("power-mode-performance-symbolic");
	gtk_image_set_icon_size (_tmp28_, GTK_ICON_SIZE_LARGE);
	g_object_ref_sink (_tmp28_);
	performance_icon = _tmp28_;
	_tmp29_ = (GtkLabel*) gtk_label_new (_ ("Performance"));
	g_object_ref_sink (_tmp29_);
	performance_label = _tmp29_;
	_tmp30_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp30_);
	performance_button_box = _tmp30_;
	_tmp31_ = performance_button_box;
	_tmp32_ = performance_icon;
	gtk_box_append (_tmp31_, (GtkWidget*) _tmp32_);
	_tmp33_ = performance_button_box;
	_tmp34_ = performance_label;
	gtk_box_append (_tmp33_, (GtkWidget*) _tmp34_);
	_tmp35_ = self->priv->saver_radio;
	_tmp36_ = _g_object_ref0 (_tmp35_);
	_tmp37_ = (GtkCheckButton*) gtk_check_button_new ();
	gtk_check_button_set_group (_tmp37_, _tmp36_);
	_g_object_unref0 (_tmp36_);
	g_object_ref_sink (_tmp37_);
	_g_object_unref0 (self->priv->performance_radio);
	self->priv->performance_radio = _tmp37_;
	_tmp38_ = self->priv->performance_radio;
	gtk_widget_add_css_class ((GtkWidget*) _tmp38_, "image-button");
	_tmp39_ = performance_button_box;
	_tmp40_ = self->priv->performance_radio;
	gtk_widget_set_parent ((GtkWidget*) _tmp39_, (GtkWidget*) _tmp40_);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	_tmp41_ = header;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp41_);
	_tmp42_ = power_power_mode_button_pprofile;
	_tmp43_ = power_power_profile_get_profiles (_tmp42_, &_tmp44_);
	_tmp43__length1 = _tmp44_;
	_tmp45_ = _tmp43_;
	_tmp45__length1 = _tmp43__length1;
	{
		GHashTable** profile_collection = NULL;
		gint profile_collection_length1 = 0;
		gint _profile_collection_size_ = 0;
		gint profile_it = 0;
		profile_collection = _tmp45_;
		profile_collection_length1 = _tmp45__length1;
		for (profile_it = 0; profile_it < profile_collection_length1; profile_it = profile_it + 1) {
			GHashTable* profile = NULL;
			profile = profile_collection[profile_it];
			{
				GHashTable* _tmp46_;
				gconstpointer _tmp47_;
				const gchar* _tmp48_;
				const gchar* _tmp49_;
				GQuark _tmp51_ = 0U;
				static GQuark _tmp50_label0 = 0;
				static GQuark _tmp50_label1 = 0;
				static GQuark _tmp50_label2 = 0;
				_tmp46_ = profile;
				_tmp47_ = g_hash_table_lookup (_tmp46_, "Profile");
				_tmp48_ = g_variant_get_string ((GVariant*) _tmp47_, NULL);
				_tmp49_ = _tmp48_;
				_tmp51_ = (NULL == _tmp49_) ? 0 : g_quark_from_string (_tmp49_);
				if (_tmp51_ == ((0 != _tmp50_label0) ? _tmp50_label0 : (_tmp50_label0 = g_quark_from_static_string ("power-saver")))) {
					switch (0) {
						default:
						{
							GtkCheckButton* _tmp52_;
							_tmp52_ = self->priv->saver_radio;
							gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp52_);
							break;
						}
					}
				} else if (_tmp51_ == ((0 != _tmp50_label1) ? _tmp50_label1 : (_tmp50_label1 = g_quark_from_static_string ("balanced")))) {
					switch (0) {
						default:
						{
							GtkCheckButton* _tmp53_;
							_tmp53_ = self->priv->balanced_radio;
							gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp53_);
							break;
						}
					}
				} else if (_tmp51_ == ((0 != _tmp50_label2) ? _tmp50_label2 : (_tmp50_label2 = g_quark_from_static_string ("performance")))) {
					switch (0) {
						default:
						{
							GtkCheckButton* _tmp54_;
							_tmp54_ = self->priv->performance_radio;
							gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp54_);
							break;
						}
					}
				}
			}
		}
		profile_collection = (_vala_array_free (profile_collection, profile_collection_length1, (GDestroyNotify) g_hash_table_unref), NULL);
	}
	power_power_mode_button_update_active_profile (self);
	_tmp55_ = self->priv->saver_radio;
	g_signal_connect_object (_tmp55_, "toggled", (GCallback) __power_power_mode_button___lambda12__gtk_check_button_toggled, self, 0);
	_tmp56_ = self->priv->balanced_radio;
	g_signal_connect_object (_tmp56_, "toggled", (GCallback) __power_power_mode_button___lambda13__gtk_check_button_toggled, self, 0);
	_tmp57_ = self->priv->performance_radio;
	g_signal_connect_object (_tmp57_, "toggled", (GCallback) __power_power_mode_button___lambda14__gtk_check_button_toggled, self, 0);
	_g_object_unref0 (performance_button_box);
	_g_object_unref0 (performance_label);
	_g_object_unref0 (performance_icon);
	_g_object_unref0 (balanced_button_box);
	_g_object_unref0 (balanced_label);
	_g_object_unref0 (balanced_icon);
	_g_object_unref0 (saver_button_box);
	_g_object_unref0 (saver_label);
	_g_object_unref0 (saver_icon);
	_g_object_unref0 (header);
	return obj;
}

static void
power_power_mode_button_class_init (PowerPowerModeButtonClass * klass,
                                    gpointer klass_data)
{
	GSettingsSchema* schema = NULL;
	GSettingsSchemaSource* _tmp0_;
	GSettingsSchema* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	GSettingsSchema* _tmp4_;
	GError* _inner_error0_ = NULL;
	power_power_mode_button_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PowerPowerModeButton_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_power_power_mode_button_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_power_power_mode_button_set_property;
	G_OBJECT_CLASS (klass)->constructor = power_power_mode_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = power_power_mode_button_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY, power_power_mode_button_properties[POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY] = g_param_spec_string ("settings-key", "settings-key", "settings-key", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	_tmp0_ = g_settings_schema_source_get_default ();
	_tmp1_ = g_settings_schema_source_lookup (_tmp0_, "io.elementary.settings-daemon.power", TRUE);
	schema = _tmp1_;
	_tmp4_ = schema;
	if (_tmp4_ != NULL) {
		GSettingsSchema* _tmp5_;
		_tmp5_ = schema;
		_tmp3_ = g_settings_schema_has_key (_tmp5_, "profile-plugged-in");
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GSettingsSchema* _tmp6_;
		_tmp6_ = schema;
		_tmp2_ = g_settings_schema_has_key (_tmp6_, "profile-on-good-battery");
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GSettings* _tmp7_;
		_tmp7_ = g_settings_new ("io.elementary.settings-daemon.power");
		_g_object_unref0 (power_power_mode_button_settings);
		power_power_mode_button_settings = _tmp7_;
	} else {
		g_critical ("PowerModeButton.vala:43: settings-daemon schema not found");
		power_power_mode_button_set_successfully_initialized (FALSE);
	}
	{
		PowerPowerProfile* _tmp8_ = NULL;
		PowerPowerProfile* _tmp9_;
		PowerPowerProfile* _tmp10_;
		_tmp9_ = (PowerPowerProfile*) g_initable_new (POWER_TYPE_POWER_PROFILE_PROXY, NULL, &_inner_error0_, "g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-name", POWER_POWER_PROFILES_DAEMON_NAME, "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", POWER_POWER_PROFILES_DAEMON_PATH, "g-interface-name", "net.hadess.PowerProfiles", NULL);
		_tmp8_ = (PowerPowerProfile*) _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp10_ = _tmp8_;
		_tmp8_ = NULL;
		_g_object_unref0 (power_power_mode_button_pprofile);
		power_power_mode_button_pprofile = _tmp10_;
		_g_object_unref0 (_tmp8_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp11_;
		const gchar* _tmp12_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp11_ = e;
		_tmp12_ = _tmp11_->message;
		g_critical ("PowerModeButton.vala:50: %s", _tmp12_);
		power_power_mode_button_set_successfully_initialized (FALSE);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_settings_schema_unref0 (schema);
		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_);
	}
	_g_settings_schema_unref0 (schema);
}

static void
power_power_mode_button_instance_init (PowerPowerModeButton * self,
                                       gpointer klass)
{
	self->priv = power_power_mode_button_get_instance_private (self);
}

static void
power_power_mode_button_finalize (GObject * obj)
{
	PowerPowerModeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, POWER_TYPE_POWER_MODE_BUTTON, PowerPowerModeButton);
	_g_free0 (self->priv->_settings_key);
	_g_object_unref0 (self->priv->saver_radio);
	_g_object_unref0 (self->priv->balanced_radio);
	_g_object_unref0 (self->priv->performance_radio);
	G_OBJECT_CLASS (power_power_mode_button_parent_class)->finalize (obj);
}

static GType
power_power_mode_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PowerPowerModeButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) power_power_mode_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PowerPowerModeButton), 0, (GInstanceInitFunc) power_power_mode_button_instance_init, NULL };
	GType power_power_mode_button_type_id;
	power_power_mode_button_type_id = g_type_register_static (gtk_box_get_type (), "PowerPowerModeButton", &g_define_type_info, 0);
	PowerPowerModeButton_private_offset = g_type_add_instance_private (power_power_mode_button_type_id, sizeof (PowerPowerModeButtonPrivate));
	return power_power_mode_button_type_id;
}

GType
power_power_mode_button_get_type (void)
{
	static volatile gsize power_power_mode_button_type_id__once = 0;
	if (g_once_init_enter (&power_power_mode_button_type_id__once)) {
		GType power_power_mode_button_type_id;
		power_power_mode_button_type_id = power_power_mode_button_get_type_once ();
		g_once_init_leave (&power_power_mode_button_type_id__once, power_power_mode_button_type_id);
	}
	return power_power_mode_button_type_id__once;
}

static void
_vala_power_power_mode_button_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	PowerPowerModeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, POWER_TYPE_POWER_MODE_BUTTON, PowerPowerModeButton);
	switch (property_id) {
		case POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY:
		g_value_set_string (value, power_power_mode_button_get_settings_key (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_power_power_mode_button_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	PowerPowerModeButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, POWER_TYPE_POWER_MODE_BUTTON, PowerPowerModeButton);
	switch (property_id) {
		case POWER_POWER_MODE_BUTTON_SETTINGS_KEY_PROPERTY:
		power_power_mode_button_set_settings_key (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

