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

/*
vattery
copyright 2011 jezra lickter http://www.jezra.net

vattery 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 3 of the License, or
(at your option) any later version.

vattery 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 vattery.	If not, see <http://www.gnu.org/licenses/>.

*/

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <stdio.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <float.h>
#include <math.h>
#include <config.h>
#include <gobject/gvaluecollector.h>


#define TYPE_MAIN_CONTROLLER (main_controller_get_type ())
#define MAIN_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_MAIN_CONTROLLER, main_controller))
#define MAIN_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_MAIN_CONTROLLER, main_controllerClass))
#define IS_MAIN_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_MAIN_CONTROLLER))
#define IS_MAIN_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_MAIN_CONTROLLER))
#define MAIN_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_MAIN_CONTROLLER, main_controllerClass))

typedef struct _main_controller main_controller;
typedef struct _main_controllerClass main_controllerClass;
typedef struct _main_controllerPrivate main_controllerPrivate;

#define TYPE_ICON_MENU (icon_menu_get_type ())
#define ICON_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ICON_MENU, IconMenu))
#define ICON_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ICON_MENU, IconMenuClass))
#define IS_ICON_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ICON_MENU))
#define IS_ICON_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ICON_MENU))
#define ICON_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ICON_MENU, IconMenuClass))

typedef struct _IconMenu IconMenu;
typedef struct _IconMenuClass IconMenuClass;

#define TYPE_CONFIGURATION (configuration_get_type ())
#define CONFIGURATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIGURATION, Configuration))
#define CONFIGURATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIGURATION, ConfigurationClass))
#define IS_CONFIGURATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIGURATION))
#define IS_CONFIGURATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIGURATION))
#define CONFIGURATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIGURATION, ConfigurationClass))

typedef struct _Configuration Configuration;
typedef struct _ConfigurationClass ConfigurationClass;

#define TYPE_BATTERY (battery_get_type ())
#define BATTERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BATTERY, Battery))
#define BATTERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BATTERY, BatteryClass))
#define IS_BATTERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BATTERY))
#define IS_BATTERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BATTERY))
#define BATTERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BATTERY, BatteryClass))

typedef struct _Battery Battery;
typedef struct _BatteryClass BatteryClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _configuration_unref0(var) ((var == NULL) ? NULL : (var = (configuration_unref (var), NULL)))
#define _battery_unref0(var) ((var == NULL) ? NULL : (var = (battery_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define TYPE_PREFERENCES (preferences_get_type ())
#define PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PREFERENCES, Preferences))
#define PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PREFERENCES, PreferencesClass))
#define IS_PREFERENCES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PREFERENCES))
#define IS_PREFERENCES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PREFERENCES))
#define PREFERENCES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PREFERENCES, PreferencesClass))

typedef struct _Preferences Preferences;
typedef struct _PreferencesClass PreferencesClass;

#define TYPE_BATTERY_DATA (battery_data_get_type ())
typedef struct _BatteryData BatteryData;
#define _main_controller_unref0(var) ((var == NULL) ? NULL : (var = (main_controller_unref (var), NULL)))
typedef struct _ParamSpecmain_controller ParamSpecmain_controller;

struct _main_controller {
	GTypeInstance parent_instance;
	volatile int ref_count;
	main_controllerPrivate * priv;
};

struct _main_controllerClass {
	GTypeClass parent_class;
	void (*finalize) (main_controller *self);
};

struct _main_controllerPrivate {
	GtkStatusIcon* si;
	gchar* app_name;
	gchar* app_version;
	gint bat_percent;
	gchar* ac_state;
	gchar* color_draining;
	gchar* color_charging;
	gchar* color_charged;
	gchar* color_background;
	gchar* color_border;
	gchar* color_text;
	gchar* percent_warning;
	gchar* percent_critical;
	gchar* command_warning;
	gchar* command_critical;
	gboolean text_mode;
	gboolean displaying_preferences;
	gboolean triggered_warning;
	gboolean triggered_critical;
	IconMenu* iconMenu;
	Configuration* config;
	Battery* battery;
};

typedef enum  {
	CONFIG_ERROR_CREATE_DIR_FAILED,
	CONFIG_ERROR_FILE_NOT_FOUND,
	CONFIG_ERROR_DOCUMENT_EMPTY,
	CONFIG_ERROR_READ_FAILED,
	CONFIG_ERROR_WRITE_FAILED,
	CONFIG_ERROR_NO_KEY_VALUE
} ConfigError;
#define CONFIG_ERROR config_error_quark ()
struct _BatteryData {
	gint percent;
	gchar* state;
};

struct _ParamSpecmain_controller {
	GParamSpec parent_instance;
};


static gpointer main_controller_parent_class = NULL;

