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

/*
 * BrightnessController
 * This file is part of budgie-extras
 *
 * Author: Serdar ŞEN github.com/serdarsen
 *
 * Copyright © 2018 Ubuntu Budgie Developers
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 */

#include "brightnesscontroller.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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  {
	BRIGHTNESS_CONTROLLER_WIDGETS_POPOVER_0_PROPERTY,
	BRIGHTNESS_CONTROLLER_WIDGETS_POPOVER_NUM_PROPERTIES
};
static GParamSpec* brightness_controller_widgets_popover_properties[BRIGHTNESS_CONTROLLER_WIDGETS_POPOVER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _brightness_controller_helpers_dim_helper_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_helpers_dim_helper_unref (var), NULL)))
#define _brightness_controller_helpers_light_helper_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_helpers_light_helper_unref (var), NULL)))
#define _brightness_controller_models_flame_unref0(var) ((var == NULL) ? NULL : (var = (brightness_controller_models_flame_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
typedef struct _Block2Data Block2Data;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block3Data Block3Data;
typedef struct _Block4Data Block4Data;
typedef struct _brightness_controller_widgets_popover_UpdateLightData brightness_controller_widgets_popover_UpdateLightData;

struct _BrightnessControllerWidgetsPopoverPrivate {
	GtkGrid* grid;
	BrightnessControllerWidgetsCustomScale* dimScale;
	BrightnessControllerWidgetsCustomScale* blueScale;
	BrightnessControllerWidgetsCustomScale* lightScale;
	GtkLabel* dimLabel;
	GtkLabel* blueLabel;
	GtkLabel* lightLabel;
	BrightnessControllerHelpersDimHelper* dimHelper;
	BrightnessControllerHelpersLightHelper* lightHelper;
	BrightnessControllerModelsDim* _CurrentDim;
	BrightnessControllerModelsLight* _CurrentLight;
};

struct _Block1Data {
	int _ref_count_;
	BrightnessControllerWidgetsPopover* self;
	BrightnessControllerWidgetsCustomMenuButton* menuButton;
};

struct _Block2Data {
	int _ref_count_;
	Block1Data * _data1_;
	GtkMenuItem* item;
	BrightnessControllerModelsDim* dim;
};

struct _Block3Data {
	int _ref_count_;
	BrightnessControllerWidgetsPopover* self;
	BrightnessControllerWidgetsCustomMenuButton* menuButton;
};

struct _Block4Data {
	int _ref_count_;
	Block3Data * _data3_;
	GtkMenuItem* item;
	BrightnessControllerModelsLight* light;
};

struct _brightness_controller_widgets_popover_UpdateLightData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	BrightnessControllerWidgetsPopover* self;
	BrightnessControllerModelsLight* _tmp0_;
};

static gint BrightnessControllerWidgetsPopover_private_offset;
static gpointer brightness_controller_widgets_popover_parent_class = NULL;
static GType brightness_controller_widgets_popover_type_id = 0;

static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda9_ (Block1Data* _data1_,
                 BrightnessControllerModelsDim* dim);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void __lambda10_ (Block2Data* _data2_);
static void brightness_controller_widgets_popover_PopulateDim (BrightnessControllerWidgetsPopover* self,
                                                        BrightnessControllerModelsDim* dim);
static void ___lambda10__gtk_menu_item_activate (GtkMenuItem* _sender,
                                          gpointer self);
static void ___lambda9__gfunc (gconstpointer data,
                        gpointer self);
static void __lambda11_ (BrightnessControllerWidgetsPopover* self);
static BrightnessControllerModelsDim* brightness_controller_widgets_popover_get_CurrentDim (BrightnessControllerWidgetsPopover* self);
static void ___lambda11__gtk_range_value_changed (GtkRange* _sender,
                                           gpointer self);
static void __lambda12_ (BrightnessControllerWidgetsPopover* self);
static void ___lambda12__gtk_range_value_changed (GtkRange* _sender,
                                           gpointer self);
