/* ConfigFolderPage.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ConfigFolderPage.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 <gio/gio.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "deja.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_BASIC_NAVIGATION_PAGE (basic_navigation_page_get_type ())
#define BASIC_NAVIGATION_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_BASIC_NAVIGATION_PAGE, BasicNavigationPage))
#define BASIC_NAVIGATION_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_BASIC_NAVIGATION_PAGE, BasicNavigationPageClass))
#define IS_BASIC_NAVIGATION_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_BASIC_NAVIGATION_PAGE))
#define IS_BASIC_NAVIGATION_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_BASIC_NAVIGATION_PAGE))
#define BASIC_NAVIGATION_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_BASIC_NAVIGATION_PAGE, BasicNavigationPageClass))

typedef struct _BasicNavigationPage BasicNavigationPage;
typedef struct _BasicNavigationPageClass BasicNavigationPageClass;
typedef struct _BasicNavigationPagePrivate BasicNavigationPagePrivate;

#define TYPE_CONFIG_FOLDER_PAGE (config_folder_page_get_type ())
#define CONFIG_FOLDER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_CONFIG_FOLDER_PAGE, ConfigFolderPage))
#define CONFIG_FOLDER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_CONFIG_FOLDER_PAGE, ConfigFolderPageClass))
#define IS_CONFIG_FOLDER_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_CONFIG_FOLDER_PAGE))
#define IS_CONFIG_FOLDER_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_CONFIG_FOLDER_PAGE))
#define CONFIG_FOLDER_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_CONFIG_FOLDER_PAGE, ConfigFolderPageClass))

typedef struct _ConfigFolderPage ConfigFolderPage;
typedef struct _ConfigFolderPageClass ConfigFolderPageClass;
typedef struct _ConfigFolderPagePrivate ConfigFolderPagePrivate;
enum  {
	CONFIG_FOLDER_PAGE_0_PROPERTY,
	CONFIG_FOLDER_PAGE_NUM_PROPERTIES
};
static GParamSpec* config_folder_page_properties[CONFIG_FOLDER_PAGE_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 _ConfigFolderPageConfirmResetData ConfigFolderPageConfirmResetData;

struct _BasicNavigationPage {
	AdwNavigationPage parent_instance;
	BasicNavigationPagePrivate * priv;
};

struct _BasicNavigationPageClass {
	AdwNavigationPageClass parent_class;
};

struct _ConfigFolderPage {
	BasicNavigationPage parent_instance;
	ConfigFolderPagePrivate * priv;
};

struct _ConfigFolderPageClass {
	BasicNavigationPageClass parent_class;
};

struct _ConfigFolderPageConfirmResetData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ConfigFolderPage* self;
	AdwAlertDialog* dlg;
	AdwAlertDialog* _tmp0_;
	AdwAlertDialog* _tmp1_;
	AdwAlertDialog* _tmp2_;
	AdwAlertDialog* _tmp3_;
	AdwAlertDialog* _tmp4_;
	gchar* choice;
	AdwAlertDialog* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	DejaDupFilteredSettings* settings;
	DejaDupFilteredSettings* _tmp9_;
	DejaDupFilteredSettings* _tmp10_;
	DejaDupFilteredSettings* _tmp11_;
};

static gpointer config_folder_page_parent_class = NULL;

VALA_EXTERN GType basic_navigation_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BasicNavigationPage, g_object_unref)
VALA_EXTERN GType config_folder_page_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ConfigFolderPage, g_object_unref)
static void config_folder_page_on_reset_clicked (ConfigFolderPage* self);
static void config_folder_page_confirm_reset (ConfigFolderPage* self,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
static void config_folder_page_confirm_reset_finish (ConfigFolderPage* self,
                                              GAsyncResult* _res_);
static void _config_folder_page_on_reset_clicked_adw_button_row_activated (AdwButtonRow* _sender,
                                                                    gpointer self);
static void config_folder_page_confirm_reset_data_free (gpointer _data);
static gboolean config_folder_page_confirm_reset_co (ConfigFolderPageConfirmResetData* _data_);
static void config_folder_page_confirm_reset_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_);
VALA_EXTERN ConfigFolderPage* config_folder_page_new (void);
VALA_EXTERN ConfigFolderPage* config_folder_page_construct (GType object_type);
VALA_EXTERN BasicNavigationPage* basic_navigation_page_new (void);
VALA_EXTERN BasicNavigationPage* basic_navigation_page_construct (GType object_type);
static GType config_folder_page_get_type_once (void);

static void
config_folder_page_on_reset_clicked (ConfigFolderPage* self)
{
	g_return_if_fail (self != NULL);
	config_folder_page_confirm_reset (self, NULL, NULL);
}

static void
_config_folder_page_on_reset_clicked_adw_button_row_activated (AdwButtonRow* _sender,
                                                               gpointer self)
{
	config_folder_page_on_reset_clicked ((ConfigFolderPage*) self);
}

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

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

static void
config_folder_page_confirm_reset (ConfigFolderPage* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	ConfigFolderPageConfirmResetData* _data_;
	ConfigFolderPage* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ConfigFolderPageConfirmResetData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, config_folder_page_confirm_reset_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	config_folder_page_confirm_reset_co (_data_);
}

static void
config_folder_page_confirm_reset_finish (ConfigFolderPage* self,
                                         GAsyncResult* _res_)
{
	ConfigFolderPageConfirmResetData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
config_folder_page_confirm_reset_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_)
{
	ConfigFolderPageConfirmResetData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	config_folder_page_confirm_reset_co (_data_);
}

static gboolean
config_folder_page_confirm_reset_co (ConfigFolderPageConfirmResetData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = (AdwAlertDialog*) adw_alert_dialog_new (_ ("Reset All Folders?"), _ ("All changes to backed up and ignored folders will be lost."));
	g_object_ref_sink (_data_->_tmp0_);
	_data_->dlg = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->dlg;
	adw_alert_dialog_add_response (_data_->_tmp1_, "cancel", _ ("_Cancel"));
	_data_->_tmp2_ = _data_->dlg;
	adw_alert_dialog_add_response (_data_->_tmp2_, "reset", _ ("Rese_t"));
	_data_->_tmp3_ = _data_->dlg;
	adw_alert_dialog_set_response_appearance (_data_->_tmp3_, "reset", ADW_RESPONSE_DESTRUCTIVE);
	_data_->_tmp4_ = _data_->dlg;
	adw_alert_dialog_set_default_response (_data_->_tmp4_, "cancel");
	_data_->_tmp5_ = _data_->dlg;
	_data_->_state_ = 1;
	adw_alert_dialog_choose (_data_->_tmp5_, (GtkWidget*) _data_->self, NULL, config_folder_page_confirm_reset_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp6_ = adw_alert_dialog_choose_finish (_data_->_tmp5_, _data_->_res_);
	_data_->_tmp7_ = g_strdup (_data_->_tmp6_);
	_data_->choice = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->choice;
	if (g_strcmp0 (_data_->_tmp8_, "reset") == 0) {
		_data_->_tmp9_ = deja_dup_get_settings (NULL);
		_data_->settings = _data_->_tmp9_;
		_data_->_tmp10_ = _data_->settings;
		g_settings_reset ((GSettings*) _data_->_tmp10_, DEJA_DUP_INCLUDE_LIST_KEY);
		_data_->_tmp11_ = _data_->settings;
		g_settings_reset ((GSettings*) _data_->_tmp11_, DEJA_DUP_EXCLUDE_LIST_KEY);
		_g_object_unref0 (_data_->settings);
	}
	_g_free0 (_data_->choice);
	_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;
}

ConfigFolderPage*
config_folder_page_construct (GType object_type)
{
	ConfigFolderPage * self = NULL;
	self = (ConfigFolderPage*) basic_navigation_page_construct (object_type);
	return self;
}

ConfigFolderPage*
config_folder_page_new (void)
{
	return config_folder_page_construct (TYPE_CONFIG_FOLDER_PAGE);
}

static void
config_folder_page_class_init (ConfigFolderPageClass * klass,
                               gpointer klass_data)
{
	config_folder_page_parent_class = g_type_class_peek_parent (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/ConfigFolderPage.ui");
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_reset_clicked", G_CALLBACK(_config_folder_page_on_reset_clicked_adw_button_row_activated));
}

static void
config_folder_page_instance_init (ConfigFolderPage * self,
                                  gpointer klass)
{
	gtk_widget_init_template (GTK_WIDGET (self));
}

 G_GNUC_NO_INLINE static GType
config_folder_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ConfigFolderPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) config_folder_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ConfigFolderPage), 0, (GInstanceInitFunc) config_folder_page_instance_init, NULL };
	GType config_folder_page_type_id;
	config_folder_page_type_id = g_type_register_static (TYPE_BASIC_NAVIGATION_PAGE, "ConfigFolderPage", &g_define_type_info, 0);
	return config_folder_page_type_id;
}

GType
config_folder_page_get_type (void)
{
	static gsize config_folder_page_type_id__once = 0;
	if (g_once_init_enter (&config_folder_page_type_id__once)) {
		GType config_folder_page_type_id;
		config_folder_page_type_id = config_folder_page_get_type_once ();
		g_once_init_leave (&config_folder_page_type_id__once, config_folder_page_type_id);
	}
	return config_folder_page_type_id__once;
}

