/* XmodemFilenameDialog.c generated by valac 0.38.4, 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.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <config.h>
#include <gdk/gdk.h>


#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 gpointer moserial_xmodem_filename_dialog_parent_class = NULL;

GType moserial_xmodem_filename_dialog_get_type (void) G_GNUC_CONST;
#define MOSERIAL_XMODEM_FILENAME_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialogPrivate))
void moserial_xmodem_filename_dialog_show (moserialXmodemFilenameDialog* self);
gboolean moserial_xmodem_filename_dialog_hide (moserialXmodemFilenameDialog* self);
static void moserial_xmodem_filename_dialog_response (moserialXmodemFilenameDialog* self, GtkWidget* w, gint r);
moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_new (void);
moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_construct (GType object_type);
static GObject * moserial_xmodem_filename_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static gboolean _moserial_xmodem_filename_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static void _moserial_xmodem_filename_dialog_response_gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
static void moserial_xmodem_filename_dialog_finalize (GObject * obj);


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) {
	gboolean result = FALSE;
	GtkDialog* _tmp0_;
	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_;
	}
}


moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_construct (GType object_type) {
	moserialXmodemFilenameDialog * self = NULL;
	self = (moserialXmodemFilenameDialog*) g_object_new (object_type, NULL);
	return self;
}


moserialXmodemFilenameDialog* moserial_xmodem_filename_dialog_new (void) {
	return moserial_xmodem_filename_dialog_construct (MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG);
}


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);
}


static GObject * moserial_xmodem_filename_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	moserialXmodemFilenameDialog * self;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	GtkBuilder* _tmp1_;
	GObject* _tmp2_;
	GtkDialog* _tmp3_;
	GtkBuilder* _tmp4_;
	GObject* _tmp5_;
	GtkEntry* _tmp6_;
	GtkDialog* _tmp7_;
	GtkDialog* _tmp8_;
	parent_class = G_OBJECT_CLASS (moserial_xmodem_filename_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_XMODEM_FILENAME_DIALOG, moserialXmodemFilenameDialog);
	_tmp0_ = gtk_builder_new_from_resource (UIROOT "xmodem_filename_dialog.ui");
	builder = _tmp0_;
	_tmp1_ = builder;
	_tmp2_ = gtk_builder_get_object (_tmp1_, "xmodem_filename_dialog");
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_dialog_get_type (), GtkDialog));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp3_;
	_tmp4_ = builder;
	_tmp5_ = gtk_builder_get_object (_tmp4_, "xmodem_filename");
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_entry_get_type (), GtkEntry));
	_g_object_unref0 (self->priv->xmodemFilename);
	self->priv->xmodemFilename = _tmp6_;
	_tmp7_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp7_, "delete-event", (GCallback) _moserial_xmodem_filename_dialog_hide_gtk_widget_delete_event, self, 0);
	_tmp8_ = self->priv->dialog;
	g_signal_connect_object (_tmp8_, "response", (GCallback) _moserial_xmodem_filename_dialog_response_gtk_dialog_response, self, 0);
	_g_object_unref0 (builder);
	return obj;
}


static void moserial_xmodem_filename_dialog_class_init (moserialXmodemFilenameDialogClass * klass) {
	moserial_xmodem_filename_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (moserialXmodemFilenameDialogPrivate));
	G_OBJECT_CLASS (klass)->constructor = moserial_xmodem_filename_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = moserial_xmodem_filename_dialog_finalize;
}


static void moserial_xmodem_filename_dialog_instance_init (moserialXmodemFilenameDialog * self) {
	self->priv = MOSERIAL_XMODEM_FILENAME_DIALOG_GET_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);
}


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)) {
		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);
		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;
}



