/* WelcomeView.c generated by valac 0.56.19, the Vala compiler
 * generated from WelcomeView.vala, do not modify */

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2017 elementary LLC. (https://elementary.io)
 *
 * 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 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/>.
 *
 * Authored by: Corentin Noël <corentin@elementary.io>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <handy.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>
#include <granite.h>
#include <gdk/gdk.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 MAIL_TYPE_WELCOME_VIEW (mail_welcome_view_get_type ())
#define MAIL_WELCOME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MAIL_TYPE_WELCOME_VIEW, MailWelcomeView))
#define MAIL_WELCOME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MAIL_TYPE_WELCOME_VIEW, MailWelcomeViewClass))
#define MAIL_IS_WELCOME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MAIL_TYPE_WELCOME_VIEW))
#define MAIL_IS_WELCOME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MAIL_TYPE_WELCOME_VIEW))
#define MAIL_WELCOME_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MAIL_TYPE_WELCOME_VIEW, MailWelcomeViewClass))

typedef struct _MailWelcomeView MailWelcomeView;
typedef struct _MailWelcomeViewClass MailWelcomeViewClass;
typedef struct _MailWelcomeViewPrivate MailWelcomeViewPrivate;
enum  {
	MAIL_WELCOME_VIEW_0_PROPERTY,
	MAIL_WELCOME_VIEW_NUM_PROPERTIES
};
static GParamSpec* mail_welcome_view_properties[MAIL_WELCOME_VIEW_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _MailWelcomeView {
	GtkBox parent_instance;
	MailWelcomeViewPrivate * priv;
};

struct _MailWelcomeViewClass {
	GtkBoxClass parent_class;
};

static gpointer mail_welcome_view_parent_class = NULL;

VALA_EXTERN GType mail_welcome_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MailWelcomeView, g_object_unref)
VALA_EXTERN MailWelcomeView* mail_welcome_view_new (void);
VALA_EXTERN MailWelcomeView* mail_welcome_view_construct (GType object_type);
static GObject * mail_welcome_view_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _mail_welcome_view___lambda130_ (MailWelcomeView* self);
static void __mail_welcome_view___lambda130__gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static GType mail_welcome_view_get_type_once (void);

MailWelcomeView*
mail_welcome_view_construct (GType object_type)
{
	MailWelcomeView * self = NULL;
	self = (MailWelcomeView*) g_object_new (object_type, NULL);
	return self;
}

MailWelcomeView*
mail_welcome_view_new (void)
{
	return mail_welcome_view_construct (MAIL_TYPE_WELCOME_VIEW);
}

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

static void
_mail_welcome_view___lambda130_ (MailWelcomeView* self)
{
	GError* _inner_error0_ = NULL;
	{
		GtkWidget* _tmp0_;
		_tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
		gtk_show_uri_on_window (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_window_get_type (), GtkWindow), "settings://accounts/online", (guint32) GDK_CURRENT_TIME, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_critical ("WelcomeView.vala:89: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
__mail_welcome_view___lambda130__gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	_mail_welcome_view___lambda130_ ((MailWelcomeView*) self);
}

static GObject *
mail_welcome_view_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	MailWelcomeView * self;
	HdyHeaderBar* headerbar = NULL;
	HdyHeaderBar* _tmp0_ = NULL;
	HdyHeaderBar* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkImage* welcome_icon = NULL;
	gchar* _tmp3_;
	GtkImage* _tmp4_ = NULL;
	GtkAlign _tmp5_ = 0;
	GtkImage* welcome_badge = NULL;
	GtkImage* _tmp6_ = NULL;
	GtkOverlay* welcome_overlay = NULL;
	GtkImage* _tmp7_;
	GtkWidget* _tmp8_;
	GtkOverlay* _tmp9_ = NULL;
	GtkOverlay* _tmp10_;
	GtkImage* _tmp11_;
	GtkLabel* welcome_title = NULL;
	GtkLabel* _tmp12_ = NULL;
	GtkLabel* _tmp13_;
	GtkStyleContext* _tmp14_;
	GtkLabel* welcome_description = NULL;
	GtkLabel* _tmp15_ = NULL;
	GtkLabel* _tmp16_;
	GtkStyleContext* _tmp17_;
	GtkButton* welcome_button = NULL;
	GtkButton* _tmp18_ = NULL;
	GtkButton* _tmp19_;
	GtkStyleContext* _tmp20_;
	GtkAlign _tmp21_ = 0;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp22_ = NULL;
	GtkGrid* _tmp23_;
	GtkOverlay* _tmp24_;
	GtkGrid* _tmp25_;
	GtkLabel* _tmp26_;
	GtkGrid* _tmp27_;
	GtkLabel* _tmp28_;
	GtkGrid* _tmp29_;
	GtkButton* _tmp30_;
	GtkBox* main_box = NULL;
	GtkBox* _tmp31_;
	GtkBox* _tmp32_;
	HdyHeaderBar* _tmp33_;
	GtkBox* _tmp34_;
	GtkGrid* _tmp35_;
	HdyWindowHandle* window_handle = NULL;
	GtkBox* _tmp36_;
	GtkWidget* _tmp37_;
	HdyWindowHandle* _tmp38_ = NULL;
	HdyWindowHandle* _tmp39_;
	GtkButton* _tmp40_;
	parent_class = G_OBJECT_CLASS (mail_welcome_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MAIL_TYPE_WELCOME_VIEW, MailWelcomeView);
	_tmp0_ = (HdyHeaderBar*) hdy_header_bar_new ();
	hdy_header_bar_set_show_close_button (_tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	headerbar = _tmp0_;
	_tmp1_ = headerbar;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_add_class (_tmp2_, GTK_STYLE_CLASS_FLAT);
	_tmp3_ = g_strdup ("io.elementary.mail");
	_tmp4_ = (GtkImage*) gtk_image_new ();
	g_object_set (_tmp4_, "icon-name", _tmp3_, NULL);
	_g_free0 (_tmp3_);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp4_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp4_, 12);
	gtk_image_set_pixel_size (_tmp4_, 64);
	g_object_ref_sink (_tmp4_);
	welcome_icon = _tmp4_;
	_tmp5_ = GTK_ALIGN_END;
	_tmp6_ = (GtkImage*) gtk_image_new_from_icon_name ("preferences-desktop-online-accounts", (GtkIconSize) GTK_ICON_SIZE_DIALOG);
	gtk_widget_set_valign ((GtkWidget*) _tmp6_, _tmp5_);
	gtk_widget_set_halign ((GtkWidget*) _tmp6_, _tmp5_);
	g_object_ref_sink (_tmp6_);
	welcome_badge = _tmp6_;
	_tmp7_ = welcome_icon;
	_tmp8_ = _g_object_ref0 ((GtkWidget*) _tmp7_);
	_tmp9_ = (GtkOverlay*) gtk_overlay_new ();
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	g_object_set ((GtkContainer*) _tmp9_, "child", _tmp8_, NULL);
	_g_object_unref0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	welcome_overlay = _tmp9_;
	_tmp10_ = welcome_overlay;
	_tmp11_ = welcome_badge;
	gtk_overlay_add_overlay (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = (GtkLabel*) gtk_label_new (_ ("Connect an Account"));
	gtk_label_set_max_width_chars (_tmp12_, 70);
	g_object_set (_tmp12_, "wrap", TRUE, NULL);
	gtk_label_set_xalign (_tmp12_, (gfloat) 0);
	g_object_ref_sink (_tmp12_);
	welcome_title = _tmp12_;
	_tmp13_ = welcome_title;
	_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
	gtk_style_context_add_class (_tmp14_, GRANITE_STYLE_CLASS_H1_LABEL);
	_tmp15_ = (GtkLabel*) gtk_label_new (_ ("Mail uses email accounts configured in System Settings."));
	gtk_label_set_max_width_chars (_tmp15_, 70);
	g_object_set (_tmp15_, "wrap", TRUE, NULL);
	gtk_label_set_xalign (_tmp15_, (gfloat) 0);
	g_object_ref_sink (_tmp15_);
	welcome_description = _tmp15_;
	_tmp16_ = welcome_description;
	_tmp17_ = gtk_widget_get_style_context ((GtkWidget*) _tmp16_);
	gtk_style_context_add_class (_tmp17_, GRANITE_STYLE_CLASS_H3_LABEL);
	_tmp18_ = (GtkButton*) gtk_button_new_with_label (_ ("Online Accounts…"));
	gtk_widget_set_margin_top ((GtkWidget*) _tmp18_, 24);
	g_object_ref_sink (_tmp18_);
	welcome_button = _tmp18_;
	_tmp19_ = welcome_button;
	_tmp20_ = gtk_widget_get_style_context ((GtkWidget*) _tmp19_);
	gtk_style_context_add_class (_tmp20_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
	_tmp21_ = GTK_ALIGN_CENTER;
	_tmp22_ = (GtkGrid*) gtk_grid_new ();
	gtk_grid_set_column_spacing (_tmp22_, 12);
	gtk_widget_set_valign ((GtkWidget*) _tmp22_, _tmp21_);
	gtk_widget_set_halign ((GtkWidget*) _tmp22_, _tmp21_);
	g_object_set ((GtkWidget*) _tmp22_, "expand", TRUE, NULL);
	g_object_ref_sink (_tmp22_);
	grid = _tmp22_;
	_tmp23_ = grid;
	_tmp24_ = welcome_overlay;
	gtk_grid_attach (_tmp23_, (GtkWidget*) _tmp24_, 0, 0, 1, 2);
	_tmp25_ = grid;
	_tmp26_ = welcome_title;
	gtk_grid_attach (_tmp25_, (GtkWidget*) _tmp26_, 1, 0, 1, 1);
	_tmp27_ = grid;
	_tmp28_ = welcome_description;
	gtk_grid_attach (_tmp27_, (GtkWidget*) _tmp28_, 1, 1, 1, 1);
	_tmp29_ = grid;
	_tmp30_ = welcome_button;
	gtk_grid_attach (_tmp29_, (GtkWidget*) _tmp30_, 1, 2, 1, 1);
	_tmp31_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	g_object_ref_sink (_tmp31_);
	main_box = _tmp31_;
	_tmp32_ = main_box;
	_tmp33_ = headerbar;
	gtk_container_add ((GtkContainer*) _tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = main_box;
	_tmp35_ = grid;
	gtk_container_add ((GtkContainer*) _tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = main_box;
	_tmp37_ = _g_object_ref0 ((GtkWidget*) _tmp36_);
	_tmp38_ = (HdyWindowHandle*) hdy_window_handle_new ();
	g_object_set ((GtkContainer*) _tmp38_, "child", _tmp37_, NULL);
	_g_object_unref0 (_tmp37_);
	g_object_ref_sink (_tmp38_);
	window_handle = _tmp38_;
	_tmp39_ = window_handle;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp39_);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp40_ = welcome_button;
	g_signal_connect_object (_tmp40_, "clicked", (GCallback) __mail_welcome_view___lambda130__gtk_button_clicked, self, 0);
	_g_object_unref0 (window_handle);
	_g_object_unref0 (main_box);
	_g_object_unref0 (grid);
	_g_object_unref0 (welcome_button);
	_g_object_unref0 (welcome_description);
	_g_object_unref0 (welcome_title);
	_g_object_unref0 (welcome_overlay);
	_g_object_unref0 (welcome_badge);
	_g_object_unref0 (welcome_icon);
	_g_object_unref0 (headerbar);
	return obj;
}

static void
mail_welcome_view_class_init (MailWelcomeViewClass * klass,
                              gpointer klass_data)
{
	mail_welcome_view_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = mail_welcome_view_constructor;
}

static void
mail_welcome_view_instance_init (MailWelcomeView * self,
                                 gpointer klass)
{
}

static GType
mail_welcome_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (MailWelcomeViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) mail_welcome_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (MailWelcomeView), 0, (GInstanceInitFunc) mail_welcome_view_instance_init, NULL };
	GType mail_welcome_view_type_id;
	mail_welcome_view_type_id = g_type_register_static (gtk_box_get_type (), "MailWelcomeView", &g_define_type_info, 0);
	return mail_welcome_view_type_id;
}

GType
mail_welcome_view_get_type (void)
{
	static volatile gsize mail_welcome_view_type_id__once = 0;
	if (g_once_init_enter (&mail_welcome_view_type_id__once)) {
		GType mail_welcome_view_type_id;
		mail_welcome_view_type_id = mail_welcome_view_get_type_once ();
		g_once_init_leave (&mail_welcome_view_type_id__once, mail_welcome_view_type_id);
	}
	return mail_welcome_view_type_id__once;
}

