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

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * 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 <gtk/gtk.h>

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

VALA_EXTERN ComposerWidget* composer_container_get_composer (ComposerContainer* self);
VALA_EXTERN void composer_container_set_composer (ComposerContainer* self,
                                      ComposerWidget* value);
static void composer_container_real_present (ComposerContainer* self);
static GtkWidget* composer_container_real_get_focus (ComposerContainer* self);
static GType composer_container_get_type_once (void);

GtkApplicationWindow*
composer_container_get_top_window (ComposerContainer* self)
{
	ComposerContainerIface* _iface_;
	g_return_val_if_fail (COMPOSER_IS_CONTAINER (self), NULL);
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->get_top_window) {
		return _iface_->get_top_window (self);
	}
	return NULL;
}

ComposerWidget*
composer_container_get_composer (ComposerContainer* self)
{
	ComposerContainerIface* _iface_;
	g_return_val_if_fail (COMPOSER_IS_CONTAINER (self), NULL);
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->get_composer) {
		return _iface_->get_composer (self);
	}
	return NULL;
}

void
composer_container_set_composer (ComposerContainer* self,
                                 ComposerWidget* value)
{
	ComposerContainerIface* _iface_;
	g_return_if_fail (COMPOSER_IS_CONTAINER (self));
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->set_composer) {
		_iface_->set_composer (self, value);
	}
}

/** Causes the composer's top-level window to be presented. */
static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
composer_container_real_present (ComposerContainer* self)
{
	GtkApplicationWindow* top = NULL;
	GtkApplicationWindow* _tmp0_;
	GtkApplicationWindow* _tmp1_;
	GtkApplicationWindow* _tmp2_;
	GtkApplicationWindow* _tmp3_;
	_tmp0_ = composer_container_get_top_window (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	top = _tmp2_;
	_tmp3_ = top;
	if (_tmp3_ != NULL) {
		GtkApplicationWindow* _tmp4_;
		_tmp4_ = top;
		gtk_window_present (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_window_get_type (), GtkWindow));
	}
	_g_object_unref0 (top);
}

void
composer_container_present (ComposerContainer* self)
{
	ComposerContainerIface* _iface_;
	g_return_if_fail (COMPOSER_IS_CONTAINER (self));
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->present) {
		_iface_->present (self);
	}
}

/** Returns the top-level window's current focus widget, if any. */
static GtkWidget*
composer_container_real_get_focus (ComposerContainer* self)
{
	GtkWidget* focus = NULL;
	GtkApplicationWindow* top = NULL;
	GtkApplicationWindow* _tmp0_;
	GtkApplicationWindow* _tmp1_;
	GtkApplicationWindow* _tmp2_;
	GtkApplicationWindow* _tmp3_;
	GtkWidget* result;
	focus = NULL;
	_tmp0_ = composer_container_get_top_window (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	top = _tmp2_;
	_tmp3_ = top;
	if (_tmp3_ != NULL) {
		GtkApplicationWindow* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		_tmp4_ = top;
		_tmp5_ = gtk_window_get_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_window_get_type (), GtkWindow));
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_g_object_unref0 (focus);
		focus = _tmp6_;
	}
	result = focus;
	_g_object_unref0 (top);
	return result;
}

GtkWidget*
composer_container_get_focus (ComposerContainer* self)
{
	ComposerContainerIface* _iface_;
	g_return_val_if_fail (COMPOSER_IS_CONTAINER (self), NULL);
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->get_focus) {
		return _iface_->get_focus (self);
	}
	return NULL;
}

/**
     * Removes the composer and destroys the container.
     */
void
composer_container_close (ComposerContainer* self)
{
	ComposerContainerIface* _iface_;
	g_return_if_fail (COMPOSER_IS_CONTAINER (self));
	_iface_ = COMPOSER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->close) {
		_iface_->close (self);
	}
}

static void
composer_container_default_init (ComposerContainerIface * iface,
                                 gpointer iface_data)
{
	iface->present = composer_container_real_present;
	iface->get_focus = composer_container_real_get_focus;
}

/**
 * A generic interface for widgets that have a single composer child.
 */
static GType
composer_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ComposerContainerIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) composer_container_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType composer_container_type_id;
	composer_container_type_id = g_type_register_static (G_TYPE_INTERFACE, "ComposerContainer", &g_define_type_info, 0);
	return composer_container_type_id;
}

GType
composer_container_get_type (void)
{
	static volatile gsize composer_container_type_id__once = 0;
	if (g_once_init_enter (&composer_container_type_id__once)) {
		GType composer_container_type_id;
		composer_container_type_id = composer_container_get_type_once ();
		g_once_init_leave (&composer_container_type_id__once, composer_container_type_id);
	}
	return composer_container_type_id__once;
}

