/* preferences-delete-cache-row.c generated by valac 0.56.19, the Vala compiler
 * generated from preferences-delete-cache-row.vala, do not modify */

#include "protonplus_core.h"
#include <gtk/gtk.h>
#include <adwaita.h>
#include <gio/gio.h>
#include <glib.h>
#include <glib-object.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

enum  {
	PROTON_PLUS_WIDGETS_PREFERENCES_DELETE_CACHE_ROW_0_PROPERTY,
	PROTON_PLUS_WIDGETS_PREFERENCES_DELETE_CACHE_ROW_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_preferences_delete_cache_row_properties[PROTON_PLUS_WIDGETS_PREFERENCES_DELETE_CACHE_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData;

struct _ProtonPlusWidgetsPreferencesDeleteCacheRowPrivate {
	GtkButton* delete_button;
	AdwSpinner* spinner;
};

struct _ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ProtonPlusWidgetsPreferencesDeleteCacheRow* self;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	AdwSpinner* _tmp2_;
	AdwSpinner* _tmp3_;
	AdwSpinner* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkButton* _tmp8_;
};

static gint ProtonPlusWidgetsPreferencesDeleteCacheRow_private_offset;
static gpointer proton_plus_widgets_preferences_delete_cache_row_parent_class = NULL;

static void proton_plus_widgets_preferences_delete_cache_row_delete_cache_data_free (gpointer _data);
static void proton_plus_widgets_preferences_delete_cache_row_delete_cache (ProtonPlusWidgetsPreferencesDeleteCacheRow* self,
                                                                    GAsyncReadyCallback _callback_,
                                                                    gpointer _user_data_);
static void proton_plus_widgets_preferences_delete_cache_row_delete_cache_finish (ProtonPlusWidgetsPreferencesDeleteCacheRow* self,
                                                                           GAsyncResult* _res_);
static gboolean proton_plus_widgets_preferences_delete_cache_row_delete_cache_co (ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData* _data_);
static void proton_plus_widgets_preferences_delete_cache_row_delete_cache_ready (GObject* source_object,
                                                                          GAsyncResult* _res_,
                                                                          gpointer _user_data_);
static GObject * proton_plus_widgets_preferences_delete_cache_row_constructor (GType type,
                                                                        guint n_construct_properties,
                                                                        GObjectConstructParam * construct_properties);
static void _proton_plus_widgets_preferences_delete_cache_row___lambda401_ (ProtonPlusWidgetsPreferencesDeleteCacheRow* self);
static void __proton_plus_widgets_preferences_delete_cache_row___lambda401__gtk_button_clicked (GtkButton* _sender,
                                                                                         gpointer self);
static void proton_plus_widgets_preferences_delete_cache_row_finalize (GObject * obj);
static GType proton_plus_widgets_preferences_delete_cache_row_get_type_once (void);

static inline gpointer
proton_plus_widgets_preferences_delete_cache_row_get_instance_private (ProtonPlusWidgetsPreferencesDeleteCacheRow* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsPreferencesDeleteCacheRow_private_offset);
}

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

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

static void
proton_plus_widgets_preferences_delete_cache_row_delete_cache (ProtonPlusWidgetsPreferencesDeleteCacheRow* self,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_)
{
	ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData* _data_;
	ProtonPlusWidgetsPreferencesDeleteCacheRow* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, proton_plus_widgets_preferences_delete_cache_row_delete_cache_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	proton_plus_widgets_preferences_delete_cache_row_delete_cache_co (_data_);
}

static void
proton_plus_widgets_preferences_delete_cache_row_delete_cache_finish (ProtonPlusWidgetsPreferencesDeleteCacheRow* self,
                                                                      GAsyncResult* _res_)
{
	ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
proton_plus_widgets_preferences_delete_cache_row_delete_cache_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_)
{
	ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	proton_plus_widgets_preferences_delete_cache_row_delete_cache_co (_data_);
}

