/* OperationBanner.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from OperationBanner.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 <gtk/gtk.h>
#include <glib.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_OPERATION_BANNER (operation_banner_get_type ())
#define OPERATION_BANNER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPERATION_BANNER, OperationBanner))
#define OPERATION_BANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPERATION_BANNER, OperationBannerClass))
#define IS_OPERATION_BANNER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPERATION_BANNER))
#define IS_OPERATION_BANNER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPERATION_BANNER))
#define OPERATION_BANNER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPERATION_BANNER, OperationBannerClass))

typedef struct _OperationBanner OperationBanner;
typedef struct _OperationBannerClass OperationBannerClass;
typedef struct _OperationBannerPrivate OperationBannerPrivate;

#define TYPE_OPERATION_WRAPPER (operation_wrapper_get_type ())
#define OPERATION_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_OPERATION_WRAPPER, OperationWrapper))
#define OPERATION_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_OPERATION_WRAPPER, OperationWrapperClass))
#define IS_OPERATION_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_OPERATION_WRAPPER))
#define IS_OPERATION_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_OPERATION_WRAPPER))
#define OPERATION_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_OPERATION_WRAPPER, OperationWrapperClass))

typedef struct _OperationWrapper OperationWrapper;
typedef struct _OperationWrapperClass OperationWrapperClass;
enum  {
	OPERATION_BANNER_0_PROPERTY,
	OPERATION_BANNER_NUM_PROPERTIES
};
static GParamSpec* operation_banner_properties[OPERATION_BANNER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _OperationBanner {
	AdwBin parent_instance;
	OperationBannerPrivate * priv;
};

struct _OperationBannerClass {
	AdwBinClass parent_class;
};

struct _OperationBannerPrivate {
	AdwBanner* banner;
	GtkProgressBar* progress;
	OperationWrapper* wrapper;
};

static gint OperationBanner_private_offset;
static gpointer operation_banner_parent_class = NULL;

VALA_EXTERN GType operation_banner_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OperationBanner, g_object_unref)
VALA_EXTERN GType operation_wrapper_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (OperationWrapper, g_object_unref)
static void operation_banner_on_button_clicked (OperationBanner* self);
VALA_EXTERN void operation_wrapper_click (OperationWrapper* self);
static void _operation_banner_on_button_clicked_adw_banner_button_clicked (AdwBanner* _sender,
                                                                    gpointer self);
static void operation_banner_handle_button_suggested_change (OperationBanner* self);
VALA_EXTERN gboolean operation_wrapper_get_button_suggested (OperationWrapper* self);
static void operation_banner_handle_error_mode_change (OperationBanner* self);
VALA_EXTERN gboolean operation_wrapper_get_error_mode (OperationWrapper* self);
VALA_EXTERN OperationBanner* operation_banner_new (void);
VALA_EXTERN OperationBanner* operation_banner_construct (GType object_type);
static GObject * operation_banner_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
VALA_EXTERN OperationWrapper* operation_wrapper_new (DejaDupOperation* operation,
                                         GtkWidget* parent);
VALA_EXTERN OperationWrapper* operation_wrapper_construct (GType object_type,
                                               DejaDupOperation* operation,
                                               GtkWidget* parent);
VALA_EXTERN void operation_wrapper_set_cancel_stops (OperationWrapper* self,
                                         gboolean value);
static void _operation_banner_handle_button_suggested_change_g_object_notify (GObject* _sender,
                                                                       GParamSpec* pspec,
                                                                       gpointer self);
static void _operation_banner_handle_error_mode_change_g_object_notify (GObject* _sender,
                                                                 GParamSpec* pspec,
                                                                 gpointer self);
static void _gtk_progress_bar_pulse_operation_wrapper_pulse (OperationWrapper* _sender,
                                                      gpointer self);
static void operation_banner_finalize (GObject * obj);
static GType operation_banner_get_type_once (void);

static inline gpointer
operation_banner_get_instance_private (OperationBanner* self)
{
	return G_STRUCT_MEMBER_P (self, OperationBanner_private_offset);
}

static void
operation_banner_on_button_clicked (OperationBanner* self)
{
	OperationWrapper* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->wrapper;
	operation_wrapper_click (_tmp0_);
}

static void
_operation_banner_on_button_clicked_adw_banner_button_clicked (AdwBanner* _sender,
                                                               gpointer self)
{
	operation_banner_on_button_clicked ((OperationBanner*) self);
}

static void
operation_banner_handle_button_suggested_change (OperationBanner* self)
{
	OperationWrapper* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->wrapper;
	_tmp1_ = operation_wrapper_get_button_suggested (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		AdwBanner* _tmp3_;
		_tmp3_ = self->priv->banner;
		adw_banner_set_button_style (_tmp3_, ADW_BANNER_BUTTON_SUGGESTED);
	} else {
		AdwBanner* _tmp4_;
		_tmp4_ = self->priv->banner;
		adw_banner_set_button_style (_tmp4_, ADW_BANNER_BUTTON_DEFAULT);
	}
}

static void
operation_banner_handle_error_mode_change (OperationBanner* self)
{
	OperationWrapper* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->wrapper;
	_tmp1_ = operation_wrapper_get_error_mode (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		AdwBanner* _tmp3_;
		_tmp3_ = self->priv->banner;
		gtk_widget_add_css_class ((GtkWidget*) _tmp3_, "error");
	} else {
		AdwBanner* _tmp4_;
		_tmp4_ = self->priv->banner;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp4_, "error");
	}
}

OperationBanner*
operation_banner_construct (GType object_type)
{
	OperationBanner * self = NULL;
	self = (OperationBanner*) g_object_new (object_type, NULL);
	return self;
}

OperationBanner*
operation_banner_new (void)
{
	return operation_banner_construct (TYPE_OPERATION_BANNER);
}

static void
_operation_banner_handle_button_suggested_change_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self)
{
	operation_banner_handle_button_suggested_change ((OperationBanner*) self);
}

static void
_operation_banner_handle_error_mode_change_g_object_notify (GObject* _sender,
                                                            GParamSpec* pspec,
                                                            gpointer self)
{
	operation_banner_handle_error_mode_change ((OperationBanner*) self);
}

static void
_gtk_progress_bar_pulse_operation_wrapper_pulse (OperationWrapper* _sender,
                                                 gpointer self)
{
	gtk_progress_bar_pulse ((GtkProgressBar*) self);
}

static GObject *
operation_banner_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	OperationBanner * self;
	DejaDupOperationWatcher* _tmp0_;
	DejaDupOperationWatcher* _tmp1_;
	OperationWrapper* _tmp2_;
	OperationWrapper* _tmp3_;
	OperationWrapper* _tmp4_;
	AdwBanner* _tmp5_;
	OperationWrapper* _tmp6_;
	GtkProgressBar* _tmp7_;
	OperationWrapper* _tmp8_;
	AdwBanner* _tmp9_;
	OperationWrapper* _tmp10_;
	AdwBanner* _tmp11_;
	OperationWrapper* _tmp12_;
	GtkProgressBar* _tmp13_;
	OperationWrapper* _tmp14_;
	OperationWrapper* _tmp15_;
	OperationWrapper* _tmp16_;
	GtkProgressBar* _tmp17_;
	parent_class = G_OBJECT_CLASS (operation_banner_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_OPERATION_BANNER, OperationBanner);
	_tmp0_ = deja_dup_operation_watcher_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = operation_wrapper_new ((DejaDupOperation*) _tmp1_, (GtkWidget*) self);
	_g_object_unref0 (self->priv->wrapper);
	self->priv->wrapper = _tmp2_;
	_g_object_unref0 (_tmp1_);
	_tmp3_ = self->priv->wrapper;
	operation_wrapper_set_cancel_stops (_tmp3_, TRUE);
	_tmp4_ = self->priv->wrapper;
	_tmp5_ = self->priv->banner;
	g_object_bind_property_with_closures ((GObject*) _tmp4_, "active", (GObject*) _tmp5_, "revealed", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp6_ = self->priv->wrapper;
	_tmp7_ = self->priv->progress;
	g_object_bind_property_with_closures ((GObject*) _tmp6_, "active", (GObject*) _tmp7_, "visible", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp8_ = self->priv->wrapper;
	_tmp9_ = self->priv->banner;
	g_object_bind_property_with_closures ((GObject*) _tmp8_, "summary", (GObject*) _tmp9_, "title", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp10_ = self->priv->wrapper;
	_tmp11_ = self->priv->banner;
	g_object_bind_property_with_closures ((GObject*) _tmp10_, "button-label", (GObject*) _tmp11_, "button-label", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp12_ = self->priv->wrapper;
	_tmp13_ = self->priv->progress;
	g_object_bind_property_with_closures ((GObject*) _tmp12_, "fraction", (GObject*) _tmp13_, "fraction", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp14_ = self->priv->wrapper;
	g_signal_connect_object ((GObject*) _tmp14_, "notify::button-suggested", (GCallback) _operation_banner_handle_button_suggested_change_g_object_notify, self, 0);
	_tmp15_ = self->priv->wrapper;
	g_signal_connect_object ((GObject*) _tmp15_, "notify::error-mode", (GCallback) _operation_banner_handle_error_mode_change_g_object_notify, self, 0);
	_tmp16_ = self->priv->wrapper;
	_tmp17_ = self->priv->progress;
	g_signal_connect_object (_tmp16_, "pulse", (GCallback) _gtk_progress_bar_pulse_operation_wrapper_pulse, _tmp17_, 0);
	return obj;
}

static void
operation_banner_class_init (OperationBannerClass * klass,
                             gpointer klass_data)
{
	operation_banner_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &OperationBanner_private_offset);
	G_OBJECT_CLASS (klass)->constructor = operation_banner_constructor;
	G_OBJECT_CLASS (klass)->finalize = operation_banner_finalize;
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/DejaDup/OperationBanner.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "banner", FALSE, OperationBanner_private_offset + G_STRUCT_OFFSET (OperationBannerPrivate, banner));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "progress", FALSE, OperationBanner_private_offset + G_STRUCT_OFFSET (OperationBannerPrivate, progress));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_button_clicked", G_CALLBACK(_operation_banner_on_button_clicked_adw_banner_button_clicked));
}

static void
operation_banner_instance_init (OperationBanner * self,
                                gpointer klass)
{
	self->priv = operation_banner_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
operation_banner_finalize (GObject * obj)
{
	OperationBanner * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_OPERATION_BANNER, OperationBanner);
	_g_object_unref0 (self->priv->wrapper);
	G_OBJECT_CLASS (operation_banner_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
operation_banner_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OperationBannerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) operation_banner_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OperationBanner), 0, (GInstanceInitFunc) operation_banner_instance_init, NULL };
	GType operation_banner_type_id;
	operation_banner_type_id = g_type_register_static (adw_bin_get_type (), "OperationBanner", &g_define_type_info, 0);
	OperationBanner_private_offset = g_type_add_instance_private (operation_banner_type_id, sizeof (OperationBannerPrivate));
	return operation_banner_type_id;
}

GType
operation_banner_get_type (void)
{
	static gsize operation_banner_type_id__once = 0;
	if (g_once_init_enter (&operation_banner_type_id__once)) {
		GType operation_banner_type_id;
		operation_banner_type_id = operation_banner_get_type_once ();
		g_once_init_leave (&operation_banner_type_id__once, operation_banner_type_id);
	}
	return operation_banner_type_id__once;
}

