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

/* WelcomePanel.vala
 *
 * Copyright 2020-2021 Dylan McCall <dylan@dylanmccall.ca>
 *
 * 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/>.
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include "settings.h"
#include <adwaita.h>
#include <glib.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

#define BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL (break_timer_settings_panels_welcome_panel_get_type ())
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanel))
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanelClass))
#define BREAK_TIMER_SETTINGS_PANELS_IS_WELCOME_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_IS_WELCOME_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL))
#define BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanelClass))

typedef struct _BreakTimerSettingsPanelsWelcomePanel BreakTimerSettingsPanelsWelcomePanel;
typedef struct _BreakTimerSettingsPanelsWelcomePanelClass BreakTimerSettingsPanelsWelcomePanelClass;
typedef struct _BreakTimerSettingsPanelsWelcomePanelPrivate BreakTimerSettingsPanelsWelcomePanelPrivate;
enum  {
	BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_0_PROPERTY,
	BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_NUM_PROPERTIES
};
static GParamSpec* break_timer_settings_panels_welcome_panel_properties[BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_TOUR_FINISHED_SIGNAL,
	BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_NUM_SIGNALS
};
static guint break_timer_settings_panels_welcome_panel_signals[BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_NUM_SIGNALS] = {0};

struct _BreakTimerSettingsPanelsWelcomePanel {
	GtkBox parent_instance;
	BreakTimerSettingsPanelsWelcomePanelPrivate * priv;
};

struct _BreakTimerSettingsPanelsWelcomePanelClass {
	GtkBoxClass parent_class;
};

struct _BreakTimerSettingsPanelsWelcomePanelPrivate {
	BreakTimerSettingsBreakManager* break_manager;
	BreakTimerSettingsMainWindow* main_window;
	AdwNavigationView* navigation_view;
	AdwNavigationPage* start_page;
	AdwNavigationPage* breaks_page;
	AdwNavigationPage* ready_page;
};

static gint BreakTimerSettingsPanelsWelcomePanel_private_offset;
static gpointer break_timer_settings_panels_welcome_panel_parent_class = NULL;

VALA_EXTERN GType break_timer_settings_panels_welcome_panel_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BreakTimerSettingsPanelsWelcomePanel* break_timer_settings_panels_welcome_panel_new (BreakTimerSettingsBreakManager* break_manager,
                                                                                     GtkBuilder* builder,
                                                                                     BreakTimerSettingsMainWindow* main_window);
VALA_EXTERN BreakTimerSettingsPanelsWelcomePanel* break_timer_settings_panels_welcome_panel_construct (GType object_type,
                                                                                           BreakTimerSettingsBreakManager* break_manager,
                                                                                           GtkBuilder* builder,
                                                                                           BreakTimerSettingsMainWindow* main_window);
static void __lambda4_ (BreakTimerSettingsPanelsWelcomePanel* self);
static void ___lambda4__gtk_button_clicked (GtkButton* _sender,
                                     gpointer self);
static void __lambda5_ (BreakTimerSettingsPanelsWelcomePanel* self);
static void ___lambda5__gtk_button_clicked (GtkButton* _sender,
                                     gpointer self);
static void break_timer_settings_panels_welcome_panel_build_overlay_arrow (BreakTimerSettingsPanelsWelcomePanel* self,
                                                                    GtkOverlay* overlay,
                                                                    GtkWidget* arrow_source,
                                                                    GtkWidget* arrow_target);
static void break_timer_settings_panels_welcome_panel_on_master_switch_toggled (BreakTimerSettingsPanelsWelcomePanel* self);
static void _break_timer_settings_panels_welcome_panel_on_master_switch_toggled_g_object_notify (GObject* _sender,
                                                                                          GParamSpec* pspec,
                                                                                          gpointer self);
VALA_EXTERN gboolean break_timer_settings_panels_welcome_panel_is_active (BreakTimerSettingsPanelsWelcomePanel* self);
VALA_EXTERN void break_timer_settings_panels_welcome_panel_settings_button_clicked (BreakTimerSettingsPanelsWelcomePanel* self);
static void break_timer_settings_panels_welcome_panel_finalize (GObject * obj);
static GType break_timer_settings_panels_welcome_panel_get_type_once (void);

static inline gpointer
break_timer_settings_panels_welcome_panel_get_instance_private (BreakTimerSettingsPanelsWelcomePanel* self)
{
	return G_STRUCT_MEMBER_P (self, BreakTimerSettingsPanelsWelcomePanel_private_offset);
}

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

static void
__lambda4_ (BreakTimerSettingsPanelsWelcomePanel* self)
{
	AdwNavigationView* _tmp0_;
	AdwNavigationPage* _tmp1_;
	_tmp0_ = self->priv->navigation_view;
	_tmp1_ = self->priv->ready_page;
	adw_navigation_view_push (_tmp0_, _tmp1_);
}

static void
___lambda4__gtk_button_clicked (GtkButton* _sender,
                                gpointer self)
{
	__lambda4_ ((BreakTimerSettingsPanelsWelcomePanel*) self);
}

static void
__lambda5_ (BreakTimerSettingsPanelsWelcomePanel* self)
{
	g_signal_emit (self, break_timer_settings_panels_welcome_panel_signals[BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_TOUR_FINISHED_SIGNAL], 0);
}

static void
___lambda5__gtk_button_clicked (GtkButton* _sender,
                                gpointer self)
{
	__lambda5_ ((BreakTimerSettingsPanelsWelcomePanel*) self);
}

static void
_break_timer_settings_panels_welcome_panel_on_master_switch_toggled_g_object_notify (GObject* _sender,
                                                                                     GParamSpec* pspec,
                                                                                     gpointer self)
{
	break_timer_settings_panels_welcome_panel_on_master_switch_toggled ((BreakTimerSettingsPanelsWelcomePanel*) self);
}

BreakTimerSettingsPanelsWelcomePanel*
break_timer_settings_panels_welcome_panel_construct (GType object_type,
                                                     BreakTimerSettingsBreakManager* break_manager,
                                                     GtkBuilder* builder,
                                                     BreakTimerSettingsMainWindow* main_window)
{
	BreakTimerSettingsPanelsWelcomePanel * self = NULL;
	BreakTimerSettingsBreakManager* _tmp0_;
	BreakTimerSettingsMainWindow* _tmp1_;
	GObject* _tmp2_;
	AdwNavigationView* _tmp3_;
	GObject* _tmp4_;
	AdwNavigationPage* _tmp5_;
	GObject* _tmp6_;
	AdwNavigationPage* _tmp7_;
	GObject* _tmp8_;
	AdwNavigationPage* _tmp9_;
	GtkOverlay* start_overlay = NULL;
	GObject* _tmp10_;
	GtkOverlay* _tmp11_;
	GtkOverlay* breaks_overlay = NULL;
	GObject* _tmp12_;
	GtkOverlay* _tmp13_;
	GtkButton* breaks_ok_button = NULL;
	GObject* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* ready_ok_button = NULL;
	GObject* _tmp16_;
	GtkButton* _tmp17_;
	GObject* _tmp18_;
	GtkWidget* _tmp19_;
	GtkWidget* _tmp20_;
	GObject* _tmp21_;
	GtkWidget* _tmp22_;
	GtkWidget* _tmp23_;
	AdwNavigationView* _tmp24_;
	g_return_val_if_fail (break_manager != NULL, NULL);
	g_return_val_if_fail (builder != NULL, NULL);
	g_return_val_if_fail (main_window != NULL, NULL);
	self = (BreakTimerSettingsPanelsWelcomePanel*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	_tmp0_ = _g_object_ref0 (break_manager);
	_g_object_unref0 (self->priv->break_manager);
	self->priv->break_manager = _tmp0_;
	_tmp1_ = _g_object_ref0 (main_window);
	_g_object_unref0 (self->priv->main_window);
	self->priv->main_window = _tmp1_;
	_tmp2_ = gtk_builder_get_object (builder, "welcome_stack");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, adw_navigation_view_get_type (), AdwNavigationView));
	_g_object_unref0 (self->priv->navigation_view);
	self->priv->navigation_view = _tmp3_;
	_tmp4_ = gtk_builder_get_object (builder, "welcome_start_page");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, adw_navigation_page_get_type (), AdwNavigationPage));
	_g_object_unref0 (self->priv->start_page);
	self->priv->start_page = _tmp5_;
	_tmp6_ = gtk_builder_get_object (builder, "welcome_breaks_page");
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, adw_navigation_page_get_type (), AdwNavigationPage));
	_g_object_unref0 (self->priv->breaks_page);
	self->priv->breaks_page = _tmp7_;
	_tmp8_ = gtk_builder_get_object (builder, "welcome_ready_page");
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, adw_navigation_page_get_type (), AdwNavigationPage));
	_g_object_unref0 (self->priv->ready_page);
	self->priv->ready_page = _tmp9_;
	_tmp10_ = gtk_builder_get_object (builder, "welcome_start_overlay");
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_overlay_get_type (), GtkOverlay));
	start_overlay = _tmp11_;
	_tmp12_ = gtk_builder_get_object (builder, "welcome_breaks_overlay");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_overlay_get_type (), GtkOverlay));
	breaks_overlay = _tmp13_;
	_tmp14_ = gtk_builder_get_object (builder, "welcome_breaks_ok_button");
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_button_get_type (), GtkButton));
	breaks_ok_button = _tmp15_;
	_tmp16_ = gtk_builder_get_object (builder, "welcome_ready_ok_button");
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, gtk_button_get_type (), GtkButton));
	ready_ok_button = _tmp17_;
	g_signal_connect_object (breaks_ok_button, "clicked", (GCallback) ___lambda4__gtk_button_clicked, self, 0);
	g_signal_connect_object (ready_ok_button, "clicked", (GCallback) ___lambda5__gtk_button_clicked, self, 0);
	_tmp18_ = gtk_builder_get_object (builder, "welcome_switch_label");
	_tmp19_ = break_timer_settings_main_window_get_master_switch (main_window);
	_tmp20_ = _tmp19_;
	break_timer_settings_panels_welcome_panel_build_overlay_arrow (self, start_overlay, G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_widget_get_type (), GtkWidget), _tmp20_);
	_g_object_unref0 (_tmp20_);
	_tmp21_ = gtk_builder_get_object (builder, "welcome_settings_label");
	_tmp22_ = break_timer_settings_main_window_get_settings_button (main_window);
	_tmp23_ = _tmp22_;
	break_timer_settings_panels_welcome_panel_build_overlay_arrow (self, breaks_overlay, G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_widget_get_type (), GtkWidget), _tmp23_);
	_g_object_unref0 (_tmp23_);
	_tmp24_ = self->priv->navigation_view;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp24_);
	g_signal_connect_object ((GObject*) break_manager, "notify::master-enabled", (GCallback) _break_timer_settings_panels_welcome_panel_on_master_switch_toggled_g_object_notify, self, 0);
	_g_object_unref0 (ready_ok_button);
	_g_object_unref0 (breaks_ok_button);
	_g_object_unref0 (breaks_overlay);
	_g_object_unref0 (start_overlay);
	return self;
}

BreakTimerSettingsPanelsWelcomePanel*
break_timer_settings_panels_welcome_panel_new (BreakTimerSettingsBreakManager* break_manager,
                                               GtkBuilder* builder,
                                               BreakTimerSettingsMainWindow* main_window)
{
	return break_timer_settings_panels_welcome_panel_construct (BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, break_manager, builder, main_window);
}

gboolean
break_timer_settings_panels_welcome_panel_is_active (BreakTimerSettingsPanelsWelcomePanel* self)
{
	gboolean _tmp0_ = FALSE;
	AdwNavigationView* _tmp1_;
	AdwNavigationPage* _tmp2_;
	AdwNavigationPage* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->navigation_view;
	_tmp2_ = adw_navigation_view_get_visible_page (_tmp1_);
	_tmp3_ = self->priv->start_page;
	if (_tmp2_ == _tmp3_) {
		_tmp0_ = TRUE;
	} else {
		AdwNavigationView* _tmp4_;
		AdwNavigationPage* _tmp5_;
		AdwNavigationPage* _tmp6_;
		_tmp4_ = self->priv->navigation_view;
		_tmp5_ = adw_navigation_view_get_visible_page (_tmp4_);
		_tmp6_ = self->priv->breaks_page;
		_tmp0_ = _tmp5_ == _tmp6_;
	}
	result = _tmp0_;
	return result;
}

void
break_timer_settings_panels_welcome_panel_settings_button_clicked (BreakTimerSettingsPanelsWelcomePanel* self)
{
	AdwNavigationView* _tmp0_;
	AdwNavigationPage* _tmp1_;
	AdwNavigationPage* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->navigation_view;
	_tmp1_ = adw_navigation_view_get_visible_page (_tmp0_);
	_tmp2_ = self->priv->breaks_page;
	if (_tmp1_ == _tmp2_) {
		AdwNavigationView* _tmp3_;
		AdwNavigationPage* _tmp4_;
		_tmp3_ = self->priv->navigation_view;
		_tmp4_ = self->priv->ready_page;
		adw_navigation_view_push (_tmp3_, _tmp4_);
	}
}

static void
break_timer_settings_panels_welcome_panel_on_master_switch_toggled (BreakTimerSettingsPanelsWelcomePanel* self)
{
	BreakTimerSettingsBreakManager* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	AdwNavigationView* _tmp3_;
	AdwNavigationPage* _tmp4_;
	AdwNavigationPage* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->break_manager;
	_tmp1_ = break_timer_settings_break_manager_get_master_enabled (_tmp0_);
	_tmp2_ = _tmp1_;
	if (!_tmp2_) {
		return;
	}
	_tmp3_ = self->priv->navigation_view;
	_tmp4_ = adw_navigation_view_get_visible_page (_tmp3_);
	_tmp5_ = self->priv->start_page;
	if (_tmp4_ == _tmp5_) {
		AdwNavigationView* _tmp6_;
		AdwNavigationPage* _tmp7_;
		_tmp6_ = self->priv->navigation_view;
		_tmp7_ = self->priv->breaks_page;
		adw_navigation_view_push (_tmp6_, _tmp7_);
	}
}

static void
break_timer_settings_panels_welcome_panel_build_overlay_arrow (BreakTimerSettingsPanelsWelcomePanel* self,
                                                               GtkOverlay* overlay,
                                                               GtkWidget* arrow_source,
                                                               GtkWidget* arrow_target)
{
	BreakTimerSettingsWidgetsOverlayArrow* arrow = NULL;
	AdwNavigationView* _tmp0_;
	BreakTimerSettingsWidgetsOverlayArrow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (overlay != NULL);
	g_return_if_fail (arrow_source != NULL);
	g_return_if_fail (arrow_target != NULL);
	_tmp0_ = self->priv->navigation_view;
	_tmp1_ = break_timer_settings_widgets_overlay_arrow_new (arrow_source, arrow_target, (GtkWidget*) _tmp0_);
	g_object_ref_sink (_tmp1_);
	arrow = _tmp1_;
	break_timer_settings_widgets_overlay_arrow_set_spacing (arrow, 10);
	gtk_overlay_add_overlay (overlay, (GtkWidget*) arrow);
	_g_object_unref0 (arrow);
}

static void
break_timer_settings_panels_welcome_panel_class_init (BreakTimerSettingsPanelsWelcomePanelClass * klass,
                                                      gpointer klass_data)
{
	break_timer_settings_panels_welcome_panel_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BreakTimerSettingsPanelsWelcomePanel_private_offset);
	G_OBJECT_CLASS (klass)->finalize = break_timer_settings_panels_welcome_panel_finalize;
	break_timer_settings_panels_welcome_panel_signals[BREAK_TIMER_SETTINGS_PANELS_WELCOME_PANEL_TOUR_FINISHED_SIGNAL] = g_signal_new ("tour-finished", BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
break_timer_settings_panels_welcome_panel_instance_init (BreakTimerSettingsPanelsWelcomePanel * self,
                                                         gpointer klass)
{
	self->priv = break_timer_settings_panels_welcome_panel_get_instance_private (self);
}

static void
break_timer_settings_panels_welcome_panel_finalize (GObject * obj)
{
	BreakTimerSettingsPanelsWelcomePanel * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_SETTINGS_PANELS_TYPE_WELCOME_PANEL, BreakTimerSettingsPanelsWelcomePanel);
	_g_object_unref0 (self->priv->break_manager);
	_g_object_unref0 (self->priv->main_window);
	_g_object_unref0 (self->priv->navigation_view);
	_g_object_unref0 (self->priv->start_page);
	_g_object_unref0 (self->priv->breaks_page);
	_g_object_unref0 (self->priv->ready_page);
	G_OBJECT_CLASS (break_timer_settings_panels_welcome_panel_parent_class)->finalize (obj);
}

static GType
break_timer_settings_panels_welcome_panel_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerSettingsPanelsWelcomePanelClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_settings_panels_welcome_panel_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerSettingsPanelsWelcomePanel), 0, (GInstanceInitFunc) break_timer_settings_panels_welcome_panel_instance_init, NULL };
	GType break_timer_settings_panels_welcome_panel_type_id;
	break_timer_settings_panels_welcome_panel_type_id = g_type_register_static (gtk_box_get_type (), "BreakTimerSettingsPanelsWelcomePanel", &g_define_type_info, 0);
	BreakTimerSettingsPanelsWelcomePanel_private_offset = g_type_add_instance_private (break_timer_settings_panels_welcome_panel_type_id, sizeof (BreakTimerSettingsPanelsWelcomePanelPrivate));
	return break_timer_settings_panels_welcome_panel_type_id;
}

GType
break_timer_settings_panels_welcome_panel_get_type (void)
{
	static volatile gsize break_timer_settings_panels_welcome_panel_type_id__once = 0;
	if (g_once_init_enter (&break_timer_settings_panels_welcome_panel_type_id__once)) {
		GType break_timer_settings_panels_welcome_panel_type_id;
		break_timer_settings_panels_welcome_panel_type_id = break_timer_settings_panels_welcome_panel_get_type_once ();
		g_once_init_leave (&break_timer_settings_panels_welcome_panel_type_id__once, break_timer_settings_panels_welcome_panel_type_id);
	}
	return break_timer_settings_panels_welcome_panel_type_id__once;
}