static gboolean ___lambda13_ (BrightnessControllerWidgetsPopover* self);
static gboolean ____lambda13__gsource_func (gpointer self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void __lambda14_ (Block3Data* _data3_,
                  BrightnessControllerModelsLight* light);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda15_ (Block4Data* _data4_);
static void brightness_controller_widgets_popover_PopulateLight (BrightnessControllerWidgetsPopover* self,
                                                          BrightnessControllerModelsLight* light);
static void ___lambda15__gtk_menu_item_activate (GtkMenuItem* _sender,
                                          gpointer self);
static void ___lambda14__gfunc (gconstpointer data,
                         gpointer self);
static void __lambda16_ (BrightnessControllerWidgetsPopover* self);
static BrightnessControllerModelsLight* brightness_controller_widgets_popover_get_CurrentLight (BrightnessControllerWidgetsPopover* self);
static void ___lambda16__gtk_range_value_changed (GtkRange* _sender,
                                           gpointer self);
static void brightness_controller_widgets_popover_set_CurrentLight (BrightnessControllerWidgetsPopover* self,
                                                             BrightnessControllerModelsLight* value);
static void brightness_controller_widgets_popover_set_CurrentDim (BrightnessControllerWidgetsPopover* self,
                                                           BrightnessControllerModelsDim* value);
static void brightness_controller_widgets_popover_UpdateLight_data_free (gpointer _data);
static void brightness_controller_widgets_popover_UpdateLight (BrightnessControllerWidgetsPopover* self,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static void brightness_controller_widgets_popover_UpdateLight_finish (BrightnessControllerWidgetsPopover* self,
                                                               GAsyncResult* _res_);
static gboolean brightness_controller_widgets_popover_UpdateLight_co (brightness_controller_widgets_popover_UpdateLightData* _data_);
static void brightness_controller_widgets_popover_finalize (GObject * obj);
static void _vala_brightness_controller_widgets_popover_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_brightness_controller_widgets_popover_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec);

static inline gpointer
brightness_controller_widgets_popover_get_instance_private (BrightnessControllerWidgetsPopover* self)
{
	return G_STRUCT_MEMBER_P (self, BrightnessControllerWidgetsPopover_private_offset);
}

BrightnessControllerWidgetsPopover*
brightness_controller_widgets_popover_construct (GType object_type,
                                                 BrightnessControllerWidgetsIndicatorButton* indicatorButton,
                                                 gint witdh,
                                                 gint height)
{
	BrightnessControllerWidgetsPopover * self = NULL;
	BrightnessControllerHelpersDimHelper* _tmp0_;
	BrightnessControllerHelpersLightHelper* _tmp1_;
	gboolean _tmp2_ = FALSE;
	BrightnessControllerHelpersDimHelper* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	g_return_val_if_fail (indicatorButton != NULL, NULL);
	self = (BrightnessControllerWidgetsPopover*) g_object_new (object_type, "relative-to", indicatorButton, NULL);
	_tmp0_ = brightness_controller_helpers_dim_helper_new ();
	_brightness_controller_helpers_dim_helper_unref0 (self->priv->dimHelper);
	self->priv->dimHelper = _tmp0_;
	_tmp1_ = brightness_controller_helpers_light_helper_new ();
	_brightness_controller_helpers_light_helper_unref0 (self->priv->lightHelper);
	self->priv->lightHelper = _tmp1_;
	_tmp3_ = self->priv->dimHelper;
	_tmp4_ = brightness_controller_helpers_dim_helper_get_IsAvailable (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		BrightnessControllerHelpersLightHelper* _tmp6_;
		gboolean _tmp7_;
		gboolean _tmp8_;
		_tmp6_ = self->priv->lightHelper;
		_tmp7_ = brightness_controller_helpers_light_helper_get_IsAvailable (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp2_ = _tmp8_;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gtk_widget_set_size_request ((GtkWidget*) self, witdh, height);
	} else {
		gtk_widget_set_size_request ((GtkWidget*) self, witdh / 2, height);
	}
	brightness_controller_widgets_popover_BuildViews (self);
	return self;
}

BrightnessControllerWidgetsPopover*
brightness_controller_widgets_popover_new (BrightnessControllerWidgetsIndicatorButton* indicatorButton,
                                           gint witdh,
                                           gint height)
{
	return brightness_controller_widgets_popover_construct (BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_POPOVER, indicatorButton, witdh, height);
}

void
brightness_controller_widgets_popover_BuildViews (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerHelpersDimHelper* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	BrightnessControllerHelpersLightHelper* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	GtkWidget* _tmp6_;
	g_return_if_fail (self != NULL);
	brightness_controller_widgets_popover_BuildGrid (self);
	_tmp0_ = self->priv->dimHelper;
	_tmp1_ = brightness_controller_helpers_dim_helper_get_IsAvailable (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		brightness_controller_widgets_popover_BuildDim (self);
	}
	_tmp3_ = self->priv->lightHelper;
	_tmp4_ = brightness_controller_helpers_light_helper_get_IsAvailable (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		brightness_controller_widgets_popover_BuildLight (self);
	}
	_tmp6_ = gtk_bin_get_child ((GtkBin*) self);
	gtk_widget_show_all (_tmp6_);
}

void
brightness_controller_widgets_popover_BuildGrid (BrightnessControllerWidgetsPopover* self)
{
	GtkGrid* _tmp0_;
	GtkGrid* _tmp1_;
	GtkGrid* _tmp2_;
	GtkGrid* _tmp3_;
	GtkGrid* _tmp4_;
	GtkGrid* _tmp5_;
	GtkGrid* _tmp6_;
	GtkGrid* _tmp7_;
	GtkGrid* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->grid);
	self->priv->grid = _tmp0_;
	_tmp1_ = self->priv->grid;
	gtk_grid_set_column_spacing (_tmp1_, (guint) 10);
	_tmp2_ = self->priv->grid;
	gtk_grid_set_row_spacing (_tmp2_, (guint) 10);
	_tmp3_ = self->priv->grid;
	gtk_grid_set_column_homogeneous (_tmp3_, TRUE);
	_tmp4_ = self->priv->grid;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp4_, 5);
	_tmp5_ = self->priv->grid;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp5_, 5);
	_tmp6_ = self->priv->grid;
	gtk_widget_set_margin_left ((GtkWidget*) _tmp6_, 5);
	_tmp7_ = self->priv->grid;
	gtk_widget_set_margin_right ((GtkWidget*) _tmp7_, 5);
	_tmp8_ = self->priv->grid;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp8_);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		BrightnessControllerWidgetsPopover* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->menuButton);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static gpointer
