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

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

#include "mouse-touchpad.h"
#include <glib-object.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <switchboard.h>
#include <gtk/gtk.h>
#include <float.h>
#include <math.h>
#include <granite-7.h>
#include <stdlib.h>
#include <string.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  {
	MOUSE_TOUCHPAD_MOUSE_VIEW_0_PROPERTY,
	MOUSE_TOUCHPAD_MOUSE_VIEW_NUM_PROPERTIES
};
static GParamSpec* mouse_touchpad_mouse_view_properties[MOUSE_TOUCHPAD_MOUSE_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block2Data Block2Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _Block2Data {
	int _ref_count_;
	MouseTouchpadMouseView* self;
	GSettings* settings;
};

static gpointer mouse_touchpad_mouse_view_parent_class = NULL;

static GObject * mouse_touchpad_mouse_view_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void _mouse_touchpad_mouse_view___lambda6_ (Block2Data* _data2_);
static void __mouse_touchpad_mouse_view___lambda6__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                      gpointer self);
static void _mouse_touchpad_mouse_view___lambda7_ (Block2Data* _data2_);
static void __mouse_touchpad_mouse_view___lambda7__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                      gpointer self);
static void _mouse_touchpad_mouse_view___lambda8_ (Block2Data* _data2_);
static void __mouse_touchpad_mouse_view___lambda8__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                      gpointer self);
static GType mouse_touchpad_mouse_view_get_type_once (void);

MouseTouchpadMouseView*
mouse_touchpad_mouse_view_construct (GType object_type)
{
	MouseTouchpadMouseView * self = NULL;
	GThemedIcon* _tmp0_;
	GThemedIcon* _tmp1_;
	_tmp0_ = (GThemedIcon*) g_themed_icon_new ("input-mouse");
	_tmp1_ = _tmp0_;
	self = (MouseTouchpadMouseView*) g_object_new (object_type, "header", _ ("Devices"), "icon", _tmp1_, "title", _ ("Mouse"), NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

MouseTouchpadMouseView*
mouse_touchpad_mouse_view_new (void)
{
	return mouse_touchpad_mouse_view_construct (MOUSE_TOUCHPAD_TYPE_MOUSE_VIEW);
}

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_)) {
		MouseTouchpadMouseView* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->settings);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

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

static void
_mouse_touchpad_mouse_view___lambda6_ (Block2Data* _data2_)
{
	MouseTouchpadMouseView* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->settings;
	g_settings_set_enum (_tmp0_, "accel-profile", 0);
}

static void
__mouse_touchpad_mouse_view___lambda6__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                 gpointer self)
{
	_mouse_touchpad_mouse_view___lambda6_ (self);
}

static void
_mouse_touchpad_mouse_view___lambda7_ (Block2Data* _data2_)
{
	MouseTouchpadMouseView* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->settings;
	g_settings_set_enum (_tmp0_, "accel-profile", 1);
}

static void
__mouse_touchpad_mouse_view___lambda7__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                 gpointer self)
{
	_mouse_touchpad_mouse_view___lambda7_ (self);
}

static void
_mouse_touchpad_mouse_view___lambda8_ (Block2Data* _data2_)
{
	MouseTouchpadMouseView* self;
	GSettings* _tmp0_;
	self = _data2_->self;
	_tmp0_ = _data2_->settings;
	g_settings_set_enum (_tmp0_, "accel-profile", 2);
}

static void
__mouse_touchpad_mouse_view___lambda8__gtk_check_button_toggled (GtkCheckButton* _sender,
                                                                 gpointer self)
{
	_mouse_touchpad_mouse_view___lambda8_ (self);
}

