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

/*
* SPDX-License-Identifier: GPL-2.0-or-later
* SPDX-FileCopyrightText: 2015-2025 elementary, Inc. (https://elementary.io)
*/

#include "sound.h"
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	SOUND_WIDGETS_SCALE_0_PROPERTY,
	SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY,
	SOUND_WIDGETS_SCALE_ICON_PROPERTY,
	SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY,
	SOUND_WIDGETS_SCALE_NUM_PROPERTIES
};
static GParamSpec* sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	SOUND_WIDGETS_SCALE_SLIDER_DROPPED_SIGNAL,
	SOUND_WIDGETS_SCALE_NUM_SIGNALS
};
static guint sound_widgets_scale_signals[SOUND_WIDGETS_SCALE_NUM_SIGNALS] = {0};

struct _SoundWidgetsScalePrivate {
	GtkAdjustment* _adjustment;
	gchar* _icon;
	gboolean _active;
	GtkGestureMultiPress* gesture_click;
};

static gint SoundWidgetsScale_private_offset;
static gpointer sound_widgets_scale_parent_class = NULL;

static GObject * sound_widgets_scale_constructor (GType type,
                                           guint n_construct_properties,
                                           GObjectConstructParam * construct_properties);
static void _sound_widgets_scale___lambda43_ (SoundWidgetsScale* self);
static void __sound_widgets_scale___lambda43__gtk_gesture_multi_press_released (GtkGestureMultiPress* _sender,
                                                                         gint n_press,
                                                                         gdouble x,
                                                                         gdouble y,
                                                                         gpointer self);
static gboolean _sound_widgets_scale___lambda44_ (SoundWidgetsScale* self,
                                           GdkEventScroll* e);
static gboolean __sound_widgets_scale___lambda44__gtk_widget_scroll_event (GtkWidget* _sender,
                                                                    GdkEventScroll* event,
                                                                    gpointer self);
static gboolean _sound_widgets_scale___lambda45_ (SoundWidgetsScale* self,
                                           GBinding* binding,
                                           GValue* srcval,
                                           GValue* targetval);
static gboolean __sound_widgets_scale___lambda45__gbinding_transform_func (GBinding* binding,
                                                                    GValue* from_value,
                                                                    GValue* to_value,
                                                                    gpointer self);
static void sound_widgets_scale_finalize (GObject * obj);
static GType sound_widgets_scale_get_type_once (void);
static void _vala_sound_widgets_scale_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_sound_widgets_scale_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);

static inline gpointer
sound_widgets_scale_get_instance_private (SoundWidgetsScale* self)
{
	return G_STRUCT_MEMBER_P (self, SoundWidgetsScale_private_offset);
}

SoundWidgetsScale*
sound_widgets_scale_construct (GType object_type,
                               GtkAdjustment* adjustment)
{
	SoundWidgetsScale * self = NULL;
	g_return_val_if_fail (adjustment != NULL, NULL);
	self = (SoundWidgetsScale*) g_object_new (object_type, "adjustment", adjustment, NULL);
	return self;
}

SoundWidgetsScale*
sound_widgets_scale_new (GtkAdjustment* adjustment)
{
	return sound_widgets_scale_construct (SOUND_WIDGETS_TYPE_SCALE, adjustment);
}

GtkAdjustment*
sound_widgets_scale_get_adjustment (SoundWidgetsScale* self)
{
	GtkAdjustment* result;
	GtkAdjustment* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_adjustment;
	result = _tmp0_;
	return result;
}

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

static void
sound_widgets_scale_set_adjustment (SoundWidgetsScale* self,
                                    GtkAdjustment* value)
{
	GtkAdjustment* old_value;
	g_return_if_fail (self != NULL);
	old_value = sound_widgets_scale_get_adjustment (self);
	if (old_value != value) {
		GtkAdjustment* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_adjustment);
		self->priv->_adjustment = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY]);
	}
}

