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

/*-
 * Copyright (c) 2017-2018 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 <granite.h>
#include <glib-object.h>
#include <handy.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>

#define SCRATCH_MAIN_WINDOW_ACTION_NEW_TAB "action-new-tab"
#define SCRATCH_MAIN_WINDOW_ACTION_OPEN "action-open"
#define SCRATCH_MAIN_WINDOW_ACTION_OPEN_PROJECT "action-open-project"
#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 CODE_TYPE_WELCOME_VIEW (code_welcome_view_get_type ())
#define CODE_WELCOME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CODE_TYPE_WELCOME_VIEW, CodeWelcomeView))
#define CODE_WELCOME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CODE_TYPE_WELCOME_VIEW, CodeWelcomeViewClass))
#define CODE_IS_WELCOME_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CODE_TYPE_WELCOME_VIEW))
#define CODE_IS_WELCOME_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CODE_TYPE_WELCOME_VIEW))
#define CODE_WELCOME_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CODE_TYPE_WELCOME_VIEW, CodeWelcomeViewClass))

typedef struct _CodeWelcomeView CodeWelcomeView;
typedef struct _CodeWelcomeViewClass CodeWelcomeViewClass;
typedef struct _CodeWelcomeViewPrivate CodeWelcomeViewPrivate;

#define SCRATCH_TYPE_MAIN_WINDOW (scratch_main_window_get_type ())
#define SCRATCH_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindow))
#define SCRATCH_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindowClass))
#define SCRATCH_IS_MAIN_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SCRATCH_TYPE_MAIN_WINDOW))
#define SCRATCH_IS_MAIN_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SCRATCH_TYPE_MAIN_WINDOW))
#define SCRATCH_MAIN_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SCRATCH_TYPE_MAIN_WINDOW, ScratchMainWindowClass))

typedef struct _ScratchMainWindow ScratchMainWindow;
typedef struct _ScratchMainWindowClass ScratchMainWindowClass;
enum  {
	CODE_WELCOME_VIEW_0_PROPERTY,
	CODE_WELCOME_VIEW_WINDOW_PROPERTY,
	CODE_WELCOME_VIEW_NUM_PROPERTIES
};
static GParamSpec* code_welcome_view_properties[CODE_WELCOME_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _CodeWelcomeView {
	GraniteWidgetsWelcome parent_instance;
	CodeWelcomeViewPrivate * priv;
};

struct _CodeWelcomeViewClass {
	GraniteWidgetsWelcomeClass parent_class;
};

struct _CodeWelcomeViewPrivate {
	ScratchMainWindow* _window;
};

static gint CodeWelcomeView_private_offset;
static gpointer code_welcome_view_parent_class = NULL;

VALA_EXTERN GType code_welcome_view_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CodeWelcomeView, g_object_unref)
VALA_EXTERN GType scratch_main_window_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ScratchMainWindow, g_object_unref)
VALA_EXTERN CodeWelcomeView* code_welcome_view_new (ScratchMainWindow* window);
VALA_EXTERN CodeWelcomeView* code_welcome_view_construct (GType object_type,
                                              ScratchMainWindow* window);
VALA_EXTERN ScratchMainWindow* code_welcome_view_get_window (CodeWelcomeView* self);
static void code_welcome_view_set_window (CodeWelcomeView* self,
                                   ScratchMainWindow* value);
static GObject * code_welcome_view_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _code_welcome_view___lambda147_ (CodeWelcomeView* self,
                                      gint i);
VALA_EXTERN GSimpleAction* scratch_utils_action_from_group (const gchar* action_name,
                                                GSimpleActionGroup* action_group);
VALA_EXTERN GSimpleActionGroup* scratch_main_window_get_actions (ScratchMainWindow* self);
static void __code_welcome_view___lambda147__granite_widgets_welcome_activated (GraniteWidgetsWelcome* _sender,
                                                                         gint index,
                                                                         gpointer self);
static void code_welcome_view_finalize (GObject * obj);
static GType code_welcome_view_get_type_once (void);
static void _vala_code_welcome_view_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_code_welcome_view_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
code_welcome_view_get_instance_private (CodeWelcomeView* self)
{
	return G_STRUCT_MEMBER_P (self, CodeWelcomeView_private_offset);
}

CodeWelcomeView*
code_welcome_view_construct (GType object_type,
                             ScratchMainWindow* window)
{
	CodeWelcomeView * self = NULL;
	g_return_val_if_fail (window != NULL, NULL);
	self = (CodeWelcomeView*) g_object_new (object_type, "window", window, "title", _ ("No Files Open"), "subtitle", _ ("Open a file to begin editing."), NULL);
	return self;
}

CodeWelcomeView*
code_welcome_view_new (ScratchMainWindow* window)
{
	return code_welcome_view_construct (CODE_TYPE_WELCOME_VIEW, window);
}

ScratchMainWindow*
code_welcome_view_get_window (CodeWelcomeView* self)
{
	ScratchMainWindow* result;
	ScratchMainWindow* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_window;
	result = _tmp0_;
	return result;
}

static void
code_welcome_view_set_window (CodeWelcomeView* self,
                              ScratchMainWindow* value)
{
	ScratchMainWindow* old_value;
	g_return_if_fail (self != NULL);
	old_value = code_welcome_view_get_window (self);
	if (old_value != value) {
		self->priv->_window = value;
		g_object_notify_by_pspec ((GObject *) self, code_welcome_view_properties[CODE_WELCOME_VIEW_WINDOW_PROPERTY]);
	}
}

static void
_code_welcome_view___lambda147_ (CodeWelcomeView* self,
                                 gint i)
{
	if (i == 0) {
		ScratchMainWindow* _tmp0_;
		GSimpleActionGroup* _tmp1_;
		GSimpleActionGroup* _tmp2_;
		GSimpleAction* _tmp3_;
		GSimpleAction* _tmp4_;
		_tmp0_ = self->priv->_window;
		_tmp1_ = scratch_main_window_get_actions (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = scratch_utils_action_from_group (SCRATCH_MAIN_WINDOW_ACTION_NEW_TAB, _tmp2_);
		_tmp4_ = _tmp3_;
		g_signal_emit_by_name (_tmp4_, "activate", NULL);
		_g_object_unref0 (_tmp4_);
	} else {
		if (i == 1) {
			ScratchMainWindow* _tmp5_;
			GSimpleActionGroup* _tmp6_;
			GSimpleActionGroup* _tmp7_;
			GSimpleAction* _tmp8_;
			GSimpleAction* _tmp9_;
			_tmp5_ = self->priv->_window;
			_tmp6_ = scratch_main_window_get_actions (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = scratch_utils_action_from_group (SCRATCH_MAIN_WINDOW_ACTION_OPEN, _tmp7_);
			_tmp9_ = _tmp8_;
			g_signal_emit_by_name (_tmp9_, "activate", NULL);
			_g_object_unref0 (_tmp9_);
		} else {
			if (i == 2) {
				ScratchMainWindow* _tmp10_;
				GSimpleActionGroup* _tmp11_;
				GSimpleActionGroup* _tmp12_;
				GSimpleAction* _tmp13_;
				GSimpleAction* _tmp14_;
				_tmp10_ = self->priv->_window;
				_tmp11_ = scratch_main_window_get_actions (_tmp10_);
				_tmp12_ = _tmp11_;
				_tmp13_ = scratch_utils_action_from_group (SCRATCH_MAIN_WINDOW_ACTION_OPEN_PROJECT, _tmp12_);
				_tmp14_ = _tmp13_;
				g_signal_emit_by_name (_tmp14_, "activate", NULL);
				_g_object_unref0 (_tmp14_);
			}
		}
	}
}

static void
__code_welcome_view___lambda147__granite_widgets_welcome_activated (GraniteWidgetsWelcome* _sender,
                                                                    gint index,
                                                                    gpointer self)
{
	_code_welcome_view___lambda147_ ((CodeWelcomeView*) self, index);
}

static GObject *
code_welcome_view_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	CodeWelcomeView * self;
	parent_class = G_OBJECT_CLASS (code_welcome_view_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_WELCOME_VIEW, CodeWelcomeView);
	granite_widgets_welcome_append ((GraniteWidgetsWelcome*) self, "document-new", _ ("New File"), _ ("Create a new empty file."));
	granite_widgets_welcome_append ((GraniteWidgetsWelcome*) self, "document-open", _ ("Open File"), _ ("Open a saved file."));
	granite_widgets_welcome_append ((GraniteWidgetsWelcome*) self, "open-project", _ ("Open Folder"), _ ("Add a project folder to the sidebar."));
	g_signal_connect_object ((GraniteWidgetsWelcome*) self, "activated", (GCallback) __code_welcome_view___lambda147__granite_widgets_welcome_activated, self, 0);
	return obj;
}

static void
code_welcome_view_class_init (CodeWelcomeViewClass * klass,
                              gpointer klass_data)
{
	code_welcome_view_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &CodeWelcomeView_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_code_welcome_view_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_code_welcome_view_set_property;
	G_OBJECT_CLASS (klass)->constructor = code_welcome_view_constructor;
	G_OBJECT_CLASS (klass)->finalize = code_welcome_view_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CODE_WELCOME_VIEW_WINDOW_PROPERTY, code_welcome_view_properties[CODE_WELCOME_VIEW_WINDOW_PROPERTY] = g_param_spec_object ("window", "window", "window", SCRATCH_TYPE_MAIN_WINDOW, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
code_welcome_view_instance_init (CodeWelcomeView * self,
                                 gpointer klass)
{
	self->priv = code_welcome_view_get_instance_private (self);
}

static void
code_welcome_view_finalize (GObject * obj)
{
	CodeWelcomeView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CODE_TYPE_WELCOME_VIEW, CodeWelcomeView);
	G_OBJECT_CLASS (code_welcome_view_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
code_welcome_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (CodeWelcomeViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) code_welcome_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (CodeWelcomeView), 0, (GInstanceInitFunc) code_welcome_view_instance_init, NULL };
	GType code_welcome_view_type_id;
	code_welcome_view_type_id = g_type_register_static (GRANITE_WIDGETS_TYPE_WELCOME, "CodeWelcomeView", &g_define_type_info, G_TYPE_FLAG_NONE);
	CodeWelcomeView_private_offset = g_type_add_instance_private (code_welcome_view_type_id, sizeof (CodeWelcomeViewPrivate));
	return code_welcome_view_type_id;
}

GType
code_welcome_view_get_type (void)
{
	static gsize code_welcome_view_type_id__once = 0;
	if (g_once_init_enter (&code_welcome_view_type_id__once)) {
		GType code_welcome_view_type_id;
		code_welcome_view_type_id = code_welcome_view_get_type_once ();
		g_once_init_leave (&code_welcome_view_type_id__once, code_welcome_view_type_id);
	}
	return code_welcome_view_type_id__once;
}

static void
_vala_code_welcome_view_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	CodeWelcomeView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_WELCOME_VIEW, CodeWelcomeView);
	switch (property_id) {
		case CODE_WELCOME_VIEW_WINDOW_PROPERTY:
		g_value_set_object (value, code_welcome_view_get_window (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_code_welcome_view_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	CodeWelcomeView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CODE_TYPE_WELCOME_VIEW, CodeWelcomeView);
	switch (property_id) {
		case CODE_WELCOME_VIEW_WINDOW_PROPERTY:
		code_welcome_view_set_window (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