_brightness_controller_models_flame_ref0 (gpointer self)
{
	return self ? brightness_controller_models_flame_ref (self) : NULL;
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		BrightnessControllerWidgetsPopover* self;
		self = _data2_->_data1_->self;
		_g_object_unref0 (_data2_->item);
		_brightness_controller_models_flame_unref0 (_data2_->dim);
		block1_data_unref (_data2_->_data1_);
		_data2_->_data1_ = NULL;
		g_slice_free (Block2Data, _data2_);
	}
}

static void
__lambda10_ (Block2Data* _data2_)
{
	Block1Data* _data1_;
	BrightnessControllerWidgetsPopover* self;
	BrightnessControllerWidgetsCustomMenuButton* _tmp0_;
	GtkMenuItem* _tmp1_;
	BrightnessControllerHelpersDimHelper* _tmp2_;
	_data1_ = _data2_->_data1_;
	self = _data1_->self;
	_tmp0_ = _data1_->menuButton;
	_tmp1_ = _data2_->item;
	brightness_controller_widgets_custom_menu_button_Select (_tmp0_, _tmp1_);
	_tmp2_ = self->priv->dimHelper;
	brightness_controller_helpers_dim_helper_SetActive (_tmp2_, _data2_->dim);
	brightness_controller_widgets_popover_PopulateDim (self, _data2_->dim);
}

static void
___lambda10__gtk_menu_item_activate (GtkMenuItem* _sender,
                                     gpointer self)
{
	__lambda10_ (self);
}

static void
__lambda9_ (Block1Data* _data1_,
            BrightnessControllerModelsDim* dim)
{
	BrightnessControllerWidgetsPopover* self;
	Block2Data* _data2_;
	BrightnessControllerModelsDim* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkMenuItem* _tmp3_;
	BrightnessControllerWidgetsCustomMenuButton* _tmp4_;
	GtkMenuItem* _tmp5_;
	GtkMenuItem* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	self = _data1_->self;
	g_return_if_fail (dim != NULL);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->_data1_ = block1_data_ref (_data1_);
	_tmp0_ = _brightness_controller_models_flame_ref0 (dim);
	_brightness_controller_models_flame_unref0 (_data2_->dim);
	_data2_->dim = _tmp0_;
	_tmp1_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _data2_->dim);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_tmp2_);
	g_object_ref_sink (_tmp3_);
	_data2_->item = _tmp3_;
	_tmp4_ = _data1_->menuButton;
	_tmp5_ = _data2_->item;
	brightness_controller_widgets_custom_menu_button_Add (_tmp4_, _tmp5_);
	_tmp6_ = _data2_->item;
	g_signal_connect_data (_tmp6_, "activate", (GCallback) ___lambda10__gtk_menu_item_activate, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp7_ = brightness_controller_models_flame_get_IsActive ((BrightnessControllerModelsFlame*) _data2_->dim);
	_tmp8_ = _tmp7_;
	if (_tmp8_) {
		GtkMenuItem* _tmp9_;
		_tmp9_ = _data2_->item;
		gtk_menu_item_select (_tmp9_);
		brightness_controller_widgets_popover_PopulateDim (self, _data2_->dim);
	}
	block2_data_unref (_data2_);
	_data2_ = NULL;
}

static void
___lambda9__gfunc (gconstpointer data,
                   gpointer self)
{
	__lambda9_ (self, (BrightnessControllerModelsDim*) data);
}

