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

/* BreakView.vala
 *
 * Copyright 2020 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 "daemon.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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  {
	BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_0_PROPERTY,
	BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_NUM_PROPERTIES
};
static GParamSpec* break_timer_daemon_break_break_view_properties[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_FOCUSED_AND_ACTIVATED_SIGNAL,
	BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_LOST_UI_FOCUS_SIGNAL,
	BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_NUM_SIGNALS
};
static guint break_timer_daemon_break_break_view_signals[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_NUM_SIGNALS] = {0};

static gpointer break_timer_daemon_break_break_view_parent_class = NULL;

static void __lambda6_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda6__break_timer_daemon_break_break_controller_enabled (BreakTimerDaemonBreakBreakController* _sender,
                                                                    gpointer self);
static void __lambda7_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda7__break_timer_daemon_break_break_controller_disabled (BreakTimerDaemonBreakBreakController* _sender,
                                                                     gpointer self);
static void __lambda8_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda8__break_timer_daemon_break_break_controller_warned (BreakTimerDaemonBreakBreakController* _sender,
                                                                   gpointer self);
static void __lambda9_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda9__break_timer_daemon_break_break_controller_unwarned (BreakTimerDaemonBreakBreakController* _sender,
                                                                     gpointer self);
static void __lambda10_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda10__break_timer_daemon_break_break_controller_activated (BreakTimerDaemonBreakBreakController* _sender,
                                                                       gpointer self);
static void __lambda11_ (BreakTimerDaemonBreakBreakView* self);
static void ___lambda11__break_timer_daemon_break_break_controller_finished (BreakTimerDaemonBreakBreakController* _sender,
                                                                      BreakTimerDaemonBreakBreakControllerFinishedReason reason,
                                                                      gboolean was_active,
                                                                      gpointer self);
static gchar* break_timer_daemon_break_break_view_real_get_status_message (BreakTimerDaemonBreakBreakView* self);
static void break_timer_daemon_break_break_view_real_dismiss_break (BreakTimerDaemonBreakBreakView* self);
static void break_timer_daemon_break_break_view_real_focus_started (BreakTimerDaemonUIFragment* base);
static void break_timer_daemon_break_break_view_real_focus_stopped (BreakTimerDaemonUIFragment* base);
static void break_timer_daemon_break_break_view_finalize (GObject * obj);
static GType break_timer_daemon_break_break_view_get_type_once (void);

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

static void
__lambda6_ (BreakTimerDaemonBreakBreakView* self)
{
	BreakTimerDaemonUIManager* _tmp0_;
	break_timer_daemon_ui_fragment_reset_ui ((BreakTimerDaemonUIFragment*) self);
	_tmp0_ = ((BreakTimerDaemonUIFragment*) self)->ui_manager;
	break_timer_daemon_ui_manager_add_break (_tmp0_, self);
}

static void
___lambda6__break_timer_daemon_break_break_controller_enabled (BreakTimerDaemonBreakBreakController* _sender,
                                                               gpointer self)
{
	__lambda6_ ((BreakTimerDaemonBreakBreakView*) self);
}

static void
__lambda7_ (BreakTimerDaemonBreakBreakView* self)
{
	BreakTimerDaemonUIManager* _tmp0_;
	break_timer_daemon_ui_fragment_reset_ui ((BreakTimerDaemonUIFragment*) self);
	_tmp0_ = ((BreakTimerDaemonUIFragment*) self)->ui_manager;
	break_timer_daemon_ui_manager_remove_break (_tmp0_, self);
}

static void
___lambda7__break_timer_daemon_break_break_controller_disabled (BreakTimerDaemonBreakBreakController* _sender,
                                                                gpointer self)
{
	__lambda7_ ((BreakTimerDaemonBreakBreakView*) self);
}

static void
__lambda8_ (BreakTimerDaemonBreakBreakView* self)
{
	break_timer_daemon_ui_fragment_request_ui_focus ((BreakTimerDaemonUIFragment*) self);
}

static void
___lambda8__break_timer_daemon_break_break_controller_warned (BreakTimerDaemonBreakBreakController* _sender,
                                                              gpointer self)
{
	__lambda8_ ((BreakTimerDaemonBreakBreakView*) self);
}

static void
__lambda9_ (BreakTimerDaemonBreakBreakView* self)
{
	break_timer_daemon_ui_fragment_release_ui_focus ((BreakTimerDaemonUIFragment*) self);
}

static void
___lambda9__break_timer_daemon_break_break_controller_unwarned (BreakTimerDaemonBreakBreakController* _sender,
                                                                gpointer self)
{
	__lambda9_ ((BreakTimerDaemonBreakBreakView*) self);
}

static void
__lambda10_ (BreakTimerDaemonBreakBreakView* self)
{
	break_timer_daemon_ui_fragment_request_ui_focus ((BreakTimerDaemonUIFragment*) self);
}

static void
___lambda10__break_timer_daemon_break_break_controller_activated (BreakTimerDaemonBreakBreakController* _sender,
                                                                  gpointer self)
{
	__lambda10_ ((BreakTimerDaemonBreakBreakView*) self);
}

static void
__lambda11_ (BreakTimerDaemonBreakBreakView* self)
{
	break_timer_daemon_ui_fragment_release_ui_focus ((BreakTimerDaemonUIFragment*) self);
}

static void
___lambda11__break_timer_daemon_break_break_controller_finished (BreakTimerDaemonBreakBreakController* _sender,
                                                                 BreakTimerDaemonBreakBreakControllerFinishedReason reason,
                                                                 gboolean was_active,
                                                                 gpointer self)
{
	__lambda11_ ((BreakTimerDaemonBreakBreakView*) self);
}

BreakTimerDaemonBreakBreakView*
break_timer_daemon_break_break_view_construct (GType object_type,
                                               BreakTimerDaemonBreakBreakController* break_controller,
                                               BreakTimerDaemonUIManager* ui_manager)
{
	BreakTimerDaemonBreakBreakView * self = NULL;
	BreakTimerDaemonUIManager* _tmp0_;
	g_return_val_if_fail (break_controller != NULL, NULL);
	g_return_val_if_fail (ui_manager != NULL, NULL);
	self = (BreakTimerDaemonBreakBreakView*) break_timer_daemon_ui_fragment_construct (object_type);
	_tmp0_ = _g_object_ref0 (ui_manager);
	_g_object_unref0 (((BreakTimerDaemonUIFragment*) self)->ui_manager);
	((BreakTimerDaemonUIFragment*) self)->ui_manager = _tmp0_;
	self->break_controller = break_controller;
	g_signal_connect_object (break_controller, "enabled", (GCallback) ___lambda6__break_timer_daemon_break_break_controller_enabled, self, 0);
	g_signal_connect_object (break_controller, "disabled", (GCallback) ___lambda7__break_timer_daemon_break_break_controller_disabled, self, 0);
	g_signal_connect_object (break_controller, "warned", (GCallback) ___lambda8__break_timer_daemon_break_break_controller_warned, self, 0);
	g_signal_connect_object (break_controller, "unwarned", (GCallback) ___lambda9__break_timer_daemon_break_break_controller_unwarned, self, 0);
	g_signal_connect_object (break_controller, "activated", (GCallback) ___lambda10__break_timer_daemon_break_break_controller_activated, self, 0);
	g_signal_connect_object (break_controller, "finished", (GCallback) ___lambda11__break_timer_daemon_break_break_controller_finished, self, G_CONNECT_AFTER);
	return self;
}

static gchar*
break_timer_daemon_break_break_view_real_get_status_message (BreakTimerDaemonBreakBreakView* self)
{
	g_critical ("Type `%s' does not implement abstract method `break_timer_daemon_break_break_view_get_status_message'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

gchar*
break_timer_daemon_break_break_view_get_status_message (BreakTimerDaemonBreakBreakView* self)
{
	BreakTimerDaemonBreakBreakViewClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_GET_CLASS (self);
	if (_klass_->get_status_message) {
		return _klass_->get_status_message (self);
	}
	return NULL;
}

/**
     * Dismiss the break according to some user input. The BreakController
     * may choose to skip the break, or delay it by some length of time.
     */
