/* preferences-panel-integrations.c generated by valac 0.56.19, the Vala compiler
 * generated from preferences-panel-integrations.vala, do not modify */

/*
 * Copyright (c) 2026 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <adwaita.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include "ft_core.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  {
	FT_PREFERENCES_PANEL_INTEGRATIONS_0_PROPERTY,
	FT_PREFERENCES_PANEL_INTEGRATIONS_NUM_PROPERTIES
};
static GParamSpec* ft_preferences_panel_integrations_properties[FT_PREFERENCES_PANEL_INTEGRATIONS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _FtPreferencesPanelIntegrationsPrivate {
	AdwPreferencesPage* page;
	AdwSwitchRow* autostart_switchrow;
	AdwPreferencesGroup* autostart_group;
	GtkLabel* autostart_label;
	GSettings* settings;
};

static gint FtPreferencesPanelIntegrations_private_offset;
static gpointer ft_preferences_panel_integrations_parent_class = NULL;

static AdwPreferencesPage* ft_preferences_panel_integrations_real_get_preferences_page (FtPreferencesPanel* base);
static gchar** ft_preferences_panel_integrations_real_get_group_order (FtPreferencesPanel* base,
                                                                gint* result_length1);
static void ft_preferences_panel_integrations_real_dispose (GObject* base);
static GObject * ft_preferences_panel_integrations_constructor (GType type,
                                                         guint n_construct_properties,
                                                         GObjectConstructParam * construct_properties);
static void ft_preferences_panel_integrations_finalize (GObject * obj);
static GType ft_preferences_panel_integrations_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static const gchar* FT_PREFERENCES_PANEL_INTEGRATIONS_GROUP_ORDER[3] = {"autostart", "desktop", "media-playback"};

static inline gpointer
ft_preferences_panel_integrations_get_instance_private (FtPreferencesPanelIntegrations* self)
{
	return G_STRUCT_MEMBER_P (self, FtPreferencesPanelIntegrations_private_offset);
}

static AdwPreferencesPage*
ft_preferences_panel_integrations_real_get_preferences_page (FtPreferencesPanel* base)
{
	FtPreferencesPanelIntegrations * self;
	AdwPreferencesPage* _tmp0_;
	AdwPreferencesPage* result;
	self = (FtPreferencesPanelIntegrations*) base;
	_tmp0_ = self->priv->page;
	result = _tmp0_;
	return result;
}

static gchar**
ft_preferences_panel_integrations_real_get_group_order (FtPreferencesPanel* base,
                                                        gint* result_length1)
{
	FtPreferencesPanelIntegrations * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** result;
	self = (FtPreferencesPanelIntegrations*) base;
	_tmp0_ = FT_PREFERENCES_PANEL_INTEGRATIONS_GROUP_ORDER;
	_tmp0__length1 = G_N_ELEMENTS (FT_PREFERENCES_PANEL_INTEGRATIONS_GROUP_ORDER);
	if (result_length1) {
		*result_length1 = _tmp0__length1;
	}
	result = _tmp0_;
	return result;
}

static void
ft_preferences_panel_integrations_real_dispose (GObject* base)
{
	FtPreferencesPanelIntegrations * self;
	self = (FtPreferencesPanelIntegrations*) base;
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = NULL;
	G_OBJECT_CLASS (ft_preferences_panel_integrations_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_PREFERENCES_PANEL, FtPreferencesPanel));
}

FtPreferencesPanelIntegrations*
ft_preferences_panel_integrations_construct (GType object_type)
{
	FtPreferencesPanelIntegrations * self = NULL;
	self = (FtPreferencesPanelIntegrations*) ft_preferences_panel_construct (object_type);
	return self;
}

FtPreferencesPanelIntegrations*
ft_preferences_panel_integrations_new (void)
{
	return ft_preferences_panel_integrations_construct (FT_TYPE_PREFERENCES_PANEL_INTEGRATIONS);
}

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

static GObject *
ft_preferences_panel_integrations_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtPreferencesPanelIntegrations * self;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GSettings* _tmp2_;
	AdwSwitchRow* _tmp3_;
	FtBackgroundManager* background_manager = NULL;
	FtBackgroundManager* _tmp4_;
	FtBackgroundManager* _tmp5_;
	GtkLabel* _tmp6_;
	AdwPreferencesGroup* _tmp7_;
	gchar* _tmp8_;
	parent_class = G_OBJECT_CLASS (ft_preferences_panel_integrations_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_PANEL_INTEGRATIONS, FtPreferencesPanelIntegrations);
	_tmp0_ = ft_get_settings ();
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = self->priv->settings;
	_tmp3_ = self->priv->autostart_switchrow;
	g_settings_bind (_tmp2_, "autostart", (GObject*) _tmp3_, "active", G_SETTINGS_BIND_DEFAULT);
	_tmp4_ = ft_background_manager_new ();
	background_manager = _tmp4_;
	_tmp5_ = background_manager;
	_tmp6_ = self->priv->autostart_label;
	g_object_bind_property_with_closures ((GObject*) _tmp5_, "autostart-allowed", (GObject*) _tmp6_, "visible", 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)));
	_tmp7_ = self->priv->autostart_group;
	_tmp8_ = g_strdup ("autostart");
	g_object_set_data_full ((GObject*) _tmp7_, "name", _tmp8_, g_free);
	_g_object_unref0 (background_manager);
	return obj;
}

static void
ft_preferences_panel_integrations_class_init (FtPreferencesPanelIntegrationsClass * klass,
                                              gpointer klass_data)
{
	ft_preferences_panel_integrations_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtPreferencesPanelIntegrations_private_offset);
	((FtPreferencesPanelClass *) klass)->get_preferences_page = (AdwPreferencesPage* (*) (FtPreferencesPanel*)) ft_preferences_panel_integrations_real_get_preferences_page;
	((FtPreferencesPanelClass *) klass)->get_group_order = (gchar** (*) (FtPreferencesPanel*, gint*)) ft_preferences_panel_integrations_real_get_group_order;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_preferences_panel_integrations_real_dispose;
	G_OBJECT_CLASS (klass)->constructor = ft_preferences_panel_integrations_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_preferences_panel_integrations_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/preferences/integrations/preferences-panel-integrations.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "page", FALSE, FtPreferencesPanelIntegrations_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelIntegrationsPrivate, page));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "autostart_switchrow", FALSE, FtPreferencesPanelIntegrations_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelIntegrationsPrivate, autostart_switchrow));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "autostart_group", FALSE, FtPreferencesPanelIntegrations_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelIntegrationsPrivate, autostart_group));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "autostart_label", FALSE, FtPreferencesPanelIntegrations_private_offset + G_STRUCT_OFFSET (FtPreferencesPanelIntegrationsPrivate, autostart_label));
}

static void
ft_preferences_panel_integrations_instance_init (FtPreferencesPanelIntegrations * self,
                                                 gpointer klass)
{
	self->priv = ft_preferences_panel_integrations_get_instance_private (self);
	self->priv->settings = NULL;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_preferences_panel_integrations_finalize (GObject * obj)
{
	FtPreferencesPanelIntegrations * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_PREFERENCES_PANEL_INTEGRATIONS, FtPreferencesPanelIntegrations);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (ft_preferences_panel_integrations_parent_class)->finalize (obj);
}

static GType
ft_preferences_panel_integrations_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtPreferencesPanelIntegrationsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_preferences_panel_integrations_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtPreferencesPanelIntegrations), 0, (GInstanceInitFunc) ft_preferences_panel_integrations_instance_init, NULL };
	GType ft_preferences_panel_integrations_type_id;
	ft_preferences_panel_integrations_type_id = g_type_register_static (FT_TYPE_PREFERENCES_PANEL, "FtPreferencesPanelIntegrations", &g_define_type_info, 0);
	FtPreferencesPanelIntegrations_private_offset = g_type_add_instance_private (ft_preferences_panel_integrations_type_id, sizeof (FtPreferencesPanelIntegrationsPrivate));
	return ft_preferences_panel_integrations_type_id;
}

GType
ft_preferences_panel_integrations_get_type (void)
{
	static volatile gsize ft_preferences_panel_integrations_type_id__once = 0;
	if (g_once_init_enter (&ft_preferences_panel_integrations_type_id__once)) {
		GType ft_preferences_panel_integrations_type_id;
		ft_preferences_panel_integrations_type_id = ft_preferences_panel_integrations_get_type_once ();
		g_once_init_leave (&ft_preferences_panel_integrations_type_id__once, ft_preferences_panel_integrations_type_id);
	}
	return ft_preferences_panel_integrations_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

