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

/*
 * Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2019 Michael Gratton <mike@vee.net>
 *
 * 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-46.0.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <handy.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  {
	COMPOSER_BOX_0_PROPERTY,
	COMPOSER_BOX_NUM_PROPERTIES
};
static GParamSpec* composer_box_properties[COMPOSER_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	COMPOSER_BOX_VANISHED_SIGNAL,
	COMPOSER_BOX_NUM_SIGNALS
};
static guint composer_box_signals[COMPOSER_BOX_NUM_SIGNALS] = {0};

struct _ComposerBoxPrivate {
	ComposerWidget* _composer;
	ComponentsConversationHeaderBar* _headerbar;
};

static gint ComposerBox_private_offset;
static gpointer composer_box_parent_class = NULL;
static ComposerContainerIface * composer_box_composer_container_parent_iface = NULL;

static ComponentsConversationHeaderBar* composer_box_get_headerbar (ComposerBox* self);
static void composer_box_set_headerbar (ComposerBox* self,
                                 ComponentsConversationHeaderBar* value);
VALA_EXTERN void composer_container_set_composer (ComposerContainer* self,
                                      ComposerWidget* value);
VALA_EXTERN ComposerWidget* composer_container_get_composer (ComposerContainer* self);
VALA_EXTERN void composer_widget_set_mode (ComposerWidget* self,
                               ComposerWidgetPresentationMode new_mode);
VALA_EXTERN ComposerHeaderbar* composer_widget_get_header (ComposerWidget* self);
static void composer_box_real_close (ComposerContainer* base);
static void composer_box_finalize (GObject * obj);
static GType composer_box_get_type_once (void);
static void _vala_composer_box_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_composer_box_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);

static inline gpointer
composer_box_get_instance_private (ComposerBox* self)
{
	return G_STRUCT_MEMBER_P (self, ComposerBox_private_offset);
}

static GtkApplicationWindow*
composer_box_real_get_top_window (ComposerContainer* base)
{
	GtkApplicationWindow* result;
	ComposerBox* self;
	GtkWidget* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, COMPOSER_TYPE_BOX, ComposerBox);
	_tmp0_ = gtk_widget_get_toplevel (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_application_window_get_type ()) ? ((GtkApplicationWindow*) _tmp0_) : NULL;
	return result;
}

static ComposerWidget*
composer_box_real_get_composer (ComposerContainer* base)
{
	ComposerWidget* result;
	ComposerBox* self;
	ComposerWidget* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, COMPOSER_TYPE_BOX, ComposerBox);
	_tmp0_ = self->priv->_composer;
	result = _tmp0_;
	return result;
}

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

static void
composer_box_real_set_composer (ComposerContainer* base,
                                ComposerWidget* value)
{
	ComposerBox* self;
	ComposerWidget* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, COMPOSER_TYPE_BOX, ComposerBox);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_composer);
	self->priv->_composer = _tmp0_;
}

static ComponentsConversationHeaderBar*
composer_box_get_headerbar (ComposerBox* self)
{
	ComponentsConversationHeaderBar* result;
	ComponentsConversationHeaderBar* _tmp0_;
	g_return_val_if_fail (COMPOSER_IS_BOX (self), NULL);
	_tmp0_ = self->priv->_headerbar;
	result = _tmp0_;
	return result;
}

static void
composer_box_set_headerbar (ComposerBox* self,
                            ComponentsConversationHeaderBar* value)
{
	ComponentsConversationHeaderBar* _tmp0_;
	g_return_if_fail (COMPOSER_IS_BOX (self));
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_headerbar);
	self->priv->_headerbar = _tmp0_;
}

ComposerBox*
composer_box_construct (GType object_type,
                        ComposerWidget* composer,
                        ComponentsConversationHeaderBar* headerbar)
{
	ComposerBox * self = NULL;
	ComposerWidget* _tmp0_;
	ComposerWidget* _tmp1_;
	ComponentsConversationHeaderBar* _tmp2_;
	ComposerHeaderbar* _tmp3_;
	ComposerHeaderbar* _tmp4_;
	GtkStyleContext* _tmp5_;
	ComposerWidget* _tmp6_;
	ComposerWidget* _tmp7_;
	g_return_val_if_fail (COMPOSER_IS_WIDGET (composer), NULL);
	g_return_val_if_fail (COMPONENTS_IS_CONVERSATION_HEADER_BAR (headerbar), NULL);
	self = (ComposerBox*) g_object_new (object_type, NULL);
	composer_container_set_composer (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_CONTAINER, ComposerContainer), composer);
	_tmp0_ = composer_container_get_composer (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_CONTAINER, ComposerContainer));
	_tmp1_ = _tmp0_;
	composer_widget_set_mode (_tmp1_, COMPOSER_WIDGET_PRESENTATION_MODE_PANED);
	composer_box_set_headerbar (self, headerbar);
	_tmp2_ = self->priv->_headerbar;
	_tmp3_ = composer_widget_get_header (composer);
	_tmp4_ = _tmp3_;
	components_conversation_header_bar_set_conversation_header (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, hdy_header_bar_get_type (), HdyHeaderBar));
	_tmp5_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	gtk_style_context_add_class (_tmp5_, "geary-composer-box");
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_FILL);
	gtk_widget_set_vexpand (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), TRUE);
	gtk_widget_set_vexpand_set (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), TRUE);
	_tmp6_ = composer_container_get_composer (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_CONTAINER, ComposerContainer));
	_tmp7_ = _tmp6_;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	return self;
}

ComposerBox*
composer_box_new (ComposerWidget* composer,
                  ComponentsConversationHeaderBar* headerbar)
{
	return composer_box_construct (COMPOSER_TYPE_BOX, composer, headerbar);
}

/** {@inheritDoc} */
static void
composer_box_real_close (ComposerContainer* base)
{
	ComposerBox * self;
	ComponentsConversationHeaderBar* _tmp0_;
	ComposerWidget* _tmp1_;
	ComposerWidget* _tmp2_;
	ComposerHeaderbar* _tmp3_;
	ComposerHeaderbar* _tmp4_;
	ComposerWidget* _tmp5_;
	ComposerWidget* _tmp6_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, COMPOSER_TYPE_BOX, ComposerBox);
	g_signal_emit (self, composer_box_signals[COMPOSER_BOX_VANISHED_SIGNAL], 0);
	_tmp0_ = self->priv->_headerbar;
	_tmp1_ = composer_container_get_composer (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_CONTAINER, ComposerContainer));
	_tmp2_ = _tmp1_;
	_tmp3_ = composer_widget_get_header (_tmp2_);
	_tmp4_ = _tmp3_;
	components_conversation_header_bar_remove_conversation_header (_tmp0_, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, hdy_header_bar_get_type (), HdyHeaderBar));
	_tmp5_ = composer_container_get_composer (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_CONTAINER, ComposerContainer));
	_tmp6_ = _tmp5_;
	gtk_container_remove (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_destroy (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

static void
composer_box_class_init (ComposerBoxClass * klass,
                         gpointer klass_data)
{
	composer_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ComposerBox_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_composer_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_composer_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = composer_box_finalize;
	/** Emitted when the container is closed. */
	composer_box_signals[COMPOSER_BOX_VANISHED_SIGNAL] = g_signal_new ("vanished", COMPOSER_TYPE_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	gtk_widget_class_set_css_name (GTK_WIDGET_CLASS (klass), "geary-composer-box");
}

static void
composer_box_composer_container_interface_init (ComposerContainerIface * iface,
                                                gpointer iface_data)
{
	composer_box_composer_container_parent_iface = g_type_interface_peek_parent (iface);
	iface->close = (void (*) (ComposerContainer*)) composer_box_real_close;
	iface->get_top_window = composer_box_real_get_top_window;
	iface->get_composer = composer_box_real_get_composer;
	iface->set_composer = composer_box_real_set_composer;
}

static void
composer_box_instance_init (ComposerBox * self,
                            gpointer klass)
{
	self->priv = composer_box_get_instance_private (self);
}

static void
composer_box_finalize (GObject * obj)
{
	ComposerBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, COMPOSER_TYPE_BOX, ComposerBox);
	_g_object_unref0 (self->priv->_composer);
	_g_object_unref0 (self->priv->_headerbar);
	G_OBJECT_CLASS (composer_box_parent_class)->finalize (obj);
}

/**
 * A container for full-height paned composers in the main window.
 *
 * Adding a composer to this container places it in {@link
 * Widget.PresentationMode.PANED} mode.
 */
static GType
composer_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ComposerBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) composer_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ComposerBox), 0, (GInstanceInitFunc) composer_box_instance_init, NULL };
	static const GInterfaceInfo composer_container_info = { (GInterfaceInitFunc) composer_box_composer_container_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType composer_box_type_id;
	composer_box_type_id = g_type_register_static (gtk_frame_get_type (), "ComposerBox", &g_define_type_info, 0);
	g_type_add_interface_static (composer_box_type_id, COMPOSER_TYPE_CONTAINER, &composer_container_info);
	ComposerBox_private_offset = g_type_add_instance_private (composer_box_type_id, sizeof (ComposerBoxPrivate));
	return composer_box_type_id;
}

GType
composer_box_get_type (void)
{
	static volatile gsize composer_box_type_id__once = 0;
	if (g_once_init_enter (&composer_box_type_id__once)) {
		GType composer_box_type_id;
		composer_box_type_id = composer_box_get_type_once ();
		g_once_init_leave (&composer_box_type_id__once, composer_box_type_id);
	}
	return composer_box_type_id__once;
}

static void
_vala_composer_box_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	ComposerBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, COMPOSER_TYPE_BOX, ComposerBox);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_composer_box_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	ComposerBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, COMPOSER_TYPE_BOX, ComposerBox);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

