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

/* Copyright 2015 Switchboard Locale Plug Developers
*
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 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, see http://www.gnu.org/licenses/.
*/

#include "io.elementary.settings.locale.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <locale.h>
#include "monetary.h"
#include <float.h>
#include <math.h>
#include <granite-7.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_WIDGETS_PREVIEW_0_PROPERTY,
	SWITCHBOARD_PLUG_LOCALE_WIDGETS_PREVIEW_NUM_PROPERTIES
};
static GParamSpec* switchboard_plug_locale_widgets_preview_properties[SWITCHBOARD_PLUG_LOCALE_WIDGETS_PREVIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _SwitchboardPlugLocaleWidgetsPreviewPrivate {
	GtkLabel* date_time_label;
	GtkLabel* date_label;
	GtkLabel* time_label;
	GtkLabel* currency_label;
	GtkLabel* number_label;
};

static gint SwitchboardPlugLocaleWidgetsPreview_private_offset;
static gpointer switchboard_plug_locale_widgets_preview_parent_class = NULL;

static GObject * switchboard_plug_locale_widgets_preview_constructor (GType type,
                                                               guint n_construct_properties,
                                                               GObjectConstructParam * construct_properties);
static void switchboard_plug_locale_widgets_preview_finalize (GObject * obj);
static GType switchboard_plug_locale_widgets_preview_get_type_once (void);

static inline gpointer
switchboard_plug_locale_widgets_preview_get_instance_private (SwitchboardPlugLocaleWidgetsPreview* self)
{
	return G_STRUCT_MEMBER_P (self, SwitchboardPlugLocaleWidgetsPreview_private_offset);
}

SwitchboardPlugLocaleWidgetsPreview*
switchboard_plug_locale_widgets_preview_construct (GType object_type)
{
	SwitchboardPlugLocaleWidgetsPreview * self = NULL;
	self = (SwitchboardPlugLocaleWidgetsPreview*) g_object_new (object_type, "row-spacing", 6, NULL);
	return self;
}

SwitchboardPlugLocaleWidgetsPreview*
switchboard_plug_locale_widgets_preview_new (void)
{
	return switchboard_plug_locale_widgets_preview_construct (SWITCHBOARD_PLUG_LOCALE_WIDGETS_TYPE_PREVIEW);
}

void
switchboard_plug_locale_widgets_preview_reload_languages (SwitchboardPlugLocaleWidgetsPreview* self,
                                                          const gchar* format)
{
	GDateTime* date = NULL;
	GDateTime* _tmp0_;
	GtkLabel* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar currency[20] = {0};
	GtkLabel* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkLabel* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkLabel* _tmp12_;
	GtkLabel* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (format != NULL);
	setlocale (LC_ALL, format);
	_tmp0_ = g_date_time_new_now_local ();
	date = _tmp0_;
	_tmp1_ = self->priv->date_time_label;
	_tmp2_ = g_date_time_format (date, "%c");
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strdup_printf ("%s", _tmp3_);
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp1_, _tmp5_);
	_g_free0 (_tmp5_);
	_g_free0 (_tmp3_);
	strfmon (currency, (gint) 20, "%5.2n", 1234.56);
	_tmp6_ = self->priv->date_label;
	_tmp7_ = g_date_time_format (date, "%x");
	_tmp8_ = _tmp7_;
	gtk_label_set_label (_tmp6_, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = self->priv->time_label;
	_tmp10_ = g_date_time_format (date, "%X");
	_tmp11_ = _tmp10_;
	gtk_label_set_label (_tmp9_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = self->priv->currency_label;
	gtk_label_set_label (_tmp12_, (const gchar*) currency);
	_tmp13_ = self->priv->number_label;
	_tmp14_ = g_strdup_printf ("%'.2f", 1234.56);
	_tmp15_ = _tmp14_;
	gtk_label_set_label (_tmp13_, _tmp15_);
	_g_free0 (_tmp15_);
	_g_date_time_unref0 (date);
}

static GObject *
switchboard_plug_locale_widgets_preview_constructor (GType type,
                                                     guint n_construct_properties,
                                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	SwitchboardPlugLocaleWidgetsPreview * self;
	GtkLabel* _tmp0_ = NULL;
	GtkLabel* _tmp1_;
	GtkLabel* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkBox* box = NULL;
	GtkBox* _tmp12_ = NULL;
	GtkBox* _tmp13_;
	GtkLabel* _tmp14_;
	GtkBox* _tmp15_;
	GtkLabel* _tmp16_;
	GtkBox* _tmp17_;
	GtkLabel* _tmp18_;
	GtkBox* _tmp19_;
	GtkLabel* _tmp20_;
	GtkLabel* _tmp21_;
	GtkBox* _tmp22_;
	parent_class = G_OBJECT_CLASS (switchboard_plug_locale_widgets_preview_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_LOCALE_WIDGETS_TYPE_PREVIEW, SwitchboardPlugLocaleWidgetsPreview);
	_tmp0_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_margin_top ((GtkWidget*) _tmp0_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp0_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp0_, 12);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->date_time_label);
	self->priv->date_time_label = _tmp0_;
	_tmp1_ = self->priv->date_time_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp1_, TRUE);
	_tmp2_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->date_label);
	self->priv->date_label = _tmp2_;
	_tmp3_ = self->priv->date_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp3_, TRUE);
	_tmp4_ = self->priv->date_label;
	gtk_label_set_xalign (_tmp4_, (gfloat) 0);
	_tmp5_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->time_label);
	self->priv->time_label = _tmp5_;
	_tmp6_ = self->priv->time_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp6_, TRUE);
	_tmp7_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->priv->currency_label);
	self->priv->currency_label = _tmp7_;
	_tmp8_ = self->priv->currency_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp8_, TRUE);
	_tmp9_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->number_label);
	self->priv->number_label = _tmp9_;
	_tmp10_ = self->priv->number_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp10_, TRUE);
	_tmp11_ = self->priv->number_label;
	gtk_label_set_xalign (_tmp11_, (gfloat) 1);
	_tmp12_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp12_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp12_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp12_, 12);
	g_object_ref_sink (_tmp12_);
	box = _tmp12_;
	_tmp13_ = box;
	_tmp14_ = self->priv->date_label;
	gtk_box_append (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = box;
	_tmp16_ = self->priv->time_label;
	gtk_box_append (_tmp15_, (GtkWidget*) _tmp16_);
	_tmp17_ = box;
	_tmp18_ = self->priv->currency_label;
	gtk_box_append (_tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = box;
	_tmp20_ = self->priv->number_label;
	gtk_box_append (_tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = self->priv->date_time_label;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp21_, 0, 0, 1, 1);
	_tmp22_ = box;
	gtk_grid_attach ((GtkGrid*) self, (GtkWidget*) _tmp22_, 0, 1, 1, 1);
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_STYLE_CLASS_CARD);
	gtk_widget_add_css_class ((GtkWidget*) self, GRANITE_STYLE_CLASS_ROUNDED);
	_g_object_unref0 (box);
	return obj;
}

