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

/* RestBreakInfoWidget.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 "settings.h"
#include <glib-object.h>
#include "common.h"
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <string.h>
#include <stdlib.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_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET (break_timer_settings_rest_break_rest_break_info_widget_get_type ())
#define BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET, BreakTimerSettingsRestBreakRestBreakInfoWidget))
#define BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET, BreakTimerSettingsRestBreakRestBreakInfoWidgetClass))
#define BREAK_TIMER_SETTINGS_REST_BREAK_IS_REST_BREAK_INFO_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET))
#define BREAK_TIMER_SETTINGS_REST_BREAK_IS_REST_BREAK_INFO_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET))
#define BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET, BreakTimerSettingsRestBreakRestBreakInfoWidgetClass))

typedef struct _BreakTimerSettingsRestBreakRestBreakInfoWidget BreakTimerSettingsRestBreakRestBreakInfoWidget;
typedef struct _BreakTimerSettingsRestBreakRestBreakInfoWidgetClass BreakTimerSettingsRestBreakRestBreakInfoWidgetClass;
typedef struct _BreakTimerSettingsRestBreakRestBreakInfoWidgetPrivate BreakTimerSettingsRestBreakRestBreakInfoWidgetPrivate;
enum  {
	BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET_0_PROPERTY,
	BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET_NUM_PROPERTIES
};
static GParamSpec* break_timer_settings_rest_break_rest_break_info_widget_properties[BREAK_TIMER_SETTINGS_REST_BREAK_REST_BREAK_INFO_WIDGET_NUM_PROPERTIES];
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))

struct _BreakTimerSettingsRestBreakRestBreakInfoWidget {
	BreakTimerSettingsBreakBreakInfoWidget parent_instance;
	BreakTimerSettingsRestBreakRestBreakInfoWidgetPrivate * priv;
};

struct _BreakTimerSettingsRestBreakRestBreakInfoWidgetClass {
	BreakTimerSettingsBreakBreakInfoWidgetClass parent_class;
};

struct _BreakTimerSettingsRestBreakRestBreakInfoWidgetPrivate {
	BreakTimerCommonTimerBreakStatus* status;
};

static gint BreakTimerSettingsRestBreakRestBreakInfoWidget_private_offset;
static gpointer break_timer_settings_rest_break_rest_break_info_widget_parent_class = NULL;

VALA_EXTERN GType break_timer_settings_rest_break_rest_break_info_widget_get_type (void) G_GNUC_CONST ;
VALA_EXTERN BreakTimerSettingsRestBreakRestBreakInfoWidget* break_timer_settings_rest_break_rest_break_info_widget_new (BreakTimerSettingsRestBreakRestBreakType* break_type);
VALA_EXTERN BreakTimerSettingsRestBreakRestBreakInfoWidget* break_timer_settings_rest_break_rest_break_info_widget_construct (GType object_type,
                                                                                                                  BreakTimerSettingsRestBreakRestBreakType* break_type);
static void break_timer_settings_rest_break_rest_break_info_widget_update_description (BreakTimerSettingsRestBreakRestBreakInfoWidget* self);
static void _break_timer_settings_rest_break_rest_break_info_widget_update_description_g_object_notify (GObject* _sender,
                                                                                                 GParamSpec* pspec,
                                                                                                 gpointer self);
static void break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb (BreakTimerSettingsRestBreakRestBreakInfoWidget* self,
                                                                                     BreakTimerCommonTimerBreakStatus* status);
static void _break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb_break_timer_settings_timer_break_timer_break_type_timer_status_changed (BreakTimerSettingsTimerBreakTimerBreakType* _sender,
                                                                                                                                                             BreakTimerCommonTimerBreakStatus* status,
                                                                                                                                                             gpointer self);
static BreakTimerCommonTimerBreakStatus* _break_timer_common_timer_break_status_dup (BreakTimerCommonTimerBreakStatus* self);
static void break_timer_settings_rest_break_rest_break_info_widget_finalize (GObject * obj);
static GType break_timer_settings_rest_break_rest_break_info_widget_get_type_once (void);

static inline gpointer
break_timer_settings_rest_break_rest_break_info_widget_get_instance_private (BreakTimerSettingsRestBreakRestBreakInfoWidget* self)
{
	return G_STRUCT_MEMBER_P (self, BreakTimerSettingsRestBreakRestBreakInfoWidget_private_offset);
}

static void
_break_timer_settings_rest_break_rest_break_info_widget_update_description_g_object_notify (GObject* _sender,
                                                                                            GParamSpec* pspec,
                                                                                            gpointer self)
{
	break_timer_settings_rest_break_rest_break_info_widget_update_description ((BreakTimerSettingsRestBreakRestBreakInfoWidget*) self);
}

static void
_break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb_break_timer_settings_timer_break_timer_break_type_timer_status_changed (BreakTimerSettingsTimerBreakTimerBreakType* _sender,
                                                                                                                                                        BreakTimerCommonTimerBreakStatus* status,
                                                                                                                                                        gpointer self)
{
	break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb ((BreakTimerSettingsRestBreakRestBreakInfoWidget*) self, status);
}

BreakTimerSettingsRestBreakRestBreakInfoWidget*
break_timer_settings_rest_break_rest_break_info_widget_construct (GType object_type,
                                                                  BreakTimerSettingsRestBreakRestBreakType* break_type)
{
	BreakTimerSettingsRestBreakRestBreakInfoWidget * self = NULL;
	g_return_val_if_fail (break_type != NULL, NULL);
	self = (BreakTimerSettingsRestBreakRestBreakInfoWidget*) break_timer_settings_break_break_info_widget_construct (object_type, (BreakTimerSettingsBreakBreakType*) break_type, _ ("Break"));
	g_signal_connect_object ((GObject*) break_type, "notify::duration", (GCallback) _break_timer_settings_rest_break_rest_break_info_widget_update_description_g_object_notify, self, 0);
	g_signal_connect_object ((BreakTimerSettingsTimerBreakTimerBreakType*) break_type, "timer-status-changed", (GCallback) _break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb_break_timer_settings_timer_break_timer_break_type_timer_status_changed, self, 0);
	return self;
}

BreakTimerSettingsRestBreakRestBreakInfoWidget*
break_timer_settings_rest_break_rest_break_info_widget_new (BreakTimerSettingsRestBreakRestBreakType* break_type)
{
	return break_timer_settings_rest_break_rest_break_info_widget_construct (BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET, break_type);
}

static BreakTimerCommonTimerBreakStatus*
_break_timer_common_timer_break_status_dup (BreakTimerCommonTimerBreakStatus* self)
{
	BreakTimerCommonTimerBreakStatus* dup;
	dup = g_new0 (BreakTimerCommonTimerBreakStatus, 1);
	memcpy (dup, self, sizeof (BreakTimerCommonTimerBreakStatus));
	return dup;
}

static gpointer
__break_timer_common_timer_break_status_dup0 (gpointer self)
{
	return self ? _break_timer_common_timer_break_status_dup (self) : NULL;
}

static void
break_timer_settings_rest_break_rest_break_info_widget_timer_status_changed_cb (BreakTimerSettingsRestBreakRestBreakInfoWidget* self,
                                                                                BreakTimerCommonTimerBreakStatus* status)
{
	BreakTimerCommonTimerBreakStatus* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = __break_timer_common_timer_break_status_dup0 (status);
	_g_free0 (self->priv->status);
	self->priv->status = _tmp0_;
	break_timer_settings_rest_break_rest_break_info_widget_update_description (self);
}

static void
break_timer_settings_rest_break_rest_break_info_widget_update_description (BreakTimerSettingsRestBreakRestBreakInfoWidget* self)
{
	BreakTimerCommonTimerBreakStatus* _tmp0_;
	gint time_remaining_value = 0;
	gchar* time_remaining_text = NULL;
	BreakTimerCommonNaturalTime* _tmp1_;
	BreakTimerCommonNaturalTime* _tmp2_;
	BreakTimerCommonTimerBreakStatus* _tmp3_;
	BreakTimerCommonTimerBreakStatus* _tmp4_;
	gint _tmp5_ = 0;
	gchar* _tmp6_;
	gchar* detail_text = NULL;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->status;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = break_timer_common_natural_time_get_instance ();
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->status;
	_tmp4_ = self->priv->status;
	_tmp6_ = break_timer_common_natural_time_get_countdown_for_seconds_with_start (_tmp2_, (*_tmp3_).time_remaining, (*_tmp4_).current_duration, &_tmp5_);
	time_remaining_value = _tmp5_;
	time_remaining_text = _tmp6_;
	_tmp7_ = time_remaining_text;
	_tmp8_ = g_strdup_printf (ngettext ("Your break has %s remaining. I’ll remind you when it’s over.", "Your break has %s remaining. I’ll remind you when it’s over.", (gulong) time_remaining_value), _tmp7_);
	detail_text = _tmp8_;
	break_timer_settings_break_break_info_widget_set_heading ((BreakTimerSettingsBreakBreakInfoWidget*) self, _ ("It’s break time"));
	break_timer_settings_break_break_info_widget_set_description ((BreakTimerSettingsBreakBreakInfoWidget*) self, _ ("Take some time away from the computer. Stretch and move around."));
	_tmp9_ = detail_text;
	break_timer_settings_break_break_info_widget_set_detail ((BreakTimerSettingsBreakBreakInfoWidget*) self, _tmp9_);
	_g_free0 (detail_text);
	_g_free0 (time_remaining_text);
}

static void
break_timer_settings_rest_break_rest_break_info_widget_class_init (BreakTimerSettingsRestBreakRestBreakInfoWidgetClass * klass,
                                                                   gpointer klass_data)
{
	break_timer_settings_rest_break_rest_break_info_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BreakTimerSettingsRestBreakRestBreakInfoWidget_private_offset);
	G_OBJECT_CLASS (klass)->finalize = break_timer_settings_rest_break_rest_break_info_widget_finalize;
}

static void
break_timer_settings_rest_break_rest_break_info_widget_instance_init (BreakTimerSettingsRestBreakRestBreakInfoWidget * self,
                                                                      gpointer klass)
{
	self->priv = break_timer_settings_rest_break_rest_break_info_widget_get_instance_private (self);
}

static void
break_timer_settings_rest_break_rest_break_info_widget_finalize (GObject * obj)
{
	BreakTimerSettingsRestBreakRestBreakInfoWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BREAK_TIMER_SETTINGS_REST_BREAK_TYPE_REST_BREAK_INFO_WIDGET, BreakTimerSettingsRestBreakRestBreakInfoWidget);
	_g_free0 (self->priv->status);
	G_OBJECT_CLASS (break_timer_settings_rest_break_rest_break_info_widget_parent_class)->finalize (obj);
}

static GType
break_timer_settings_rest_break_rest_break_info_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BreakTimerSettingsRestBreakRestBreakInfoWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) break_timer_settings_rest_break_rest_break_info_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BreakTimerSettingsRestBreakRestBreakInfoWidget), 0, (GInstanceInitFunc) break_timer_settings_rest_break_rest_break_info_widget_instance_init, NULL };
	GType break_timer_settings_rest_break_rest_break_info_widget_type_id;
	break_timer_settings_rest_break_rest_break_info_widget_type_id = g_type_register_static (BREAK_TIMER_SETTINGS_BREAK_TYPE_BREAK_INFO_WIDGET, "BreakTimerSettingsRestBreakRestBreakInfoWidget", &g_define_type_info, 0);
	BreakTimerSettingsRestBreakRestBreakInfoWidget_private_offset = g_type_add_instance_private (break_timer_settings_rest_break_rest_break_info_widget_type_id, sizeof (BreakTimerSettingsRestBreakRestBreakInfoWidgetPrivate));
	return break_timer_settings_rest_break_rest_break_info_widget_type_id;
}

GType
break_timer_settings_rest_break_rest_break_info_widget_get_type (void)
{
	static volatile gsize break_timer_settings_rest_break_rest_break_info_widget_type_id__once = 0;
	if (g_once_init_enter (&break_timer_settings_rest_break_rest_break_info_widget_type_id__once)) {
		GType break_timer_settings_rest_break_rest_break_info_widget_type_id;
		break_timer_settings_rest_break_rest_break_info_widget_type_id = break_timer_settings_rest_break_rest_break_info_widget_get_type_once ();
		g_once_init_leave (&break_timer_settings_rest_break_rest_break_info_widget_type_id__once, break_timer_settings_rest_break_rest_break_info_widget_type_id);
	}
	return break_timer_settings_rest_break_rest_break_info_widget_type_id__once;
}

