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

/*
    IGtkBuilderContainer.vala
    Copyright (C) 2010 Maia Kozheva <sikon@ubuntu.com>

    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/>.
*/

#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.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
#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

#define STEADYFLOW_UI_TYPE_IGTK_BUILDER_CONTAINER (steadyflow_ui_igtk_builder_container_get_type ())
#define STEADYFLOW_UI_IGTK_BUILDER_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STEADYFLOW_UI_TYPE_IGTK_BUILDER_CONTAINER, SteadyflowUIIGtkBuilderContainer))
#define STEADYFLOW_UI_IS_IGTK_BUILDER_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STEADYFLOW_UI_TYPE_IGTK_BUILDER_CONTAINER))
#define STEADYFLOW_UI_IGTK_BUILDER_CONTAINER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), STEADYFLOW_UI_TYPE_IGTK_BUILDER_CONTAINER, SteadyflowUIIGtkBuilderContainerIface))

typedef struct _SteadyflowUIIGtkBuilderContainer SteadyflowUIIGtkBuilderContainer;
typedef struct _SteadyflowUIIGtkBuilderContainerIface SteadyflowUIIGtkBuilderContainerIface;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _SteadyflowUIIGtkBuilderContainerIface {
	GTypeInterface parent_iface;
	GtkBuilder* (*get_builder) (SteadyflowUIIGtkBuilderContainer* self);
};

VALA_EXTERN GType steadyflow_ui_igtk_builder_container_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GtkBuilder* steadyflow_ui_igtk_builder_container_get_builder (SteadyflowUIIGtkBuilderContainer* self);
static GtkBuilder* steadyflow_ui_igtk_builder_container_resolve (const gchar* file_id,
                                                          GError** error);
VALA_EXTERN gchar* steadyflow_core_util_resolve_path (const gchar* rel_path);
VALA_EXTERN GtkBuilder* steadyflow_ui_igtk_builder_container_init_builder (SteadyflowUIIGtkBuilderContainer* self,
                                                               GtkContainer* container,
                                                               const gchar* file_id);
VALA_EXTERN void steadyflow_core_util_fatal_error (GError* e,
                                       const gchar* message);
VALA_EXTERN void steadyflow_ui_igtk_builder_container_autoconnect (SteadyflowUIIGtkBuilderContainer* self);
VALA_EXTERN GObject* steadyflow_ui_igtk_builder_container_get_object (SteadyflowUIIGtkBuilderContainer* self,
                                                          const gchar* id);
static GType steadyflow_ui_igtk_builder_container_get_type_once (void);

GtkBuilder*
steadyflow_ui_igtk_builder_container_get_builder (SteadyflowUIIGtkBuilderContainer* self)
{
	SteadyflowUIIGtkBuilderContainerIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = STEADYFLOW_UI_IGTK_BUILDER_CONTAINER_GET_INTERFACE (self);
	if (_iface_->get_builder) {
		return _iface_->get_builder (self);
	}
	return NULL;
}

static GtkBuilder*
steadyflow_ui_igtk_builder_container_resolve (const gchar* file_id,
                                              GError** error)
{
	gchar* file_name = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp6_;
	GError* _inner_error0_ = NULL;
	GtkBuilder* result;
	g_return_val_if_fail (file_id != NULL, NULL);
	_tmp0_ = g_strconcat ("ui/", file_id, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (_tmp1_, ".ui", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = steadyflow_core_util_resolve_path (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	_g_free0 (_tmp1_);
	file_name = _tmp5_;
	_tmp6_ = gtk_builder_new ();
	builder = _tmp6_;
	gtk_builder_add_from_file (builder, file_name, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (builder);
		_g_free0 (file_name);
		return NULL;
	}
	result = builder;
	_g_free0 (file_name);
	return result;
}

GtkBuilder*
steadyflow_ui_igtk_builder_container_init_builder (SteadyflowUIIGtkBuilderContainer* self,
                                                   GtkContainer* container,
                                                   const gchar* file_id)
{
	GError* _inner_error0_ = NULL;
	GtkBuilder* result;
	g_return_val_if_fail (container != NULL, NULL);
	g_return_val_if_fail (file_id != NULL, NULL);
	{
		GtkBuilder* builder = NULL;
		GtkBuilder* _tmp0_;
		GObject* _tmp1_;
		_tmp0_ = steadyflow_ui_igtk_builder_container_resolve (file_id, &_inner_error0_);
		builder = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = gtk_builder_get_object (builder, "_window_content");
		gtk_container_add (container, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
		result = builder;
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		gchar* _tmp2_;
		gchar* _tmp3_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp2_ = g_strdup_printf (_ ("Cannot find XML definition file for window %s"), file_id);
		_tmp3_ = _tmp2_;
		steadyflow_core_util_fatal_error (e, _tmp3_);
		_g_free0 (_tmp3_);
		_g_error_free0 (e);
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

void
steadyflow_ui_igtk_builder_container_autoconnect (SteadyflowUIIGtkBuilderContainer* self)
{
	GtkBuilder* _tmp0_;
	GtkBuilder* _tmp1_;
	_tmp0_ = steadyflow_ui_igtk_builder_container_get_builder (self);
	_tmp1_ = _tmp0_;
	gtk_builder_connect_signals (_tmp1_, self);
	_g_object_unref0 (_tmp1_);
}

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

GObject*
steadyflow_ui_igtk_builder_container_get_object (SteadyflowUIIGtkBuilderContainer* self,
                                                 const gchar* id)
{
	GtkBuilder* _tmp0_;
	GtkBuilder* _tmp1_;
	GObject* _tmp2_;
	GObject* _tmp3_;
	GObject* _tmp4_;
	GObject* result;
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = steadyflow_ui_igtk_builder_container_get_builder (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = gtk_builder_get_object (_tmp1_, id);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_tmp4_ = _tmp3_;
	_g_object_unref0 (_tmp1_);
	result = _tmp4_;
	return result;
}

static void
steadyflow_ui_igtk_builder_container_default_init (SteadyflowUIIGtkBuilderContainerIface * iface,
                                                   gpointer iface_data)
{
}

static GType
steadyflow_ui_igtk_builder_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SteadyflowUIIGtkBuilderContainerIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) steadyflow_ui_igtk_builder_container_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType steadyflow_ui_igtk_builder_container_type_id;
	steadyflow_ui_igtk_builder_container_type_id = g_type_register_static (G_TYPE_INTERFACE, "SteadyflowUIIGtkBuilderContainer", &g_define_type_info, 0);
	return steadyflow_ui_igtk_builder_container_type_id;
}

GType
steadyflow_ui_igtk_builder_container_get_type (void)
{
	static volatile gsize steadyflow_ui_igtk_builder_container_type_id__once = 0;
	if (g_once_init_enter (&steadyflow_ui_igtk_builder_container_type_id__once)) {
		GType steadyflow_ui_igtk_builder_container_type_id;
		steadyflow_ui_igtk_builder_container_type_id = steadyflow_ui_igtk_builder_container_get_type_once ();
		g_once_init_leave (&steadyflow_ui_igtk_builder_container_type_id__once, steadyflow_ui_igtk_builder_container_type_id);
	}
	return steadyflow_ui_igtk_builder_container_type_id__once;
}