static void
switchboard_plug_locale_widgets_preview_class_init (SwitchboardPlugLocaleWidgetsPreviewClass * klass,
                                                    gpointer klass_data)
{
	switchboard_plug_locale_widgets_preview_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SwitchboardPlugLocaleWidgetsPreview_private_offset);
	G_OBJECT_CLASS (klass)->constructor = switchboard_plug_locale_widgets_preview_constructor;
	G_OBJECT_CLASS (klass)->finalize = switchboard_plug_locale_widgets_preview_finalize;
}

static void
switchboard_plug_locale_widgets_preview_instance_init (SwitchboardPlugLocaleWidgetsPreview * self,
                                                       gpointer klass)
{
	self->priv = switchboard_plug_locale_widgets_preview_get_instance_private (self);
}

static void
switchboard_plug_locale_widgets_preview_finalize (GObject * obj)
{
	SwitchboardPlugLocaleWidgetsPreview * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWITCHBOARD_PLUG_LOCALE_WIDGETS_TYPE_PREVIEW, SwitchboardPlugLocaleWidgetsPreview);
	_g_object_unref0 (self->priv->date_time_label);
	_g_object_unref0 (self->priv->date_label);
	_g_object_unref0 (self->priv->time_label);
	_g_object_unref0 (self->priv->currency_label);
	_g_object_unref0 (self->priv->number_label);
	G_OBJECT_CLASS (switchboard_plug_locale_widgets_preview_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
switchboard_plug_locale_widgets_preview_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SwitchboardPlugLocaleWidgetsPreviewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) switchboard_plug_locale_widgets_preview_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwitchboardPlugLocaleWidgetsPreview), 0, (GInstanceInitFunc) switchboard_plug_locale_widgets_preview_instance_init, NULL };
	GType switchboard_plug_locale_widgets_preview_type_id;
	switchboard_plug_locale_widgets_preview_type_id = g_type_register_static (gtk_grid_get_type (), "SwitchboardPlugLocaleWidgetsPreview", &g_define_type_info, 0);
	SwitchboardPlugLocaleWidgetsPreview_private_offset = g_type_add_instance_private (switchboard_plug_locale_widgets_preview_type_id, sizeof (SwitchboardPlugLocaleWidgetsPreviewPrivate));
	return switchboard_plug_locale_widgets_preview_type_id;
}

GType
switchboard_plug_locale_widgets_preview_get_type (void)
{
	static gsize switchboard_plug_locale_widgets_preview_type_id__once = 0;
	if (g_once_init_enter (&switchboard_plug_locale_widgets_preview_type_id__once)) {
		GType switchboard_plug_locale_widgets_preview_type_id;
		switchboard_plug_locale_widgets_preview_type_id = switchboard_plug_locale_widgets_preview_get_type_once ();
		g_once_init_leave (&switchboard_plug_locale_widgets_preview_type_id__once, switchboard_plug_locale_widgets_preview_type_id);
	}
	return switchboard_plug_locale_widgets_preview_type_id__once;
}

