/* components-headerbar-conversation.c generated by valac 0.56.3, the Vala compiler
 * generated from components-headerbar-conversation.vala, do not modify */

/*
 * Copyright © 2017 Software Freedom Conservancy Inc.
 * Copyright © 2021 Michael Gratton <mike@vee.net>
 * Copyright © 2022 Cédric Bellegarde <cedric.bellegarde@adishatz.org>
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later). See the COPYING file in this distribution.
 */

#include "geary-client-43.0.h"
#include <glib.h>
#include <handy.h>
#include <gtk/gtk.h>
#include <glib-object.h>

enum  {
	COMPONENTS_CONVERSATION_HEADER_BAR_0_PROPERTY,
	COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY,
	COMPONENTS_CONVERSATION_HEADER_BAR_SHOWN_ACTIONS_PROPERTY,
	COMPONENTS_CONVERSATION_HEADER_BAR_NUM_PROPERTIES
};
static GParamSpec* components_conversation_header_bar_properties[COMPONENTS_CONVERSATION_HEADER_BAR_NUM_PROPERTIES];

struct _ComponentsConversationHeaderBarPrivate {
	gboolean _find_open;
	HdySqueezer* actions_squeezer;
	GtkToggleButton* find_button;
	HdyHeaderBar* conversation_header;
};

static gint ComponentsConversationHeaderBar_private_offset;
static gpointer components_conversation_header_bar_parent_class = NULL;

static GObject * components_conversation_header_bar_constructor (GType type,
                                                          guint n_construct_properties,
                                                          GObjectConstructParam * construct_properties);
static void _components_conversation_header_bar___lambda154_ (ComponentsConversationHeaderBar* self);
static void __components_conversation_header_bar___lambda154__g_object_notify (GObject* _sender,
                                                                        GParamSpec* pspec,
                                                                        gpointer self);
static void components_conversation_header_bar_finalize (GObject * obj);
static GType components_conversation_header_bar_get_type_once (void);
static void _vala_components_conversation_header_bar_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec);
static void _vala_components_conversation_header_bar_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec);

static inline gpointer
components_conversation_header_bar_get_instance_private (ComponentsConversationHeaderBar* self)
{
	return G_STRUCT_MEMBER_P (self, ComponentsConversationHeaderBar_private_offset);
}

gboolean
components_conversation_header_bar_get_find_open (ComponentsConversationHeaderBar* self)
{
	gboolean result;
	g_return_val_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (self), FALSE);
	result = self->priv->_find_open;
	return result;
}

void
components_conversation_header_bar_set_find_open (ComponentsConversationHeaderBar* self,
                                                  gboolean value)
{
	gboolean old_value;
	g_return_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (self));
	old_value = components_conversation_header_bar_get_find_open (self);
	if (old_value != value) {
		self->priv->_find_open = value;
		g_object_notify_by_pspec ((GObject *) self, components_conversation_header_bar_properties[COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY]);
	}
}

ComponentsConversationActions*
components_conversation_header_bar_get_shown_actions (ComponentsConversationHeaderBar* self)
{
	ComponentsConversationActions* result;
	HdySqueezer* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	g_return_val_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (self), NULL);
	_tmp0_ = self->priv->actions_squeezer;
	_tmp1_ = hdy_squeezer_get_visible_child (_tmp0_);
	_tmp2_ = _tmp1_;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, COMPONENTS_TYPE_CONVERSATION_ACTIONS, ComponentsConversationActions);
	return result;
}

void
components_conversation_header_bar_set_conversation_header (ComponentsConversationHeaderBar* self,
                                                            HdyHeaderBar* header)
{
	HdyHeaderBar* _tmp0_;
	g_return_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (header, hdy_header_bar_get_type ()));
	_tmp0_ = self->priv->conversation_header;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_set_hexpand (G_TYPE_CHECK_INSTANCE_CAST (header, gtk_widget_get_type (), GtkWidget), TRUE);
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (header, gtk_widget_get_type (), GtkWidget));
}

void
components_conversation_header_bar_remove_conversation_header (ComponentsConversationHeaderBar* self,
                                                               HdyHeaderBar* header)
{
	HdyHeaderBar* _tmp0_;
	g_return_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (header, hdy_header_bar_get_type ()));
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (header, gtk_widget_get_type (), GtkWidget));
	_tmp0_ = self->priv->conversation_header;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_widget_get_type (), GtkWidget));
}

ComponentsConversationHeaderBar*
components_conversation_header_bar_construct (GType object_type)
{
	ComponentsConversationHeaderBar * self = NULL;
	self = (ComponentsConversationHeaderBar*) g_object_new (object_type, NULL);
	return self;
}

ComponentsConversationHeaderBar*
components_conversation_header_bar_new (void)
{
	return components_conversation_header_bar_construct (COMPONENTS_TYPE_CONVERSATION_HEADER_BAR);
}

static void
_components_conversation_header_bar___lambda154_ (ComponentsConversationHeaderBar* self)
{
	g_object_notify (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), "shown-actions");
}

static void
__components_conversation_header_bar___lambda154__g_object_notify (GObject* _sender,
                                                                   GParamSpec* pspec,
                                                                   gpointer self)
{
	_components_conversation_header_bar___lambda154_ ((ComponentsConversationHeaderBar*) self);
}

