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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*-
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: Michael Terry
 */

#include <adwaita.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include "deja.h"
#include <gio/gio.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TYPE_SWITCH_ROW (switch_row_get_type ())
#define SWITCH_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_SWITCH_ROW, SwitchRow))
#define SWITCH_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_SWITCH_ROW, SwitchRowClass))
#define IS_SWITCH_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_SWITCH_ROW))
#define IS_SWITCH_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_SWITCH_ROW))
#define SWITCH_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_SWITCH_ROW, SwitchRowClass))

typedef struct _SwitchRow SwitchRow;
typedef struct _SwitchRowClass SwitchRowClass;
typedef struct _SwitchRowPrivate SwitchRowPrivate;

#define TYPE_CONFIG_RESTIC_ROW (config_restic_row_get_type ())
#define CONFIG_RESTIC_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIG_RESTIC_ROW, ConfigResticRow))
#define CONFIG_RESTIC_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIG_RESTIC_ROW, ConfigResticRowClass))
#define IS_CONFIG_RESTIC_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIG_RESTIC_ROW))
#define IS_CONFIG_RESTIC_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIG_RESTIC_ROW))
#define CONFIG_RESTIC_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIG_RESTIC_ROW, ConfigResticRowClass))

typedef struct _ConfigResticRow ConfigResticRow;
typedef struct _ConfigResticRowClass ConfigResticRowClass;
typedef struct _ConfigResticRowPrivate ConfigResticRowPrivate;
enum  {
	CONFIG_RESTIC_ROW_0_PROPERTY,
	CONFIG_RESTIC_ROW_NUM_PROPERTIES
};
static GParamSpec* config_restic_row_properties[CONFIG_RESTIC_ROW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _SwitchRow {
	AdwActionRow parent_instance;
	SwitchRowPrivate * priv;
};

struct _SwitchRowClass {
	AdwActionRowClass parent_class;
};

struct _ConfigResticRow {
	SwitchRow parent_instance;
	ConfigResticRowPrivate * priv;
};

struct _ConfigResticRowClass {
	SwitchRowClass parent_class;
};

static gpointer config_restic_row_parent_class = NULL;

VALA_EXTERN GType switch_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SwitchRow, g_object_unref)
VALA_EXTERN GType config_restic_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigResticRow, g_object_unref)
static gboolean config_restic_row_get_mapping (GValue* val,
                                        GVariant* variant,
                                        void* data);
static GVariant* config_restic_row_set_mapping (GValue* val,
                                         const GVariantType* expected_type,
                                         void* data);
VALA_EXTERN ConfigResticRow* config_restic_row_new (void);
VALA_EXTERN ConfigResticRow* config_restic_row_construct (GType object_type);
VALA_EXTERN SwitchRow* switch_row_new (void);
VALA_EXTERN SwitchRow* switch_row_construct (GType object_type);
static GObject * config_restic_row_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static gboolean _config_restic_row_get_mapping_gsettings_bind_get_mapping (GValue* value,
                                                                    GVariant* variant,
                                                                    void* user_data);
static GVariant* _config_restic_row_set_mapping_gsettings_bind_set_mapping (GValue* value,
                                                                     const GVariantType* expected_type,
                                                                     void* user_data);
static GType config_restic_row_get_type_once (void);

static gboolean
config_restic_row_get_mapping (GValue* val,
                               GVariant* variant,
                               void* data)
{
	gchar* tool_name = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean result;
	g_return_val_if_fail (val != NULL, FALSE);
	g_return_val_if_fail (variant != NULL, FALSE);
	_tmp0_ = g_variant_get_string (variant, NULL);
	_tmp1_ = g_strdup (_tmp0_);
	tool_name = _tmp1_;
	g_value_set_boolean (val, g_strcmp0 (tool_name, "restic") == 0);
	result = TRUE;
	_g_free0 (tool_name);
	return result;
}

static GVariant*
config_restic_row_set_mapping (GValue* val,
                               const GVariantType* expected_type,
                               void* data)
{
	const gchar* _tmp0_ = NULL;
	gchar* tool_name = NULL;
	gchar* _tmp1_;
	GVariant* _tmp2_;
	GVariant* result;
	g_return_val_if_fail (val != NULL, NULL);
	g_return_val_if_fail (expected_type != NULL, NULL);
	if (g_value_get_boolean (val)) {
		_tmp0_ = "restic";
	} else {
		_tmp0_ = "auto";
	}
	_tmp1_ = g_strdup (_tmp0_);
	tool_name = _tmp1_;
	_tmp2_ = g_variant_new_string (tool_name);
	g_variant_ref_sink (_tmp2_);
	result = _tmp2_;
	_g_free0 (tool_name);
	return result;
}

ConfigResticRow*
config_restic_row_construct (GType object_type)
{
	ConfigResticRow * self = NULL;
	self = (ConfigResticRow*) switch_row_construct (object_type);
	return self;
}

ConfigResticRow*
config_restic_row_new (void)
{
	return config_restic_row_construct (TYPE_CONFIG_RESTIC_ROW);
}

static gboolean
_config_restic_row_get_mapping_gsettings_bind_get_mapping (GValue* value,
                                                           GVariant* variant,
                                                           void* user_data)
{
	gboolean result;
	result = config_restic_row_get_mapping (value, variant, user_data);
	return result;
}

static GVariant*
_config_restic_row_set_mapping_gsettings_bind_set_mapping (GValue* value,
                                                           const GVariantType* expected_type,
                                                           void* user_data)
{
	GVariant* result;
	result = config_restic_row_set_mapping (value, expected_type, user_data);
	return result;
}

static GObject *
config_restic_row_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConfigResticRow * self;
	DejaDupFilteredSettings* settings = NULL;
	DejaDupFilteredSettings* _tmp0_;
	DejaDupFilteredSettings* _tmp1_;
	parent_class = G_OBJECT_CLASS (config_restic_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CONFIG_RESTIC_ROW, ConfigResticRow);
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _ ("Use _Restic for new backups"));
	_tmp0_ = deja_dup_get_settings (NULL);
	settings = _tmp0_;
	_tmp1_ = settings;
	g_settings_bind_with_mapping ((GSettings*) _tmp1_, DEJA_DUP_TOOL_WHEN_NEW_KEY, (GObject*) self, "active", G_SETTINGS_BIND_DEFAULT, _config_restic_row_get_mapping_gsettings_bind_get_mapping, _config_restic_row_set_mapping_gsettings_bind_set_mapping, NULL, NULL);
	_g_object_unref0 (settings);
	return obj;
}

static void
config_restic_row_class_init (ConfigResticRowClass * klass,
                              gpointer klass_data)
{
	config_restic_row_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = config_restic_row_constructor;
}

static void
config_restic_row_instance_init (ConfigResticRow * self,
                                 gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
config_restic_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConfigResticRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) config_restic_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConfigResticRow), 0, (GInstanceInitFunc) config_restic_row_instance_init, NULL };
	GType config_restic_row_type_id;
	config_restic_row_type_id = g_type_register_static (TYPE_SWITCH_ROW, "ConfigResticRow", &g_define_type_info, 0);
	return config_restic_row_type_id;
}

GType
config_restic_row_get_type (void)
{
	static gsize config_restic_row_type_id__once = 0;
	if (g_once_init_enter (&config_restic_row_type_id__once)) {
		GType config_restic_row_type_id;
		config_restic_row_type_id = config_restic_row_get_type_once ();
		g_once_init_leave (&config_restic_row_type_id__once, config_restic_row_type_id);
	}
	return config_restic_row_type_id__once;
}