gpointer main_controller_ref (gpointer instance);
void main_controller_unref (gpointer instance);
GParamSpec* param_spec_main_controller (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_main_controller (GValue* value, gpointer v_object);
void value_take_main_controller (GValue* value, gpointer v_object);
gpointer value_get_main_controller (const GValue* value);
GType main_controller_get_type (void) G_GNUC_CONST;
GType icon_menu_get_type (void) G_GNUC_CONST;
gpointer configuration_ref (gpointer instance);
void configuration_unref (gpointer instance);
GParamSpec* param_spec_configuration (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_configuration (GValue* value, gpointer v_object);
void value_take_configuration (GValue* value, gpointer v_object);
gpointer value_get_configuration (const GValue* value);
GType configuration_get_type (void) G_GNUC_CONST;
gpointer battery_ref (gpointer instance);
void battery_unref (gpointer instance);
GParamSpec* param_spec_battery (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void value_set_battery (GValue* value, gpointer v_object);
void value_take_battery (GValue* value, gpointer v_object);
gpointer value_get_battery (const GValue* value);
GType battery_get_type (void) G_GNUC_CONST;
#define MAIN_CONTROLLER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_MAIN_CONTROLLER, main_controllerPrivate))
enum  {
	MAIN_CONTROLLER_DUMMY_PROPERTY
};
main_controller* main_controller_new (const gchar* name, const gchar* version);
main_controller* main_controller_construct (GType object_type, const gchar* name, const gchar* version);
Configuration* configuration_new (const gchar* config_file_path);
Configuration* configuration_construct (GType object_type, const gchar* config_file_path);
gchar* configuration_get_value (Configuration* self, const gchar* group, const gchar* key);
void configuration_set_key_value (Configuration* self, const gchar* group, const gchar* key, const gchar* val);
gboolean configuration_get_boolean_value (Configuration* self, const gchar* group, const gchar* key);
GQuark config_error_quark (void);
void configuration_save_config (Configuration* self, GError** error);
Battery* battery_new (void);
Battery* battery_construct (GType object_type);
static void __lambda4_ (main_controller* self, GtkStatusIcon* source, guint button, guint time);
static void main_controller_status_icon_menu (main_controller* self, guint button, guint time);
static void ___lambda4__gtk_status_icon_popup_menu (GtkStatusIcon* _sender, guint button, guint activate_time, gpointer self);
IconMenu* icon_menu_new (void);
IconMenu* icon_menu_construct (GType object_type);
static void main_controller_display_about_dialog (main_controller* self);
static void _main_controller_display_about_dialog_icon_menu_show_about (IconMenu* _sender, gpointer self);
static void main_controller_display_preferences_dialog (main_controller* self);
static void _main_controller_display_preferences_dialog_icon_menu_show_preferences (IconMenu* _sender, gpointer self);
static gboolean main_controller_get_battery_status (main_controller* self);
static gboolean _main_controller_get_battery_status_gsource_func (gpointer self);
static void main_controller_preferences_destroyed (main_controller* self);
Preferences* preferences_new (void);
Preferences* preferences_construct (GType object_type);
GType preferences_get_type (void) G_GNUC_CONST;
void preferences_set_colors (Preferences* self, const gchar* charging, const gchar* charged, const gchar* draining, const gchar* border, const gchar* background);
void preferences_set_warnings (Preferences* self, const gchar* wp, const gchar* wc, const gchar* cp, const gchar* cc);
void preferences_set_text_mode (Preferences* self, gboolean mode);
static void _main_controller_preferences_destroyed_preferences_gui_destroyed (Preferences* _sender, gpointer self);
static void ___lambda5_ (main_controller* self, GdkColor* charge, GdkColor* charged, GdkColor* drain, GdkColor* border, GdkColor* background, const gchar* wp, const gchar* wc, const gchar* cp, const gchar* cc, gboolean m);
static void main_controller_update_and_save_preferences (main_controller* self, GdkColor* charging, GdkColor* charged, GdkColor* draining, GdkColor* border, GdkColor* background, const gchar* pw, const gchar* cw, const gchar* pc, const gchar* cc, gboolean mode);
static void ____lambda5__preferences_emit_preferences (Preferences* _sender, GdkColor* charge, GdkColor* charged, GdkColor* drain, GdkColor* border, GdkColor* background, const gchar* wp, const gchar* wc, const gchar* cp, const gchar* cc, gboolean text_mode, gpointer self);
void preferences_display (Preferences* self);
static gchar* main_controller_hex_color (main_controller* self, GdkColor* c);
static void main_controller_update_status_icon (main_controller* self);
static void main_controller_run (main_controller* self);
static void main_controller_set_tooltip_text (main_controller* self, const gchar* str);
static void main_controller_die (main_controller* self, const gchar* str);
GType battery_data_get_type (void) G_GNUC_CONST;
BatteryData* battery_data_dup (const BatteryData* self);
void battery_data_free (BatteryData* self);
void battery_data_copy (const BatteryData* self, BatteryData* dest);
void battery_data_destroy (BatteryData* self);
void battery_get_status (Battery* self, BatteryData* result);
static void main_controller_check_triggers (main_controller* self);
void main_controller_do_command (main_controller* self, const gchar* raw_command);
static void main_controller_main (gchar** args, int args_length1);
static void main_controller_finalize (main_controller* obj);


static void __lambda4_ (main_controller* self, GtkStatusIcon* source, guint button, guint time) {
	guint _tmp0_;
	guint _tmp1_;
	g_return_if_fail (source != NULL);
	_tmp0_ = button;
	_tmp1_ = time;
	main_controller_status_icon_menu (self, _tmp0_, _tmp1_);
}


static void ___lambda4__gtk_status_icon_popup_menu (GtkStatusIcon* _sender, guint button, guint activate_time, gpointer self) {
	__lambda4_ (self, _sender, button, activate_time);
}


static void _main_controller_display_about_dialog_icon_menu_show_about (IconMenu* _sender, gpointer self) {
	main_controller_display_about_dialog (self);
}


static void _main_controller_display_preferences_dialog_icon_menu_show_preferences (IconMenu* _sender, gpointer self) {
	main_controller_display_preferences_dialog (self);
}


static gboolean _main_controller_get_battery_status_gsource_func (gpointer self) {
	gboolean result;
	result = main_controller_get_battery_status (self);
	return result;
}


main_controller* main_controller_construct (GType object_type, const gchar* name, const gchar* version) {
	main_controller* self = NULL;
	gboolean color_changed;
	gboolean percent_command_changed;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_ = NULL;
	gchar* _tmp13_;
	const gchar* _tmp14_ = NULL;
	gchar* _tmp15_;
	const gchar* _tmp16_ = NULL;
	const gchar* _tmp17_;
	gchar* _tmp18_ = NULL;
	gchar* config_file_path;
	const gchar* _tmp19_;
	Configuration* _tmp20_;
	Configuration* _tmp21_;
	gchar* _tmp22_ = NULL;
	gchar* color_charging;
	const gchar* _tmp23_;
	Configuration* _tmp28_;
	gchar* _tmp29_ = NULL;
	gchar* color_charged;
	const gchar* _tmp30_;
	Configuration* _tmp35_;
	gchar* _tmp36_ = NULL;
	gchar* color_draining;
	const gchar* _tmp37_;
	Configuration* _tmp42_;
	gchar* _tmp43_ = NULL;
	gchar* color_background;
	const gchar* _tmp44_;
	Configuration* _tmp49_;
	gchar* _tmp50_ = NULL;
	gchar* color_border;
	const gchar* _tmp51_;
	Configuration* _tmp56_;
	gchar* _tmp57_ = NULL;
	gchar* color_text;
	const gchar* _tmp58_;
	Configuration* _tmp63_;
	gboolean _tmp64_ = FALSE;
	gboolean _tmp65_;
	Configuration* _tmp67_;
	gchar* _tmp68_ = NULL;
	gchar* warn_percent;
	const gchar* _tmp69_;
	Configuration* _tmp74_;
	gchar* _tmp75_ = NULL;
	gchar* warn_command;
	const gchar* _tmp76_;
	Configuration* _tmp81_;
	gchar* _tmp82_ = NULL;
	gchar* crit_percent;
	const gchar* _tmp83_;
	Configuration* _tmp88_;
	gchar* _tmp89_ = NULL;
	gchar* crit_command;
	const gchar* _tmp90_;
	gboolean _tmp95_ = FALSE;
	gboolean _tmp96_;
	gboolean _tmp98_;
	Battery* _tmp103_;
	GtkStatusIcon* _tmp104_;
	GtkStatusIcon* _tmp105_;
	IconMenu* _tmp106_;
	IconMenu* _tmp107_;
	IconMenu* _tmp108_;
	IconMenu* _tmp109_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (version != NULL, NULL);
	self = (main_controller*) g_type_create_instance (object_type);
	color_changed = FALSE;
	percent_command_changed = FALSE;
	_tmp0_ = name;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->app_name);
	self->priv->app_name = _tmp1_;
	_tmp2_ = version;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->app_version);
	self->priv->app_version = _tmp3_;
	self->priv->displaying_preferences = FALSE;
	self->priv->triggered_warning = FALSE;
	self->priv->triggered_critical = FALSE;
	_tmp4_ = g_strdup ("#0000ff");
	_g_free0 (self->priv->color_charging);
	self->priv->color_charging = _tmp4_;
	_tmp5_ = g_strdup ("#ff0000");
	_g_free0 (self->priv->color_draining);
	self->priv->color_draining = _tmp5_;
	_tmp6_ = g_strdup ("#ffffff");
	_g_free0 (self->priv->color_background);
	self->priv->color_background = _tmp6_;
	_tmp7_ = g_strdup ("#00ff00");
	_g_free0 (self->priv->color_charged);
	self->priv->color_charged = _tmp7_;
	_tmp8_ = g_strdup ("#000000");
	_g_free0 (self->priv->color_border);
	self->priv->color_border = _tmp8_;
	_tmp9_ = g_strdup ("#000000");
	_g_free0 (self->priv->color_text);
	self->priv->color_text = _tmp9_;
	self->priv->text_mode = FALSE;
	_tmp10_ = g_strdup ("15");
	_g_free0 (self->priv->percent_warning);
	self->priv->percent_warning = _tmp10_;
	_tmp11_ = g_strdup ("5");
	_g_free0 (self->priv->percent_critical);
	self->priv->percent_critical = _tmp11_;
	_tmp12_ = _ ("battery is very low");
	_tmp13_ = g_strconcat ("xmessage ", _tmp12_, NULL);
	_g_free0 (self->priv->command_warning);
	self->priv->command_warning = _tmp13_;
	_tmp14_ = _ ("battery is critically low");
	_tmp15_ = g_strconcat ("xmessage ", _tmp14_, NULL);
	_g_free0 (self->priv->command_critical);
	self->priv->command_critical = _tmp15_;
	_tmp16_ = g_get_user_config_dir ();
	_tmp17_ = name;
	_tmp18_ = g_build_filename (_tmp16_, _tmp17_, "config", NULL);
	config_file_path = _tmp18_;
	_tmp19_ = config_file_path;
	_tmp20_ = configuration_new (_tmp19_);
	_configuration_unref0 (self->priv->config);
	self->priv->config = _tmp20_;
	_tmp21_ = self->priv->config;
	_tmp22_ = configuration_get_value (_tmp21_, "colors", "charging");
	color_charging = _tmp22_;
	_tmp23_ = color_charging;
	if (_tmp23_ != NULL) {
		const gchar* _tmp24_;
		gchar* _tmp25_;
		_tmp24_ = color_charging;
		_tmp25_ = g_strdup (_tmp24_);
		_g_free0 (self->priv->color_charging);
		self->priv->color_charging = _tmp25_;
	} else {
		Configuration* _tmp26_;
		const gchar* _tmp27_;
		_tmp26_ = self->priv->config;
		_tmp27_ = self->priv->color_charging;
		configuration_set_key_value (_tmp26_, "colors", "charging", _tmp27_);
		color_changed = TRUE;
	}
	_tmp28_ = self->priv->config;
	_tmp29_ = configuration_get_value (_tmp28_, "colors", "charged");
	color_charged = _tmp29_;
	_tmp30_ = color_charged;
	if (_tmp30_ != NULL) {
		const gchar* _tmp31_;
		gchar* _tmp32_;
		_tmp31_ = color_charged;
		_tmp32_ = g_strdup (_tmp31_);
		_g_free0 (self->priv->color_charged);
		self->priv->color_charged = _tmp32_;
	} else {
		Configuration* _tmp33_;
		const gchar* _tmp34_;
		_tmp33_ = self->priv->config;
		_tmp34_ = self->priv->color_charged;
		configuration_set_key_value (_tmp33_, "colors", "charged", _tmp34_);
		color_changed = TRUE;
	}
	_tmp35_ = self->priv->config;
	_tmp36_ = configuration_get_value (_tmp35_, "colors", "draining");
	color_draining = _tmp36_;
	_tmp37_ = color_draining;
	if (_tmp37_ != NULL) {
		const gchar* _tmp38_;
		gchar* _tmp39_;
		_tmp38_ = color_draining;
		_tmp39_ = g_strdup (_tmp38_);
		_g_free0 (self->priv->color_draining);
		self->priv->color_draining = _tmp39_;
	} else {
		Configuration* _tmp40_;
		const gchar* _tmp41_;
		_tmp40_ = self->priv->config;
		_tmp41_ = self->priv->color_draining;
		configuration_set_key_value (_tmp40_, "colors", "draining", _tmp41_);
		color_changed = TRUE;
	}
	_tmp42_ = self->priv->config;
	_tmp43_ = configuration_get_value (_tmp42_, "colors", "background");
	color_background = _tmp43_;
	_tmp44_ = color_background;
	if (_tmp44_ != NULL) {
		const gchar* _tmp45_;
		gchar* _tmp46_;
		_tmp45_ = color_background;
		_tmp46_ = g_strdup (_tmp45_);
		_g_free0 (self->priv->color_background);
		self->priv->color_background = _tmp46_;
	} else {
		Configuration* _tmp47_;
		const gchar* _tmp48_;
		_tmp47_ = self->priv->config;
		_tmp48_ = self->priv->color_background;
		configuration_set_key_value (_tmp47_, "colors", "background", _tmp48_);
		color_changed = TRUE;
	}
	_tmp49_ = self->priv->config;
	_tmp50_ = configuration_get_value (_tmp49_, "colors", "border");
	color_border = _tmp50_;
	_tmp51_ = color_border;
	if (_tmp51_ != NULL) {
		const gchar* _tmp52_;
		gchar* _tmp53_;
		_tmp52_ = color_border;
		_tmp53_ = g_strdup (_tmp52_);
		_g_free0 (self->priv->color_border);
		self->priv->color_border = _tmp53_;
	} else {
		Configuration* _tmp54_;
		const gchar* _tmp55_;
		_tmp54_ = self->priv->config;
		_tmp55_ = self->priv->color_border;
		configuration_set_key_value (_tmp54_, "colors", "border", _tmp55_);
		color_changed = TRUE;
	}
	_tmp56_ = self->priv->config;
	_tmp57_ = configuration_get_value (_tmp56_, "colors", "text");
	color_text = _tmp57_;
	_tmp58_ = color_text;
	if (_tmp58_ != NULL) {
		const gchar* _tmp59_;
		gchar* _tmp60_;
		_tmp59_ = color_text;
		_tmp60_ = g_strdup (_tmp59_);
		_g_free0 (self->priv->color_text);
		self->priv->color_text = _tmp60_;
	} else {
		Configuration* _tmp61_;
		const gchar* _tmp62_;
		_tmp61_ = self->priv->config;
		_tmp62_ = self->priv->color_text;
		configuration_set_key_value (_tmp61_, "colors", "text", _tmp62_);
		color_changed = TRUE;
	}
	_tmp63_ = self->priv->config;
	_tmp64_ = configuration_get_boolean_value (_tmp63_, "mode", "text");
	self->priv->text_mode = _tmp64_;
	_tmp65_ = self->priv->text_mode;
	if (_tmp65_) {
	} else {
		Configuration* _tmp66_;
		_tmp66_ = self->priv->config;
		configuration_set_key_value (_tmp66_, "mode", "text", "false");
	}
	_tmp67_ = self->priv->config;
	_tmp68_ = configuration_get_value (_tmp67_, "percents", "warning");
	warn_percent = _tmp68_;
	_tmp69_ = warn_percent;
	if (_tmp69_ != NULL) {
		const gchar* _tmp70_;
		gchar* _tmp71_;
		_tmp70_ = warn_percent;
		_tmp71_ = g_strdup (_tmp70_);
		_g_free0 (self->priv->percent_warning);
		self->priv->percent_warning = _tmp71_;
	} else {
		Configuration* _tmp72_;
		const gchar* _tmp73_;
		_tmp72_ = self->priv->config;
		_tmp73_ = self->priv->percent_warning;
		configuration_set_key_value (_tmp72_, "percents", "warning", _tmp73_);
		percent_command_changed = TRUE;
	}
	_tmp74_ = self->priv->config;
	_tmp75_ = configuration_get_value (_tmp74_, "commands", "warning");
	warn_command = _tmp75_;
	_tmp76_ = warn_command;
	if (_tmp76_ != NULL) {
		const gchar* _tmp77_;
		gchar* _tmp78_;
		_tmp77_ = warn_command;
		_tmp78_ = g_strdup (_tmp77_);
		_g_free0 (self->priv->command_warning);
		self->priv->command_warning = _tmp78_;
	} else {
		Configuration* _tmp79_;
		const gchar* _tmp80_;
		_tmp79_ = self->priv->config;
		_tmp80_ = self->priv->command_warning;
		configuration_set_key_value (_tmp79_, "commands", "warning", _tmp80_);
		percent_command_changed = TRUE;
	}
	_tmp81_ = self->priv->config;
	_tmp82_ = configuration_get_value (_tmp81_, "percents", "critical");
	crit_percent = _tmp82_;
	_tmp83_ = crit_percent;
	if (_tmp83_ != NULL) {
		const gchar* _tmp84_;
		gchar* _tmp85_;
		_tmp84_ = crit_percent;
		_tmp85_ = g_strdup (_tmp84_);
		_g_free0 (self->priv->percent_critical);
		self->priv->percent_critical = _tmp85_;
	} else {
		Configuration* _tmp86_;
		const gchar* _tmp87_;
		_tmp86_ = self->priv->config;
		_tmp87_ = self->priv->percent_critical;
		configuration_set_key_value (_tmp86_, "percents", "critical", _tmp87_);
		percent_command_changed = TRUE;
	}
	_tmp88_ = self->priv->config;
	_tmp89_ = configuration_get_value (_tmp88_, "commands", "critical");
	crit_command = _tmp89_;
	_tmp90_ = crit_command;
	if (_tmp90_ != NULL) {
		const gchar* _tmp91_;
		gchar* _tmp92_;
		_tmp91_ = crit_command;
		_tmp92_ = g_strdup (_tmp91_);
		_g_free0 (self->priv->command_critical);
		self->priv->command_critical = _tmp92_;
	} else {
		Configuration* _tmp93_;
		const gchar* _tmp94_;
		_tmp93_ = self->priv->config;
		_tmp94_ = self->priv->command_critical;
		configuration_set_key_value (_tmp93_, "commands", "critical", _tmp94_);
		percent_command_changed = TRUE;
	}
	_tmp96_ = color_changed;
	if (_tmp96_) {
		_tmp95_ = TRUE;
	} else {
		gboolean _tmp97_;
		_tmp97_ = percent_command_changed;
		_tmp95_ = _tmp97_;
	}
	_tmp98_ = _tmp95_;
	if (_tmp98_) {
		{
			Configuration* _tmp99_;
			_tmp99_ = self->priv->config;
			configuration_save_config (_tmp99_, &_inner_error_);
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == CONFIG_ERROR) {
					goto __catch0_config_error;
				}
				_g_free0 (crit_command);
				_g_free0 (crit_percent);
				_g_free0 (warn_command);
				_g_free0 (warn_percent);
				_g_free0 (color_text);
				_g_free0 (color_border);
				_g_free0 (color_background);
				_g_free0 (color_draining);
				_g_free0 (color_charged);
				_g_free0 (color_charging);
				_g_free0 (config_file_path);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return NULL;
			}
		}
		goto __finally0;
		__catch0_config_error:
		{
			GError* err = NULL;
			FILE* _tmp100_;
			GError* _tmp101_;
			const gchar* _tmp102_;
			err = _inner_error_;
			_inner_error_ = NULL;
			_tmp100_ = stderr;
			_tmp101_ = err;
			_tmp102_ = _tmp101_->message;
			fprintf (_tmp100_, "%s", _tmp102_);
			_g_error_free0 (err);
		}
		__finally0:
		if (_inner_error_ != NULL) {
			_g_free0 (crit_command);
			_g_free0 (crit_percent);
			_g_free0 (warn_command);
			_g_free0 (warn_percent);
			_g_free0 (color_text);
			_g_free0 (color_border);
			_g_free0 (color_background);
			_g_free0 (color_draining);
			_g_free0 (color_charged);
			_g_free0 (color_charging);
			_g_free0 (config_file_path);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	_tmp103_ = battery_new ();
	_battery_unref0 (self->priv->battery);
	self->priv->battery = _tmp103_;
	_tmp104_ = gtk_status_icon_new ();
	_g_object_unref0 (self->priv->si);
	self->priv->si = _tmp104_;
	_tmp105_ = self->priv->si;
	g_signal_connect (_tmp105_, "popup-menu", (GCallback) ___lambda4__gtk_status_icon_popup_menu, self);
	_tmp106_ = icon_menu_new ();
	_tmp107_ = g_object_ref_sink (_tmp106_);
	_g_object_unref0 (self->priv->iconMenu);
	self->priv->iconMenu = _tmp107_;
	_tmp108_ = self->priv->iconMenu;
	g_signal_connect (_tmp108_, "show-about", (GCallback) _main_controller_display_about_dialog_icon_menu_show_about, self);
	_tmp109_ = self->priv->iconMenu;
	g_signal_connect (_tmp109_, "show-preferences", (GCallback) _main_controller_display_preferences_dialog_icon_menu_show_preferences, self);
	g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 2000, _main_controller_get_battery_status_gsource_func, main_controller_ref (self), main_controller_unref);
	main_controller_get_battery_status (self);
	_g_free0 (crit_command);
	_g_free0 (crit_percent);
	_g_free0 (warn_command);
	_g_free0 (warn_percent);
	_g_free0 (color_text);
	_g_free0 (color_border);
	_g_free0 (color_background);
	_g_free0 (color_draining);
	_g_free0 (color_charged);
	_g_free0 (color_charging);
	_g_free0 (config_file_path);
	return self;
}