static GObject *
components_conversation_header_bar_constructor (GType type,
                                                guint n_construct_properties,
                                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ComponentsConversationHeaderBar * self;
	HdySqueezer* _tmp0_;
	GtkToggleButton* _tmp1_;
	parent_class = G_OBJECT_CLASS (components_conversation_header_bar_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPONENTS_TYPE_CONVERSATION_HEADER_BAR, ComponentsConversationHeaderBar);
	_tmp0_ = self->priv->actions_squeezer;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, G_TYPE_OBJECT, GObject), "notify::visible-child", (GCallback) __components_conversation_header_bar___lambda154__g_object_notify, self, G_CONNECT_AFTER);
	_tmp1_ = self->priv->find_button;
	g_object_bind_property_with_closures (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), "find-open", G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, G_TYPE_OBJECT, GObject), "active", G_BINDING_SYNC_CREATE | G_BINDING_BIDIRECTIONAL, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return obj;
}

static void
components_conversation_header_bar_class_init (ComponentsConversationHeaderBarClass * klass,
                                               gpointer klass_data)
{
	components_conversation_header_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ComponentsConversationHeaderBar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_components_conversation_header_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_components_conversation_header_bar_set_property;
	G_OBJECT_CLASS (klass)->constructor = components_conversation_header_bar_constructor;
	G_OBJECT_CLASS (klass)->finalize = components_conversation_header_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY, components_conversation_header_bar_properties[COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY] = g_param_spec_boolean ("find-open", "find-open", "find-open", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), COMPONENTS_CONVERSATION_HEADER_BAR_SHOWN_ACTIONS_PROPERTY, components_conversation_header_bar_properties[COMPONENTS_CONVERSATION_HEADER_BAR_SHOWN_ACTIONS_PROPERTY] = g_param_spec_object ("shown-actions", "shown-actions", "shown-actions", COMPONENTS_TYPE_CONVERSATION_ACTIONS, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Geary/components-headerbar-conversation.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "actions_squeezer", FALSE, ComponentsConversationHeaderBar_private_offset + G_STRUCT_OFFSET (ComponentsConversationHeaderBarPrivate, actions_squeezer));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "full_actions", FALSE, G_STRUCT_OFFSET (ComponentsConversationHeaderBar, full_actions));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "compact_actions", FALSE, G_STRUCT_OFFSET (ComponentsConversationHeaderBar, compact_actions));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "find_button", FALSE, ComponentsConversationHeaderBar_private_offset + G_STRUCT_OFFSET (ComponentsConversationHeaderBarPrivate, find_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "back_button", FALSE, G_STRUCT_OFFSET (ComponentsConversationHeaderBar, back_button));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "conversation_header", FALSE, ComponentsConversationHeaderBar_private_offset + G_STRUCT_OFFSET (ComponentsConversationHeaderBarPrivate, conversation_header));
}

static void
components_conversation_header_bar_instance_init (ComponentsConversationHeaderBar * self,
                                                  gpointer klass)
{
	self->priv = components_conversation_header_bar_get_instance_private (self);
	self->priv->_find_open = FALSE;
	g_type_ensure (COMPONENTS_TYPE_CONVERSATION_ACTIONS);
	g_type_ensure (COMPONENTS_TYPE_CONVERSATION_ACTIONS);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
components_conversation_header_bar_finalize (GObject * obj)
{
	ComponentsConversationHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPONENTS_TYPE_CONVERSATION_HEADER_BAR, ComponentsConversationHeaderBar);
	G_OBJECT_CLASS (components_conversation_header_bar_parent_class)->finalize (obj);
}

/**
 * The conversations headerbar.
 *
 * @see Application.MainWindow
 */
static GType
components_conversation_header_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ComponentsConversationHeaderBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) components_conversation_header_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ComponentsConversationHeaderBar), 0, (GInstanceInitFunc) components_conversation_header_bar_instance_init, NULL };
	GType components_conversation_header_bar_type_id;
	components_conversation_header_bar_type_id = g_type_register_static (gtk_bin_get_type (), "ComponentsConversationHeaderBar", &g_define_type_info, 0);
	ComponentsConversationHeaderBar_private_offset = g_type_add_instance_private (components_conversation_header_bar_type_id, sizeof (ComponentsConversationHeaderBarPrivate));
	return components_conversation_header_bar_type_id;
}

GType
components_conversation_header_bar_get_type (void)
{
	static volatile gsize components_conversation_header_bar_type_id__once = 0;
	if (g_once_init_enter (&components_conversation_header_bar_type_id__once)) {
		GType components_conversation_header_bar_type_id;
		components_conversation_header_bar_type_id = components_conversation_header_bar_get_type_once ();
		g_once_init_leave (&components_conversation_header_bar_type_id__once, components_conversation_header_bar_type_id);
	}
	return components_conversation_header_bar_type_id__once;
}

static void
_vala_components_conversation_header_bar_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec)
{
	ComponentsConversationHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, COMPONENTS_TYPE_CONVERSATION_HEADER_BAR, ComponentsConversationHeaderBar);
	switch (property_id) {
		case COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY:
		g_value_set_boolean (value, components_conversation_header_bar_get_find_open (self));
		break;
		case COMPONENTS_CONVERSATION_HEADER_BAR_SHOWN_ACTIONS_PROPERTY:
		g_value_set_object (value, components_conversation_header_bar_get_shown_actions (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_components_conversation_header_bar_set_property (GObject * object,
                                                       guint property_id,
                                                       const GValue * value,
                                                       GParamSpec * pspec)
{
	ComponentsConversationHeaderBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, COMPONENTS_TYPE_CONVERSATION_HEADER_BAR, ComponentsConversationHeaderBar);
	switch (property_id) {
		case COMPONENTS_CONVERSATION_HEADER_BAR_FIND_OPEN_PROPERTY:
		components_conversation_header_bar_set_find_open (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

