/* header-bar.c generated by valac 0.56.0, the Vala compiler
 * generated from header-bar.vala, do not modify */

/*
 * © 2013 Paolo Borelli <pborelli@gnome.org>
 * © 2019 Bilal Elmoussaoui <bilal.elmoussaoui@gnome.org> &
 *        Zander Brown <zbrown@gnome.org>
 *
 * 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <glib-object.h>
#include <adwaita.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>

#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

typedef enum  {
	CLOCKS_BUTTON_MODE_NEW,
	CLOCKS_BUTTON_MODE_NONE
} ClocksButtonMode;

#define CLOCKS_TYPE_BUTTON_MODE (clocks_button_mode_get_type ())

#define CLOCKS_TYPE_HEADER_BAR (clocks_header_bar_get_type ())
#define CLOCKS_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBar))
#define CLOCKS_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBarClass))
#define CLOCKS_IS_HEADER_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLOCKS_TYPE_HEADER_BAR))
#define CLOCKS_IS_HEADER_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLOCKS_TYPE_HEADER_BAR))
#define CLOCKS_HEADER_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBarClass))

typedef struct _ClocksHeaderBar ClocksHeaderBar;
typedef struct _ClocksHeaderBarClass ClocksHeaderBarClass;
typedef struct _ClocksHeaderBarPrivate ClocksHeaderBarPrivate;
enum  {
	CLOCKS_HEADER_BAR_0_PROPERTY,
	CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY,
	CLOCKS_HEADER_BAR_STACK_PROPERTY,
	CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY,
	CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY,
	CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY,
	CLOCKS_HEADER_BAR_NUM_PROPERTIES
};
static GParamSpec* clocks_header_bar_properties[CLOCKS_HEADER_BAR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ClocksHeaderBar {
	AdwBin parent_instance;
	ClocksHeaderBarPrivate * priv;
};

struct _ClocksHeaderBarClass {
	AdwBinClass parent_class;
};

struct _ClocksHeaderBarPrivate {
	AdwViewStack* _stack;
	AdwViewSwitcherBar* _switcher_bar;
	gchar* _new_label;
	gboolean _title_visible;
	ClocksButtonMode _button_mode;
	AdwViewStack* start_button_stack;
	GtkMenuButton* menu_button;
};

static gint ClocksHeaderBar_private_offset;
static gpointer clocks_header_bar_parent_class = NULL;

VALA_EXTERN GType clocks_button_mode_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType clocks_header_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ClocksHeaderBar, g_object_unref)
VALA_EXTERN void clocks_header_bar_show_primary_menu (ClocksHeaderBar* self);
VALA_EXTERN ClocksHeaderBar* clocks_header_bar_new (void);
VALA_EXTERN ClocksHeaderBar* clocks_header_bar_construct (GType object_type);
VALA_EXTERN ClocksButtonMode clocks_header_bar_get_button_mode (ClocksHeaderBar* self);
VALA_EXTERN void clocks_header_bar_set_button_mode (ClocksHeaderBar* self,
                                        ClocksButtonMode value);
VALA_EXTERN AdwViewStack* clocks_header_bar_get_stack (ClocksHeaderBar* self);
VALA_EXTERN void clocks_header_bar_set_stack (ClocksHeaderBar* self,
                                  AdwViewStack* value);
VALA_EXTERN AdwViewSwitcherBar* clocks_header_bar_get_switcher_bar (ClocksHeaderBar* self);
VALA_EXTERN void clocks_header_bar_set_switcher_bar (ClocksHeaderBar* self,
                                         AdwViewSwitcherBar* value);
VALA_EXTERN const gchar* clocks_header_bar_get_new_label (ClocksHeaderBar* self);
VALA_EXTERN void clocks_header_bar_set_new_label (ClocksHeaderBar* self,
                                      const gchar* value);
VALA_EXTERN gboolean clocks_header_bar_get_title_visible (ClocksHeaderBar* self);
VALA_EXTERN void clocks_header_bar_set_title_visible (ClocksHeaderBar* self,
                                          gboolean value);
static void clocks_header_bar_finalize (GObject * obj);
static GType clocks_header_bar_get_type_once (void);
static void _vala_clocks_header_bar_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_clocks_header_bar_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

 G_GNUC_NO_INLINE static GType
clocks_button_mode_get_type_once (void)
{
	static const GEnumValue values[] = {{CLOCKS_BUTTON_MODE_NEW, "CLOCKS_BUTTON_MODE_NEW", "new"}, {CLOCKS_BUTTON_MODE_NONE, "CLOCKS_BUTTON_MODE_NONE", "none"}, {0, NULL, NULL}};
	GType clocks_button_mode_type_id;
	clocks_button_mode_type_id = g_enum_register_static ("ClocksButtonMode", values);
	return clocks_button_mode_type_id;
}

GType
clocks_button_mode_get_type (void)
{
	static volatile gsize clocks_button_mode_type_id__once = 0;
	if (g_once_init_enter (&clocks_button_mode_type_id__once)) {
		GType clocks_button_mode_type_id;
		clocks_button_mode_type_id = clocks_button_mode_get_type_once ();
		g_once_init_leave (&clocks_button_mode_type_id__once, clocks_button_mode_type_id);
	}
	return clocks_button_mode_type_id__once;
}

static inline gpointer
clocks_header_bar_get_instance_private (ClocksHeaderBar* self)
{
	return G_STRUCT_MEMBER_P (self, ClocksHeaderBar_private_offset);
}

void
clocks_header_bar_show_primary_menu (ClocksHeaderBar* self)
{
	GtkMenuButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->menu_button;
	g_signal_emit_by_name (_tmp0_, "activate");
}

ClocksHeaderBar*
clocks_header_bar_construct (GType object_type)
{
	ClocksHeaderBar * self = NULL;
	self = (ClocksHeaderBar*) g_object_new (object_type, NULL);
	return self;
}

ClocksHeaderBar*
clocks_header_bar_new (void)
{
	return clocks_header_bar_construct (CLOCKS_TYPE_HEADER_BAR);
}

ClocksButtonMode
clocks_header_bar_get_button_mode (ClocksHeaderBar* self)
{
	ClocksButtonMode result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_button_mode;
	return result;
}

void
clocks_header_bar_set_button_mode (ClocksHeaderBar* self,
                                   ClocksButtonMode value)
{
	g_return_if_fail (self != NULL);
	switch (value) {
		case CLOCKS_BUTTON_MODE_NEW:
		{
			AdwViewStack* _tmp0_;
			_tmp0_ = self->priv->start_button_stack;
			adw_view_stack_set_visible_child_name (_tmp0_, "new");
			break;
		}
		case CLOCKS_BUTTON_MODE_NONE:
		{
			AdwViewStack* _tmp1_;
			_tmp1_ = self->priv->start_button_stack;
			adw_view_stack_set_visible_child_name (_tmp1_, "empty");
			break;
		}
		default:
		break;
	}
	self->priv->_button_mode = value;
	g_object_notify_by_pspec ((GObject *) self, clocks_header_bar_properties[CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY]);
}

AdwViewStack*
clocks_header_bar_get_stack (ClocksHeaderBar* self)
{
	AdwViewStack* result;
	AdwViewStack* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_stack;
	result = _tmp0_;
	return result;
}

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

void
clocks_header_bar_set_stack (ClocksHeaderBar* self,
                             AdwViewStack* value)
{
	AdwViewStack* old_value;
	g_return_if_fail (self != NULL);
	old_value = clocks_header_bar_get_stack (self);
	if (old_value != value) {
		AdwViewStack* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_stack);
		self->priv->_stack = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, clocks_header_bar_properties[CLOCKS_HEADER_BAR_STACK_PROPERTY]);
	}
}

AdwViewSwitcherBar*
clocks_header_bar_get_switcher_bar (ClocksHeaderBar* self)
{
	AdwViewSwitcherBar* result;
	AdwViewSwitcherBar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_switcher_bar;
	result = _tmp0_;
	return result;
}

void
clocks_header_bar_set_switcher_bar (ClocksHeaderBar* self,
                                    AdwViewSwitcherBar* value)
{
	AdwViewSwitcherBar* old_value;
	g_return_if_fail (self != NULL);
	old_value = clocks_header_bar_get_switcher_bar (self);
	if (old_value != value) {
		AdwViewSwitcherBar* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_switcher_bar);
		self->priv->_switcher_bar = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, clocks_header_bar_properties[CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY]);
	}
}

const gchar*
clocks_header_bar_get_new_label (ClocksHeaderBar* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_new_label;
	result = _tmp0_;
	return result;
}

void
clocks_header_bar_set_new_label (ClocksHeaderBar* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = clocks_header_bar_get_new_label (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_new_label);
		self->priv->_new_label = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, clocks_header_bar_properties[CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY]);
	}
}

gboolean
clocks_header_bar_get_title_visible (ClocksHeaderBar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_title_visible;
	return result;
}

void
clocks_header_bar_set_title_visible (ClocksHeaderBar* self,
                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = clocks_header_bar_get_title_visible (self);
	if (old_value != value) {
		self->priv->_title_visible = value;
		g_object_notify_by_pspec ((GObject *) self, clocks_header_bar_properties[CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY]);
	}
}

static void
clocks_header_bar_class_init (ClocksHeaderBarClass * klass,
                              gpointer klass_data)
{
	clocks_header_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ClocksHeaderBar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_clocks_header_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_clocks_header_bar_set_property;
	G_OBJECT_CLASS (klass)->finalize = clocks_header_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY, clocks_header_bar_properties[CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY] = g_param_spec_enum ("button-mode", "button-mode", "button-mode", CLOCKS_TYPE_BUTTON_MODE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CLOCKS_HEADER_BAR_STACK_PROPERTY, clocks_header_bar_properties[CLOCKS_HEADER_BAR_STACK_PROPERTY] = g_param_spec_object ("stack", "stack", "stack", adw_view_stack_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY, clocks_header_bar_properties[CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY] = g_param_spec_object ("switcher-bar", "switcher-bar", "switcher-bar", adw_view_switcher_bar_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY, clocks_header_bar_properties[CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY] = g_param_spec_string ("new-label", "new-label", "new-label", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY, clocks_header_bar_properties[CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY] = g_param_spec_boolean ("title-visible", "title-visible", "title-visible", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/clocks/ui/header-bar.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "start_button_stack", FALSE, ClocksHeaderBar_private_offset + G_STRUCT_OFFSET (ClocksHeaderBarPrivate, start_button_stack));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "menu_button", FALSE, ClocksHeaderBar_private_offset + G_STRUCT_OFFSET (ClocksHeaderBarPrivate, menu_button));
}

static void
clocks_header_bar_instance_init (ClocksHeaderBar * self,
                                 gpointer klass)
{
	self->priv = clocks_header_bar_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
clocks_header_bar_finalize (GObject * obj)
{
	ClocksHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBar);
	_g_object_unref0 (self->priv->_stack);
	_g_object_unref0 (self->priv->_switcher_bar);
	_g_free0 (self->priv->_new_label);
	G_OBJECT_CLASS (clocks_header_bar_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
clocks_header_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ClocksHeaderBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) clocks_header_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ClocksHeaderBar), 0, (GInstanceInitFunc) clocks_header_bar_instance_init, NULL };
	GType clocks_header_bar_type_id;
	clocks_header_bar_type_id = g_type_register_static (adw_bin_get_type (), "ClocksHeaderBar", &g_define_type_info, 0);
	ClocksHeaderBar_private_offset = g_type_add_instance_private (clocks_header_bar_type_id, sizeof (ClocksHeaderBarPrivate));
	return clocks_header_bar_type_id;
}

GType
clocks_header_bar_get_type (void)
{
	static volatile gsize clocks_header_bar_type_id__once = 0;
	if (g_once_init_enter (&clocks_header_bar_type_id__once)) {
		GType clocks_header_bar_type_id;
		clocks_header_bar_type_id = clocks_header_bar_get_type_once ();
		g_once_init_leave (&clocks_header_bar_type_id__once, clocks_header_bar_type_id);
	}
	return clocks_header_bar_type_id__once;
}

static void
_vala_clocks_header_bar_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	ClocksHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBar);
	switch (property_id) {
		case CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY:
		g_value_set_enum (value, clocks_header_bar_get_button_mode (self));
		break;
		case CLOCKS_HEADER_BAR_STACK_PROPERTY:
		g_value_set_object (value, clocks_header_bar_get_stack (self));
		break;
		case CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY:
		g_value_set_object (value, clocks_header_bar_get_switcher_bar (self));
		break;
		case CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY:
		g_value_set_string (value, clocks_header_bar_get_new_label (self));
		break;
		case CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY:
		g_value_set_boolean (value, clocks_header_bar_get_title_visible (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_clocks_header_bar_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	ClocksHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CLOCKS_TYPE_HEADER_BAR, ClocksHeaderBar);
	switch (property_id) {
		case CLOCKS_HEADER_BAR_BUTTON_MODE_PROPERTY:
		clocks_header_bar_set_button_mode (self, g_value_get_enum (value));
		break;
		case CLOCKS_HEADER_BAR_STACK_PROPERTY:
		clocks_header_bar_set_stack (self, g_value_get_object (value));
		break;
		case CLOCKS_HEADER_BAR_SWITCHER_BAR_PROPERTY:
		clocks_header_bar_set_switcher_bar (self, g_value_get_object (value));
		break;
		case CLOCKS_HEADER_BAR_NEW_LABEL_PROPERTY:
		clocks_header_bar_set_new_label (self, g_value_get_string (value));
		break;
		case CLOCKS_HEADER_BAR_TITLE_VISIBLE_PROPERTY:
		clocks_header_bar_set_title_visible (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