main_controller* main_controller_new (const gchar* name, const gchar* version) {
	return main_controller_construct (TYPE_MAIN_CONTROLLER, name, version);
}


static void main_controller_preferences_destroyed (main_controller* self) {
	g_return_if_fail (self != NULL);
	self->priv->displaying_preferences = FALSE;
}


static void _main_controller_preferences_destroyed_preferences_gui_destroyed (Preferences* _sender, gpointer self) {
	main_controller_preferences_destroyed (self);
}


static void ___lambda5_ (main_controller* self, GdkColor* charge, GdkColor* charged, GdkColor* drain, GdkColor* border, GdkColor* background, const gchar* wp, const gchar* wc, const gchar* cp, const gchar* cc, gboolean m) {
	GdkColor _tmp0_;
	GdkColor _tmp1_;
	GdkColor _tmp2_;
	GdkColor _tmp3_;
	GdkColor _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gboolean _tmp9_;
	g_return_if_fail (charge != NULL);
	g_return_if_fail (charged != NULL);
	g_return_if_fail (drain != NULL);
	g_return_if_fail (border != NULL);
	g_return_if_fail (background != NULL);
	g_return_if_fail (wp != NULL);
	g_return_if_fail (wc != NULL);
	g_return_if_fail (cp != NULL);
	g_return_if_fail (cc != NULL);
	_tmp0_ = *charge;
	_tmp1_ = *charged;
	_tmp2_ = *drain;
	_tmp3_ = *border;
	_tmp4_ = *background;
	_tmp5_ = wp;
	_tmp6_ = wc;
	_tmp7_ = cp;
	_tmp8_ = cc;
	_tmp9_ = m;
	main_controller_update_and_save_preferences (self, &_tmp0_, &_tmp1_, &_tmp2_, &_tmp3_, &_tmp4_, _tmp5_, _tmp6_, _tmp7_, _tmp8_, _tmp9_);
}