static GObject *
mouse_touchpad_mouse_view_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MouseTouchpadMouseView * self;
	Block2Data* _data2_;
	GtkAdjustment* pointer_speed_adjustment = NULL;
	GtkAdjustment* _tmp0_;
	GtkScale* pointer_speed_scale = NULL;
	GtkAdjustment* _tmp1_;
	GtkScale* _tmp2_ = NULL;
	GtkScale* _tmp3_;
	GtkScale* _tmp4_;
	GtkScale* _tmp5_;
	GraniteHeaderLabel* pointer_speed_header = NULL;
	GtkScale* _tmp6_;
	GtkWidget* _tmp7_;
	GraniteHeaderLabel* _tmp8_ = NULL;
	GtkCheckButton* accel_profile_default = NULL;
	GtkCheckButton* _tmp9_;
	GtkCheckButton* accel_profile_flat = NULL;
	GtkCheckButton* _tmp10_;
	GtkCheckButton* _tmp11_;
	GtkCheckButton* _tmp12_ = NULL;
	GtkCheckButton* accel_profile_adaptive = NULL;
	GtkCheckButton* _tmp13_;
	GtkCheckButton* _tmp14_;
	GtkCheckButton* _tmp15_ = NULL;
	GraniteBox* accel_profile_box = NULL;
	GraniteBox* _tmp16_ = NULL;
	GraniteBox* _tmp17_;
	GtkCheckButton* _tmp18_;
	GraniteBox* _tmp19_;
	GtkCheckButton* _tmp20_;
	GraniteBox* _tmp21_;
	GtkCheckButton* _tmp22_;
	GraniteHeaderLabel* accel_profile_header = NULL;
	GraniteBox* _tmp23_;
	GtkWidget* _tmp24_;
	GraniteHeaderLabel* _tmp25_ = NULL;
	GtkSwitch* natural_scrolling_switch = NULL;
	GtkSwitch* _tmp26_ = NULL;
	GraniteHeaderLabel* natural_scrolling_header = NULL;
	GtkSwitch* _tmp27_;
	GtkWidget* _tmp28_;
	gchar* _tmp29_;
	GraniteHeaderLabel* _tmp30_ = NULL;
	GraniteBox* natural_scrolling_box = NULL;
	GraniteBox* _tmp31_ = NULL;
	GraniteBox* _tmp32_;
	GraniteHeaderLabel* _tmp33_;
	GraniteBox* _tmp34_;
	GtkSwitch* _tmp35_;
	GraniteBox* content_box = NULL;
	GraniteBox* _tmp36_;
	GraniteBox* _tmp37_;
	GraniteHeaderLabel* _tmp38_;
	GraniteBox* _tmp39_;
	GtkScale* _tmp40_;
	GraniteBox* _tmp41_;
	GraniteHeaderLabel* _tmp42_;
	GraniteBox* _tmp43_;
	GraniteBox* _tmp44_;
	GraniteBox* _tmp45_;
	GraniteBox* _tmp46_;
	GraniteBox* _tmp47_;
	GSettings* _tmp48_;
	GSettings* _tmp49_;
	GtkSwitch* _tmp50_;
	GSettings* _tmp51_;
	GtkAdjustment* _tmp52_;
	GSettings* _tmp53_;
	GtkCheckButton* _tmp57_;
	GtkCheckButton* _tmp58_;
	GtkCheckButton* _tmp59_;
	parent_class = G_OBJECT_CLASS (mouse_touchpad_mouse_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOUSE_TOUCHPAD_TYPE_MOUSE_VIEW, MouseTouchpadMouseView);
	_data2_ = g_slice_new0 (Block2Data);
	_data2_->_ref_count_ = 1;
	_data2_->self = g_object_ref (self);
	switchboard_settings_page_set_show_end_title_buttons ((SwitchboardSettingsPage*) self, TRUE);
	_tmp0_ = gtk_adjustment_new ((gdouble) 0, (gdouble) -1, (gdouble) 1, 0.1, (gdouble) 0, (gdouble) 0);
	g_object_ref_sink (_tmp0_);
	pointer_speed_adjustment = _tmp0_;
	_tmp1_ = pointer_speed_adjustment;
	_tmp2_ = (GtkScale*) gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, _tmp1_);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	g_object_ref_sink (_tmp2_);
	pointer_speed_scale = _tmp2_;
	_tmp3_ = pointer_speed_scale;
	gtk_scale_add_mark (_tmp3_, (gdouble) -1, GTK_POS_BOTTOM, _ ("Slower"));
	_tmp4_ = pointer_speed_scale;
	gtk_scale_add_mark (_tmp4_, (gdouble) 0, GTK_POS_BOTTOM, NULL);
	_tmp5_ = pointer_speed_scale;
	gtk_scale_add_mark (_tmp5_, (gdouble) 1, GTK_POS_BOTTOM, _ ("Faster"));
	_tmp6_ = pointer_speed_scale;
	_tmp7_ = _g_object_ref0 ((GtkWidget*) _tmp6_);
	_tmp8_ = granite_header_label_new (_ ("Pointer Speed"));
	granite_header_label_set_mnemonic_widget (_tmp8_, _tmp7_);
	_g_object_unref0 (_tmp7_);
	g_object_ref_sink (_tmp8_);
	pointer_speed_header = _tmp8_;
	_tmp9_ = (GtkCheckButton*) gtk_check_button_new_with_label (_ ("Hardware default"));
	g_object_ref_sink (_tmp9_);
	accel_profile_default = _tmp9_;
	_tmp10_ = accel_profile_default;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	_tmp12_ = (GtkCheckButton*) gtk_check_button_new_with_label (_ ("None"));
	gtk_check_button_set_group (_tmp12_, _tmp11_);
	_g_object_unref0 (_tmp11_);
	g_object_ref_sink (_tmp12_);
	accel_profile_flat = _tmp12_;
	_tmp13_ = accel_profile_default;
	_tmp14_ = _g_object_ref0 (_tmp13_);
	_tmp15_ = (GtkCheckButton*) gtk_check_button_new_with_label (_ ("Adaptive"));
	gtk_check_button_set_group (_tmp15_, _tmp14_);
	_g_object_unref0 (_tmp14_);
	g_object_ref_sink (_tmp15_);
	accel_profile_adaptive = _tmp15_;
	_tmp16_ = granite_box_new (GTK_ORIENTATION_VERTICAL, GRANITE_BOX_SPACING_HALF);
	g_object_set ((GtkAccessible*) _tmp16_, "accessible-role", GTK_ACCESSIBLE_ROLE_LIST, NULL);
	g_object_ref_sink (_tmp16_);
	accel_profile_box = _tmp16_;
	_tmp17_ = accel_profile_box;
	_tmp18_ = accel_profile_default;
	gtk_box_append ((GtkBox*) _tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = accel_profile_box;
	_tmp20_ = accel_profile_flat;
	gtk_box_append ((GtkBox*) _tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = accel_profile_box;
	_tmp22_ = accel_profile_adaptive;
	gtk_box_append ((GtkBox*) _tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = accel_profile_box;
	_tmp24_ = _g_object_ref0 ((GtkWidget*) _tmp23_);
	_tmp25_ = granite_header_label_new (_ ("Pointer Acceleration"));
	granite_header_label_set_mnemonic_widget (_tmp25_, _tmp24_);
	_g_object_unref0 (_tmp24_);
	g_object_ref_sink (_tmp25_);
	accel_profile_header = _tmp25_;
	_tmp26_ = (GtkSwitch*) gtk_switch_new ();
	gtk_widget_set_halign ((GtkWidget*) _tmp26_, GTK_ALIGN_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp26_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp26_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp26_);
	natural_scrolling_switch = _tmp26_;
	_tmp27_ = natural_scrolling_switch;
	_tmp28_ = _g_object_ref0 ((GtkWidget*) _tmp27_);
	_tmp29_ = g_strdup (_ ("Scrolling moves the content, not the view"));
	_tmp30_ = granite_header_label_new (_ ("Natural Scrolling"));
	granite_header_label_set_mnemonic_widget (_tmp30_, _tmp28_);
	_g_object_unref0 (_tmp28_);
	granite_header_label_set_secondary_text (_tmp30_, _tmp29_);
	_g_free0 (_tmp29_);
	g_object_ref_sink (_tmp30_);
	natural_scrolling_header = _tmp30_;
	_tmp31_ = granite_box_new (GTK_ORIENTATION_HORIZONTAL, GRANITE_BOX_SPACING_SINGLE);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp31_, 12);
	g_object_ref_sink (_tmp31_);
	natural_scrolling_box = _tmp31_;
	_tmp32_ = natural_scrolling_box;
	_tmp33_ = natural_scrolling_header;
	gtk_box_append ((GtkBox*) _tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = natural_scrolling_box;
	_tmp35_ = natural_scrolling_switch;
	gtk_box_append ((GtkBox*) _tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = granite_box_new (GTK_ORIENTATION_VERTICAL, GRANITE_BOX_SPACING_HALF);
	g_object_ref_sink (_tmp36_);
	content_box = _tmp36_;
	_tmp37_ = content_box;
	_tmp38_ = pointer_speed_header;
	gtk_box_append ((GtkBox*) _tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = content_box;
	_tmp40_ = pointer_speed_scale;
	gtk_box_append ((GtkBox*) _tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = content_box;
	_tmp42_ = accel_profile_header;
	gtk_box_append ((GtkBox*) _tmp41_, (GtkWidget*) _tmp42_);
	_tmp43_ = content_box;
	_tmp44_ = accel_profile_box;
	gtk_box_append ((GtkBox*) _tmp43_, (GtkWidget*) _tmp44_);
	_tmp45_ = content_box;
	_tmp46_ = natural_scrolling_box;
	gtk_box_append ((GtkBox*) _tmp45_, (GtkWidget*) _tmp46_);
	_tmp47_ = content_box;
	switchboard_settings_page_set_child ((SwitchboardSettingsPage*) self, (GtkWidget*) _tmp47_);
	_tmp48_ = g_settings_new ("org.gnome.desktop.peripherals.mouse");
	_data2_->settings = _tmp48_;
	_tmp49_ = _data2_->settings;
	_tmp50_ = natural_scrolling_switch;
	g_settings_bind (_tmp49_, "natural-scroll", (GObject*) _tmp50_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp51_ = _data2_->settings;
	_tmp52_ = pointer_speed_adjustment;
	g_settings_bind (_tmp51_, "speed", (GObject*) _tmp52_, "value", G_SETTINGS_BIND_DEFAULT);
	_tmp53_ = _data2_->settings;
	switch (g_settings_get_enum (_tmp53_, "accel-profile")) {
		case 1:
		{
			GtkCheckButton* _tmp54_;
			_tmp54_ = accel_profile_flat;
			gtk_check_button_set_active (_tmp54_, TRUE);
			break;
		}
		case 2:
		{
			GtkCheckButton* _tmp55_;
			_tmp55_ = accel_profile_adaptive;
			gtk_check_button_set_active (_tmp55_, TRUE);
			break;
		}
		default:
		case 0:
		{
			GtkCheckButton* _tmp56_;
			_tmp56_ = accel_profile_default;
			gtk_check_button_set_active (_tmp56_, TRUE);
			break;
		}
	}
	_tmp57_ = accel_profile_default;
	g_signal_connect_data (_tmp57_, "toggled", (GCallback) __mouse_touchpad_mouse_view___lambda6__gtk_check_button_toggled, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp58_ = accel_profile_flat;
	g_signal_connect_data (_tmp58_, "toggled", (GCallback) __mouse_touchpad_mouse_view___lambda7__gtk_check_button_toggled, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_tmp59_ = accel_profile_adaptive;
	g_signal_connect_data (_tmp59_, "toggled", (GCallback) __mouse_touchpad_mouse_view___lambda8__gtk_check_button_toggled, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
	_g_object_unref0 (content_box);
	_g_object_unref0 (natural_scrolling_box);
	_g_object_unref0 (natural_scrolling_header);
	_g_object_unref0 (natural_scrolling_switch);
	_g_object_unref0 (accel_profile_header);
	_g_object_unref0 (accel_profile_box);
	_g_object_unref0 (accel_profile_adaptive);
	_g_object_unref0 (accel_profile_flat);
	_g_object_unref0 (accel_profile_default);
	_g_object_unref0 (pointer_speed_header);
	_g_object_unref0 (pointer_speed_scale);
	_g_object_unref0 (pointer_speed_adjustment);
	block2_data_unref (_data2_);
	_data2_ = NULL;
	return obj;
}

static void
mouse_touchpad_mouse_view_class_init (MouseTouchpadMouseViewClass * klass,
                                      gpointer klass_data)
{
	mouse_touchpad_mouse_view_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = mouse_touchpad_mouse_view_constructor;
}

static void
mouse_touchpad_mouse_view_instance_init (MouseTouchpadMouseView * self,
                                         gpointer klass)
{
}

static GType
mouse_touchpad_mouse_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MouseTouchpadMouseViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mouse_touchpad_mouse_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MouseTouchpadMouseView), 0, (GInstanceInitFunc) mouse_touchpad_mouse_view_instance_init, NULL };
	GType mouse_touchpad_mouse_view_type_id;
	mouse_touchpad_mouse_view_type_id = g_type_register_static (SWITCHBOARD_TYPE_SETTINGS_PAGE, "MouseTouchpadMouseView", &g_define_type_info, 0);
	return mouse_touchpad_mouse_view_type_id;
}

GType
mouse_touchpad_mouse_view_get_type (void)
{
	static volatile gsize mouse_touchpad_mouse_view_type_id__once = 0;
	if (g_once_init_enter (&mouse_touchpad_mouse_view_type_id__once)) {
		GType mouse_touchpad_mouse_view_type_id;
		mouse_touchpad_mouse_view_type_id = mouse_touchpad_mouse_view_get_type_once ();
		g_once_init_leave (&mouse_touchpad_mouse_view_type_id__once, mouse_touchpad_mouse_view_type_id);
	}
	return mouse_touchpad_mouse_view_type_id__once;
}