static void
break_timer_daemon_break_break_view_real_dismiss_break (BreakTimerDaemonBreakBreakView* self)
{
	BreakTimerDaemonBreakBreakController* _tmp0_;
	_tmp0_ = self->break_controller;
	break_timer_daemon_break_break_controller_skip (_tmp0_, FALSE);
}

void
break_timer_daemon_break_break_view_dismiss_break (BreakTimerDaemonBreakBreakView* self)
{
	BreakTimerDaemonBreakBreakViewClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_GET_CLASS (self);
	if (_klass_->dismiss_break) {
		_klass_->dismiss_break (self);
	}
}

static void
break_timer_daemon_break_break_view_real_focus_started (BreakTimerDaemonUIFragment* base)
{
	BreakTimerDaemonBreakBreakView * self;
	BreakTimerDaemonBreakBreakController* _tmp0_;
	self = (BreakTimerDaemonBreakBreakView*) base;
	_tmp0_ = self->break_controller;
	if (break_timer_daemon_break_break_controller_is_active (_tmp0_)) {
		g_signal_emit (self, break_timer_daemon_break_break_view_signals[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_FOCUSED_AND_ACTIVATED_SIGNAL], 0);
	}
}

static void
break_timer_daemon_break_break_view_real_focus_stopped (BreakTimerDaemonUIFragment* base)
{
	BreakTimerDaemonBreakBreakView * self;
	self = (BreakTimerDaemonBreakBreakView*) base;
	g_signal_emit (self, break_timer_daemon_break_break_view_signals[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_LOST_UI_FOCUS_SIGNAL], 0);
}