static void ____lambda5__preferences_emit_preferences (Preferences* _sender, GdkColor* charge, GdkColor* charged, GdkColor* drain, GdkColor* border, GdkColor* background, const gchar* wp, const gchar* wc, const gchar* cp, const gchar* cc, gboolean text_mode, gpointer self) {
	___lambda5_ (self, charge, charged, drain, border, background, wp, wc, cp, cc, text_mode);
}


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


static void main_controller_display_preferences_dialog (main_controller* self) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->displaying_preferences;
	if (!_tmp0_) {
		Preferences* _tmp1_;
		Preferences* _tmp2_;
		Preferences* preferences;
		Preferences* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		Preferences* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		Preferences* _tmp14_;
		gboolean _tmp15_;
		Preferences* _tmp16_;
		Preferences* _tmp17_;
		GtkStatusIcon* _tmp18_;
		GdkPixbuf* _tmp19_ = NULL;
		GdkPixbuf* _tmp20_;
		GdkPixbuf* pb;
		Preferences* _tmp21_;
		GdkPixbuf* _tmp22_;
		Preferences* _tmp23_;
		_tmp1_ = preferences_new ();
		_tmp2_ = g_object_ref_sink (_tmp1_);
		preferences = _tmp2_;
		self->priv->displaying_preferences = TRUE;
		_tmp3_ = preferences;
		_tmp4_ = self->priv->color_charging;
		_tmp5_ = self->priv->color_charged;
		_tmp6_ = self->priv->color_draining;
		_tmp7_ = self->priv->color_border;
		_tmp8_ = self->priv->color_background;
		preferences_set_colors (_tmp3_, _tmp4_, _tmp5_, _tmp6_, _tmp7_, _tmp8_);
		_tmp9_ = preferences;
		_tmp10_ = self->priv->percent_warning;
		_tmp11_ = self->priv->command_warning;
		_tmp12_ = self->priv->percent_critical;
		_tmp13_ = self->priv->command_critical;
		preferences_set_warnings (_tmp9_, _tmp10_, _tmp11_, _tmp12_, _tmp13_);
		_tmp14_ = preferences;
		_tmp15_ = self->priv->text_mode;
		preferences_set_text_mode (_tmp14_, _tmp15_);
		_tmp16_ = preferences;
		g_signal_connect (_tmp16_, "gui-destroyed", (GCallback) _main_controller_preferences_destroyed_preferences_gui_destroyed, self);
		_tmp17_ = preferences;
		g_signal_connect (_tmp17_, "emit-preferences", (GCallback) ____lambda5__preferences_emit_preferences, self);
		_tmp18_ = self->priv->si;
		_tmp19_ = gtk_status_icon_get_pixbuf (_tmp18_);
		_tmp20_ = _g_object_ref0 (_tmp19_);
		pb = _tmp20_;
		_tmp21_ = preferences;
		_tmp22_ = pb;
		gtk_window_set_icon ((GtkWindow*) _tmp21_, _tmp22_);
		_tmp23_ = preferences;
		preferences_display (_tmp23_);
		_g_object_unref0 (pb);
		_g_object_unref0 (preferences);
	}
}


static gchar* bool_to_string (gboolean self) {
	gchar* result = NULL;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}