const gchar*
sound_widgets_scale_get_icon (SoundWidgetsScale* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_icon;
	result = _tmp0_;
	return result;
}

void
sound_widgets_scale_set_icon (SoundWidgetsScale* self,
                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = sound_widgets_scale_get_icon (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_icon);
		self->priv->_icon = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ICON_PROPERTY]);
	}
}

gboolean
sound_widgets_scale_get_active (SoundWidgetsScale* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_active;
	return result;
}

void
sound_widgets_scale_set_active (SoundWidgetsScale* self,
                                gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = sound_widgets_scale_get_active (self);
	if (old_value != value) {
		self->priv->_active = value;
		g_object_notify_by_pspec ((GObject *) self, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY]);
	}
}

static void
_sound_widgets_scale___lambda43_ (SoundWidgetsScale* self)
{
	g_signal_emit (self, sound_widgets_scale_signals[SOUND_WIDGETS_SCALE_SLIDER_DROPPED_SIGNAL], 0);
}

static void
__sound_widgets_scale___lambda43__gtk_gesture_multi_press_released (GtkGestureMultiPress* _sender,
                                                                    gint n_press,
                                                                    gdouble x,
                                                                    gdouble y,
                                                                    gpointer self)
{
	_sound_widgets_scale___lambda43_ ((SoundWidgetsScale*) self);
}

static gboolean
_sound_widgets_scale___lambda44_ (SoundWidgetsScale* self,
                                  GdkEventScroll* e)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (e != NULL, FALSE);
	g_signal_emit_by_name ((GtkWidget*) self, "scroll-event", e, &_tmp0_);
	result = GDK_EVENT_STOP;
	return result;
}

static gboolean
__sound_widgets_scale___lambda44__gtk_widget_scroll_event (GtkWidget* _sender,
                                                           GdkEventScroll* event,
                                                           gpointer self)
{
	gboolean result;
	result = _sound_widgets_scale___lambda44_ ((SoundWidgetsScale*) self, event);
	return result;
}

static gboolean
_sound_widgets_scale___lambda45_ (SoundWidgetsScale* self,
                                  GBinding* binding,
                                  GValue* srcval,
                                  GValue* targetval)
{
	GValue _tmp0_;
	gboolean result;
	g_return_val_if_fail (binding != NULL, FALSE);
	g_return_val_if_fail (srcval != NULL, FALSE);
	g_return_val_if_fail (targetval != NULL, FALSE);
	_tmp0_ = *srcval;
	if (g_value_get_boolean (&_tmp0_)) {
		g_value_set_string (targetval, _ ("Mute"));
	} else {
		g_value_set_string (targetval, _ ("Unmute"));
	}
	result = TRUE;
	return result;
}

static gboolean
__sound_widgets_scale___lambda45__gbinding_transform_func (GBinding* binding,
                                                           GValue* from_value,
                                                           GValue* to_value,
                                                           gpointer self)
{
	gboolean result;
	result = _sound_widgets_scale___lambda45_ ((SoundWidgetsScale*) self, binding, from_value, to_value);
	return result;
}

