/* ConfigFolderRow.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ConfigFolderRow.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 <gio/gio.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include "deja.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
#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_CONFIG_FOLDER_ROW (config_folder_row_get_type ())
#define CONFIG_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIG_FOLDER_ROW, ConfigFolderRow))
#define CONFIG_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIG_FOLDER_ROW, ConfigFolderRowClass))
#define IS_CONFIG_FOLDER_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIG_FOLDER_ROW))
#define IS_CONFIG_FOLDER_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIG_FOLDER_ROW))
#define CONFIG_FOLDER_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIG_FOLDER_ROW, ConfigFolderRowClass))

typedef struct _ConfigFolderRow ConfigFolderRow;
typedef struct _ConfigFolderRowClass ConfigFolderRowClass;
typedef struct _ConfigFolderRowPrivate ConfigFolderRowPrivate;

#define TYPE_HELP_BUTTON (help_button_get_type ())
#define HELP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_HELP_BUTTON, HelpButton))
#define HELP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_HELP_BUTTON, HelpButtonClass))
#define IS_HELP_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_HELP_BUTTON))
#define IS_HELP_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_HELP_BUTTON))
#define HELP_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_HELP_BUTTON, HelpButtonClass))

typedef struct _HelpButton HelpButton;
typedef struct _HelpButtonClass HelpButtonClass;
enum  {
	CONFIG_FOLDER_ROW_0_PROPERTY,
	CONFIG_FOLDER_ROW_FILE_PROPERTY,
	CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY,
	CONFIG_FOLDER_ROW_NUM_PROPERTIES
};
static GParamSpec* config_folder_row_properties[CONFIG_FOLDER_ROW_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))
typedef struct _ConfigFolderRowUpdateRowData ConfigFolderRowUpdateRowData;
enum  {
	CONFIG_FOLDER_ROW_REMOVE_CLICKED_SIGNAL,
	CONFIG_FOLDER_ROW_NUM_SIGNALS
};
static guint config_folder_row_signals[CONFIG_FOLDER_ROW_NUM_SIGNALS] = {0};

struct _ConfigFolderRow {
	AdwActionRow parent_instance;
	ConfigFolderRowPrivate * priv;
};

struct _ConfigFolderRowClass {
	AdwActionRowClass parent_class;
};

struct _ConfigFolderRowPrivate {
	GFile* _file;
	gboolean _check_access;
	HelpButton* warning_button;
	GtkLabel* warning_label;
};

struct _ConfigFolderRowUpdateRowData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ConfigFolderRow* self;
	gchar* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	GFile* _tmp3_;
	gchar* _tmp4_;
	gboolean has_warning;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GFile* _tmp7_;
	DejaDupInstallEnv* install_env;
	DejaDupInstallEnv* _tmp8_;
	GFile* _tmp9_;
	GtkLabel* _tmp10_;
	DejaDupInstallEnv* _tmp11_;
	GFile* _tmp12_;
	GtkLabel* _tmp13_;
	HelpButton* _tmp14_;
	HelpButton* _tmp15_;
};

static gint ConfigFolderRow_private_offset;
static gpointer config_folder_row_parent_class = NULL;

VALA_EXTERN GType config_folder_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFolderRow, g_object_unref)
VALA_EXTERN GType help_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (HelpButton, g_object_unref)
static void config_folder_row_update_row_data_free (gpointer _data);
static void config_folder_row_update_row (ConfigFolderRow* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static void config_folder_row_update_row_finish (ConfigFolderRow* self,
                                          GAsyncResult* _res_);
static gboolean config_folder_row_update_row_co (ConfigFolderRowUpdateRowData* _data_);
VALA_EXTERN GFile* config_folder_row_get_file (ConfigFolderRow* self);
static void config_folder_row_update_row_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
VALA_EXTERN gboolean config_folder_row_get_check_access (ConfigFolderRow* self);
static void config_folder_row_on_remove_clicked (ConfigFolderRow* self);
static void _config_folder_row_on_remove_clicked_gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self);
VALA_EXTERN ConfigFolderRow* config_folder_row_new (void);
VALA_EXTERN ConfigFolderRow* config_folder_row_construct (GType object_type);
VALA_EXTERN void config_folder_row_set_file (ConfigFolderRow* self,
                                 GFile* value);
VALA_EXTERN void config_folder_row_set_check_access (ConfigFolderRow* self,
                                         gboolean value);
static GObject * config_folder_row_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _config_folder_row___lambda25_ (ConfigFolderRow* self);
static void __config_folder_row___lambda25__g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self);
static void _config_folder_row___lambda26_ (ConfigFolderRow* self);
static void __config_folder_row___lambda26__g_object_notify (GObject* _sender,
                                                      GParamSpec* pspec,
                                                      gpointer self);
static void config_folder_row_finalize (GObject * obj);
static GType config_folder_row_get_type_once (void);
static void _vala_config_folder_row_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_config_folder_row_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
config_folder_row_get_instance_private (ConfigFolderRow* self)
{
	return G_STRUCT_MEMBER_P (self, ConfigFolderRow_private_offset);
}

static void
config_folder_row_update_row_data_free (gpointer _data)
{
	ConfigFolderRowUpdateRowData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ConfigFolderRowUpdateRowData, _data_);
}

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

static void
config_folder_row_update_row (ConfigFolderRow* self,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	ConfigFolderRowUpdateRowData* _data_;
	ConfigFolderRow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ConfigFolderRowUpdateRowData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, config_folder_row_update_row_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	config_folder_row_update_row_co (_data_);
}

static void
config_folder_row_update_row_finish (ConfigFolderRow* self,
                                     GAsyncResult* _res_)
{
	ConfigFolderRowUpdateRowData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
config_folder_row_update_row_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	ConfigFolderRowUpdateRowData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	config_folder_row_update_row_co (_data_);
}

static gboolean
config_folder_row_update_row_co (ConfigFolderRowUpdateRowData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->_file;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp2_ = g_strdup ("");
		_g_free0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp2_;
	} else {
		_data_->_tmp3_ = _data_->self->priv->_file;
		_data_->_state_ = 1;
		deja_dup_get_nickname (_data_->_tmp3_, config_folder_row_update_row_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = deja_dup_get_nickname_finish (_data_->_res_);
		_g_free0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp4_;
	}
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->self, _data_->_tmp0_);
	_data_->has_warning = FALSE;
	_data_->_tmp6_ = _data_->self->priv->_check_access;
	if (_data_->_tmp6_) {
		_data_->_tmp7_ = _data_->self->priv->_file;
		_data_->_tmp5_ = _data_->_tmp7_ != NULL;
	} else {
		_data_->_tmp5_ = FALSE;
	}
	if (_data_->_tmp5_) {
		_data_->_tmp8_ = deja_dup_install_env_instance ();
		_data_->install_env = _data_->_tmp8_;
		_data_->_tmp9_ = _data_->self->priv->_file;
		if (!g_file_is_native (_data_->_tmp9_)) {
			_data_->_tmp10_ = _data_->self->priv->warning_label;
			gtk_label_set_label (_data_->_tmp10_, _ ("This folder cannot be backed up because it is a network folder."));
			_data_->has_warning = TRUE;
		} else {
			_data_->_tmp11_ = _data_->install_env;
			_data_->_tmp12_ = _data_->self->priv->_file;
			if (!deja_dup_install_env_is_file_available (_data_->_tmp11_, _data_->_tmp12_)) {
				_data_->_tmp13_ = _data_->self->priv->warning_label;
				gtk_label_set_label (_data_->_tmp13_, _ ("This folder cannot be backed up because Backups does not have access t" \
"o it."));
				_data_->has_warning = TRUE;
			}
		}
		_g_object_unref0 (_data_->install_env);
	}
	if (_data_->has_warning) {
		_data_->_tmp14_ = _data_->self->priv->warning_button;
		gtk_widget_set_visible ((GtkWidget*) _data_->_tmp14_, TRUE);
		gtk_widget_add_css_class ((GtkWidget*) _data_->self, "warning");
	} else {
		_data_->_tmp15_ = _data_->self->priv->warning_button;
		gtk_widget_set_visible ((GtkWidget*) _data_->_tmp15_, FALSE);
		gtk_widget_remove_css_class ((GtkWidget*) _data_->self, "warning");
	}
	_g_free0 (_data_->_tmp0_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
config_folder_row_on_remove_clicked (ConfigFolderRow* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, config_folder_row_signals[CONFIG_FOLDER_ROW_REMOVE_CLICKED_SIGNAL], 0);
}

static void
_config_folder_row_on_remove_clicked_gtk_button_clicked (GtkButton* _sender,
                                                         gpointer self)
{
	config_folder_row_on_remove_clicked ((ConfigFolderRow*) self);
}

ConfigFolderRow*
config_folder_row_construct (GType object_type)
{
	ConfigFolderRow * self = NULL;
	self = (ConfigFolderRow*) g_object_new (object_type, NULL);
	return self;
}

ConfigFolderRow*
config_folder_row_new (void)
{
	return config_folder_row_construct (TYPE_CONFIG_FOLDER_ROW);
}

GFile*
config_folder_row_get_file (ConfigFolderRow* self)
{
	GFile* result;
	GFile* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file;
	result = _tmp0_;
	return result;
}

void
config_folder_row_set_file (ConfigFolderRow* self,
                            GFile* value)
{
	GFile* old_value;
	g_return_if_fail (self != NULL);
	old_value = config_folder_row_get_file (self);
	if (old_value != value) {
		GFile* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_file);
		self->priv->_file = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, config_folder_row_properties[CONFIG_FOLDER_ROW_FILE_PROPERTY]);
	}
}

gboolean
config_folder_row_get_check_access (ConfigFolderRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_check_access;
	return result;
}

void
config_folder_row_set_check_access (ConfigFolderRow* self,
                                    gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = config_folder_row_get_check_access (self);
	if (old_value != value) {
		self->priv->_check_access = value;
		g_object_notify_by_pspec ((GObject *) self, config_folder_row_properties[CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY]);
	}
}

static void
_config_folder_row___lambda25_ (ConfigFolderRow* self)
{
	config_folder_row_update_row (self, NULL, NULL);
}

static void
__config_folder_row___lambda25__g_object_notify (GObject* _sender,
                                                 GParamSpec* pspec,
                                                 gpointer self)
{
	_config_folder_row___lambda25_ ((ConfigFolderRow*) self);
}

static void
_config_folder_row___lambda26_ (ConfigFolderRow* self)
{
	config_folder_row_update_row (self, NULL, NULL);
}

static void
__config_folder_row___lambda26__g_object_notify (GObject* _sender,
                                                 GParamSpec* pspec,
                                                 gpointer self)
{
	_config_folder_row___lambda26_ ((ConfigFolderRow*) self);
}

static GObject *
config_folder_row_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ConfigFolderRow * self;
	parent_class = G_OBJECT_CLASS (config_folder_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CONFIG_FOLDER_ROW, ConfigFolderRow);
	g_signal_connect_object ((GObject*) self, "notify::file", (GCallback) __config_folder_row___lambda25__g_object_notify, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::check-access", (GCallback) __config_folder_row___lambda26__g_object_notify, self, 0);
	config_folder_row_update_row (self, NULL, NULL);
	return obj;
}

static void
config_folder_row_class_init (ConfigFolderRowClass * klass,
                              gpointer klass_data)
{
	config_folder_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConfigFolderRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_config_folder_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_config_folder_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = config_folder_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = config_folder_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONFIG_FOLDER_ROW_FILE_PROPERTY, config_folder_row_properties[CONFIG_FOLDER_ROW_FILE_PROPERTY] = g_param_spec_object ("file", "file", "file", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY, config_folder_row_properties[CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY] = g_param_spec_boolean ("check-access", "check-access", "check-access", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/ConfigFolderRow.ui");
	config_folder_row_signals[CONFIG_FOLDER_ROW_REMOVE_CLICKED_SIGNAL] = g_signal_new ("remove-clicked", TYPE_CONFIG_FOLDER_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "warning_button", FALSE, ConfigFolderRow_private_offset + G_STRUCT_OFFSET (ConfigFolderRowPrivate, warning_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "warning_label", FALSE, ConfigFolderRow_private_offset + G_STRUCT_OFFSET (ConfigFolderRowPrivate, warning_label));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_remove_clicked", G_CALLBACK(_config_folder_row_on_remove_clicked_gtk_button_clicked));
}

static void
config_folder_row_instance_init (ConfigFolderRow * self,
                                 gpointer klass)
{
	self->priv = config_folder_row_get_instance_private (self);
	g_type_ensure (TYPE_HELP_BUTTON);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
config_folder_row_finalize (GObject * obj)
{
	ConfigFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CONFIG_FOLDER_ROW, ConfigFolderRow);
	_g_object_unref0 (self->priv->_file);
	G_OBJECT_CLASS (config_folder_row_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
config_folder_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConfigFolderRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) config_folder_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConfigFolderRow), 0, (GInstanceInitFunc) config_folder_row_instance_init, NULL };
	GType config_folder_row_type_id;
	config_folder_row_type_id = g_type_register_static (adw_action_row_get_type (), "ConfigFolderRow", &g_define_type_info, 0);
	ConfigFolderRow_private_offset = g_type_add_instance_private (config_folder_row_type_id, sizeof (ConfigFolderRowPrivate));
	return config_folder_row_type_id;
}

GType
config_folder_row_get_type (void)
{
	static gsize config_folder_row_type_id__once = 0;
	if (g_once_init_enter (&config_folder_row_type_id__once)) {
		GType config_folder_row_type_id;
		config_folder_row_type_id = config_folder_row_get_type_once ();
		g_once_init_leave (&config_folder_row_type_id__once, config_folder_row_type_id);
	}
	return config_folder_row_type_id__once;
}

static void
_vala_config_folder_row_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	ConfigFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONFIG_FOLDER_ROW, ConfigFolderRow);
	switch (property_id) {
		case CONFIG_FOLDER_ROW_FILE_PROPERTY:
		g_value_set_object (value, config_folder_row_get_file (self));
		break;
		case CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY:
		g_value_set_boolean (value, config_folder_row_get_check_access (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_config_folder_row_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	ConfigFolderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONFIG_FOLDER_ROW, ConfigFolderRow);
	switch (property_id) {
		case CONFIG_FOLDER_ROW_FILE_PROPERTY:
		config_folder_row_set_file (self, g_value_get_object (value));
		break;
		case CONFIG_FOLDER_ROW_CHECK_ACCESS_PROPERTY:
		config_folder_row_set_check_access (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