static void main_controller_update_and_save_preferences (main_controller* self, GdkColor* charging, GdkColor* charged, GdkColor* draining, GdkColor* border, GdkColor* background, const gchar* pw, const gchar* cw, const gchar* pc, const gchar* cc, gboolean mode) {
	GdkColor _tmp0_;
	gchar* _tmp1_ = NULL;
	Configuration* _tmp2_;
	const gchar* _tmp3_;
	GdkColor _tmp4_;
	gchar* _tmp5_ = NULL;
	Configuration* _tmp6_;
	const gchar* _tmp7_;
	GdkColor _tmp8_;
	gchar* _tmp9_ = NULL;
	Configuration* _tmp10_;
	const gchar* _tmp11_;
	GdkColor _tmp12_;
	gchar* _tmp13_ = NULL;
	Configuration* _tmp14_;
	const gchar* _tmp15_;
	GdkColor _tmp16_;
	gchar* _tmp17_ = NULL;
	Configuration* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	gchar* _tmp21_;
	Configuration* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	gchar* _tmp25_;
	Configuration* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	Configuration* _tmp30_;
	const gchar* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	Configuration* _tmp34_;
	const gchar* _tmp35_;
	gboolean _tmp36_;
	Configuration* _tmp37_;
	gboolean _tmp38_;
	gchar* _tmp39_ = NULL;
	gchar* _tmp40_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (charging != NULL);
	g_return_if_fail (charged != NULL);
	g_return_if_fail (draining != NULL);
	g_return_if_fail (border != NULL);
	g_return_if_fail (background != NULL);
	g_return_if_fail (pw != NULL);
	g_return_if_fail (cw != NULL);
	g_return_if_fail (pc != NULL);
	g_return_if_fail (cc != NULL);
	_tmp0_ = *charging;
	_tmp1_ = main_controller_hex_color (self, &_tmp0_);
	_g_free0 (self->priv->color_charging);
	self->priv->color_charging = _tmp1_;
	_tmp2_ = self->priv->config;
	_tmp3_ = self->priv->color_charging;
	configuration_set_key_value (_tmp2_, "colors", "charging", _tmp3_);
	_tmp4_ = *charged;
	_tmp5_ = main_controller_hex_color (self, &_tmp4_);
	_g_free0 (self->priv->color_charged);
	self->priv->color_charged = _tmp5_;
	_tmp6_ = self->priv->config;
	_tmp7_ = self->priv->color_charged;
	configuration_set_key_value (_tmp6_, "colors", "charged", _tmp7_);
	_tmp8_ = *draining;
	_tmp9_ = main_controller_hex_color (self, &_tmp8_);
	_g_free0 (self->priv->color_draining);
	self->priv->color_draining = _tmp9_;
	_tmp10_ = self->priv->config;
	_tmp11_ = self->priv->color_draining;
	configuration_set_key_value (_tmp10_, "colors", "draining", _tmp11_);
	_tmp12_ = *border;
	_tmp13_ = main_controller_hex_color (self, &_tmp12_);
	_g_free0 (self->priv->color_border);
	self->priv->color_border = _tmp13_;
	_tmp14_ = self->priv->config;
	_tmp15_ = self->priv->color_border;
	configuration_set_key_value (_tmp14_, "colors", "border", _tmp15_);
	_tmp16_ = *background;
	_tmp17_ = main_controller_hex_color (self, &_tmp16_);
	_g_free0 (self->priv->color_background);
	self->priv->color_background = _tmp17_;
	_tmp18_ = self->priv->config;
	_tmp19_ = self->priv->color_background;
	configuration_set_key_value (_tmp18_, "colors", "background", _tmp19_);
	_tmp20_ = pw;
	_tmp21_ = g_strdup (_tmp20_);
	_g_free0 (self->priv->percent_warning);
	self->priv->percent_warning = _tmp21_;
	_tmp22_ = self->priv->config;
	_tmp23_ = self->priv->percent_warning;
	configuration_set_key_value (_tmp22_, "percents", "warning", _tmp23_);
	_tmp24_ = cw;
	_tmp25_ = g_strdup (_tmp24_);
	_g_free0 (self->priv->command_warning);
	self->priv->command_warning = _tmp25_;
	_tmp26_ = self->priv->config;
	_tmp27_ = self->priv->command_warning;
	configuration_set_key_value (_tmp26_, "commands", "warning", _tmp27_);
	_tmp28_ = pc;
	_tmp29_ = g_strdup (_tmp28_);
	_g_free0 (self->priv->percent_critical);
	self->priv->percent_critical = _tmp29_;
	_tmp30_ = self->priv->config;
	_tmp31_ = self->priv->percent_critical;
	configuration_set_key_value (_tmp30_, "percents", "critical", _tmp31_);
	_tmp32_ = cc;
	_tmp33_ = g_strdup (_tmp32_);
	_g_free0 (self->priv->command_critical);
	self->priv->command_critical = _tmp33_;
	_tmp34_ = self->priv->config;
	_tmp35_ = self->priv->command_critical;
	configuration_set_key_value (_tmp34_, "commands", "critical", _tmp35_);
	_tmp36_ = mode;
	self->priv->text_mode = _tmp36_;
	_tmp37_ = self->priv->config;
	_tmp38_ = mode;
	_tmp39_ = bool_to_string (_tmp38_);
	_tmp40_ = _tmp39_;
	configuration_set_key_value (_tmp37_, "mode", "text", _tmp40_);
	_g_free0 (_tmp40_);
	{
		Configuration* _tmp41_;
		_tmp41_ = self->priv->config;
		configuration_save_config (_tmp41_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == CONFIG_ERROR) {
				goto __catch1_config_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally1;
	__catch1_config_error:
	{
		GError* err = NULL;
		FILE* _tmp42_;
		GError* _tmp43_;
		const gchar* _tmp44_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp42_ = stderr;
		_tmp43_ = err;
		_tmp44_ = _tmp43_->message;
		fprintf (_tmp42_, "%s", _tmp44_);
		_g_error_free0 (err);
	}
	__finally1:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	main_controller_update_status_icon (self);
}


static void main_controller_display_about_dialog (main_controller* self) {
	GtkAboutDialog* _tmp0_;
	GtkAboutDialog* _tmp1_;
	GtkAboutDialog* aboutDialog;
	GtkStatusIcon* _tmp2_;
	GdkPixbuf* _tmp3_ = NULL;
	GdkPixbuf* _tmp4_;
	GdkPixbuf* pb;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkAboutDialog*) gtk_about_dialog_new ();
	_tmp1_ = g_object_ref_sink (_tmp0_);
	aboutDialog = _tmp1_;
	_tmp2_ = self->priv->si;
	_tmp3_ = gtk_status_icon_get_pixbuf (_tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	pb = _tmp4_;
	gtk_window_set_icon ((GtkWindow*) aboutDialog, pb);
	_tmp5_ = self->priv->app_name;
	gtk_about_dialog_set_program_name (aboutDialog, _tmp5_);
	_tmp6_ = self->priv->app_version;
	gtk_about_dialog_set_version (aboutDialog, _tmp6_);
	gtk_about_dialog_set_comments (aboutDialog, "A fairly simple battery monitor.");
	gtk_about_dialog_set_website (aboutDialog, "http://www.jezra.net/projects/vattery");
	gtk_about_dialog_set_copyright (aboutDialog, "©2011 Jezra J Lickter");
	gtk_widget_show_all ((GtkWidget*) aboutDialog);
	gtk_dialog_run ((GtkDialog*) aboutDialog);
	gtk_object_destroy ((GtkObject*) aboutDialog);
	_g_object_unref0 (pb);
	_g_object_unref0 (aboutDialog);
}


static void main_controller_run (main_controller* self) {
	g_return_if_fail (self != NULL);
	gtk_main ();
}


static void main_controller_status_icon_menu (main_controller* self, guint button, guint time) {
	IconMenu* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->iconMenu;
	_tmp1_ = button;
	_tmp2_ = time;
	gtk_menu_popup ((GtkMenu*) _tmp0_, NULL, NULL, NULL, NULL, _tmp1_, (guint32) _tmp2_);
}


static gchar string_get (const gchar* self, glong index) {
	gchar result = '\0';
	glong _tmp0_;
	gchar _tmp1_;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = index;
	_tmp1_ = ((gchar*) self)[_tmp0_];
	result = _tmp1_;
	return result;
}


static void main_controller_update_status_icon (main_controller* self) {
	GdkPixbufLoader* ploader = NULL;
	GdkPixbuf* pb = NULL;
	gchar* svg_str = NULL;
	gchar* frect_color = NULL;
	gdouble frect_y = 0.0;
	gdouble frect_height = 0.0;
	gdouble frect_x = 0.0;
	gdouble frect_width = 0.0;
	gdouble brect_x = 0.0;
	gdouble brect_width = 0.0;
	gint border_width;
	gdouble _tmp0_;
	gint _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	gboolean _tmp18_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	const gchar* _tmp48_;
	gint _tmp49_;
	gint _tmp50_;
	guchar* _tmp51_ = NULL;
	guchar* svg_data;
	gint svg_data_length1;
	gint _svg_data_size_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	border_width = 2;
	brect_width = (gdouble) 50;
	_tmp0_ = brect_width;
	_tmp1_ = border_width;
	frect_width = _tmp0_ - _tmp1_;
	_tmp2_ = brect_width;
	brect_x = (100 - _tmp2_) / 2;
	_tmp3_ = frect_width;
	frect_x = (100 - _tmp3_) / 2;
	_tmp4_ = self->priv->ac_state;
	if (g_strcmp0 (_tmp4_, "charging") == 0) {
		const gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = self->priv->color_charging;
		_tmp6_ = g_strdup (_tmp5_);
		_g_free0 (frect_color);
		frect_color = _tmp6_;
	} else {
		gboolean _tmp7_ = FALSE;
		const gchar* _tmp8_;
		gboolean _tmp10_;
		_tmp8_ = self->priv->ac_state;
		if (g_strcmp0 (_tmp8_, "charged") == 0) {
			_tmp7_ = TRUE;
		} else {
			gint _tmp9_;
			_tmp9_ = self->priv->bat_percent;
			_tmp7_ = _tmp9_ == 100;
		}
		_tmp10_ = _tmp7_;
		if (_tmp10_) {
			const gchar* _tmp11_;
			gchar* _tmp12_;
			_tmp11_ = self->priv->color_charged;
			_tmp12_ = g_strdup (_tmp11_);
			_g_free0 (frect_color);
			frect_color = _tmp12_;
		} else {
			const gchar* _tmp13_;
			gchar* _tmp14_;
			_tmp13_ = self->priv->color_draining;
			_tmp14_ = g_strdup (_tmp13_);
			_g_free0 (frect_color);
			frect_color = _tmp14_;
		}
	}
	_tmp15_ = g_strdup ("<?xml version=\"1.0\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C" \
"//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" \
"\">\n");
	_g_free0 (svg_str);
	svg_str = _tmp15_;
	_tmp16_ = svg_str;
	_tmp17_ = g_strconcat (_tmp16_, "<svg width=\"100px\" height=\"100px\" viewbox=\"0 0 200 200\" preserve" \
"AspectRatio=\"meet\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/sv" \
"g\">\n", NULL);
	_g_free0 (svg_str);
	svg_str = _tmp17_;
	_tmp18_ = self->priv->text_mode;
	if (_tmp18_) {
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		gint _tmp21_;
		gchar* _tmp22_ = NULL;
		gchar* _tmp23_;
		gchar* _tmp24_;
		_tmp19_ = svg_str;
		_tmp20_ = frect_color;
		_tmp21_ = self->priv->bat_percent;
		_tmp22_ = g_strdup_printf (" <text style=\"text-align:center;\" x=\"0\" y=\"65\" fill=\"%s\" font-" \
"size = \"40\">%d%</text>", _tmp20_, _tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = g_strconcat (_tmp19_, _tmp23_, NULL);
		_g_free0 (svg_str);
		svg_str = _tmp24_;
		_g_free0 (_tmp23_);
	} else {
		const gchar* _tmp25_;
		gdouble _tmp26_;
		gdouble _tmp27_;
		const gchar* _tmp28_;
		const gchar* _tmp29_;
		gint _tmp30_;
		gchar* _tmp31_ = NULL;
		gchar* _tmp32_;
		gchar* _tmp33_;
		gint _tmp34_;
		gint _tmp35_;
		gdouble _tmp36_;
		gint _tmp37_;
		const gchar* _tmp38_;
		gdouble _tmp39_;
		gdouble _tmp40_;
		gdouble _tmp41_;
		const gchar* _tmp42_;
		gchar* _tmp43_ = NULL;
		gchar* _tmp44_;
		gchar* _tmp45_;
		_tmp25_ = svg_str;
		_tmp26_ = brect_x;
		_tmp27_ = brect_width;
		_tmp28_ = self->priv->color_background;
		_tmp29_ = self->priv->color_border;
		_tmp30_ = border_width;
		_tmp31_ = g_strdup_printf ("<rect x=\"%.0f\" y=\"0\" width=\"%.0fpx\" height=\"100px\" fill=\"%s\"" \
" stroke=\"%s\" stroke-width=\"%i\"	/>\n", _tmp26_, _tmp27_, _tmp28_, _tmp29_, _tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = g_strconcat (_tmp25_, _tmp32_, NULL);
		_g_free0 (svg_str);
		svg_str = _tmp33_;
		_g_free0 (_tmp32_);
		_tmp34_ = self->priv->bat_percent;
		_tmp35_ = border_width;
		frect_height = (gdouble) (_tmp34_ - (_tmp35_ * 2));
		_tmp36_ = frect_height;
		_tmp37_ = border_width;
		frect_y = 100 - (_tmp36_ + (_tmp37_ / 2));
		_tmp38_ = svg_str;
		_tmp39_ = frect_x;
		_tmp40_ = frect_y;
		_tmp41_ = frect_height;
		_tmp42_ = frect_color;
		_tmp43_ = g_strdup_printf ("<rect x=\"%.0f\" y=\"%0.1f\" width=\"48px\" height=\"%0.1fpx\" fill=\"" \
"%s\" stroke-width=\"0\"	/>\n", _tmp39_, _tmp40_, _tmp41_, _tmp42_);
		_tmp44_ = _tmp43_;
		_tmp45_ = g_strconcat (_tmp38_, _tmp44_, NULL);
		_g_free0 (svg_str);
		svg_str = _tmp45_;
		_g_free0 (_tmp44_);
	}
	_tmp46_ = svg_str;
	_tmp47_ = g_strconcat (_tmp46_, "</svg>\n", NULL);
	_g_free0 (svg_str);
	svg_str = _tmp47_;
	_tmp48_ = svg_str;
	_tmp49_ = strlen (_tmp48_);
	_tmp50_ = _tmp49_;
	_tmp51_ = g_new0 (guchar, _tmp50_);
	svg_data = _tmp51_;
	svg_data_length1 = _tmp50_;
	_svg_data_size_ = svg_data_length1;
	{
		gint i;
		i = 0;
		{
			gboolean _tmp52_;
			_tmp52_ = TRUE;
			while (TRUE) {
				gboolean _tmp53_;
				gint _tmp55_;
				const gchar* _tmp56_;
				gint _tmp57_;
				gint _tmp58_;
				guchar* _tmp59_;
				gint _tmp59__length1;
				gint _tmp60_;
				const gchar* _tmp61_;
				gint _tmp62_;
				gchar _tmp63_ = '\0';
				guchar _tmp64_;
				_tmp53_ = _tmp52_;
				if (!_tmp53_) {
					gint _tmp54_;
					_tmp54_ = i;
					i = _tmp54_ + 1;
				}
				_tmp52_ = FALSE;
				_tmp55_ = i;
				_tmp56_ = svg_str;
				_tmp57_ = strlen (_tmp56_);
				_tmp58_ = _tmp57_;
				if (!(_tmp55_ < _tmp58_)) {
					break;
				}
				_tmp59_ = svg_data;
				_tmp59__length1 = svg_data_length1;
				_tmp60_ = i;
				_tmp61_ = svg_str;
				_tmp62_ = i;
				_tmp63_ = string_get (_tmp61_, (glong) _tmp62_);
				_tmp59_[_tmp60_] = (guchar) _tmp63_;
				_tmp64_ = _tmp59_[_tmp60_];
			}
		}
	}
	{
		GdkPixbufLoader* _tmp65_;
		GdkPixbufLoader* _tmp66_;
		GdkPixbufLoader* _tmp67_;
		guchar* _tmp68_;
		gint _tmp68__length1;
		GdkPixbufLoader* _tmp69_;
		GdkPixbufLoader* _tmp70_;
		GdkPixbuf* _tmp71_ = NULL;
		GdkPixbuf* _tmp72_;
		GtkStatusIcon* _tmp73_;
		GdkPixbuf* _tmp74_;
		gint _tmp75_;
		gchar* _tmp76_ = NULL;
		gchar* _tmp77_;
		_tmp65_ = gdk_pixbuf_loader_new_with_type ("svg", &_inner_error_);
		_tmp66_ = _tmp65_;
		if (_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		_g_object_unref0 (ploader);
		ploader = _tmp66_;
		_tmp67_ = ploader;
		_tmp68_ = svg_data;
		_tmp68__length1 = svg_data_length1;
		gdk_pixbuf_loader_write (_tmp67_, _tmp68_, (gsize) _tmp68__length1, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		_tmp69_ = ploader;
		gdk_pixbuf_loader_close (_tmp69_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch2_g_error;
		}
		_tmp70_ = ploader;
		_tmp71_ = gdk_pixbuf_loader_get_pixbuf (_tmp70_);
		_tmp72_ = _g_object_ref0 (_tmp71_);
		_g_object_unref0 (pb);
		pb = _tmp72_;
		_tmp73_ = self->priv->si;
		_tmp74_ = pb;
		gtk_status_icon_set_from_pixbuf (_tmp73_, _tmp74_);
		_tmp75_ = self->priv->bat_percent;
		_tmp76_ = g_strdup_printf ("%i%%", _tmp75_);
		_tmp77_ = _tmp76_;
		main_controller_set_tooltip_text (self, _tmp77_);
		_g_free0 (_tmp77_);
	}
	goto __finally2;
	__catch2_g_error:
	{
		GError* er = NULL;
		GError* _tmp78_;
		const gchar* _tmp79_;
		er = _inner_error_;
		_inner_error_ = NULL;
		_tmp78_ = er;
		_tmp79_ = _tmp78_->message;
		main_controller_die (self, _tmp79_);
		_g_error_free0 (er);
	}
	__finally2:
	if (_inner_error_ != NULL) {
		svg_data = (g_free (svg_data), NULL);
		_g_free0 (frect_color);
		_g_free0 (svg_str);
		_g_object_unref0 (pb);
		_g_object_unref0 (ploader);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	svg_data = (g_free (svg_data), NULL);
	_g_free0 (frect_color);
	_g_free0 (svg_str);
	_g_object_unref0 (pb);
	_g_object_unref0 (ploader);
}


static void main_controller_set_tooltip_text (main_controller* self, const gchar* str) {
	GtkStatusIcon* _tmp0_;
	const gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (str != NULL);
	_tmp0_ = self->priv->si;
	_tmp1_ = str;
	gtk_status_icon_set_tooltip_text (_tmp0_, _tmp1_);
}


static void main_controller_die (main_controller* self, const gchar* str) {
	FILE* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (str != NULL);
	_tmp0_ = stdout;
	_tmp1_ = self->priv->app_name;
	_tmp2_ = self->priv->app_version;
	_tmp3_ = str;
	fprintf (_tmp0_, "%s v%s: %s\n", _tmp1_, _tmp2_, _tmp3_);
	gtk_main_quit ();
}


static glong string_strnlen (gchar* str, glong maxlen) {
	glong result = 0L;
	gchar* _tmp0_;
	glong _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* end;
	gchar* _tmp3_;
	_tmp0_ = str;
	_tmp1_ = maxlen;
	_tmp2_ = memchr (_tmp0_, 0, (gsize) _tmp1_);
	end = _tmp2_;
	_tmp3_ = end;
	if (_tmp3_ == NULL) {
		glong _tmp4_;
		_tmp4_ = maxlen;
		result = _tmp4_;
		return result;
	} else {
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp5_ = end;
		_tmp6_ = str;
		result = (glong) (_tmp5_ - _tmp6_);
		return result;
	}
}


static gchar* string_substring (const gchar* self, glong offset, glong len) {
	gchar* result = NULL;
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	glong _tmp1_;
	gboolean _tmp3_;
	glong _tmp9_;
	glong _tmp15_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	glong _tmp22_;
	gchar* _tmp23_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = offset;
	if (_tmp1_ >= ((glong) 0)) {
		glong _tmp2_;
		_tmp2_ = len;
		_tmp0_ = _tmp2_ >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	_tmp3_ = _tmp0_;
	if (_tmp3_) {
		glong _tmp4_;
		glong _tmp5_;
		glong _tmp6_ = 0L;
		_tmp4_ = offset;
		_tmp5_ = len;
		_tmp6_ = string_strnlen ((gchar*) self, _tmp4_ + _tmp5_);
		string_length = _tmp6_;
	} else {
		gint _tmp7_;
		gint _tmp8_;
		_tmp7_ = strlen (self);
		_tmp8_ = _tmp7_;
		string_length = (glong) _tmp8_;
	}
	_tmp9_ = offset;
	if (_tmp9_ < ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		glong _tmp12_;
		_tmp10_ = string_length;
		_tmp11_ = offset;
		offset = _tmp10_ + _tmp11_;
		_tmp12_ = offset;
		g_return_val_if_fail (_tmp12_ >= ((glong) 0), NULL);
	} else {
		glong _tmp13_;
		glong _tmp14_;
		_tmp13_ = offset;
		_tmp14_ = string_length;
		g_return_val_if_fail (_tmp13_ <= _tmp14_, NULL);
	}
	_tmp15_ = len;
	if (_tmp15_ < ((glong) 0)) {
		glong _tmp16_;
		glong _tmp17_;
		_tmp16_ = string_length;
		_tmp17_ = offset;
		len = _tmp16_ - _tmp17_;
	}
	_tmp18_ = offset;
	_tmp19_ = len;
	_tmp20_ = string_length;
	g_return_val_if_fail ((_tmp18_ + _tmp19_) <= _tmp20_, NULL);
	_tmp21_ = offset;
	_tmp22_ = len;
	_tmp23_ = g_strndup (((gchar*) self) + _tmp21_, (gsize) _tmp22_);
	result = _tmp23_;
	return result;
}


static gchar* main_controller_hex_color (main_controller* self, GdkColor* c) {
	gchar* result = NULL;
	gchar* _tmp0_;
	gchar* ret;
	gchar* _tmp1_ = NULL;
	gchar* color;
	gchar* _tmp2_ = NULL;
	gchar* red;
	gchar* _tmp3_ = NULL;
	gchar* blue;
	gchar* _tmp4_ = NULL;
	gchar* green;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (c != NULL, NULL);
	_tmp0_ = g_strdup ("#");
	ret = _tmp0_;
	_tmp1_ = gdk_color_to_string (c);
	color = _tmp1_;
	_tmp2_ = string_substring (color, (glong) 1, (glong) 2);
	red = _tmp2_;
	_tmp3_ = string_substring (color, (glong) 5, (glong) 2);
	blue = _tmp3_;
	_tmp4_ = string_substring (color, (glong) 9, (glong) 2);
	green = _tmp4_;
	_tmp5_ = ret;
	_tmp6_ = g_strconcat (red, blue, NULL);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (_tmp7_, green, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp5_, _tmp9_, NULL);
	_g_free0 (ret);
	ret = _tmp10_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	result = ret;
	_g_free0 (green);
	_g_free0 (blue);
	_g_free0 (red);
	_g_free0 (color);
	return result;
}


static gboolean main_controller_get_battery_status (main_controller* self) {
	gboolean result = FALSE;
	gchar* ac_state = NULL;
	gint bat_percent = 0;
	Battery* _tmp0_;
	BatteryData _tmp1_ = {0};
	BatteryData data;
	BatteryData _tmp2_;
	gint _tmp3_;
	BatteryData _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	gint _tmp8_;
	gboolean _tmp10_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->battery;
	battery_get_status (_tmp0_, &_tmp1_);
	data = _tmp1_;
	_tmp2_ = data;
	_tmp3_ = _tmp2_.percent;
	bat_percent = _tmp3_;
	_tmp4_ = data;
	_tmp5_ = _tmp4_.state;
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (ac_state);
	ac_state = _tmp6_;
	_tmp8_ = bat_percent;
	if (_tmp8_ != 0) {
		const gchar* _tmp9_;
		_tmp9_ = ac_state;
		_tmp7_ = g_strcmp0 (_tmp9_, "NONE") != 0;
	} else {
		_tmp7_ = FALSE;
	}
	_tmp10_ = _tmp7_;
	if (_tmp10_) {
		gboolean _tmp11_ = FALSE;
		gint _tmp12_;
		gint _tmp13_;
		gboolean _tmp16_;
		_tmp12_ = bat_percent;
		_tmp13_ = self->priv->bat_percent;
		if (_tmp12_ != _tmp13_) {
			_tmp11_ = TRUE;
		} else {
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			_tmp14_ = ac_state;
			_tmp15_ = self->priv->ac_state;
			_tmp11_ = g_strcmp0 (_tmp14_, _tmp15_) != 0;
		}
		_tmp16_ = _tmp11_;
		if (_tmp16_) {
			gint _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
			_tmp17_ = bat_percent;
			self->priv->bat_percent = _tmp17_;
			_tmp18_ = ac_state;
			_tmp19_ = g_strdup (_tmp18_);
			_g_free0 (self->priv->ac_state);
			self->priv->ac_state = _tmp19_;
			main_controller_check_triggers (self);
			main_controller_update_status_icon (self);
		}
	} else {
		const gchar* _tmp20_ = NULL;
		_tmp20_ = _ ("No batteries where found");
		main_controller_set_tooltip_text (self, _tmp20_);
	}
	result = TRUE;
	battery_data_destroy (&data);
	_g_free0 (ac_state);
	return result;
}


static void main_controller_check_triggers (main_controller* self) {
	const gchar* _tmp0_;
	gint _tmp1_ = 0;
	gint wp;
	const gchar* _tmp2_;
	gint _tmp3_ = 0;
	gint cp;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->percent_warning;
	_tmp1_ = atoi (_tmp0_);
	wp = _tmp1_;
	_tmp2_ = self->priv->percent_critical;
	_tmp3_ = atoi (_tmp2_);
	cp = _tmp3_;
	_tmp4_ = self->priv->ac_state;
	if (g_strcmp0 (_tmp4_, "charging") == 0) {
		gint _tmp5_;
		gint _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		_tmp5_ = self->priv->bat_percent;
		_tmp6_ = wp;
		if (_tmp5_ >= _tmp6_) {
			self->priv->triggered_warning = FALSE;
		}
		_tmp7_ = self->priv->bat_percent;
		_tmp8_ = cp;
		if (_tmp7_ >= _tmp8_) {
			self->priv->triggered_critical = FALSE;
		}
	} else {
		gboolean _tmp9_ = FALSE;
		gint _tmp10_;
		gint _tmp11_;
		gboolean _tmp13_;
		gboolean _tmp15_ = FALSE;
		gint _tmp16_;
		gint _tmp17_;
		gboolean _tmp19_;
		_tmp10_ = self->priv->bat_percent;
		_tmp11_ = wp;
		if (_tmp10_ <= _tmp11_) {
			gboolean _tmp12_;
			_tmp12_ = self->priv->triggered_warning;
			_tmp9_ = _tmp12_ == FALSE;
		} else {
			_tmp9_ = FALSE;
		}
		_tmp13_ = _tmp9_;
		if (_tmp13_) {
			const gchar* _tmp14_;
			_tmp14_ = self->priv->command_warning;
			main_controller_do_command (self, _tmp14_);
			self->priv->triggered_warning = TRUE;
		}
		_tmp16_ = self->priv->bat_percent;
		_tmp17_ = cp;
		if (_tmp16_ <= _tmp17_) {
			gboolean _tmp18_;
			_tmp18_ = self->priv->triggered_critical;
			_tmp15_ = _tmp18_ == FALSE;
		} else {
			_tmp15_ = FALSE;
		}
		_tmp19_ = _tmp15_;
		if (_tmp19_) {
			const gchar* _tmp20_;
			_tmp20_ = self->priv->command_critical;
			main_controller_do_command (self, _tmp20_);
			self->priv->triggered_critical = TRUE;
		}
	}
}


static gchar* string_strip (const gchar* self) {
	gchar* result = NULL;
	gchar* _tmp0_ = NULL;
	gchar* _result_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	g_strstrip (_tmp1_);
	result = _result_;
	return result;
}


void main_controller_do_command (main_controller* self, const gchar* raw_command) {
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* command;
	const gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	gboolean _tmp5_ = FALSE;
	const gchar* _tmp6_;
	gboolean _tmp8_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (raw_command != NULL);
	_tmp0_ = raw_command;
	_tmp1_ = g_strdup (_tmp0_);
	command = _tmp1_;
	_tmp2_ = command;
	_tmp3_ = string_strip (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp4_);
	_tmp6_ = command;
	if (_tmp6_ == NULL) {
		_tmp5_ = TRUE;
	} else {
		const gchar* _tmp7_;
		_tmp7_ = command;
		_tmp5_ = g_strcmp0 (_tmp7_, "") == 0;
	}
	_tmp8_ = _tmp5_;
	if (_tmp8_) {
		_g_free0 (command);
		return;
	}
	{
		const gchar* _tmp9_;
		_tmp9_ = command;
		g_spawn_command_line_async (_tmp9_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == G_SPAWN_ERROR) {
				goto __catch3_g_spawn_error;
			}
			_g_free0 (command);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally3;
	__catch3_g_spawn_error:
	{
		GError* err = NULL;
		FILE* _tmp10_;
		GError* _tmp11_;
		const gchar* _tmp12_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp10_ = stderr;
		_tmp11_ = err;
		_tmp12_ = _tmp11_->message;
		fprintf (_tmp10_, "%s\n", _tmp12_);
		_g_error_free0 (err);
	}
	__finally3:
	if (_inner_error_ != NULL) {
		_g_free0 (command);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_free0 (command);
}


static void main_controller_main (gchar** args, int args_length1) {
	gchar* _tmp0_;
	gchar* app_name;
	gchar* _tmp1_;
	gchar* app_version;
	main_controller* _tmp2_;
	main_controller* mc;
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp0_ = g_strdup (PACKAGE_NAME);
	app_name = _tmp0_;
	_tmp1_ = g_strdup (PACKAGE_VERSION);
	app_version = _tmp1_;
	gtk_init (&args_length1, &args);
	_tmp2_ = main_controller_new (app_name, app_version);
	mc = _tmp2_;
	main_controller_run (mc);
	_main_controller_unref0 (mc);
	_g_free0 (app_version);
	_g_free0 (app_name);
}


int main (int argc, char ** argv) {
	g_type_init ();
	main_controller_main (argv, argc);
	return 0;
}


static void value_main_controller_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void value_main_controller_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		main_controller_unref (value->data[0].v_pointer);
	}
}


static void value_main_controller_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = main_controller_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer value_main_controller_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* value_main_controller_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		main_controller* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = main_controller_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* value_main_controller_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	main_controller** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = main_controller_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* param_spec_main_controller (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	ParamSpecmain_controller* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_MAIN_CONTROLLER), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer value_get_main_controller (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_CONTROLLER), NULL);
	return value->data[0].v_pointer;
}


void value_set_main_controller (GValue* value, gpointer v_object) {
	main_controller* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_CONTROLLER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_CONTROLLER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		main_controller_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_controller_unref (old);
	}
}


void value_take_main_controller (GValue* value, gpointer v_object) {
	main_controller* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_MAIN_CONTROLLER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_MAIN_CONTROLLER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		main_controller_unref (old);
	}
}


static void main_controller_class_init (main_controllerClass * klass) {
	main_controller_parent_class = g_type_class_peek_parent (klass);
	MAIN_CONTROLLER_CLASS (klass)->finalize = main_controller_finalize;
	g_type_class_add_private (klass, sizeof (main_controllerPrivate));
}


static void main_controller_instance_init (main_controller * self) {
	self->priv = MAIN_CONTROLLER_GET_PRIVATE (self);
	self->ref_count = 1;
}


static void main_controller_finalize (main_controller* obj) {
	main_controller * self;
	self = MAIN_CONTROLLER (obj);
	_g_object_unref0 (self->priv->si);
	_g_free0 (self->priv->app_name);
	_g_free0 (self->priv->app_version);
	_g_free0 (self->priv->ac_state);
	_g_free0 (self->priv->color_draining);
	_g_free0 (self->priv->color_charging);
	_g_free0 (self->priv->color_charged);
	_g_free0 (self->priv->color_background);
	_g_free0 (self->priv->color_border);
	_g_free0 (self->priv->color_text);
	_g_free0 (self->priv->percent_warning);
	_g_free0 (self->priv->percent_critical);
	_g_free0 (self->priv->command_warning);
	_g_free0 (self->priv->command_critical);
	_g_object_unref0 (self->priv->iconMenu);
	_configuration_unref0 (self->priv->config);
	_battery_unref0 (self->priv->battery);
}


GType main_controller_get_type (void) {
	static volatile gsize main_controller_type_id__volatile = 0;
	if (g_once_init_enter (&main_controller_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { value_main_controller_init, value_main_controller_free_value, value_main_controller_copy_value, value_main_controller_peek_pointer, "p", value_main_controller_collect_value, "p", value_main_controller_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (main_controllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) main_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (main_controller), 0, (GInstanceInitFunc) main_controller_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType main_controller_type_id;
		main_controller_type_id = g_type_register_fundamental (g_type_fundamental_next (), "main_controller", &g_define_type_info, &g_define_type_fundamental_info, 0);
		g_once_init_leave (&main_controller_type_id__volatile, main_controller_type_id);
	}
	return main_controller_type_id__volatile;
}


gpointer main_controller_ref (gpointer instance) {
	main_controller* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void main_controller_unref (gpointer instance) {
	main_controller* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		MAIN_CONTROLLER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}