static gboolean
proton_plus_widgets_preferences_delete_cache_row_delete_cache_co (ProtonPlusWidgetsPreferencesDeleteCacheRowDeleteCacheData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->delete_button;
	gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp0_, FALSE);
	_data_->_tmp1_ = _data_->self->priv->delete_button;
	_data_->_tmp2_ = _data_->self->priv->spinner;
	gtk_button_set_child (_data_->_tmp1_, (GtkWidget*) _data_->_tmp2_);
	_data_->_state_ = 1;
	proton_plus_utils_cache_manager_clear_cache (proton_plus_widgets_preferences_delete_cache_row_delete_cache_ready, _data_);
	return FALSE;
	_state_1:
	if (!proton_plus_utils_cache_manager_clear_cache_finish (_data_->_res_)) {
		g_warning ("preferences-delete-cache-row.vala:31: Could not clear and recreate the" \
" cache directory.");
	}
	_data_->_tmp4_ = _data_->self->priv->spinner;
	_data_->_tmp3_ = _data_->_tmp4_;
	if (_data_->_tmp3_ != NULL) {
		gtk_widget_unparent ((GtkWidget*) _data_->_tmp3_);
	}
	_data_->_tmp6_ = _data_->self->priv->delete_button;
	_data_->_tmp5_ = _data_->_tmp6_;
	if (_data_->_tmp5_ != NULL) {
		gtk_button_set_icon_name (_data_->_tmp5_, "user-trash-symbolic");
	}
	_data_->_tmp8_ = _data_->self->priv->delete_button;
	_data_->_tmp7_ = _data_->_tmp8_;
	if (_data_->_tmp7_ != NULL) {
		gtk_widget_set_sensitive ((GtkWidget*) _data_->_tmp7_, TRUE);
	}
	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;
}

ProtonPlusWidgetsPreferencesDeleteCacheRow*
proton_plus_widgets_preferences_delete_cache_row_construct (GType object_type)
{
	ProtonPlusWidgetsPreferencesDeleteCacheRow * self = NULL;
	self = (ProtonPlusWidgetsPreferencesDeleteCacheRow*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusWidgetsPreferencesDeleteCacheRow*
proton_plus_widgets_preferences_delete_cache_row_new (void)
{
	return proton_plus_widgets_preferences_delete_cache_row_construct (PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_DELETE_CACHE_ROW);
}

static void
_proton_plus_widgets_preferences_delete_cache_row___lambda401_ (ProtonPlusWidgetsPreferencesDeleteCacheRow* self)
{
	proton_plus_widgets_preferences_delete_cache_row_delete_cache (self, NULL, NULL);
}

static void
__proton_plus_widgets_preferences_delete_cache_row___lambda401__gtk_button_clicked (GtkButton* _sender,
                                                                                    gpointer self)
{
	_proton_plus_widgets_preferences_delete_cache_row___lambda401_ ((ProtonPlusWidgetsPreferencesDeleteCacheRow*) self);
}

static GObject *
proton_plus_widgets_preferences_delete_cache_row_constructor (GType type,
                                                              guint n_construct_properties,
                                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ProtonPlusWidgetsPreferencesDeleteCacheRow * self;
	GtkButton* _tmp0_;
	GtkButton* _tmp1_;
	GtkButton* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	GtkButton* _tmp6_;
	AdwSpinner* _tmp7_;
	GtkButton* _tmp8_;
	GtkButton* _tmp9_;
	parent_class = G_OBJECT_CLASS (proton_plus_widgets_preferences_delete_cache_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_DELETE_CACHE_ROW, ProtonPlusWidgetsPreferencesDeleteCacheRow);
	_tmp0_ = (GtkButton*) gtk_button_new_from_icon_name ("user-trash-symbolic");
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->delete_button);
	self->priv->delete_button = _tmp0_;
	_tmp1_ = self->priv->delete_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "flat");
	_tmp2_ = self->priv->delete_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp2_, "destructive-action");
	_tmp3_ = self->priv->delete_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_CENTER);
	_tmp4_ = self->priv->delete_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp4_, _ ("Delete cache"));
	_tmp5_ = self->priv->delete_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp5_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Delete cache"), -1, -1);
	_tmp6_ = self->priv->delete_button;
	g_signal_connect_object (_tmp6_, "clicked", (GCallback) __proton_plus_widgets_preferences_delete_cache_row___lambda401__gtk_button_clicked, self, 0);
	_tmp7_ = (AdwSpinner*) adw_spinner_new ();
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->spinner);
	self->priv->spinner = _tmp7_;
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _ ("Delete cache"));
	adw_action_row_set_subtitle ((AdwActionRow*) self, _ ("Removes all cached information and temporary downloads"));
	_tmp8_ = self->priv->delete_button;
	adw_action_row_add_suffix ((AdwActionRow*) self, (GtkWidget*) _tmp8_);
	_tmp9_ = self->priv->delete_button;
	adw_action_row_set_activatable_widget ((AdwActionRow*) self, (GtkWidget*) _tmp9_);
	return obj;
}

