/* ConfigFolderGroup.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ConfigFolderGroup.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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.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_CONFIG_FOLDER_GROUP (config_folder_group_get_type ())
#define CONFIG_FOLDER_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroup))
#define CONFIG_FOLDER_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroupClass))
#define IS_CONFIG_FOLDER_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIG_FOLDER_GROUP))
#define IS_CONFIG_FOLDER_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIG_FOLDER_GROUP))
#define CONFIG_FOLDER_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroupClass))

typedef struct _ConfigFolderGroup ConfigFolderGroup;
typedef struct _ConfigFolderGroupClass ConfigFolderGroupClass;
typedef struct _ConfigFolderGroupPrivate ConfigFolderGroupPrivate;
enum  {
	CONFIG_FOLDER_GROUP_0_PROPERTY,
	CONFIG_FOLDER_GROUP_KEY_PROPERTY,
	CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY,
	CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY,
	CONFIG_FOLDER_GROUP_NUM_PROPERTIES
};
static GParamSpec* config_folder_group_properties[CONFIG_FOLDER_GROUP_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)))

#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;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _ConfigFolderGroupUpdateListItemsData ConfigFolderGroupUpdateListItemsData;
typedef struct _ConfigFolderGroupSelectFoldersData ConfigFolderGroupSelectFoldersData;

struct _ConfigFolderGroup {
	AdwPreferencesGroup parent_instance;
	ConfigFolderGroupPrivate * priv;
};

struct _ConfigFolderGroupClass {
	AdwPreferencesGroupClass parent_class;
};

struct _ConfigFolderGroupPrivate {
	gchar* _key;
	gboolean _check_access;
	gchar* _add_label;
	GtkWidget* add_row;
	DejaDupFilteredSettings* settings;
	GList* rows;
};

struct _ConfigFolderGroupUpdateListItemsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ConfigFolderGroup* self;
	GList* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GVariant* folder_value;
	DejaDupFilteredSettings* _tmp3_;
	const gchar* _tmp4_;
	GVariant* _tmp5_;
	const gchar** folder_list;
	GVariant* _tmp6_;
	gsize _tmp7_;
	const gchar** _tmp8_;
	gint folder_list_length1;
	gint _folder_list_size_;
	const gchar** _tmp9_;
	gint _tmp9__length1;
	const gchar** folder_collection;
	gint folder_collection_length1;
	gint _folder_collection_size_;
	gint folder_it;
	const gchar* folder;
	GFile* file;
	const gchar* _tmp10_;
	GFile* _tmp11_;
	GFile* _tmp12_;
	ConfigFolderRow* row;
	ConfigFolderRow* _tmp13_;
	ConfigFolderRow* _tmp14_;
	GFile* _tmp15_;
	ConfigFolderRow* _tmp16_;
	gboolean _tmp17_;
	ConfigFolderRow* _tmp18_;
	const gchar* _tmp19_;
	gchar* _tmp20_;
	ConfigFolderRow* _tmp21_;
	ConfigFolderRow* _tmp22_;
	ConfigFolderRow* _tmp23_;
	GtkWidget* _tmp24_;
	GtkWidget* _tmp25_;
};

struct _ConfigFolderGroupSelectFoldersData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ConfigFolderGroup* self;
	GtkFileDialog* dlg;
	GtkFileDialog* _tmp0_;
	GListModel* folders;
	GtkRoot* _tmp1_;
	GtkRoot* _tmp2_;
	GListModel* _tmp3_;
	GError* _inner_error0_;
};

static gint ConfigFolderGroup_private_offset;
static gpointer config_folder_group_parent_class = NULL;

VALA_EXTERN GType config_folder_group_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFolderGroup, g_object_unref)
static void config_folder_group_on_key_changed (ConfigFolderGroup* self);
VALA_EXTERN const gchar* config_folder_group_get_key (ConfigFolderGroup* self);
static void __lambda23_ (ConfigFolderGroup* self);
static void config_folder_group_update_list_items (ConfigFolderGroup* self,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static void config_folder_group_update_list_items_finish (ConfigFolderGroup* self,
                                                   GAsyncResult* _res_);
static void ___lambda23__g_settings_changed (GSettings* _sender,
                                      const gchar* key,
                                      gpointer self);
static void _config_folder_group_on_key_changed_g_object_notify (GObject* _sender,
                                                          GParamSpec* pspec,
                                                          gpointer self);
static void config_folder_group_on_check_access_changed (ConfigFolderGroup* self);
static void _config_folder_group_on_check_access_changed_g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self);
static void config_folder_group_update_list_items_data_free (gpointer _data);
static gboolean config_folder_group_update_list_items_co (ConfigFolderGroupUpdateListItemsData* _data_);
static void __lambda24_ (ConfigFolderGroup* self,
                  GtkWidget* item);
static void ___lambda24__gfunc (gconstpointer data,
                         gpointer self);
VALA_EXTERN GType config_folder_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFolderRow, g_object_unref)
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 gboolean config_folder_group_get_check_access (ConfigFolderGroup* self);
VALA_EXTERN void config_folder_row_set_check_access (ConfigFolderRow* self,
                                         gboolean value);
static void ____lambda27_ (ConfigFolderGroup* self,
                    ConfigFolderRow* r);
static void config_folder_group_handle_remove (ConfigFolderGroup* self,
                                        const gchar* folder);
static void _____lambda27__config_folder_row_remove_clicked (ConfigFolderRow* _sender,
                                                      gpointer self);
static void config_folder_group_on_add_clicked (ConfigFolderGroup* self);
static void config_folder_group_select_folders (ConfigFolderGroup* self,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static void config_folder_group_select_folders_finish (ConfigFolderGroup* self,
                                                GAsyncResult* _res_);
static void _config_folder_group_on_add_clicked_adw_button_row_activated (AdwButtonRow* _sender,
                                                                   gpointer self);
static void config_folder_group_select_folders_data_free (gpointer _data);
static gboolean config_folder_group_select_folders_co (ConfigFolderGroupSelectFoldersData* _data_);
static void config_folder_group_select_folders_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static gboolean config_folder_group_add_files (ConfigFolderGroup* self,
                                        GListModel* files);
static void _vala_array_add1 (const gchar** * array,
                       gint* length,
                       gint* size,
                       const gchar* value);
static void _vala_array_add2 (gchar** * array,
                       gint* length,
                       gint* size,
                       gchar* value);
VALA_EXTERN ConfigFolderGroup* config_folder_group_new (void);
VALA_EXTERN ConfigFolderGroup* config_folder_group_construct (GType object_type);
VALA_EXTERN void config_folder_group_set_key (ConfigFolderGroup* self,
                                  const gchar* value);
VALA_EXTERN void config_folder_group_set_check_access (ConfigFolderGroup* self,
                                           gboolean value);
VALA_EXTERN const gchar* config_folder_group_get_add_label (ConfigFolderGroup* self);
VALA_EXTERN void config_folder_group_set_add_label (ConfigFolderGroup* self,
                                        const gchar* value);
static void config_folder_group_finalize (GObject * obj);
static GType config_folder_group_get_type_once (void);
static void _vala_config_folder_group_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_config_folder_group_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
config_folder_group_get_instance_private (ConfigFolderGroup* self)
{
	return G_STRUCT_MEMBER_P (self, ConfigFolderGroup_private_offset);
}

static void
__lambda23_ (ConfigFolderGroup* self)
{
	config_folder_group_update_list_items (self, NULL, NULL);
}

static void
___lambda23__g_settings_changed (GSettings* _sender,
                                 const gchar* key,
                                 gpointer self)
{
	__lambda23_ ((ConfigFolderGroup*) self);
}

static void
config_folder_group_on_key_changed (ConfigFolderGroup* self)
{
	const gchar* _tmp0_;
	DejaDupFilteredSettings* _tmp1_;
	DejaDupFilteredSettings* _tmp2_;
	const gchar* _tmp3_;
	DejaDupFilteredSettings* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_key;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = deja_dup_get_settings (NULL);
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp1_;
	_tmp2_ = self->priv->settings;
	_tmp3_ = self->priv->_key;
	g_settings_bind_writable ((GSettings*) _tmp2_, _tmp3_, (GObject*) self, "sensitive", FALSE);
	_tmp4_ = self->priv->settings;
	_tmp5_ = self->priv->_key;
	_tmp6_ = g_strconcat ("changed::", _tmp5_, NULL);
	g_signal_connect_object ((GSettings*) _tmp4_, _tmp6_, (GCallback) ___lambda23__g_settings_changed, self, 0);
	_g_free0 (_tmp6_);
	config_folder_group_update_list_items (self, NULL, NULL);
}

static void
_config_folder_group_on_key_changed_g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self)
{
	config_folder_group_on_key_changed ((ConfigFolderGroup*) self);
}

static void
config_folder_group_on_check_access_changed (ConfigFolderGroup* self)
{
	g_return_if_fail (self != NULL);
	config_folder_group_update_list_items (self, NULL, NULL);
}

static void
_config_folder_group_on_check_access_changed_g_object_notify (GObject* _sender,
                                                              GParamSpec* pspec,
                                                              gpointer self)
{
	config_folder_group_on_check_access_changed ((ConfigFolderGroup*) self);
}

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

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

static void
config_folder_group_update_list_items (ConfigFolderGroup* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	ConfigFolderGroupUpdateListItemsData* _data_;
	ConfigFolderGroup* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ConfigFolderGroupUpdateListItemsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, config_folder_group_update_list_items_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	config_folder_group_update_list_items_co (_data_);
}

static void
config_folder_group_update_list_items_finish (ConfigFolderGroup* self,
                                              GAsyncResult* _res_)
{
	ConfigFolderGroupUpdateListItemsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
__lambda24_ (ConfigFolderGroup* self,
             GtkWidget* item)
{
	g_return_if_fail (item != NULL);
	adw_preferences_group_remove ((AdwPreferencesGroup*) self, item);
}

static void
___lambda24__gfunc (gconstpointer data,
                    gpointer self)
{
	__lambda24_ ((ConfigFolderGroup*) self, (GtkWidget*) data);
}

static void
____lambda27_ (ConfigFolderGroup* self,
               ConfigFolderRow* r)
{
	gconstpointer _tmp0_;
	g_return_if_fail (r != NULL);
	_tmp0_ = g_object_get_data ((GObject*) r, "folder");
	config_folder_group_handle_remove (self, (const gchar*) _tmp0_);
}

static void
_____lambda27__config_folder_row_remove_clicked (ConfigFolderRow* _sender,
                                                 gpointer self)
{
	____lambda27_ ((ConfigFolderGroup*) self, _sender);
}

static gboolean
config_folder_group_update_list_items_co (ConfigFolderGroupUpdateListItemsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->rows;
	g_list_foreach (_data_->_tmp0_, ___lambda24__gfunc, _data_->self);
	(_data_->self->priv->rows == NULL) ? NULL : (_data_->self->priv->rows = (g_list_free (_data_->self->priv->rows), NULL));
	_data_->self->priv->rows = NULL;
	_data_->_tmp1_ = _data_->self->priv->add_row;
	g_object_ref ((GObject*) _data_->_tmp1_);
	_data_->_tmp2_ = _data_->self->priv->add_row;
	adw_preferences_group_remove ((AdwPreferencesGroup*) _data_->self, _data_->_tmp2_);
	_data_->_tmp3_ = _data_->self->priv->settings;
	_data_->_tmp4_ = _data_->self->priv->_key;
	_data_->_tmp5_ = g_settings_get_value ((GSettings*) _data_->_tmp3_, _data_->_tmp4_);
	_data_->folder_value = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->folder_value;
	_data_->_tmp7_ = 0;
	_data_->_tmp8_ = g_variant_get_strv (_data_->_tmp6_, &_data_->_tmp7_);
	_data_->folder_list = _data_->_tmp8_;
	_data_->folder_list_length1 = _data_->_tmp7_;
	_data_->_folder_list_size_ = _data_->folder_list_length1;
	_data_->_tmp9_ = _data_->folder_list;
	_data_->_tmp9__length1 = _data_->folder_list_length1;
	{
		_data_->folder_collection_length1 = 0;
		_data_->_folder_collection_size_ = 0;
		_data_->folder_collection = _data_->_tmp9_;
		_data_->folder_collection_length1 = _data_->_tmp9__length1;
		for (_data_->folder_it = 0; _data_->folder_it < _data_->folder_collection_length1; _data_->folder_it = _data_->folder_it + 1) {
			_data_->folder = _data_->folder_collection[_data_->folder_it];
			{
				_data_->_tmp10_ = _data_->folder;
				_data_->_tmp11_ = deja_dup_parse_dir (_data_->_tmp10_);
				_data_->file = _data_->_tmp11_;
				_data_->_tmp12_ = _data_->file;
				if (_data_->_tmp12_ == NULL) {
					_g_object_unref0 (_data_->file);
					continue;
				}
				_data_->_tmp13_ = config_folder_row_new ();
				g_object_ref_sink (_data_->_tmp13_);
				_data_->row = _data_->_tmp13_;
				_data_->_tmp14_ = _data_->row;
				_data_->_tmp15_ = _data_->file;
				config_folder_row_set_file (_data_->_tmp14_, _data_->_tmp15_);
				_data_->_tmp16_ = _data_->row;
				_data_->_tmp17_ = _data_->self->priv->_check_access;
				config_folder_row_set_check_access (_data_->_tmp16_, _data_->_tmp17_);
				_data_->_tmp18_ = _data_->row;
				_data_->_tmp19_ = _data_->folder;
				_data_->_tmp20_ = g_strdup (_data_->_tmp19_);
				g_object_set_data_full ((GObject*) _data_->_tmp18_, "folder", _data_->_tmp20_, g_free);
				_data_->_tmp21_ = _data_->row;
				g_signal_connect_object (_data_->_tmp21_, "remove-clicked", (GCallback) _____lambda27__config_folder_row_remove_clicked, _data_->self, 0);
				_data_->_tmp22_ = _data_->row;
				_data_->self->priv->rows = g_list_append (_data_->self->priv->rows, (GtkWidget*) _data_->_tmp22_);
				_data_->_tmp23_ = _data_->row;
				adw_preferences_group_add ((AdwPreferencesGroup*) _data_->self, (GtkWidget*) _data_->_tmp23_);
				_g_object_unref0 (_data_->row);
				_g_object_unref0 (_data_->file);
			}
		}
	}
	_data_->_tmp24_ = _data_->self->priv->add_row;
	adw_preferences_group_add ((AdwPreferencesGroup*) _data_->self, _data_->_tmp24_);
	_data_->_tmp25_ = _data_->self->priv->add_row;
	g_object_unref ((GObject*) _data_->_tmp25_);
	_data_->folder_list = (g_free (_data_->folder_list), NULL);
	_g_variant_unref0 (_data_->folder_value);
	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_group_on_add_clicked (ConfigFolderGroup* self)
{
	g_return_if_fail (self != NULL);
	config_folder_group_select_folders (self, NULL, NULL);
}

static void
_config_folder_group_on_add_clicked_adw_button_row_activated (AdwButtonRow* _sender,
                                                              gpointer self)
{
	config_folder_group_on_add_clicked ((ConfigFolderGroup*) self);
}

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

static void
config_folder_group_select_folders (ConfigFolderGroup* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	ConfigFolderGroupSelectFoldersData* _data_;
	ConfigFolderGroup* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ConfigFolderGroupSelectFoldersData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, config_folder_group_select_folders_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	config_folder_group_select_folders_co (_data_);
}

static void
config_folder_group_select_folders_finish (ConfigFolderGroup* self,
                                           GAsyncResult* _res_)
{
	ConfigFolderGroupSelectFoldersData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
config_folder_group_select_folders_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	ConfigFolderGroupSelectFoldersData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	config_folder_group_select_folders_co (_data_);
}

static gboolean
config_folder_group_select_folders_co (ConfigFolderGroupSelectFoldersData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gtk_file_dialog_new ();
	_data_->dlg = _data_->_tmp0_;
	gtk_file_dialog_set_modal (_data_->dlg, TRUE);
	{
		_data_->_tmp1_ = gtk_widget_get_root ((GtkWidget*) _data_->self);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_state_ = 1;
		gtk_file_dialog_select_multiple_folders (_data_->dlg, G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp2_, gtk_window_get_type ()) ? ((GtkWindow*) _data_->_tmp2_) : NULL, NULL, config_folder_group_select_folders_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp3_ = gtk_file_dialog_select_multiple_folders_finish (_data_->dlg, _data_->_res_, &_data_->_inner_error0_);
		_data_->folders = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		config_folder_group_add_files (_data_->self, _data_->folders);
		_g_object_unref0 (_data_->folders);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->dlg);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->dlg);
	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
_vala_array_add1 (const gchar** * array,
                  gint* length,
                  gint* size,
                  const gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (const gchar*, *array, *size);
	}
	(*array)[(*length)++] = value;
}

static gboolean
config_folder_group_add_files (ConfigFolderGroup* self,
                               GListModel* files)
{
	GVariant* slist_val = NULL;
	DejaDupFilteredSettings* _tmp0_;
	const gchar* _tmp1_;
	GVariant* _tmp2_;
	const gchar** slist = NULL;
	GVariant* _tmp3_;
	gsize _tmp4_ = 0;
	const gchar** _tmp5_;
	gint slist_length1;
	gint _slist_size_;
	gboolean changed = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (files != NULL, FALSE);
	_tmp0_ = self->priv->settings;
	_tmp1_ = self->priv->_key;
	_tmp2_ = g_settings_get_value ((GSettings*) _tmp0_, _tmp1_);
	slist_val = _tmp2_;
	_tmp3_ = slist_val;
	_tmp5_ = g_variant_get_strv (_tmp3_, &_tmp4_);
	slist = _tmp5_;
	slist_length1 = _tmp4_;
	_slist_size_ = slist_length1;
	changed = FALSE;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				GFile* folder = NULL;
				GObject* _tmp8_;
				GFile* _tmp9_;
				GFile* _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				gboolean _tmp13_;
				GFile* _tmp14_;
				GFile* _tmp15_;
				gboolean found = FALSE;
				const gchar** _tmp16_;
				gint _tmp16__length1;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				if (!(((guint) i) < g_list_model_get_n_items (files))) {
					break;
				}
				_tmp8_ = g_list_model_get_item (files, (guint) i);
				_tmp9_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, g_file_get_type ()) ? ((GFile*) _tmp8_) : NULL;
				if (_tmp9_ == NULL) {
					_g_object_unref0 (_tmp8_);
				}
				folder = _tmp9_;
				_tmp10_ = folder;
				_tmp11_ = g_file_get_path (_tmp10_);
				_tmp12_ = _tmp11_;
				_tmp13_ = _tmp12_ == NULL;
				_g_free0 (_tmp12_);
				if (_tmp13_) {
					_g_object_unref0 (folder);
					continue;
				}
				_tmp14_ = folder;
				_tmp15_ = deja_dup_remove_read_root (_tmp14_);
				_g_object_unref0 (folder);
				folder = _tmp15_;
				found = FALSE;
				_tmp16_ = slist;
				_tmp16__length1 = slist_length1;
				{
					const gchar** s_collection = NULL;
					gint s_collection_length1 = 0;
					gint _s_collection_size_ = 0;
					gint s_it = 0;
					s_collection = _tmp16_;
					s_collection_length1 = _tmp16__length1;
					for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
						gchar* _tmp17_;
						gchar* s = NULL;
						_tmp17_ = g_strdup ((gchar*) s_collection[s_it]);
						s = _tmp17_;
						{
							GFile* sfile = NULL;
							const gchar* _tmp18_;
							GFile* _tmp19_;
							gboolean _tmp20_ = FALSE;
							GFile* _tmp21_;
							_tmp18_ = s;
							_tmp19_ = deja_dup_parse_dir (_tmp18_);
							sfile = _tmp19_;
							_tmp21_ = sfile;
							if (_tmp21_ != NULL) {
								GFile* _tmp22_;
								GFile* _tmp23_;
								_tmp22_ = sfile;
								_tmp23_ = folder;
								_tmp20_ = g_file_equal (_tmp22_, _tmp23_);
							} else {
								_tmp20_ = FALSE;
							}
							if (_tmp20_) {
								found = TRUE;
								_g_object_unref0 (sfile);
								_g_free0 (s);
								break;
							}
							_g_object_unref0 (sfile);
							_g_free0 (s);
						}
					}
				}
				if (!found) {
					GFile* _tmp24_;
					gchar* _tmp25_;
					_tmp24_ = folder;
					_tmp25_ = g_file_get_parse_name (_tmp24_);
					_vala_array_add1 (&slist, &slist_length1, &_slist_size_, _tmp25_);
					changed = TRUE;
				}
				_g_object_unref0 (folder);
			}
		}
	}
	if (changed) {
		DejaDupFilteredSettings* _tmp26_;
		const gchar* _tmp27_;
		const gchar** _tmp28_;
		gint _tmp28__length1;
		GVariant* _tmp29_;
		GVariant* _tmp30_;
		_tmp26_ = self->priv->settings;
		_tmp27_ = self->priv->_key;
		_tmp28_ = slist;
		_tmp28__length1 = slist_length1;
		_tmp29_ = g_variant_new_strv (_tmp28_, _tmp28__length1);
		g_variant_ref_sink (_tmp29_);
		_tmp30_ = _tmp29_;
		deja_dup_filtered_settings_set_value (_tmp26_, _tmp27_, _tmp30_);
		_g_variant_unref0 (_tmp30_);
	}
	result = changed;
	slist = (g_free (slist), NULL);
	_g_variant_unref0 (slist_val);
	return result;
}

static void
_vala_array_add2 (gchar** * array,
                  gint* length,
                  gint* size,
                  gchar* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (gchar*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
config_folder_group_handle_remove (ConfigFolderGroup* self,
                                   const gchar* folder)
{
	GVariant* old_value = NULL;
	DejaDupFilteredSettings* _tmp0_;
	const gchar* _tmp1_;
	GVariant* _tmp2_;
	const gchar** old_list = NULL;
	GVariant* _tmp3_;
	gsize _tmp4_ = 0;
	const gchar** _tmp5_;
	gint old_list_length1;
	gint _old_list_size_;
	gchar** new_list = NULL;
	gchar** _tmp6_;
	gint new_list_length1;
	gint _new_list_size_;
	const gchar** _tmp7_;
	gint _tmp7__length1;
	DejaDupFilteredSettings* _tmp12_;
	const gchar* _tmp13_;
	gchar** _tmp14_;
	gint _tmp14__length1;
	GVariant* _tmp15_;
	GVariant* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (folder != NULL);
	_tmp0_ = self->priv->settings;
	_tmp1_ = self->priv->_key;
	_tmp2_ = g_settings_get_value ((GSettings*) _tmp0_, _tmp1_);
	old_value = _tmp2_;
	_tmp3_ = old_value;
	_tmp5_ = g_variant_get_strv (_tmp3_, &_tmp4_);
	old_list = _tmp5_;
	old_list_length1 = _tmp4_;
	_old_list_size_ = old_list_length1;
	_tmp6_ = g_new0 (gchar*, 0 + 1);
	new_list = _tmp6_;
	new_list_length1 = 0;
	_new_list_size_ = new_list_length1;
	_tmp7_ = old_list;
	_tmp7__length1 = old_list_length1;
	{
		const gchar** old_collection = NULL;
		gint old_collection_length1 = 0;
		gint _old_collection_size_ = 0;
		gint old_it = 0;
		old_collection = _tmp7_;
		old_collection_length1 = _tmp7__length1;
		for (old_it = 0; old_it < old_collection_length1; old_it = old_it + 1) {
			gchar* _tmp8_;
			gchar* old = NULL;
			_tmp8_ = g_strdup (old_collection[old_it]);
			old = _tmp8_;
			{
				const gchar* _tmp9_;
				_tmp9_ = old;
				if (g_strcmp0 (_tmp9_, folder) != 0) {
					const gchar* _tmp10_;
					gchar* _tmp11_;
					_tmp10_ = old;
					_tmp11_ = g_strdup (_tmp10_);
					_vala_array_add2 (&new_list, &new_list_length1, &_new_list_size_, _tmp11_);
				}
				_g_free0 (old);
			}
		}
	}
	_tmp12_ = self->priv->settings;
	_tmp13_ = self->priv->_key;
	_tmp14_ = new_list;
	_tmp14__length1 = new_list_length1;
	_tmp15_ = g_variant_new_strv (_tmp14_, _tmp14__length1);
	g_variant_ref_sink (_tmp15_);
	_tmp16_ = _tmp15_;
	deja_dup_filtered_settings_set_value (_tmp12_, _tmp13_, _tmp16_);
	_g_variant_unref0 (_tmp16_);
	new_list = (_vala_array_free (new_list, new_list_length1, (GDestroyNotify) g_free), NULL);
	old_list = (g_free (old_list), NULL);
	_g_variant_unref0 (old_value);
}

ConfigFolderGroup*
config_folder_group_construct (GType object_type)
{
	ConfigFolderGroup * self = NULL;
	self = (ConfigFolderGroup*) g_object_new (object_type, NULL);
	return self;
}

ConfigFolderGroup*
config_folder_group_new (void)
{
	return config_folder_group_construct (TYPE_CONFIG_FOLDER_GROUP);
}

const gchar*
config_folder_group_get_key (ConfigFolderGroup* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_key;
	result = _tmp0_;
	return result;
}

void
config_folder_group_set_key (ConfigFolderGroup* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = config_folder_group_get_key (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_key);
		self->priv->_key = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, config_folder_group_properties[CONFIG_FOLDER_GROUP_KEY_PROPERTY]);
	}
}

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

void
config_folder_group_set_check_access (ConfigFolderGroup* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = config_folder_group_get_check_access (self);
	if (old_value != value) {
		self->priv->_check_access = value;
		g_object_notify_by_pspec ((GObject *) self, config_folder_group_properties[CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY]);
	}
}

const gchar*
config_folder_group_get_add_label (ConfigFolderGroup* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_add_label;
	result = _tmp0_;
	return result;
}

void
config_folder_group_set_add_label (ConfigFolderGroup* self,
                                   const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = config_folder_group_get_add_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_add_label);
		self->priv->_add_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, config_folder_group_properties[CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY]);
	}
}

static void
config_folder_group_class_init (ConfigFolderGroupClass * klass,
                                gpointer klass_data)
{
	config_folder_group_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ConfigFolderGroup_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_config_folder_group_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_config_folder_group_set_property;
	G_OBJECT_CLASS (klass)->finalize = config_folder_group_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONFIG_FOLDER_GROUP_KEY_PROPERTY, config_folder_group_properties[CONFIG_FOLDER_GROUP_KEY_PROPERTY] = g_param_spec_string ("key", "key", "key", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY, config_folder_group_properties[CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY] = g_param_spec_boolean ("check-access", "check-access", "check-access", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY, config_folder_group_properties[CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY] = g_param_spec_string ("add-label", "add-label", "add-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/ConfigFolderGroup.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "add_row", FALSE, ConfigFolderGroup_private_offset + G_STRUCT_OFFSET (ConfigFolderGroupPrivate, add_row));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_key_changed", G_CALLBACK(_config_folder_group_on_key_changed_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_check_access_changed", G_CALLBACK(_config_folder_group_on_check_access_changed_g_object_notify));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_add_clicked", G_CALLBACK(_config_folder_group_on_add_clicked_adw_button_row_activated));
}

static void
config_folder_group_instance_init (ConfigFolderGroup * self,
                                   gpointer klass)
{
	self->priv = config_folder_group_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
config_folder_group_finalize (GObject * obj)
{
	ConfigFolderGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroup);
	_g_free0 (self->priv->_key);
	_g_free0 (self->priv->_add_label);
	_g_object_unref0 (self->priv->settings);
	(self->priv->rows == NULL) ? NULL : (self->priv->rows = (g_list_free (self->priv->rows), NULL));
	G_OBJECT_CLASS (config_folder_group_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
config_folder_group_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConfigFolderGroupClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) config_folder_group_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConfigFolderGroup), 0, (GInstanceInitFunc) config_folder_group_instance_init, NULL };
	GType config_folder_group_type_id;
	config_folder_group_type_id = g_type_register_static (adw_preferences_group_get_type (), "ConfigFolderGroup", &g_define_type_info, 0);
	ConfigFolderGroup_private_offset = g_type_add_instance_private (config_folder_group_type_id, sizeof (ConfigFolderGroupPrivate));
	return config_folder_group_type_id;
}

GType
config_folder_group_get_type (void)
{
	static gsize config_folder_group_type_id__once = 0;
	if (g_once_init_enter (&config_folder_group_type_id__once)) {
		GType config_folder_group_type_id;
		config_folder_group_type_id = config_folder_group_get_type_once ();
		g_once_init_leave (&config_folder_group_type_id__once, config_folder_group_type_id);
	}
	return config_folder_group_type_id__once;
}

static void
_vala_config_folder_group_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	ConfigFolderGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroup);
	switch (property_id) {
		case CONFIG_FOLDER_GROUP_KEY_PROPERTY:
		g_value_set_string (value, config_folder_group_get_key (self));
		break;
		case CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY:
		g_value_set_boolean (value, config_folder_group_get_check_access (self));
		break;
		case CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY:
		g_value_set_string (value, config_folder_group_get_add_label (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_config_folder_group_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	ConfigFolderGroup * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_CONFIG_FOLDER_GROUP, ConfigFolderGroup);
	switch (property_id) {
		case CONFIG_FOLDER_GROUP_KEY_PROPERTY:
		config_folder_group_set_key (self, g_value_get_string (value));
		break;
		case CONFIG_FOLDER_GROUP_CHECK_ACCESS_PROPERTY:
		config_folder_group_set_check_access (self, g_value_get_boolean (value));
		break;
		case CONFIG_FOLDER_GROUP_ADD_LABEL_PROPERTY:
		config_folder_group_set_add_label (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