static void
__lambda11_ (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerModelsDim* _tmp0_;
	BrightnessControllerWidgetsCustomScale* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	GtkLabel* _tmp4_;
	BrightnessControllerModelsDim* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	BrightnessControllerHelpersDimHelper* _tmp9_;
	BrightnessControllerModelsDim* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	BrightnessControllerModelsDim* _tmp13_;
	gdouble _tmp14_;
	gdouble _tmp15_;
	BrightnessControllerModelsDim* _tmp16_;
	gdouble _tmp17_;
	gdouble _tmp18_;
	_tmp0_ = self->priv->_CurrentDim;
	_tmp1_ = self->priv->dimScale;
	_tmp2_ = brightness_controller_widgets_custom_scale_get_Value (_tmp1_);
	_tmp3_ = _tmp2_;
	brightness_controller_models_flame_set_Brightness ((BrightnessControllerModelsFlame*) _tmp0_, _tmp3_);
	_tmp4_ = self->priv->dimLabel;
	_tmp5_ = self->priv->_CurrentDim;
	_tmp6_ = brightness_controller_models_dim_get_BrightnessText (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	gtk_label_set_text (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->priv->dimHelper;
	_tmp10_ = self->priv->_CurrentDim;
	_tmp11_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = self->priv->_CurrentDim;
	_tmp14_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = self->priv->_CurrentDim;
	_tmp17_ = brightness_controller_models_dim_get_Blue (_tmp16_);
	_tmp18_ = _tmp17_;
	brightness_controller_helpers_dim_helper_SetBrightness (_tmp9_, _tmp12_, _tmp15_, _tmp18_);
}

static void
___lambda11__gtk_range_value_changed (GtkRange* _sender,
                                      gpointer self)
{
	__lambda11_ ((BrightnessControllerWidgetsPopover*) self);
}

static void
__lambda12_ (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerModelsDim* _tmp0_;
	BrightnessControllerWidgetsCustomScale* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	GtkLabel* _tmp4_;
	BrightnessControllerModelsDim* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	BrightnessControllerHelpersDimHelper* _tmp9_;
	BrightnessControllerModelsDim* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	BrightnessControllerModelsDim* _tmp13_;
	gdouble _tmp14_;
	gdouble _tmp15_;
	BrightnessControllerModelsDim* _tmp16_;
	gdouble _tmp17_;
	gdouble _tmp18_;
	_tmp0_ = self->priv->_CurrentDim;
	_tmp1_ = self->priv->blueScale;
	_tmp2_ = brightness_controller_widgets_custom_scale_get_Value (_tmp1_);
	_tmp3_ = _tmp2_;
	brightness_controller_models_dim_set_Blue (_tmp0_, _tmp3_);
	_tmp4_ = self->priv->blueLabel;
	_tmp5_ = self->priv->_CurrentDim;
	_tmp6_ = brightness_controller_models_dim_get_BlueText (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	gtk_label_set_text (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->priv->dimHelper;
	_tmp10_ = self->priv->_CurrentDim;
	_tmp11_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = self->priv->_CurrentDim;
	_tmp14_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = self->priv->_CurrentDim;
	_tmp17_ = brightness_controller_models_dim_get_Blue (_tmp16_);
	_tmp18_ = _tmp17_;
	brightness_controller_helpers_dim_helper_SetBrightness (_tmp9_, _tmp12_, _tmp15_, _tmp18_);
}

static void
___lambda12__gtk_range_value_changed (GtkRange* _sender,
                                      gpointer self)
{
	__lambda12_ ((BrightnessControllerWidgetsPopover*) self);
}

static gboolean
___lambda13_ (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerHelpersDimHelper* _tmp0_;
	BrightnessControllerModelsDim* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	BrightnessControllerModelsDim* _tmp4_;
	gdouble _tmp5_;
	gdouble _tmp6_;
	BrightnessControllerModelsDim* _tmp7_;
	gdouble _tmp8_;
	gdouble _tmp9_;
	gboolean result;
	_tmp0_ = self->priv->dimHelper;
	_tmp1_ = self->priv->_CurrentDim;
	_tmp2_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->_CurrentDim;
	_tmp5_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_CurrentDim;
	_tmp8_ = brightness_controller_models_dim_get_Blue (_tmp7_);
	_tmp9_ = _tmp8_;
	brightness_controller_helpers_dim_helper_SetBrightness (_tmp0_, _tmp3_, _tmp6_, _tmp9_);
	result = FALSE;
	return result;
}

static gboolean
____lambda13__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda13_ ((BrightnessControllerWidgetsPopover*) self);
	return result;
}

void
brightness_controller_widgets_popover_BuildDim (BrightnessControllerWidgetsPopover* self)
{
	Block1Data* _data1_;
	BrightnessControllerWidgetsCustomMenuButton* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	BrightnessControllerWidgetsCustomScale* _tmp7_;
	BrightnessControllerWidgetsCustomScale* _tmp8_;
	BrightnessControllerHelpersDimHelper* _tmp9_;
	GList* _tmp10_;
	BrightnessControllerWidgetsCustomMenuButton* _tmp11_;
	BrightnessControllerWidgetsCustomScale* _tmp12_;
	BrightnessControllerWidgetsCustomScale* _tmp13_;
	BrightnessControllerHelpersDimHelper* _tmp14_;
	GtkGrid* _tmp15_;
	BrightnessControllerWidgetsCustomMenuButton* _tmp16_;
	GtkGrid* _tmp17_;
	BrightnessControllerWidgetsCustomScale* _tmp18_;
	GtkGrid* _tmp19_;
	GtkLabel* _tmp20_;
	GtkGrid* _tmp21_;
	BrightnessControllerWidgetsCustomScale* _tmp22_;
	GtkGrid* _tmp23_;
	GtkLabel* _tmp24_;
	g_return_if_fail (self != NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = brightness_controller_widgets_custom_menu_button_new (_ ("Dim"));
	g_object_ref_sink (_tmp0_);
	_data1_->menuButton = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->dimLabel);
	self->priv->dimLabel = _tmp1_;
	_tmp2_ = self->priv->dimLabel;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _ ("Brightness"));
	_tmp3_ = self->priv->dimLabel;
	gtk_label_set_width_chars (_tmp3_, 5);
	_tmp4_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->blueLabel);
	self->priv->blueLabel = _tmp4_;
	_tmp5_ = self->priv->blueLabel;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp5_, _ ("Temperature"));
	_tmp6_ = self->priv->blueLabel;
	gtk_label_set_width_chars (_tmp6_, 5);
	_tmp7_ = brightness_controller_widgets_custom_scale_new ((gdouble) 0, (gdouble) 10, (gdouble) 0, (gdouble) 1, 0.1, (gdouble) 0);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->dimScale);
	self->priv->dimScale = _tmp7_;
	_tmp8_ = brightness_controller_widgets_custom_scale_new ((gdouble) 0, (gdouble) 10, (gdouble) 0, (gdouble) 1, 0.1, (gdouble) 0);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->blueScale);
	self->priv->blueScale = _tmp8_;
	_tmp9_ = self->priv->dimHelper;
	_tmp10_ = _tmp9_->list;
	g_list_foreach (_tmp10_, ___lambda9__gfunc, _data1_);
	_tmp11_ = _data1_->menuButton;
	brightness_controller_widgets_custom_menu_button_ShowAll (_tmp11_);
	_tmp12_ = self->priv->dimScale;
	g_signal_connect_object ((GtkRange*) _tmp12_, "value-changed", (GCallback) ___lambda11__gtk_range_value_changed, self, 0);
	_tmp13_ = self->priv->blueScale;
	g_signal_connect_object ((GtkRange*) _tmp13_, "value-changed", (GCallback) ___lambda12__gtk_range_value_changed, self, 0);
	_tmp14_ = self->priv->dimHelper;
	if (!brightness_controller_helpers_dim_helper_NightlightOn (_tmp14_)) {
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ____lambda13__gsource_func, g_object_ref (self), g_object_unref);
	}
	_tmp15_ = self->priv->grid;
	_tmp16_ = _data1_->menuButton;
	gtk_grid_attach (_tmp15_, (GtkWidget*) _tmp16_, 1, 0, 2, 1);
	_tmp17_ = self->priv->grid;
	_tmp18_ = self->priv->dimScale;
	gtk_grid_attach (_tmp17_, (GtkWidget*) _tmp18_, 1, 1, 1, 1);
	_tmp19_ = self->priv->grid;
	_tmp20_ = self->priv->dimLabel;
	gtk_grid_attach (_tmp19_, (GtkWidget*) _tmp20_, 1, 2, 1, 1);
	_tmp21_ = self->priv->grid;
	_tmp22_ = self->priv->blueScale;
	gtk_grid_attach (_tmp21_, (GtkWidget*) _tmp22_, 2, 1, 1, 1);
	_tmp23_ = self->priv->grid;
	_tmp24_ = self->priv->blueLabel;
	gtk_grid_attach (_tmp23_, (GtkWidget*) _tmp24_, 2, 2, 1, 1);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

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_)) {
		BrightnessControllerWidgetsPopover* self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->menuButton);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		BrightnessControllerWidgetsPopover* self;
		self = _data4_->_data3_->self;
		_g_object_unref0 (_data4_->item);
		_brightness_controller_models_flame_unref0 (_data4_->light);
		block3_data_unref (_data4_->_data3_);
		_data4_->_data3_ = NULL;
		g_slice_free (Block4Data, _data4_);
	}
}

