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

#include <glib-object.h>
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <string.h>

#define TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW (tootle_dialogs_isaved_window_get_type ())
#define TOOTLE_DIALOGS_ISAVED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW, TootleDialogsISavedWindow))
#define TOOTLE_DIALOGS_IS_ISAVED_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW))
#define TOOTLE_DIALOGS_ISAVED_WINDOW_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TOOTLE_DIALOGS_TYPE_ISAVED_WINDOW, TootleDialogsISavedWindowIface))

typedef struct _TootleDialogsISavedWindow TootleDialogsISavedWindow;
typedef struct _TootleDialogsISavedWindowIface TootleDialogsISavedWindowIface;

#define TOOTLE_TYPE_SETTINGS (tootle_settings_get_type ())
#define TOOTLE_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOOTLE_TYPE_SETTINGS, TootleSettings))
#define TOOTLE_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))
#define TOOTLE_IS_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_IS_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOOTLE_TYPE_SETTINGS))
#define TOOTLE_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOOTLE_TYPE_SETTINGS, TootleSettingsClass))

typedef struct _TootleSettings TootleSettings;
typedef struct _TootleSettingsClass TootleSettingsClass;
typedef struct _Block30Data Block30Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _TootleDialogsISavedWindowIface {
	GTypeInterface parent_iface;
};

struct _Block30Data {
	int _ref_count_;
	TootleDialogsISavedWindow* self;
	TootleSettings* settings;
};

GType tootle_dialogs_isaved_window_get_type (void) G_GNUC_CONST ;
void tootle_dialogs_isaved_window_restore_state (TootleDialogsISavedWindow* self);
GType tootle_settings_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TootleSettings, g_object_unref)
static Block30Data* block30_data_ref (Block30Data* _data30_);
static void block30_data_unref (void * _userdata_);
TootleSettings* tootle_settings_new (void);
TootleSettings* tootle_settings_construct (GType object_type);
void tootle_dialogs_isaved_window_configure_window (TootleDialogsISavedWindow* self,
                                                    TootleSettings* settings);
static gboolean __lambda4_ (Block30Data* _data30_,
                     GdkEventConfigure* ev);
gboolean tootle_dialogs_isaved_window_on_configure (TootleDialogsISavedWindow* self,
                                                    GdkEventConfigure* event,
                                                    TootleSettings* settings);
static gboolean ___lambda4__gtk_widget_configure_event (GtkWidget* _sender,
                                                 GdkEventConfigure* event,
                                                 gpointer self);
void tootle_settings_set_window_x (TootleSettings* self,
                                   gint value);
void tootle_settings_set_window_y (TootleSettings* self,
                                   gint value);
void tootle_settings_set_window_w (TootleSettings* self,
                                   gint value);
void tootle_settings_set_window_h (TootleSettings* self,
                                   gint value);
gint tootle_settings_get_window_x (TootleSettings* self);
gint tootle_settings_get_window_y (TootleSettings* self);
gint tootle_settings_get_window_w (TootleSettings* self);
gint tootle_settings_get_window_h (TootleSettings* self);
static GType tootle_dialogs_isaved_window_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static Block30Data*
block30_data_ref (Block30Data* _data30_)
{
	g_atomic_int_inc (&_data30_->_ref_count_);
	return _data30_;
}

static void
block30_data_unref (void * _userdata_)
{
	Block30Data* _data30_;
	_data30_ = (Block30Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data30_->_ref_count_)) {
		TootleDialogsISavedWindow* self;
		self = _data30_->self;
		_g_object_unref0 (_data30_->settings);
		_g_object_unref0 (self);
		g_slice_free (Block30Data, _data30_);
	}
}

static gboolean
__lambda4_ (Block30Data* _data30_,
            GdkEventConfigure* ev)
{
	TootleDialogsISavedWindow* self;
	gboolean result = FALSE;
	self = _data30_->self;
	g_return_val_if_fail (ev != NULL, FALSE);
	result = tootle_dialogs_isaved_window_on_configure (self, ev, _data30_->settings);
	return result;
}

static gboolean
___lambda4__gtk_widget_configure_event (GtkWidget* _sender,
                                        GdkEventConfigure* event,
                                        gpointer self)
{
	gboolean result;
	result = __lambda4_ (self, event);
	return result;
}

