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

/*
 *  Copyright (C) 2009-2010 Michael J. Chudobiak.
 *
 *  This file is part of moserial.
 *
 *  moserial 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.
 *
 *  moserial 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 moserial.  If not, see <http://www.gnu.org/licenses/>.
 */

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

#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 MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG (moserial_xmodem_filename_dialog_get_type ())
#define MOSERIAL_XMODEM_FILENAME_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialog))
#define MOSERIAL_XMODEM_FILENAME_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialogClass))
#define MOSERIAL_IS_XMODEM_FILENAME_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG))
#define MOSERIAL_IS_XMODEM_FILENAME_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG))
#define MOSERIAL_XMODEM_FILENAME_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialogClass))

typedef struct _moserialXmodemFilenameDialog moserialXmodemFilenameDialog;
typedef struct _moserialXmodemFilenameDialogClass moserialXmodemFilenameDialogClass;
typedef struct _moserialXmodemFilenameDialogPrivate moserialXmodemFilenameDialogPrivate;
enum  {
	MOSERIAL_XMODEM_FILENAME_DIALOG_0_PROPERTY,
	MOSERIAL_XMODEM_FILENAME_DIALOG_NUM_PROPERTIES
};
static GParamSpec* moserial_xmodem_filename_dialog_properties[MOSERIAL_XMODEM_FILENAME_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _moserialXmodemFilenameDialog {
	GObject parent_instance;
	moserialXmodemFilenameDialogPrivate * priv;
	gchar* filename;
};

struct _moserialXmodemFilenameDialogClass {
	GObjectClass parent_class;
};

struct _moserialXmodemFilenameDialogPrivate {
	GtkDialog* dialog;
	GtkEntry* xmodemFilename;
};

static gint moserialXmodemFilenameDialog_private_offset;
static gpointer moserial_xmodem_filename_dialog_parent_class = NULL;

VALA_EXTERN GType moserial_xmodem_filename_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (moserialXmodemFilenameDialog, g_object_unref)
VALA_EXTERN moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_new (GtkWindow* parent);
VALA_EXTERN moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_construct (GType object_type,
                                                                         GtkWindow* parent);
VALA_EXTERN gboolean moserial_xmodem_filename_dialog_hide (moserialXmodemFilenameDialog* self);
static gboolean _moserial_xmodem_filename_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender,
                                                                        GdkEventAny* event,
                                                                        gpointer self);
static void moserial_xmodem_filename_dialog_response (moserialXmodemFilenameDialog* self,
                                               GtkWidget* w,
                                               gint r);
static void _moserial_xmodem_filename_dialog_response_gtk_dialog_response (GtkDialog* _sender,
                                                                    gint response_id,
                                                                    gpointer self);
VALA_EXTERN void moserial_xmodem_filename_dialog_show (moserialXmodemFilenameDialog* self);
static void moserial_xmodem_filename_dialog_finalize (GObject * obj);
static GType moserial_xmodem_filename_dialog_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
moserial_xmodem_filename_dialog_get_instance_private (moserialXmodemFilenameDialog* self)
{
	return G_STRUCT_MEMBER_P (self, moserialXmodemFilenameDialog_private_offset);
}

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

static gboolean
_moserial_xmodem_filename_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender,
                                                               GdkEventAny* event,
                                                               gpointer self)
{
	gboolean result;
	result = moserial_xmodem_filename_dialog_hide ((moserialXmodemFilenameDialog*) self);
	return result;
}

static void
_moserial_xmodem_filename_dialog_response_gtk_dialog_response (GtkDialog* _sender,
                                                               gint response_id,
                                                               gpointer self)
{
	moserial_xmodem_filename_dialog_response ((moserialXmodemFilenameDialog*) self, _sender, response_id);
}