static void
__lambda15_ (Block4Data* _data4_)
{
	Block3Data* _data3_;
	BrightnessControllerWidgetsPopover* self;
	GtkMenuItem* _tmp0_;
	BrightnessControllerHelpersLightHelper* _tmp1_;
	_data3_ = _data4_->_data3_;
	self = _data3_->self;
	_tmp0_ = _data4_->item;
	brightness_controller_widgets_custom_menu_button_Select (_data3_->menuButton, _tmp0_);
	_tmp1_ = self->priv->lightHelper;
	brightness_controller_helpers_light_helper_SetActive (_tmp1_, _data4_->light);
	brightness_controller_widgets_popover_PopulateLight (self, _data4_->light);
}

static void
___lambda15__gtk_menu_item_activate (GtkMenuItem* _sender,
                                     gpointer self)
{
	__lambda15_ (self);
}

static void
__lambda14_ (Block3Data* _data3_,
             BrightnessControllerModelsLight* light)
{
	BrightnessControllerWidgetsPopover* self;
	Block4Data* _data4_;
	BrightnessControllerModelsLight* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkMenuItem* _tmp3_;
	GtkMenuItem* _tmp4_;
	GtkMenuItem* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	self = _data3_->self;
	g_return_if_fail (light != NULL);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->_data3_ = block3_data_ref (_data3_);
	_tmp0_ = _brightness_controller_models_flame_ref0 (light);
	_brightness_controller_models_flame_unref0 (_data4_->light);
	_data4_->light = _tmp0_;
	_tmp1_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _data4_->light);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_tmp2_);
	g_object_ref_sink (_tmp3_);
	_data4_->item = _tmp3_;
	_tmp4_ = _data4_->item;
	brightness_controller_widgets_custom_menu_button_Add (_data3_->menuButton, _tmp4_);
	_tmp5_ = _data4_->item;
	g_signal_connect_data (_tmp5_, "activate", (GCallback) ___lambda15__gtk_menu_item_activate, block4_data_ref (_data4_), (GClosureNotify) block4_data_unref, 0);
	_tmp6_ = brightness_controller_models_flame_get_IsActive ((BrightnessControllerModelsFlame*) _data4_->light);
	_tmp7_ = _tmp6_;
	if (_tmp7_) {
		GtkMenuItem* _tmp8_;
		_tmp8_ = _data4_->item;
		gtk_menu_item_select (_tmp8_);
		brightness_controller_widgets_popover_PopulateLight (self, _data4_->light);
	}
	block4_data_unref (_data4_);
	_data4_ = NULL;
}

