/* CustomScale.c generated by valac 0.56.19, the Vala compiler
 * generated from CustomScale.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 <glib-object.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gtk/gtk.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_CUSTOM_SCALE_0_PROPERTY,
	BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY,
	BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_NUM_PROPERTIES
};
static GParamSpec* brightness_controller_widgets_custom_scale_properties[BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_NUM_PROPERTIES];

static gpointer brightness_controller_widgets_custom_scale_parent_class = NULL;
static GType brightness_controller_widgets_custom_scale_type_id = 0;

static void _vala_brightness_controller_widgets_custom_scale_get_property (GObject * object,
                                                                    guint property_id,
                                                                    GValue * value,
                                                                    GParamSpec * pspec);
static void _vala_brightness_controller_widgets_custom_scale_set_property (GObject * object,
                                                                    guint property_id,
                                                                    const GValue * value,
                                                                    GParamSpec * pspec);

BrightnessControllerWidgetsCustomScale*
brightness_controller_widgets_custom_scale_construct (GType object_type,
                                                      gdouble currentValue,
                                                      gdouble lower,
                                                      gdouble upper,
                                                      gdouble stepIncrement,
                                                      gdouble pageIncrement,
                                                      gdouble pageSize)
{
	BrightnessControllerWidgetsCustomScale * self = NULL;
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	GtkAdjustment* _tmp4_;
	GtkAdjustment* _tmp5_;
	GtkAdjustment* _tmp6_;
	GtkAdjustment* _tmp7_;
	GtkAdjustment* _tmp8_;
	GtkAdjustment* _tmp9_;
	self = (BrightnessControllerWidgetsCustomScale*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp1_ = _tmp0_;
	gtk_adjustment_set_value (_tmp1_, currentValue);
	_tmp2_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp3_ = _tmp2_;
	gtk_adjustment_set_lower (_tmp3_, lower);
	_tmp4_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp5_ = _tmp4_;
	gtk_adjustment_set_step_increment (_tmp5_, stepIncrement);
	_tmp6_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp7_ = _tmp6_;
	gtk_adjustment_set_page_increment (_tmp7_, pageIncrement);
	_tmp8_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp9_ = _tmp8_;
	gtk_adjustment_set_page_size (_tmp9_, pageSize);
	gtk_orientable_set_orientation ((GtkOrientable*) self, GTK_ORIENTATION_VERTICAL);
	gtk_scale_set_value_pos ((GtkScale*) self, GTK_POS_BOTTOM);
	gtk_scale_set_draw_value ((GtkScale*) self, FALSE);
	gtk_widget_set_vexpand ((GtkWidget*) self, TRUE);
	gtk_widget_set_hexpand ((GtkWidget*) self, TRUE);
	gtk_range_set_inverted ((GtkRange*) self, TRUE);
	gtk_range_set_value ((GtkRange*) self, currentValue);
	return self;
}

BrightnessControllerWidgetsCustomScale*
brightness_controller_widgets_custom_scale_new (gdouble currentValue,
                                                gdouble lower,
                                                gdouble upper,
                                                gdouble stepIncrement,
                                                gdouble pageIncrement,
                                                gdouble pageSize)
{
	return brightness_controller_widgets_custom_scale_construct (BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_CUSTOM_SCALE, currentValue, lower, upper, stepIncrement, pageIncrement, pageSize);
}

void
brightness_controller_widgets_custom_scale_Update (BrightnessControllerWidgetsCustomScale* self,
                                                   gdouble currentValue,
                                                   gdouble lower,
                                                   gdouble upper)
{
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	GtkAdjustment* _tmp2_;
	GtkAdjustment* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp1_ = _tmp0_;
	gtk_adjustment_set_value (_tmp1_, currentValue);
	_tmp2_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp3_ = _tmp2_;
	gtk_adjustment_set_upper (_tmp3_, upper);
	if (upper >= ((gdouble) 100)) {
		GtkAdjustment* _tmp4_;
		GtkAdjustment* _tmp5_;
		_tmp4_ = gtk_range_get_adjustment ((GtkRange*) self);
		_tmp5_ = _tmp4_;
		gtk_adjustment_set_lower (_tmp5_, (gdouble) 10);
	} else {
		GtkAdjustment* _tmp6_;
		GtkAdjustment* _tmp7_;
		_tmp6_ = gtk_range_get_adjustment ((GtkRange*) self);
		_tmp7_ = _tmp6_;
		gtk_adjustment_set_lower (_tmp7_, lower);
	}
	gtk_range_set_value ((GtkRange*) self, currentValue);
}

gdouble
brightness_controller_widgets_custom_scale_get_Value (BrightnessControllerWidgetsCustomScale* self)
{
	gdouble result;
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	gdouble _tmp2_;
	gdouble _tmp3_;
	g_return_val_if_fail (self != NULL, -1.0);
	_tmp0_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_adjustment_get_value (_tmp1_);
	_tmp3_ = _tmp2_;
	result = _tmp3_;
	return result;
}

void
brightness_controller_widgets_custom_scale_set_Value (BrightnessControllerWidgetsCustomScale* self,
                                                      gdouble value)
{
	GtkAdjustment* _tmp0_;
	GtkAdjustment* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gtk_range_get_adjustment ((GtkRange*) self);
	_tmp1_ = _tmp0_;
	gtk_adjustment_set_value (_tmp1_, value);
	g_object_notify_by_pspec ((GObject *) self, brightness_controller_widgets_custom_scale_properties[BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY]);
}

static void
brightness_controller_widgets_custom_scale_class_init (BrightnessControllerWidgetsCustomScaleClass * klass,
                                                       gpointer klass_data)
{
	brightness_controller_widgets_custom_scale_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_brightness_controller_widgets_custom_scale_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_brightness_controller_widgets_custom_scale_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY, brightness_controller_widgets_custom_scale_properties[BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY] = g_param_spec_double ("Value", "Value", "Value", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
brightness_controller_widgets_custom_scale_instance_init (BrightnessControllerWidgetsCustomScale * self,
                                                          gpointer klass)
{
}

GType
brightness_controller_widgets_custom_scale_get_type (void)
{
	return brightness_controller_widgets_custom_scale_type_id;
}

GType
brightness_controller_widgets_custom_scale_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (BrightnessControllerWidgetsCustomScaleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) brightness_controller_widgets_custom_scale_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BrightnessControllerWidgetsCustomScale), 0, (GInstanceInitFunc) brightness_controller_widgets_custom_scale_instance_init, NULL };
	brightness_controller_widgets_custom_scale_type_id = g_type_module_register_type (module, gtk_scale_get_type (), "BrightnessControllerWidgetsCustomScale", &g_define_type_info, 0);
	return brightness_controller_widgets_custom_scale_type_id;
}

static void
_vala_brightness_controller_widgets_custom_scale_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec)
{
	BrightnessControllerWidgetsCustomScale * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_CUSTOM_SCALE, BrightnessControllerWidgetsCustomScale);
	switch (property_id) {
		case BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY:
		g_value_set_double (value, brightness_controller_widgets_custom_scale_get_Value (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_brightness_controller_widgets_custom_scale_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec)
{
	BrightnessControllerWidgetsCustomScale * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BRIGHTNESS_CONTROLLER_WIDGETS_TYPE_CUSTOM_SCALE, BrightnessControllerWidgetsCustomScale);
	switch (property_id) {
		case BRIGHTNESS_CONTROLLER_WIDGETS_CUSTOM_SCALE_VALUE_PROPERTY:
		brightness_controller_widgets_custom_scale_set_Value (self, g_value_get_double (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

