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

/*
 * Copyright 2011-2023 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Authored by: Marcus Wichelmann <marcus.wichelmann@hotmail.de>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <granite-7.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <glib/gi18n-lib.h>
#include <gst/gst.h>

#define GETTEXT_PACKAGE "io.elementary.camera"
#define LOCALEDIR "/usr/share/locale"
#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_TYPE_APPLICATION (camera_application_get_type ())
#define CAMERA_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAMERA_TYPE_APPLICATION, CameraApplication))
#define CAMERA_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAMERA_TYPE_APPLICATION, CameraApplicationClass))
#define CAMERA_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAMERA_TYPE_APPLICATION))
#define CAMERA_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAMERA_TYPE_APPLICATION))
#define CAMERA_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAMERA_TYPE_APPLICATION, CameraApplicationClass))

typedef struct _CameraApplication CameraApplication;
typedef struct _CameraApplicationClass CameraApplicationClass;
typedef struct _CameraApplicationPrivate CameraApplicationPrivate;
enum  {
	CAMERA_APPLICATION_0_PROPERTY,
	CAMERA_APPLICATION_NUM_PROPERTIES
};
static GParamSpec* camera_application_properties[CAMERA_APPLICATION_NUM_PROPERTIES];
typedef struct _Block1Data Block1Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define CAMERA_TYPE_MAIN_WINDOW (camera_main_window_get_type ())
#define CAMERA_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAMERA_TYPE_MAIN_WINDOW, CameraMainWindow))
#define CAMERA_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAMERA_TYPE_MAIN_WINDOW, CameraMainWindowClass))
#define CAMERA_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAMERA_TYPE_MAIN_WINDOW))
#define CAMERA_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CAMERA_TYPE_MAIN_WINDOW))
#define CAMERA_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CAMERA_TYPE_MAIN_WINDOW, CameraMainWindowClass))

typedef struct _CameraMainWindow CameraMainWindow;
typedef struct _CameraMainWindowClass CameraMainWindowClass;

struct _CameraApplication {
	GtkApplication parent_instance;
	CameraApplicationPrivate * priv;
};

struct _CameraApplicationClass {
	GtkApplicationClass parent_class;
};

struct _Block1Data {
	int _ref_count_;
	CameraApplication* self;
	GraniteSettings* granite_settings;
	GtkSettings* gtk_settings;
};

static gpointer camera_application_parent_class = NULL;
VALA_EXTERN GSettings* camera_application_settings;
GSettings* camera_application_settings = NULL;

VALA_EXTERN GType camera_application_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CameraApplication, g_object_unref)
VALA_EXTERN CameraApplication* camera_application_new (void);
VALA_EXTERN CameraApplication* camera_application_construct (GType object_type);
static void camera_application_real_startup (GApplication* base);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void _g_application_quit_g_simple_action_activate (GSimpleAction* _sender,
                                                   GVariant* parameter,
                                                   gpointer self);
static void __lambda4_ (Block1Data* _data1_);
static void ___lambda4__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void camera_application_real_activate (GApplication* base);
VALA_EXTERN GType camera_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CameraMainWindow, g_object_unref)
VALA_EXTERN CameraMainWindow* camera_main_window_new (CameraApplication* application);
VALA_EXTERN CameraMainWindow* camera_main_window_construct (GType object_type,
                                                CameraApplication* application);
static gint camera_application_main (gchar** args,
                              gint args_length1);
static GObject * camera_application_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static void camera_application_finalize (GObject * obj);
static GType camera_application_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

CameraApplication*
camera_application_construct (GType object_type)
{
	CameraApplication * self = NULL;
	self = (CameraApplication*) g_object_new (object_type, "application-id", "io.elementary.camera", "flags", G_APPLICATION_FLAGS_NONE, NULL);
	return self;
}

CameraApplication*
camera_application_new (void)
{
	return camera_application_construct (CAMERA_TYPE_APPLICATION);
}

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_)) {
		CameraApplication* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->gtk_settings);
		_g_object_unref0 (_data1_->granite_settings);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
_g_application_quit_g_simple_action_activate (GSimpleAction* _sender,
                                              GVariant* parameter,
                                              gpointer self)
{
	g_application_quit ((GApplication*) self);
}

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

static void
__lambda4_ (Block1Data* _data1_)
{
	CameraApplication* self;
	GraniteSettingsColorScheme _tmp0_;
	GraniteSettingsColorScheme _tmp1_;
	self = _data1_->self;
	_tmp0_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp1_ = _tmp0_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp1_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
}

static void
___lambda4__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda4_ (self);
}

static void
camera_application_real_startup (GApplication* base)
{
	CameraApplication * self;
	Block1Data* _data1_;
	GSimpleAction* quit_action = NULL;
	GSimpleAction* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	GraniteSettings* _tmp4_;
	GraniteSettings* _tmp5_;
	GtkSettings* _tmp6_;
	GtkSettings* _tmp7_;
	GraniteSettingsColorScheme _tmp8_;
	GraniteSettingsColorScheme _tmp9_;
	self = (CameraApplication*) base;
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_data1_->self = g_object_ref (self);
	G_APPLICATION_CLASS (camera_application_parent_class)->startup ((GApplication*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_application_get_type (), GtkApplication));
	granite_init ();
	_tmp0_ = g_simple_action_new ("quit", NULL);
	quit_action = _tmp0_;
	g_signal_connect_object (quit_action, "activate", (GCallback) _g_application_quit_g_simple_action_activate, (GApplication*) self, 0);
	g_action_map_add_action ((GActionMap*) self, (GAction*) quit_action);
	_tmp1_ = g_strdup ("<Control>q");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	gtk_application_set_accels_for_action ((GtkApplication*) self, "app.quit", _tmp3_);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp4_ = granite_settings_get_default ();
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_data1_->granite_settings = _tmp5_;
	_tmp6_ = gtk_settings_get_default ();
	_tmp7_ = _g_object_ref0 (_tmp6_);
	_data1_->gtk_settings = _tmp7_;
	_tmp8_ = granite_settings_get_prefers_color_scheme (_data1_->granite_settings);
	_tmp9_ = _tmp8_;
	g_object_set (_data1_->gtk_settings, "gtk-application-prefer-dark-theme", _tmp9_ == GRANITE_SETTINGS_COLOR_SCHEME_DARK, NULL);
	g_signal_connect_data ((GObject*) _data1_->granite_settings, "notify::prefers-color-scheme", (GCallback) ___lambda4__g_object_notify, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	_g_object_unref0 (quit_action);
	block1_data_unref (_data1_);
	_data1_ = NULL;
}

static void
camera_application_real_activate (GApplication* base)
{
	CameraApplication * self;
	GtkWindow* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp11_;
	GtkWindow* _tmp12_;
	self = (CameraApplication*) base;
	_tmp0_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == NULL) {
		CameraMainWindow* main_window = NULL;
		CameraMainWindow* _tmp2_;
		GSettings* _tmp3_;
		CameraMainWindow* _tmp4_;
		GSettings* _tmp5_;
		CameraMainWindow* _tmp6_;
		GSettings* _tmp7_;
		GSettings* _tmp9_;
		CameraMainWindow* _tmp10_;
		_tmp2_ = camera_main_window_new (self);
		g_object_ref_sink (_tmp2_);
		main_window = _tmp2_;
		_tmp3_ = camera_application_settings;
		_tmp4_ = main_window;
		g_settings_bind (_tmp3_, "window-height", (GObject*) _tmp4_, "default-height", G_SETTINGS_BIND_DEFAULT);
		_tmp5_ = camera_application_settings;
		_tmp6_ = main_window;
		g_settings_bind (_tmp5_, "window-width", (GObject*) _tmp6_, "default-width", G_SETTINGS_BIND_DEFAULT);
		_tmp7_ = camera_application_settings;
		if (g_settings_get_boolean (_tmp7_, "window-maximized")) {
			CameraMainWindow* _tmp8_;
			_tmp8_ = main_window;
			gtk_window_maximize ((GtkWindow*) _tmp8_);
		}
		_tmp9_ = camera_application_settings;
		_tmp10_ = main_window;
		g_settings_bind (_tmp9_, "window-maximized", (GObject*) _tmp10_, "maximized", G_SETTINGS_BIND_SET);
		_g_object_unref0 (main_window);
	}
	_tmp11_ = gtk_application_get_active_window ((GtkApplication*) self);
	_tmp12_ = _tmp11_;
	gtk_window_present (_tmp12_);
}

static gint
camera_application_main (gchar** args,
                         gint args_length1)
{
	CameraApplication* _tmp0_;
	CameraApplication* _tmp1_;
	gint _tmp2_;
	gint result;
	_tmp0_ = camera_application_new ();
	_tmp1_ = _tmp0_;
	_tmp2_ = g_application_run ((GApplication*) _tmp1_, (gint) args_length1, args);
	_g_object_unref0 (_tmp1_);
	result = _tmp2_;
	return result;
}

int
main (int argc,
      char ** argv)
{
	return camera_application_main (argv, argc);
}

static GObject *
camera_application_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CameraApplication * self;
	GSettings* _tmp0_;
	GOptionGroup* _tmp1_;
	parent_class = G_OBJECT_CLASS (camera_application_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAMERA_TYPE_APPLICATION, CameraApplication);
	_tmp0_ = g_settings_new ("io.elementary.camera.settings");
	_g_object_unref0 (camera_application_settings);
	camera_application_settings = _tmp0_;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	_tmp1_ = gst_init_get_option_group ();
	g_application_add_option_group ((GApplication*) self, _tmp1_);
	return obj;
}

static void
camera_application_class_init (CameraApplicationClass * klass,
                               gpointer klass_data)
{
	camera_application_parent_class = g_type_class_peek_parent (klass);
	((GApplicationClass *) klass)->startup = (void (*) (GApplication*)) camera_application_real_startup;
	((GApplicationClass *) klass)->activate = (void (*) (GApplication*)) camera_application_real_activate;
	G_OBJECT_CLASS (klass)->constructor = camera_application_constructor;
	G_OBJECT_CLASS (klass)->finalize = camera_application_finalize;
}

static void
camera_application_instance_init (CameraApplication * self,
                                  gpointer klass)
{
}

static void
camera_application_finalize (GObject * obj)
{
	CameraApplication * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CAMERA_TYPE_APPLICATION, CameraApplication);
	G_OBJECT_CLASS (camera_application_parent_class)->finalize (obj);
}

static GType
camera_application_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CameraApplicationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) camera_application_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CameraApplication), 0, (GInstanceInitFunc) camera_application_instance_init, NULL };
	GType camera_application_type_id;
	camera_application_type_id = g_type_register_static (gtk_application_get_type (), "CameraApplication", &g_define_type_info, 0);
	return camera_application_type_id;
}

GType
camera_application_get_type (void)
{
	static volatile gsize camera_application_type_id__once = 0;
	if (g_once_init_enter (&camera_application_type_id__once)) {
		GType camera_application_type_id;
		camera_application_type_id = camera_application_get_type_once ();
		g_once_init_leave (&camera_application_type_id__once, camera_application_type_id);
	}
	return camera_application_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