static void
___lambda14__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda14_ (self, (BrightnessControllerModelsLight*) data);
}

static void
__lambda16_ (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerModelsLight* _tmp0_;
	BrightnessControllerWidgetsCustomScale* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	GtkLabel* _tmp4_;
	BrightnessControllerModelsLight* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	BrightnessControllerHelpersLightHelper* _tmp9_;
	BrightnessControllerModelsLight* _tmp10_;
	gdouble _tmp11_;
	gdouble _tmp12_;
	BrightnessControllerModelsLight* _tmp13_;
	gdouble _tmp14_;
	gdouble _tmp15_;
	_tmp0_ = self->priv->_CurrentLight;
	_tmp1_ = self->priv->lightScale;
	_tmp2_ = brightness_controller_widgets_custom_scale_get_Value (_tmp1_);
	_tmp3_ = _tmp2_;
	brightness_controller_models_flame_set_Brightness ((BrightnessControllerModelsFlame*) _tmp0_, _tmp3_);
	_tmp4_ = self->priv->lightLabel;
	_tmp5_ = self->priv->_CurrentLight;
	_tmp6_ = brightness_controller_models_light_get_BrightnessText (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	gtk_label_set_text (_tmp4_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->priv->lightHelper;
	_tmp10_ = self->priv->_CurrentLight;
	_tmp11_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = self->priv->_CurrentLight;
	_tmp14_ = brightness_controller_models_flame_get_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp13_);
	_tmp15_ = _tmp14_;
	brightness_controller_helpers_light_helper_SetBrightness (_tmp9_, (gint) ((((gdouble) _tmp12_) / ((gdouble) _tmp15_)) * 100.0));
}

static void
___lambda16__gtk_range_value_changed (GtkRange* _sender,
                                      gpointer self)
{
	__lambda16_ ((BrightnessControllerWidgetsPopover*) self);
}

void
brightness_controller_widgets_popover_BuildLight (BrightnessControllerWidgetsPopover* self)
{
	Block3Data* _data3_;
	BrightnessControllerWidgetsCustomMenuButton* _tmp0_;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	BrightnessControllerWidgetsCustomScale* _tmp4_;
	BrightnessControllerHelpersLightHelper* _tmp5_;
	GList* _tmp6_;
	BrightnessControllerWidgetsCustomScale* _tmp7_;
	GtkGrid* _tmp8_;
	GtkGrid* _tmp9_;
	BrightnessControllerWidgetsCustomScale* _tmp10_;
	GtkGrid* _tmp11_;
	GtkLabel* _tmp12_;
	g_return_if_fail (self != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = brightness_controller_widgets_custom_menu_button_new (_ ("Light"));
	g_object_ref_sink (_tmp0_);
	_data3_->menuButton = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->lightLabel);
	self->priv->lightLabel = _tmp1_;
	_tmp2_ = self->priv->lightLabel;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp2_, _ ("Brightness"));
	_tmp3_ = self->priv->lightLabel;
	gtk_label_set_width_chars (_tmp3_, 5);
	_tmp4_ = brightness_controller_widgets_custom_scale_new ((gdouble) 0, (gdouble) 0, (gdouble) 0, (gdouble) 1, (gdouble) 1, (gdouble) 0);
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->lightScale);
	self->priv->lightScale = _tmp4_;
	_tmp5_ = self->priv->lightHelper;
	_tmp6_ = _tmp5_->list;
	g_list_foreach (_tmp6_, ___lambda14__gfunc, _data3_);
	brightness_controller_widgets_custom_menu_button_ShowAll (_data3_->menuButton);
	_tmp7_ = self->priv->lightScale;
	g_signal_connect_object ((GtkRange*) _tmp7_, "value-changed", (GCallback) ___lambda16__gtk_range_value_changed, self, 0);
	_tmp8_ = self->priv->grid;
	gtk_grid_attach (_tmp8_, (GtkWidget*) _data3_->menuButton, 0, 0, 1, 1);
	_tmp9_ = self->priv->grid;
	_tmp10_ = self->priv->lightScale;
	gtk_grid_attach (_tmp9_, (GtkWidget*) _tmp10_, 0, 1, 1, 1);
	_tmp11_ = self->priv->grid;
	_tmp12_ = self->priv->lightLabel;
	gtk_grid_attach (_tmp11_, (GtkWidget*) _tmp12_, 0, 2, 1, 1);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

