/* ProgressDialog.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from ProgressDialog.vala, do not modify */

/*
 * SPDX-License-Identifier: LGPL-3.0-or-later
 * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
 */

#include "io.elementary.settings.locale.h"
#include <glib-object.h>
#include <granite-7.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.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  {
	SWITCHBOARD_PLUG_LOCALE_PROGRESS_DIALOG_0_PROPERTY,
	SWITCHBOARD_PLUG_LOCALE_PROGRESS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* switchboard_plug_locale_progress_dialog_properties[SWITCHBOARD_PLUG_LOCALE_PROGRESS_DIALOG_NUM_PROPERTIES];
typedef struct _Block1Data Block1Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _Block1Data {
	int _ref_count_;
	SwitchboardPlugLocaleProgressDialog* self;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* installer;
	GtkProgressBar* progress_bar;
};

static gpointer switchboard_plug_locale_progress_dialog_parent_class = NULL;

static GObject * switchboard_plug_locale_progress_dialog_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void _switchboard_plug_locale_progress_dialog___lambda19_ (Block1Data* _data1_,
                                                           gint value);
static void __switchboard_plug_locale_progress_dialog___lambda19__switchboard_plug_locale_installer_ubuntu_installer_progress_changed (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                                gint progress,
                                                                                                                                gpointer self);
static void _switchboard_plug_locale_progress_dialog___lambda20_ (Block1Data* _data1_,
                                                           gint response);
static void __switchboard_plug_locale_progress_dialog___lambda20__gtk_dialog_response (GtkDialog* _sender,
                                                                                gint response_id,
                                                                                gpointer self);
static GType switchboard_plug_locale_progress_dialog_get_type_once (void);

SwitchboardPlugLocaleProgressDialog*
switchboard_plug_locale_progress_dialog_construct (GType object_type)
{
	SwitchboardPlugLocaleProgressDialog * self = NULL;
	self = (SwitchboardPlugLocaleProgressDialog*) granite_dialog_construct (object_type);
	return self;
}

SwitchboardPlugLocaleProgressDialog*
switchboard_plug_locale_progress_dialog_new (void)
{
	return switchboard_plug_locale_progress_dialog_construct (SWITCHBOARD_PLUG_LOCALE_TYPE_PROGRESS_DIALOG);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		SwitchboardPlugLocaleProgressDialog* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->progress_bar);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

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

static void
_switchboard_plug_locale_progress_dialog___lambda19_ (Block1Data* _data1_,
                                                      gint value)
{
	SwitchboardPlugLocaleProgressDialog* self;
	GtkProgressBar* _tmp0_;
	self = _data1_->self;
	if (value >= 100) {
		gtk_dialog_response ((GtkDialog*) self, (gint) GTK_RESPONSE_DELETE_EVENT);
	}
	_tmp0_ = _data1_->progress_bar;
	gtk_progress_bar_set_fraction (_tmp0_, value / 100.0);
}

static void
__switchboard_plug_locale_progress_dialog___lambda19__switchboard_plug_locale_installer_ubuntu_installer_progress_changed (SwitchboardPlugLocaleInstallerUbuntuInstaller* _sender,
                                                                                                                           gint progress,
                                                                                                                           gpointer self)
{
	_switchboard_plug_locale_progress_dialog___lambda19_ (self, progress);
}

static void
_switchboard_plug_locale_progress_dialog___lambda20_ (Block1Data* _data1_,
                                                      gint response)
{
	SwitchboardPlugLocaleProgressDialog* self;
	self = _data1_->self;
	if (response == ((gint) GTK_RESPONSE_CANCEL)) {
		SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp0_;
		_tmp0_ = _data1_->installer;
		switchboard_plug_locale_installer_ubuntu_installer_cancel_install (_tmp0_);
	}
	g_signal_emit_by_name ((GtkDialog*) self, "close");
}

static void
__switchboard_plug_locale_progress_dialog___lambda20__gtk_dialog_response (GtkDialog* _sender,
                                                                           gint response_id,
                                                                           gpointer self)
{
	_switchboard_plug_locale_progress_dialog___lambda20_ (self, response_id);
}

