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

/*
 * This file is part of budgie-desktop
 *
 * Copyright Budgie Desktop 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 2 of the License, or
 * (at your option) any later version.
 */

#include "caffeineapplet.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.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  {
	CAFFEINE_APPLET_SETTINGS_0_PROPERTY,
	CAFFEINE_APPLET_SETTINGS_NUM_PROPERTIES
};
static GParamSpec* caffeine_applet_settings_properties[CAFFEINE_APPLET_SETTINGS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _CaffeineAppletSettingsPrivate {
	GSettings* settings;
	GSettings* wm_settings;
	GtkSwitch* notify_switch;
	GtkSwitch* brightness_switch;
	GtkSpinButton* brightness_level;
};

static gint CaffeineAppletSettings_private_offset;
static gpointer caffeine_applet_settings_parent_class = NULL;
static GType caffeine_applet_settings_type_id = 0;

static void caffeine_applet_settings_finalize (GObject * obj);

static inline gpointer
caffeine_applet_settings_get_instance_private (CaffeineAppletSettings* self)
{
	return G_STRUCT_MEMBER_P (self, CaffeineAppletSettings_private_offset);
}

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

CaffeineAppletSettings*
caffeine_applet_settings_construct (GType object_type,
                                    GSettings* settings)
{
	CaffeineAppletSettings * self = NULL;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GSettings* _tmp2_;
	GtkSwitch* _tmp3_;
	GSettings* _tmp4_;
	GtkSwitch* _tmp5_;
	GSettings* _tmp6_;
	GtkSpinButton* _tmp7_;
	self = (CaffeineAppletSettings*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (settings);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp0_;
	_tmp1_ = g_settings_new ("com.solus-project.budgie-wm");
	_g_object_unref0 (self->priv->wm_settings);
	self->priv->wm_settings = _tmp1_;
	_tmp2_ = self->priv->wm_settings;
	_tmp3_ = self->priv->notify_switch;
	g_settings_bind (_tmp2_, "caffeine-mode-notification", (GObject*) _tmp3_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp4_ = self->priv->wm_settings;
	_tmp5_ = self->priv->brightness_switch;
	g_settings_bind (_tmp4_, "caffeine-mode-toggle-brightness", (GObject*) _tmp5_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp6_ = self->priv->wm_settings;
	_tmp7_ = self->priv->brightness_level;
	g_settings_bind (_tmp6_, "caffeine-mode-screen-brightness", (GObject*) _tmp7_, "value", G_SETTINGS_BIND_DEFAULT);
	return self;
}

CaffeineAppletSettings*
caffeine_applet_settings_new (GSettings* settings)
{
	return caffeine_applet_settings_construct (CAFFEINE_TYPE_APPLET_SETTINGS, settings);
}

static void
caffeine_applet_settings_class_init (CaffeineAppletSettingsClass * klass,
                                     gpointer klass_data)
{
	caffeine_applet_settings_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CaffeineAppletSettings_private_offset);
	G_OBJECT_CLASS (klass)->finalize = caffeine_applet_settings_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/solus-project/caffeine/settings.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "notify_switch", FALSE, CaffeineAppletSettings_private_offset + G_STRUCT_OFFSET (CaffeineAppletSettingsPrivate, notify_switch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "brightness_switch", FALSE, CaffeineAppletSettings_private_offset + G_STRUCT_OFFSET (CaffeineAppletSettingsPrivate, brightness_switch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "brightness_level", FALSE, CaffeineAppletSettings_private_offset + G_STRUCT_OFFSET (CaffeineAppletSettingsPrivate, brightness_level));
}

static void
caffeine_applet_settings_instance_init (CaffeineAppletSettings * self,
                                        gpointer klass)
{
	self->priv = caffeine_applet_settings_get_instance_private (self);
	self->priv->settings = NULL;
	self->priv->wm_settings = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
caffeine_applet_settings_finalize (GObject * obj)
{
	CaffeineAppletSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAFFEINE_TYPE_APPLET_SETTINGS, CaffeineAppletSettings);
	_g_object_unref0 (self->priv->settings);
	_g_object_unref0 (self->priv->wm_settings);
	G_OBJECT_CLASS (caffeine_applet_settings_parent_class)->finalize (obj);
}

GType
caffeine_applet_settings_get_type (void)
{
	return caffeine_applet_settings_type_id;
}

GType
caffeine_applet_settings_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (CaffeineAppletSettingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) caffeine_applet_settings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CaffeineAppletSettings), 0, (GInstanceInitFunc) caffeine_applet_settings_instance_init, NULL };
	caffeine_applet_settings_type_id = g_type_module_register_type (module, gtk_grid_get_type (), "CaffeineAppletSettings", &g_define_type_info, 0);
	CaffeineAppletSettings_private_offset = sizeof (CaffeineAppletSettingsPrivate);
	return caffeine_applet_settings_type_id;
}