void
tootle_dialogs_isaved_window_restore_state (TootleDialogsISavedWindow* self)
{
	Block30Data* _data30_;
	TootleSettings* _tmp0_;
	_data30_ = g_slice_new0 (Block30Data);
	_data30_->_ref_count_ = 1;
	_data30_->self = g_object_ref (self);
	_tmp0_ = tootle_settings_new ();
	_data30_->settings = _tmp0_;
	tootle_dialogs_isaved_window_configure_window (self, _data30_->settings);
	g_signal_connect_data ((GtkWidget*) self, "configure-event", (GCallback) ___lambda4__gtk_widget_configure_event, block30_data_ref (_data30_), (GClosureNotify) block30_data_unref, 0);
	block30_data_unref (_data30_);
	_data30_ = NULL;
}

gboolean
tootle_dialogs_isaved_window_on_configure (TootleDialogsISavedWindow* self,
                                           GdkEventConfigure* event,
                                           TootleSettings* settings)
{
	gint x = 0;
	gint y = 0;
	gint w = 0;
	gint h = 0;
	gint _tmp0_ = 0;
	gint _tmp1_ = 0;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gboolean result = FALSE;
	g_return_val_if_fail (event != NULL, FALSE);
	g_return_val_if_fail (settings != NULL, FALSE);
	gtk_window_get_position ((GtkWindow*) self, &_tmp0_, &_tmp1_);
	x = _tmp0_;
	y = _tmp1_;
	gtk_window_get_size ((GtkWindow*) self, &_tmp2_, &_tmp3_);
	w = _tmp2_;
	h = _tmp3_;
	tootle_settings_set_window_x (settings, x);
	tootle_settings_set_window_y (settings, y);
	tootle_settings_set_window_w (settings, w);
	tootle_settings_set_window_h (settings, h);
	result = FALSE;
	return result;
}

void
tootle_dialogs_isaved_window_configure_window (TootleDialogsISavedWindow* self,
                                               TootleSettings* settings)
{
	gint x = 0;
	gint _tmp0_;
	gint _tmp1_;
	gint y = 0;
	gint _tmp2_;
	gint _tmp3_;
	gint w = 0;
	gint _tmp4_;
	gint _tmp5_;
	gint h = 0;
	gint _tmp6_;
	gint _tmp7_;
	g_return_if_fail (settings != NULL);
	_tmp0_ = tootle_settings_get_window_x (settings);
	_tmp1_ = _tmp0_;
	x = _tmp1_;
	_tmp2_ = tootle_settings_get_window_y (settings);
	_tmp3_ = _tmp2_;
	y = _tmp3_;
	_tmp4_ = tootle_settings_get_window_w (settings);
	_tmp5_ = _tmp4_;
	w = _tmp5_;
	_tmp6_ = tootle_settings_get_window_h (settings);
	_tmp7_ = _tmp6_;
	h = _tmp7_;
	if ((x + y) > 0) {
		gtk_window_move ((GtkWindow*) self, x, y);
	}
	if ((h + w) > 0) {
		g_object_set ((GtkWindow*) self, "default-width", w, NULL);
		g_object_set ((GtkWindow*) self, "default-height", h, NULL);
	}
}

static void
tootle_dialogs_isaved_window_default_init (TootleDialogsISavedWindowIface * iface,
                                           gpointer iface_data)
{
}

static GType
tootle_dialogs_isaved_window_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (TootleDialogsISavedWindowIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tootle_dialogs_isaved_window_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType tootle_dialogs_isaved_window_type_id;
	tootle_dialogs_isaved_window_type_id = g_type_register_static (G_TYPE_INTERFACE, "TootleDialogsISavedWindow", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (tootle_dialogs_isaved_window_type_id, gtk_window_get_type ());
	return tootle_dialogs_isaved_window_type_id;
}

GType
tootle_dialogs_isaved_window_get_type (void)
{
	static volatile gsize tootle_dialogs_isaved_window_type_id__volatile = 0;
	if (g_once_init_enter (&tootle_dialogs_isaved_window_type_id__volatile)) {
		GType tootle_dialogs_isaved_window_type_id;
		tootle_dialogs_isaved_window_type_id = tootle_dialogs_isaved_window_get_type_once ();
		g_once_init_leave (&tootle_dialogs_isaved_window_type_id__volatile, tootle_dialogs_isaved_window_type_id);
	}
	return tootle_dialogs_isaved_window_type_id__volatile;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