static GObject *
switchboard_plug_locale_progress_dialog_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwitchboardPlugLocaleProgressDialog * self;
	Block1Data* _data1_;
	GtkImage* image = NULL;
	GtkImage* _tmp0_ = NULL;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp1_;
	gchar* transaction_language_name = NULL;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	GtkLabel* primary_label = NULL;
	GtkLabel* _tmp6_ = NULL;
	GtkLabel* _tmp7_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp8_;
	SwitchboardPlugLocaleInstallerUbuntuInstallerTransactionMode _tmp9_;
	SwitchboardPlugLocaleInstallerUbuntuInstallerTransactionMode _tmp10_;
	GtkProgressBar* _tmp20_ = NULL;
	GtkButton* cancel_button = NULL;
	GtkWidget* _tmp21_;
	GtkButton* _tmp22_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp23_ = NULL;
	GtkGrid* _tmp24_;
	GtkImage* _tmp25_;
	GtkGrid* _tmp26_;
	GtkLabel* _tmp27_;
	GtkGrid* _tmp28_;
	GtkProgressBar* _tmp29_;
	GtkBox* _tmp30_;
	GtkGrid* _tmp31_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp32_;
	GtkButton* _tmp33_;
	SwitchboardPlugLocaleInstallerUbuntuInstaller* _tmp34_;
	parent_class = G_OBJECT_CLASS (switchboard_plug_locale_progress_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_LOCALE_TYPE_PROGRESS_DIALOG, SwitchboardPlugLocaleProgressDialog);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	_tmp0_ = (GtkImage*) gtk_image_new_from_icon_name ("preferences-desktop-locale");
	gtk_image_set_pixel_size (_tmp0_, 48);
	gtk_widget_set_valign ((GtkWidget*) _tmp0_, GTK_ALIGN_START);
	g_object_ref_sink (_tmp0_);
	image = _tmp0_;
	_tmp1_ = switchboard_plug_locale_installer_ubuntu_installer_get_default ();
	_data1_->installer = _tmp1_;
	_tmp2_ = _data1_->installer;
	_tmp3_ = switchboard_plug_locale_installer_ubuntu_installer_get_transaction_language_code (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = switchboard_plug_locale_utils_translate (_tmp4_, NULL);
	transaction_language_name = _tmp5_;
	_tmp6_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_max_width_chars (_tmp6_, 50);
	gtk_label_set_wrap (_tmp6_, TRUE);
	gtk_label_set_xalign (_tmp6_, (gfloat) 0);
	g_object_ref_sink (_tmp6_);
	primary_label = _tmp6_;
	_tmp7_ = primary_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp7_, GRANITE_STYLE_CLASS_TITLE_LABEL);
	_tmp8_ = _data1_->installer;
	_tmp9_ = switchboard_plug_locale_installer_ubuntu_installer_get_transaction_mode (_tmp8_);
	_tmp10_ = _tmp9_;
	switch (_tmp10_) {
		case SWITCHBOARD_PLUG_LOCALE_INSTALLER_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL:
		{
			GtkLabel* _tmp11_;
			const gchar* _tmp12_;
			gchar* _tmp13_;
			gchar* _tmp14_;
			_tmp11_ = primary_label;
			_tmp12_ = transaction_language_name;
			_tmp13_ = g_strdup_printf (_ ("Installing %s"), _tmp12_);
			_tmp14_ = _tmp13_;
			gtk_label_set_label (_tmp11_, _tmp14_);
			_g_free0 (_tmp14_);
			break;
		}
		case SWITCHBOARD_PLUG_LOCALE_INSTALLER_UBUNTU_INSTALLER_TRANSACTION_MODE_REMOVE:
		{
			GtkLabel* _tmp15_;
			const gchar* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			_tmp15_ = primary_label;
			_tmp16_ = transaction_language_name;
			_tmp17_ = g_strdup_printf (_ ("Removing %s"), _tmp16_);
			_tmp18_ = _tmp17_;
			gtk_label_set_label (_tmp15_, _tmp18_);
			_g_free0 (_tmp18_);
			break;
		}
		case SWITCHBOARD_PLUG_LOCALE_INSTALLER_UBUNTU_INSTALLER_TRANSACTION_MODE_INSTALL_MISSING:
		{
			GtkLabel* _tmp19_;
			_tmp19_ = primary_label;
			gtk_label_set_label (_tmp19_, _ ("Installing missing language"));
			break;
		}
		default:
		break;
	}
	_tmp20_ = (GtkProgressBar*) gtk_progress_bar_new ();
	gtk_widget_set_hexpand ((GtkWidget*) _tmp20_, TRUE);
	gtk_widget_set_valign ((GtkWidget*) _tmp20_, GTK_ALIGN_START);
	g_object_set ((GtkWidget*) _tmp20_, "width-request", 300, NULL);
	g_object_ref_sink (_tmp20_);
	_data1_->progress_bar = _tmp20_;
	_tmp21_ = granite_dialog_add_button ((GraniteDialog*) self, _ ("Cancel"), (gint) GTK_RESPONSE_CANCEL);
	_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_button_get_type (), GtkButton));
	cancel_button = _tmp22_;
	_tmp23_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp23_, 12);
	gtk_grid_set_row_spacing (_tmp23_, 6);
	g_object_ref_sink (_tmp23_);
	grid = _tmp23_;
	_tmp24_ = grid;
	_tmp25_ = image;
	gtk_grid_attach (_tmp24_, (GtkWidget*) _tmp25_, 0, 0, 1, 2);
	_tmp26_ = grid;
	_tmp27_ = primary_label;
	gtk_grid_attach (_tmp26_, (GtkWidget*) _tmp27_, 1, 0, 1, 1);
	_tmp28_ = grid;
	_tmp29_ = _data1_->progress_bar;
	gtk_grid_attach (_tmp28_, (GtkWidget*) _tmp29_, 1, 1, 1, 1);
	gtk_window_set_modal ((GtkWindow*) self, TRUE);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	_tmp30_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp31_ = grid;
	gtk_box_append (_tmp30_, (GtkWidget*) _tmp31_);
	_tmp32_ = _data1_->installer;
	_tmp33_ = cancel_button;
	g_object_bind_property_with_closures ((GObject*) _tmp32_, "install-cancellable", (GObject*) _tmp33_, "sensitive", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp34_ = _data1_->installer;
	g_signal_connect_data (_tmp34_, "progress-changed", (GCallback) __switchboard_plug_locale_progress_dialog___lambda19__switchboard_plug_locale_installer_ubuntu_installer_progress_changed, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	g_signal_connect_data ((GtkDialog*) self, "response", (GCallback) __switchboard_plug_locale_progress_dialog___lambda20__gtk_dialog_response, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_g_object_unref0 (grid);
	_g_object_unref0 (cancel_button);
	_g_object_unref0 (primary_label);
	_g_free0 (transaction_language_name);
	_g_object_unref0 (image);
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return obj;
}

static void
switchboard_plug_locale_progress_dialog_class_init (SwitchboardPlugLocaleProgressDialogClass * klass,
                                                    gpointer klass_data)
{
	switchboard_plug_locale_progress_dialog_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = switchboard_plug_locale_progress_dialog_constructor;
}

static void
switchboard_plug_locale_progress_dialog_instance_init (SwitchboardPlugLocaleProgressDialog * self,
                                                       gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
switchboard_plug_locale_progress_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardPlugLocaleProgressDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_plug_locale_progress_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardPlugLocaleProgressDialog), 0, (GInstanceInitFunc) switchboard_plug_locale_progress_dialog_instance_init, NULL };
	GType switchboard_plug_locale_progress_dialog_type_id;
	switchboard_plug_locale_progress_dialog_type_id = g_type_register_static (GRANITE_TYPE_DIALOG, "SwitchboardPlugLocaleProgressDialog", &g_define_type_info, 0);
	return switchboard_plug_locale_progress_dialog_type_id;
}

GType
switchboard_plug_locale_progress_dialog_get_type (void)
{
	static gsize switchboard_plug_locale_progress_dialog_type_id__once = 0;
	if (g_once_init_enter (&switchboard_plug_locale_progress_dialog_type_id__once)) {
		GType switchboard_plug_locale_progress_dialog_type_id;
		switchboard_plug_locale_progress_dialog_type_id = switchboard_plug_locale_progress_dialog_get_type_once ();
		g_once_init_leave (&switchboard_plug_locale_progress_dialog_type_id__once, switchboard_plug_locale_progress_dialog_type_id);
	}
	return switchboard_plug_locale_progress_dialog_type_id__once;
}