static GObject *
sound_widgets_scale_constructor (GType type,
                                 guint n_construct_properties,
                                 GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SoundWidgetsScale * self;
	GtkImage* image = NULL;
	GtkImage* _tmp0_;
	GtkToggleButton* toggle = NULL;
	GtkToggleButton* _tmp1_;
	GtkToggleButton* _tmp2_;
	GtkImage* _tmp3_;
	GtkScale* scale_widget = NULL;
	GtkAdjustment* _tmp4_;
	GtkScale* _tmp5_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp6_ = NULL;
	GtkBox* _tmp7_;
	GtkToggleButton* _tmp8_;
	GtkBox* _tmp9_;
	GtkScale* _tmp10_;
	GtkBox* _tmp11_;
	GtkScale* _tmp12_;
	GtkGestureMultiPress* _tmp13_;
	GtkGestureMultiPress* _tmp14_;
	GtkScale* _tmp15_;
	GtkImage* _tmp16_;
	GtkScale* _tmp17_;
	GtkToggleButton* _tmp18_;
	GtkToggleButton* _tmp19_;
	parent_class = G_OBJECT_CLASS (sound_widgets_scale_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SOUND_WIDGETS_TYPE_SCALE, SoundWidgetsScale);
	_tmp0_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp0_);
	image = _tmp0_;
	_tmp1_ = (GtkToggleButton*) gtk_toggle_button_new ();
	g_object_ref_sink (_tmp1_);
	toggle = _tmp1_;
	_tmp2_ = toggle;
	_tmp3_ = image;
	gtk_button_set_image ((GtkButton*) _tmp2_, (GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->_adjustment;
	_tmp5_ = (GtkScale*) gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, _tmp4_);
	gtk_scale_set_draw_value (_tmp5_, FALSE);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp5_, TRUE);
	g_object_set ((GtkWidget*) _tmp5_, "width-request", 175, NULL);
	g_object_ref_sink (_tmp5_);
	scale_widget = _tmp5_;
	_tmp6_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp6_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp6_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp6_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp6_, 12);
	g_object_ref_sink (_tmp6_);
	box = _tmp6_;
	_tmp7_ = box;
	_tmp8_ = toggle;
	gtk_container_add ((GtkContainer*) _tmp7_, (GtkWidget*) _tmp8_);
	_tmp9_ = box;
	_tmp10_ = scale_widget;
	gtk_container_add ((GtkContainer*) _tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = box;
	g_object_set ((GtkContainer*) self, "child", (GtkWidget*) _tmp11_, NULL);
	gtk_widget_add_events ((GtkWidget*) self, (gint) GDK_SMOOTH_SCROLL_MASK);
	gtk_event_box_set_above_child ((GtkEventBox*) self, FALSE);
	_tmp12_ = scale_widget;
	_tmp13_ = (GtkGestureMultiPress*) gtk_gesture_multi_press_new ((GtkWidget*) _tmp12_);
	_g_object_unref0 (self->priv->gesture_click);
	self->priv->gesture_click = _tmp13_;
	_tmp14_ = self->priv->gesture_click;
	g_signal_connect_object (_tmp14_, "released", (GCallback) __sound_widgets_scale___lambda43__gtk_gesture_multi_press_released, self, 0);
	_tmp15_ = scale_widget;
	g_signal_connect_object ((GtkWidget*) _tmp15_, "scroll-event", (GCallback) __sound_widgets_scale___lambda44__gtk_widget_scroll_event, self, 0);
	_tmp16_ = image;
	g_object_bind_property_with_closures ((GObject*) self, "icon", (GObject*) _tmp16_, "icon-name", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp17_ = scale_widget;
	g_object_bind_property_with_closures ((GObject*) self, "active", (GObject*) _tmp17_, "sensitive", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp18_ = toggle;
	g_object_bind_property_with_closures ((GObject*) self, "active", (GObject*) _tmp18_, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp19_ = toggle;
	g_object_bind_property_with_closures ((GObject*) self, "active", (GObject*) _tmp19_, "tooltip-text", G_BINDING_SYNC_CREATE, (GClosure*) ((__sound_widgets_scale___lambda45__gbinding_transform_func == NULL) ? NULL : g_cclosure_new ((GCallback) __sound_widgets_scale___lambda45__gbinding_transform_func, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_g_object_unref0 (box);
	_g_object_unref0 (scale_widget);
	_g_object_unref0 (toggle);
	_g_object_unref0 (image);
	return obj;
}

static void
sound_widgets_scale_base_init (SoundWidgetsScaleClass * klass)
{
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "device-scale");
}

static void
sound_widgets_scale_class_init (SoundWidgetsScaleClass * klass,
                                gpointer klass_data)
{
	sound_widgets_scale_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SoundWidgetsScale_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_sound_widgets_scale_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_sound_widgets_scale_set_property;
	G_OBJECT_CLASS (klass)->constructor = sound_widgets_scale_constructor;
	G_OBJECT_CLASS (klass)->finalize = sound_widgets_scale_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY] = g_param_spec_object ("adjustment", "adjustment", "adjustment", gtk_adjustment_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SOUND_WIDGETS_SCALE_ICON_PROPERTY, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ICON_PROPERTY] = g_param_spec_string ("icon", "icon", "icon", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY, sound_widgets_scale_properties[SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", TRUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	sound_widgets_scale_signals[SOUND_WIDGETS_SCALE_SLIDER_DROPPED_SIGNAL] = g_signal_new ("slider-dropped", SOUND_WIDGETS_TYPE_SCALE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
sound_widgets_scale_instance_init (SoundWidgetsScale * self,
                                   gpointer klass)
{
	self->priv = sound_widgets_scale_get_instance_private (self);
	self->priv->_active = TRUE;
}

static void
sound_widgets_scale_finalize (GObject * obj)
{
	SoundWidgetsScale * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SOUND_WIDGETS_TYPE_SCALE, SoundWidgetsScale);
	_g_object_unref0 (self->priv->_adjustment);
	_g_free0 (self->priv->_icon);
	_g_object_unref0 (self->priv->gesture_click);
	G_OBJECT_CLASS (sound_widgets_scale_parent_class)->finalize (obj);
}

static GType
sound_widgets_scale_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SoundWidgetsScaleClass), (GBaseInitFunc) sound_widgets_scale_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) sound_widgets_scale_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SoundWidgetsScale), 0, (GInstanceInitFunc) sound_widgets_scale_instance_init, NULL };
	GType sound_widgets_scale_type_id;
	sound_widgets_scale_type_id = g_type_register_static (gtk_event_box_get_type (), "SoundWidgetsScale", &g_define_type_info, 0);
	SoundWidgetsScale_private_offset = g_type_add_instance_private (sound_widgets_scale_type_id, sizeof (SoundWidgetsScalePrivate));
	return sound_widgets_scale_type_id;
}

GType
sound_widgets_scale_get_type (void)
{
	static volatile gsize sound_widgets_scale_type_id__once = 0;
	if (g_once_init_enter (&sound_widgets_scale_type_id__once)) {
		GType sound_widgets_scale_type_id;
		sound_widgets_scale_type_id = sound_widgets_scale_get_type_once ();
		g_once_init_leave (&sound_widgets_scale_type_id__once, sound_widgets_scale_type_id);
	}
	return sound_widgets_scale_type_id__once;
}

static void
_vala_sound_widgets_scale_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	SoundWidgetsScale * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SOUND_WIDGETS_TYPE_SCALE, SoundWidgetsScale);
	switch (property_id) {
		case SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY:
		g_value_set_object (value, sound_widgets_scale_get_adjustment (self));
		break;
		case SOUND_WIDGETS_SCALE_ICON_PROPERTY:
		g_value_set_string (value, sound_widgets_scale_get_icon (self));
		break;
		case SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY:
		g_value_set_boolean (value, sound_widgets_scale_get_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_sound_widgets_scale_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	SoundWidgetsScale * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SOUND_WIDGETS_TYPE_SCALE, SoundWidgetsScale);
	switch (property_id) {
		case SOUND_WIDGETS_SCALE_ADJUSTMENT_PROPERTY:
		sound_widgets_scale_set_adjustment (self, g_value_get_object (value));
		break;
		case SOUND_WIDGETS_SCALE_ICON_PROPERTY:
		sound_widgets_scale_set_icon (self, g_value_get_string (value));
		break;
		case SOUND_WIDGETS_SCALE_ACTIVE_PROPERTY:
		sound_widgets_scale_set_active (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