static void
proton_plus_widgets_preferences_delete_cache_row_class_init (ProtonPlusWidgetsPreferencesDeleteCacheRowClass * klass,
                                                             gpointer klass_data)
{
	proton_plus_widgets_preferences_delete_cache_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsPreferencesDeleteCacheRow_private_offset);
	G_OBJECT_CLASS (klass)->constructor = proton_plus_widgets_preferences_delete_cache_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_preferences_delete_cache_row_finalize;
}

static void
proton_plus_widgets_preferences_delete_cache_row_instance_init (ProtonPlusWidgetsPreferencesDeleteCacheRow * self,
                                                                gpointer klass)
{
	self->priv = proton_plus_widgets_preferences_delete_cache_row_get_instance_private (self);
}

static void
proton_plus_widgets_preferences_delete_cache_row_finalize (GObject * obj)
{
	ProtonPlusWidgetsPreferencesDeleteCacheRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_DELETE_CACHE_ROW, ProtonPlusWidgetsPreferencesDeleteCacheRow);
	_g_object_unref0 (self->priv->delete_button);
	_g_object_unref0 (self->priv->spinner);
	G_OBJECT_CLASS (proton_plus_widgets_preferences_delete_cache_row_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_preferences_delete_cache_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsPreferencesDeleteCacheRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_preferences_delete_cache_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsPreferencesDeleteCacheRow), 0, (GInstanceInitFunc) proton_plus_widgets_preferences_delete_cache_row_instance_init, NULL };
	GType proton_plus_widgets_preferences_delete_cache_row_type_id;
	proton_plus_widgets_preferences_delete_cache_row_type_id = g_type_register_static (adw_action_row_get_type (), "ProtonPlusWidgetsPreferencesDeleteCacheRow", &g_define_type_info, 0);
	ProtonPlusWidgetsPreferencesDeleteCacheRow_private_offset = g_type_add_instance_private (proton_plus_widgets_preferences_delete_cache_row_type_id, sizeof (ProtonPlusWidgetsPreferencesDeleteCacheRowPrivate));
	return proton_plus_widgets_preferences_delete_cache_row_type_id;
}

GType
proton_plus_widgets_preferences_delete_cache_row_get_type (void)
{
	static volatile gsize proton_plus_widgets_preferences_delete_cache_row_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_preferences_delete_cache_row_type_id__once)) {
		GType proton_plus_widgets_preferences_delete_cache_row_type_id;
		proton_plus_widgets_preferences_delete_cache_row_type_id = proton_plus_widgets_preferences_delete_cache_row_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_preferences_delete_cache_row_type_id__once, proton_plus_widgets_preferences_delete_cache_row_type_id);
	}
	return proton_plus_widgets_preferences_delete_cache_row_type_id__once;
}