moserialXmodemFilenameDialog*
moserial_xmodem_filename_dialog_construct (GType object_type,
                                           GtkWindow* parent)
{
	moserialXmodemFilenameDialog * self = NULL;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	GObject* _tmp1_;
	GtkDialog* _tmp2_;
	GtkDialog* _tmp3_;
	GObject* _tmp4_;
	GtkEntry* _tmp5_;
	GtkDialog* _tmp6_;
	GtkDialog* _tmp7_;
	g_return_val_if_fail (parent != NULL, NULL);
	self = (moserialXmodemFilenameDialog*) g_object_new (object_type, NULL);
	_tmp0_ = gtk_builder_new_from_resource (UIROOT "xmodem_filename_dialog.ui");
	builder = _tmp0_;
	_tmp1_ = gtk_builder_get_object (builder, "xmodem_filename_dialog");
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_dialog_get_type (), GtkDialog));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp2_;
	_tmp3_ = self->priv->dialog;
	gtk_window_set_transient_for ((GtkWindow*) _tmp3_, parent);
	_tmp4_ = gtk_builder_get_object (builder, "xmodem_filename");
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_entry_get_type (), GtkEntry));
	_g_object_unref0 (self->priv->xmodemFilename);
	self->priv->xmodemFilename = _tmp5_;
	_tmp6_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp6_, "delete-event", (GCallback) _moserial_xmodem_filename_dialog_hide_gtk_widget_delete_event, self, 0);
	_tmp7_ = self->priv->dialog;
	g_signal_connect_object (_tmp7_, "response", (GCallback) _moserial_xmodem_filename_dialog_response_gtk_dialog_response, self, 0);
	_g_object_unref0 (builder);
	return self;
}

moserialXmodemFilenameDialog*
moserial_xmodem_filename_dialog_new (GtkWindow* parent)
{
	return moserial_xmodem_filename_dialog_construct (MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, parent);
}

void
moserial_xmodem_filename_dialog_show (moserialXmodemFilenameDialog* self)
{
	GtkDialog* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->dialog;
	gtk_dialog_run (_tmp0_);
}

gboolean
moserial_xmodem_filename_dialog_hide (moserialXmodemFilenameDialog* self)
{
	GtkDialog* _tmp0_;
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
	result = TRUE;
	return result;
}

static void
moserial_xmodem_filename_dialog_response (moserialXmodemFilenameDialog* self,
                                          GtkWidget* w,
                                          gint r)
{
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (w != NULL);
	_tmp0_ = self->priv->xmodemFilename;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	_g_free0 (self->filename);
	self->filename = _tmp2_;
	moserial_xmodem_filename_dialog_hide (self);
	_tmp3_ = self->filename;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("xmodem.file");
		_g_free0 (self->filename);
		self->filename = _tmp4_;
	}
}

static void
moserial_xmodem_filename_dialog_class_init (moserialXmodemFilenameDialogClass * klass,
                                            gpointer klass_data)
{
	moserial_xmodem_filename_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &moserialXmodemFilenameDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = moserial_xmodem_filename_dialog_finalize;
}

static void
moserial_xmodem_filename_dialog_instance_init (moserialXmodemFilenameDialog * self,
                                               gpointer klass)
{
	self->priv = moserial_xmodem_filename_dialog_get_instance_private (self);
}

static void
moserial_xmodem_filename_dialog_finalize (GObject * obj)
{
	moserialXmodemFilenameDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialog);
	_g_object_unref0 (self->priv->dialog);
	_g_object_unref0 (self->priv->xmodemFilename);
	_g_free0 (self->filename);
	G_OBJECT_CLASS (moserial_xmodem_filename_dialog_parent_class)->finalize (obj);
}

static GType
moserial_xmodem_filename_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (moserialXmodemFilenameDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) moserial_xmodem_filename_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (moserialXmodemFilenameDialog), 0, (GInstanceInitFunc) moserial_xmodem_filename_dialog_instance_init, NULL };
	GType moserial_xmodem_filename_dialog_type_id;
	moserial_xmodem_filename_dialog_type_id = g_type_register_static (G_TYPE_OBJECT, "moserialXmodemFilenameDialog", &g_define_type_info, 0);
	moserialXmodemFilenameDialog_private_offset = g_type_add_instance_private (moserial_xmodem_filename_dialog_type_id, sizeof (moserialXmodemFilenameDialogPrivate));
	return moserial_xmodem_filename_dialog_type_id;
}

GType
moserial_xmodem_filename_dialog_get_type (void)
{
	static volatile gsize moserial_xmodem_filename_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&moserial_xmodem_filename_dialog_type_id__volatile)) {
		GType moserial_xmodem_filename_dialog_type_id;
		moserial_xmodem_filename_dialog_type_id = moserial_xmodem_filename_dialog_get_type_once ();
		g_once_init_leave (&moserial_xmodem_filename_dialog_type_id__volatile, moserial_xmodem_filename_dialog_type_id);
	}
	return moserial_xmodem_filename_dialog_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;
}