static void
brightness_controller_widgets_popover_PopulateLight (BrightnessControllerWidgetsPopover* self,
                                                     BrightnessControllerModelsLight* light)
{
	GtkLabel* _tmp0_;
	BrightnessControllerModelsLight* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	BrightnessControllerWidgetsCustomScale* _tmp5_;
	BrightnessControllerModelsLight* _tmp6_;
	gdouble _tmp7_;
	gdouble _tmp8_;
	BrightnessControllerModelsLight* _tmp9_;
	gdouble _tmp10_;
	gdouble _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (light != NULL);
	brightness_controller_widgets_popover_set_CurrentLight (self, light);
	_tmp0_ = self->priv->lightLabel;
	_tmp1_ = self->priv->_CurrentLight;
	_tmp2_ = brightness_controller_models_light_get_BrightnessText (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	gtk_label_set_text (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = self->priv->lightScale;
	_tmp6_ = self->priv->_CurrentLight;
	_tmp7_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->_CurrentLight;
	_tmp10_ = brightness_controller_models_flame_get_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp9_);
	_tmp11_ = _tmp10_;
	brightness_controller_widgets_custom_scale_Update (_tmp5_, _tmp8_, (gdouble) 0, _tmp11_);
}

static void
brightness_controller_widgets_popover_PopulateDim (BrightnessControllerWidgetsPopover* self,
                                                   BrightnessControllerModelsDim* dim)
{
	GtkLabel* _tmp0_;
	BrightnessControllerModelsDim* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	BrightnessControllerWidgetsCustomScale* _tmp5_;
	BrightnessControllerModelsDim* _tmp6_;
	gdouble _tmp7_;
	gdouble _tmp8_;
	BrightnessControllerModelsDim* _tmp9_;
	gdouble _tmp10_;
	gdouble _tmp11_;
	GtkLabel* _tmp12_;
	BrightnessControllerModelsDim* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	BrightnessControllerWidgetsCustomScale* _tmp17_;
	BrightnessControllerModelsDim* _tmp18_;
	gdouble _tmp19_;
	gdouble _tmp20_;
	BrightnessControllerModelsDim* _tmp21_;
	gdouble _tmp22_;
	gdouble _tmp23_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (dim != NULL);
	brightness_controller_widgets_popover_set_CurrentDim (self, dim);
	_tmp0_ = self->priv->dimLabel;
	_tmp1_ = self->priv->_CurrentDim;
	_tmp2_ = brightness_controller_models_dim_get_BrightnessText (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	gtk_label_set_text (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = self->priv->dimScale;
	_tmp6_ = self->priv->_CurrentDim;
	_tmp7_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->_CurrentDim;
	_tmp10_ = brightness_controller_models_flame_get_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp9_);
	_tmp11_ = _tmp10_;
	brightness_controller_widgets_custom_scale_Update (_tmp5_, _tmp8_, (gdouble) 10, _tmp11_);
	_tmp12_ = self->priv->blueLabel;
	_tmp13_ = self->priv->_CurrentDim;
	_tmp14_ = brightness_controller_models_dim_get_BlueText (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = _tmp15_;
	gtk_label_set_text (_tmp12_, _tmp16_);
	_g_free0 (_tmp16_);
	_tmp17_ = self->priv->blueScale;
	_tmp18_ = self->priv->_CurrentDim;
	_tmp19_ = brightness_controller_models_dim_get_Blue (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = self->priv->_CurrentDim;
	_tmp22_ = brightness_controller_models_flame_get_MaxBrightness ((BrightnessControllerModelsFlame*) _tmp21_);
	_tmp23_ = _tmp22_;
	brightness_controller_widgets_custom_scale_Update (_tmp17_, _tmp20_, (gdouble) 10, _tmp23_);
}

static void
brightness_controller_widgets_popover_UpdateLight_data_free (gpointer _data)
{
	brightness_controller_widgets_popover_UpdateLightData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (brightness_controller_widgets_popover_UpdateLightData, _data_);
}

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

static void
brightness_controller_widgets_popover_UpdateLight (BrightnessControllerWidgetsPopover* self,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	brightness_controller_widgets_popover_UpdateLightData* _data_;
	BrightnessControllerWidgetsPopover* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (brightness_controller_widgets_popover_UpdateLightData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, brightness_controller_widgets_popover_UpdateLight_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	brightness_controller_widgets_popover_UpdateLight_co (_data_);
}

static void
brightness_controller_widgets_popover_UpdateLight_finish (BrightnessControllerWidgetsPopover* self,
                                                          GAsyncResult* _res_)
{
	brightness_controller_widgets_popover_UpdateLightData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
brightness_controller_widgets_popover_UpdateLight_co (brightness_controller_widgets_popover_UpdateLightData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_CurrentLight;
	brightness_controller_widgets_popover_PopulateLight (_data_->self, _data_->_tmp0_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
brightness_controller_widgets_popover_OnShow (BrightnessControllerWidgetsPopover* self)
{
	gboolean _tmp0_ = FALSE;
	BrightnessControllerHelpersDimHelper* _tmp1_;
	BrightnessControllerHelpersDimHelper* _tmp3_;
	BrightnessControllerModelsDim* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->dimHelper;
	if (_tmp1_ == NULL) {
		BrightnessControllerHelpersLightHelper* _tmp2_;
		_tmp2_ = self->priv->lightHelper;
		_tmp0_ = _tmp2_ == NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	brightness_controller_widgets_popover_UpdateLight (self, NULL, NULL);
	_tmp3_ = self->priv->dimHelper;
	if (!brightness_controller_helpers_dim_helper_NightlightOn (_tmp3_)) {
		BrightnessControllerHelpersDimHelper* _tmp4_;
		BrightnessControllerModelsDim* _tmp5_;
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		BrightnessControllerModelsDim* _tmp8_;
		gdouble _tmp9_;
		gdouble _tmp10_;
		BrightnessControllerModelsDim* _tmp11_;
		gdouble _tmp12_;
		gdouble _tmp13_;
		_tmp4_ = self->priv->dimHelper;
		_tmp5_ = self->priv->_CurrentDim;
		_tmp6_ = brightness_controller_models_flame_get_Name ((BrightnessControllerModelsFlame*) _tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = self->priv->_CurrentDim;
		_tmp9_ = brightness_controller_models_flame_get_Brightness ((BrightnessControllerModelsFlame*) _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->_CurrentDim;
		_tmp12_ = brightness_controller_models_dim_get_Blue (_tmp11_);
		_tmp13_ = _tmp12_;
		brightness_controller_helpers_dim_helper_SetBrightness (_tmp4_, _tmp7_, _tmp10_, _tmp13_);
	}
	_tmp14_ = self->priv->_CurrentDim;
	brightness_controller_widgets_popover_PopulateDim (self, _tmp14_);
}

static BrightnessControllerModelsDim*
brightness_controller_widgets_popover_get_CurrentDim (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerModelsDim* result;
	BrightnessControllerModelsDim* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_CurrentDim;
	result = _tmp0_;
	return result;
}

static void
brightness_controller_widgets_popover_set_CurrentDim (BrightnessControllerWidgetsPopover* self,
                                                      BrightnessControllerModelsDim* value)
{
	BrightnessControllerModelsDim* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _brightness_controller_models_flame_ref0 (value);
	_brightness_controller_models_flame_unref0 (self->priv->_CurrentDim);
	self->priv->_CurrentDim = _tmp0_;
}

static BrightnessControllerModelsLight*
brightness_controller_widgets_popover_get_CurrentLight (BrightnessControllerWidgetsPopover* self)
{
	BrightnessControllerModelsLight* result;
	BrightnessControllerModelsLight* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_CurrentLight;
	result = _tmp0_;
	return result;
}

static void
brightness_controller_widgets_popover_set_CurrentLight (BrightnessControllerWidgetsPopover* self,
                                                        BrightnessControllerModelsLight* value)
{
	BrightnessControllerModelsLight* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _brightness_controller_models_flame_ref0 (value);
	_brightness_controller_models_flame_unref0 (self->priv->_CurrentLight);
	self->priv->_CurrentLight = _tmp0_;
}

static void
brightness_controller_widgets_popover_class_init (BrightnessControllerWidgetsPopoverClass * klass,
                                                  gpointer klass_data)
{
	brightness_controller_widgets_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BrightnessControllerWidgetsPopover_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_brightness_controller_widgets_popover_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_brightness_controller_widgets_popover_set_property;
	G_OBJECT_CLASS (klass)->finalize = brightness_controller_widgets_popover_finalize;
}

static void
brightness_controller_widgets_popover_instance_init (BrightnessControllerWidgetsPopover * self,
                                                     gpointer klass)
{
	self->priv = brightness_controller_widgets_popover_get_instance_private (self);
}

static void
brightness_controller_widgets_popover_finalize (GObject * obj)
{
	BrightnessControllerWidgetsPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_POPOVER, BrightnessControllerWidgetsPopover);
	_g_object_unref0 (self->priv->grid);
	_g_object_unref0 (self->priv->dimScale);
	_g_object_unref0 (self->priv->blueScale);
	_g_object_unref0 (self->priv->lightScale);
	_g_object_unref0 (self->priv->dimLabel);
	_g_object_unref0 (self->priv->blueLabel);
	_g_object_unref0 (self->priv->lightLabel);
	_brightness_controller_helpers_dim_helper_unref0 (self->priv->dimHelper);
	_brightness_controller_helpers_light_helper_unref0 (self->priv->lightHelper);
	_brightness_controller_models_flame_unref0 (self->priv->_CurrentDim);
	_brightness_controller_models_flame_unref0 (self->priv->_CurrentLight);
	G_OBJECT_CLASS (brightness_controller_widgets_popover_parent_class)->finalize (obj);
}

GType
brightness_controller_widgets_popover_get_type (void)
{
	return brightness_controller_widgets_popover_type_id;
}

GType
brightness_controller_widgets_popover_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (BrightnessControllerWidgetsPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) brightness_controller_widgets_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BrightnessControllerWidgetsPopover), 0, (GInstanceInitFunc) brightness_controller_widgets_popover_instance_init, NULL };
	brightness_controller_widgets_popover_type_id = g_type_module_register_type (module, budgie_popover_get_type (), "BrightnessControllerWidgetsPopover", &g_define_type_info, 0);
	BrightnessControllerWidgetsPopover_private_offset = sizeof (BrightnessControllerWidgetsPopoverPrivate);
	return brightness_controller_widgets_popover_type_id;
}

static void
_vala_brightness_controller_widgets_popover_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	BrightnessControllerWidgetsPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_POPOVER, BrightnessControllerWidgetsPopover);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_brightness_controller_widgets_popover_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	BrightnessControllerWidgetsPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_POPOVER, BrightnessControllerWidgetsPopover);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