static void
break_timer_daemon_break_break_view_class_init (BreakTimerDaemonBreakBreakViewClass * klass,
                                                gpointer klass_data)
{
	break_timer_daemon_break_break_view_parent_class = g_type_class_peek_parent (klass);
	((BreakTimerDaemonBreakBreakViewClass *) klass)->get_status_message = (gchar* (*) (BreakTimerDaemonBreakBreakView*)) break_timer_daemon_break_break_view_real_get_status_message;
	((BreakTimerDaemonBreakBreakViewClass *) klass)->dismiss_break = (void (*) (BreakTimerDaemonBreakBreakView*)) break_timer_daemon_break_break_view_real_dismiss_break;
	((BreakTimerDaemonUIFragmentClass *) klass)->focus_started = (void (*) (BreakTimerDaemonUIFragment*)) break_timer_daemon_break_break_view_real_focus_started;
	((BreakTimerDaemonUIFragmentClass *) klass)->focus_stopped = (void (*) (BreakTimerDaemonUIFragment*)) break_timer_daemon_break_break_view_real_focus_stopped;
	G_OBJECT_CLASS (klass)->finalize = break_timer_daemon_break_break_view_finalize;
	/** The break is active and has been given UI focus. This is the point where we start caring about it. */
	break_timer_daemon_break_break_view_signals[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_FOCUSED_AND_ACTIVATED_SIGNAL] = g_signal_new ("focused-and-activated", BREAK_TIMER_DAEMON_BREAK_TYPE_BREAK_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	/** The break has lost UI focus. We don't need to display anything at this point. */
	break_timer_daemon_break_break_view_signals[BREAK_TIMER_DAEMON_BREAK_BREAK_VIEW_LOST_UI_FOCUS_SIGNAL] = g_signal_new ("lost-ui-focus", BREAK_TIMER_DAEMON_BREAK_TYPE_BREAK_VIEW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
break_timer_daemon_break_break_view_instance_init (BreakTimerDaemonBreakBreakView * self,
                                                   gpointer klass)
{
}

static void
break_timer_daemon_break_break_view_finalize (GObject * obj)
{
	BreakTimerDaemonBreakBreakView * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_DAEMON_BREAK_TYPE_BREAK_VIEW, BreakTimerDaemonBreakBreakView);
	G_OBJECT_CLASS (break_timer_daemon_break_break_view_parent_class)->finalize (obj);
}

static GType
break_timer_daemon_break_break_view_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerDaemonBreakBreakViewClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_daemon_break_break_view_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerDaemonBreakBreakView), 0, (GInstanceInitFunc) break_timer_daemon_break_break_view_instance_init, NULL };
	GType break_timer_daemon_break_break_view_type_id;
	break_timer_daemon_break_break_view_type_id = g_type_register_static (BREAK_TIMER_DAEMON_TYPE_UI_FRAGMENT, "BreakTimerDaemonBreakBreakView", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return break_timer_daemon_break_break_view_type_id;
}

GType
break_timer_daemon_break_break_view_get_type (void)
{
	static volatile gsize break_timer_daemon_break_break_view_type_id__once = 0;
	if (g_once_init_enter (&break_timer_daemon_break_break_view_type_id__once)) {
		GType break_timer_daemon_break_break_view_type_id;
		break_timer_daemon_break_break_view_type_id = break_timer_daemon_break_break_view_get_type_once ();
		g_once_init_leave (&break_timer_daemon_break_break_view_type_id__once, break_timer_daemon_break_break_view_type_id);
	}
	return break_timer_daemon_break_break_view_type_id__once;
}

