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

/*
 * Copyright 2011-2024 elementary, Inc. (https://github.com/elementary/camera)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 * Authored by: Alain M. <alain23@protonmail.com>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.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 CAMERA_WIDGETS_TYPE_TIMER_BUTTON (camera_widgets_timer_button_get_type ())
#define CAMERA_WIDGETS_TIMER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAMERA_WIDGETS_TYPE_TIMER_BUTTON, CameraWidgetsTimerButton))
#define CAMERA_WIDGETS_TIMER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAMERA_WIDGETS_TYPE_TIMER_BUTTON, CameraWidgetsTimerButtonClass))
#define CAMERA_WIDGETS_IS_TIMER_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAMERA_WIDGETS_TYPE_TIMER_BUTTON))
#define CAMERA_WIDGETS_IS_TIMER_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAMERA_WIDGETS_TYPE_TIMER_BUTTON))
#define CAMERA_WIDGETS_TIMER_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAMERA_WIDGETS_TYPE_TIMER_BUTTON, CameraWidgetsTimerButtonClass))

typedef struct _CameraWidgetsTimerButton CameraWidgetsTimerButton;
typedef struct _CameraWidgetsTimerButtonClass CameraWidgetsTimerButtonClass;
typedef struct _CameraWidgetsTimerButtonPrivate CameraWidgetsTimerButtonPrivate;
typedef enum  {
	CAMERA_WIDGETS_TIMER_BUTTON_DELAY_DISABLED = 0,
	CAMERA_WIDGETS_TIMER_BUTTON_DELAY_3_SEC = 3,
	CAMERA_WIDGETS_TIMER_BUTTON_DELAY_5_SEC = 5,
	CAMERA_WIDGETS_TIMER_BUTTON_DELAY_10_SEC = 10
} CameraWidgetsTimerButtonDelay;

#define CAMERA_WIDGETS_TIMER_BUTTON_TYPE_DELAY (camera_widgets_timer_button_delay_get_type ())
enum  {
	CAMERA_WIDGETS_TIMER_BUTTON_0_PROPERTY,
	CAMERA_WIDGETS_TIMER_BUTTON_NUM_PROPERTIES
};
static GParamSpec* camera_widgets_timer_button_properties[CAMERA_WIDGETS_TIMER_BUTTON_NUM_PROPERTIES];
typedef struct _Block7Data Block7Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _CameraWidgetsTimerButton {
	GtkButton parent_instance;
	CameraWidgetsTimerButtonPrivate * priv;
	CameraWidgetsTimerButtonDelay delay;
};

struct _CameraWidgetsTimerButtonClass {
	GtkButtonClass parent_class;
};

struct _Block7Data {
	int _ref_count_;
	CameraWidgetsTimerButton* self;
	GtkLabel* label_widget;
};

static gpointer camera_widgets_timer_button_parent_class = NULL;
VALA_EXTERN GSettings* camera_application_settings;

VALA_EXTERN GType camera_widgets_timer_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CameraWidgetsTimerButton, g_object_unref)
VALA_EXTERN GType camera_widgets_timer_button_delay_get_type (void) G_GNUC_CONST ;
VALA_EXTERN CameraWidgetsTimerButtonDelay camera_widgets_timer_button_delay_next (CameraWidgetsTimerButtonDelay self);
VALA_EXTERN gchar* camera_widgets_timer_button_delay_to_string (CameraWidgetsTimerButtonDelay self);
VALA_EXTERN CameraWidgetsTimerButton* camera_widgets_timer_button_new (void);
VALA_EXTERN CameraWidgetsTimerButton* camera_widgets_timer_button_construct (GType object_type);
static GObject * camera_widgets_timer_button_constructor (GType type,
                                                   guint n_construct_properties,
                                                   GObjectConstructParam * construct_properties);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void _camera_widgets_timer_button___lambda10_ (Block7Data* _data7_);
static void __camera_widgets_timer_button___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                                   gpointer self);
static void camera_widgets_timer_button_finalize (GObject * obj);
static GType camera_widgets_timer_button_get_type_once (void);

CameraWidgetsTimerButtonDelay
camera_widgets_timer_button_delay_next (CameraWidgetsTimerButtonDelay self)
{
	CameraWidgetsTimerButtonDelay result;
	switch (self) {
		case CAMERA_WIDGETS_TIMER_BUTTON_DELAY_3_SEC:
		{
			result = CAMERA_WIDGETS_TIMER_BUTTON_DELAY_5_SEC;
			return result;
		}
		case CAMERA_WIDGETS_TIMER_BUTTON_DELAY_5_SEC:
		{
			result = CAMERA_WIDGETS_TIMER_BUTTON_DELAY_10_SEC;
			return result;
		}
		case CAMERA_WIDGETS_TIMER_BUTTON_DELAY_10_SEC:
		{
			result = CAMERA_WIDGETS_TIMER_BUTTON_DELAY_DISABLED;
			return result;
		}
		default:
		{
			result = CAMERA_WIDGETS_TIMER_BUTTON_DELAY_3_SEC;
			return result;
		}
	}
}

gchar*
camera_widgets_timer_button_delay_to_string (CameraWidgetsTimerButtonDelay self)
{
	gchar* result;
	if (self == CAMERA_WIDGETS_TIMER_BUTTON_DELAY_DISABLED) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (_ ("Disabled"));
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup_printf (ngettext ("%d Sec", "%d Sec", (gulong) self), (gint) self);
		result = _tmp1_;
		return result;
	}
}

static GType
camera_widgets_timer_button_delay_get_type_once (void)
{
	static const GEnumValue values[] = {{CAMERA_WIDGETS_TIMER_BUTTON_DELAY_DISABLED, "CAMERA_WIDGETS_TIMER_BUTTON_DELAY_DISABLED", "disabled"}, {CAMERA_WIDGETS_TIMER_BUTTON_DELAY_3_SEC, "CAMERA_WIDGETS_TIMER_BUTTON_DELAY_3_SEC", "3-sec"}, {CAMERA_WIDGETS_TIMER_BUTTON_DELAY_5_SEC, "CAMERA_WIDGETS_TIMER_BUTTON_DELAY_5_SEC", "5-sec"}, {CAMERA_WIDGETS_TIMER_BUTTON_DELAY_10_SEC, "CAMERA_WIDGETS_TIMER_BUTTON_DELAY_10_SEC", "10-sec"}, {0, NULL, NULL}};
	GType camera_widgets_timer_button_delay_type_id;
	camera_widgets_timer_button_delay_type_id = g_enum_register_static ("CameraWidgetsTimerButtonDelay", values);
	return camera_widgets_timer_button_delay_type_id;
}

GType
camera_widgets_timer_button_delay_get_type (void)
{
	static volatile gsize camera_widgets_timer_button_delay_type_id__once = 0;
	if (g_once_init_enter (&camera_widgets_timer_button_delay_type_id__once)) {
		GType camera_widgets_timer_button_delay_type_id;
		camera_widgets_timer_button_delay_type_id = camera_widgets_timer_button_delay_get_type_once ();
		g_once_init_leave (&camera_widgets_timer_button_delay_type_id__once, camera_widgets_timer_button_delay_type_id);
	}
	return camera_widgets_timer_button_delay_type_id__once;
}

CameraWidgetsTimerButton*
camera_widgets_timer_button_construct (GType object_type)
{
	CameraWidgetsTimerButton * self = NULL;
	self = (CameraWidgetsTimerButton*) g_object_new (object_type, NULL);
	return self;
}

CameraWidgetsTimerButton*
camera_widgets_timer_button_new (void)
{
	return camera_widgets_timer_button_construct (CAMERA_WIDGETS_TYPE_TIMER_BUTTON);
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		CameraWidgetsTimerButton* self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->label_widget);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static void
_camera_widgets_timer_button___lambda10_ (Block7Data* _data7_)
{
	CameraWidgetsTimerButton* self;
	GSettings* _tmp0_;
	GtkLabel* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	self = _data7_->self;
	self->delay = camera_widgets_timer_button_delay_next (self->delay);
	_tmp0_ = camera_application_settings;
	g_settings_set_enum (_tmp0_, "delay", (gint) self->delay);
	_tmp1_ = _data7_->label_widget;
	_tmp2_ = camera_widgets_timer_button_delay_to_string (self->delay);
	_tmp3_ = _tmp2_;
	gtk_label_set_label (_tmp1_, _tmp3_);
	_g_free0 (_tmp3_);
}

static void
__camera_widgets_timer_button___lambda10__gtk_button_clicked (GtkButton* _sender,
                                                              gpointer self)
{
	_camera_widgets_timer_button___lambda10_ (self);
}

static GObject *
camera_widgets_timer_button_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CameraWidgetsTimerButton * self;
	Block7Data* _data7_;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GtkLabel* _tmp3_ = NULL;
	GtkLabel* _tmp4_;
	GtkBox* box = NULL;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkImage* _tmp7_;
	GtkImage* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkBox* _tmp11_;
	parent_class = G_OBJECT_CLASS (camera_widgets_timer_button_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAMERA_WIDGETS_TYPE_TIMER_BUTTON, CameraWidgetsTimerButton);
	_data7_ = g_slice_new0 (Block7Data);
	_data7_->_ref_count_ = 1;
	_data7_->self = g_object_ref (self);
	_tmp0_ = camera_application_settings;
	self->delay = (CameraWidgetsTimerButtonDelay) g_settings_get_enum (_tmp0_, "delay");
	_tmp1_ = camera_widgets_timer_button_delay_to_string (self->delay);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new (_tmp2_);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp3_, 3);
	g_object_ref_sink (_tmp3_);
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	_data7_->label_widget = _tmp4_;
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
	g_object_ref_sink (_tmp5_);
	box = _tmp5_;
	_tmp6_ = box;
	_tmp7_ = (GtkImage*) gtk_image_new_from_icon_name ("timer-symbolic");
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	gtk_box_append (_tmp6_, (GtkWidget*) _tmp8_);
	_g_object_unref0 (_tmp8_);
	_tmp9_ = box;
	_tmp10_ = _data7_->label_widget;
	gtk_box_append (_tmp9_, (GtkWidget*) _tmp10_);
	_tmp11_ = box;
	gtk_button_set_child ((GtkButton*) self, (GtkWidget*) _tmp11_);
	gtk_button_set_has_frame ((GtkButton*) self, FALSE);
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _ ("Delay before photo is taken"));
	g_signal_connect_data ((GtkButton*) self, "clicked", (GCallback) __camera_widgets_timer_button___lambda10__gtk_button_clicked, block7_data_ref (_data7_), (GClosureNotify) block7_data_unref, 0);
	_g_object_unref0 (box);
	block7_data_unref (_data7_);
	_data7_ = NULL;
	return obj;
}

static void
camera_widgets_timer_button_class_init (CameraWidgetsTimerButtonClass * klass,
                                        gpointer klass_data)
{
	camera_widgets_timer_button_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = camera_widgets_timer_button_constructor;
	G_OBJECT_CLASS (klass)->finalize = camera_widgets_timer_button_finalize;
}

static void
camera_widgets_timer_button_instance_init (CameraWidgetsTimerButton * self,
                                           gpointer klass)
{
}

static void
camera_widgets_timer_button_finalize (GObject * obj)
{
	CameraWidgetsTimerButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAMERA_WIDGETS_TYPE_TIMER_BUTTON, CameraWidgetsTimerButton);
	G_OBJECT_CLASS (camera_widgets_timer_button_parent_class)->finalize (obj);
}

static GType
camera_widgets_timer_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CameraWidgetsTimerButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) camera_widgets_timer_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CameraWidgetsTimerButton), 0, (GInstanceInitFunc) camera_widgets_timer_button_instance_init, NULL };
	GType camera_widgets_timer_button_type_id;
	camera_widgets_timer_button_type_id = g_type_register_static (gtk_button_get_type (), "CameraWidgetsTimerButton", &g_define_type_info, 0);
	return camera_widgets_timer_button_type_id;
}

GType
camera_widgets_timer_button_get_type (void)
{
	static volatile gsize camera_widgets_timer_button_type_id__once = 0;
	if (g_once_init_enter (&camera_widgets_timer_button_type_id__once)) {
		GType camera_widgets_timer_button_type_id;
		camera_widgets_timer_button_type_id = camera_widgets_timer_button_get_type_once ();
		g_once_init_leave (&camera_widgets_timer_button_type_id__once, camera_widgets_timer_button_type_id);
	}
	return camera_widgets_timer_button_type_id__once;
}

