/* ReceiveProgressDialog.c generated by valac 0.38.4, the Vala compiler
 * generated from ReceiveProgressDialog.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 <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include <gdk/gdk.h>


#define MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG (moserial_receive_progress_dialog_get_type ())
#define MOSERIAL_RECEIVE_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialog))
#define MOSERIAL_RECEIVE_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialogClass))
#define MOSERIAL_IS_RECEIVE_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG))
#define MOSERIAL_IS_RECEIVE_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG))
#define MOSERIAL_RECEIVE_PROGRESS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialogClass))

typedef struct _moserialReceiveProgressDialog moserialReceiveProgressDialog;
typedef struct _moserialReceiveProgressDialogClass moserialReceiveProgressDialogClass;
typedef struct _moserialReceiveProgressDialogPrivate moserialReceiveProgressDialogPrivate;
enum  {
	MOSERIAL_RECEIVE_PROGRESS_DIALOG_0_PROPERTY,
	MOSERIAL_RECEIVE_PROGRESS_DIALOG_NUM_PROPERTIES
};
static GParamSpec* moserial_receive_progress_dialog_properties[MOSERIAL_RECEIVE_PROGRESS_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	MOSERIAL_RECEIVE_PROGRESS_DIALOG_TRANSFER_CANCELED_SIGNAL,
	MOSERIAL_RECEIVE_PROGRESS_DIALOG_NUM_SIGNALS
};
static guint moserial_receive_progress_dialog_signals[MOSERIAL_RECEIVE_PROGRESS_DIALOG_NUM_SIGNALS] = {0};

struct _moserialReceiveProgressDialog {
	GObject parent_instance;
	moserialReceiveProgressDialogPrivate * priv;
};

struct _moserialReceiveProgressDialogClass {
	GObjectClass parent_class;
};

struct _moserialReceiveProgressDialogPrivate {
	GtkDialog* dialog;
	GtkButton* cancelButton;
	GtkLabel* status;
	GtkProgressBar* progressBar;
};


static gpointer moserial_receive_progress_dialog_parent_class = NULL;

GType moserial_receive_progress_dialog_get_type (void) G_GNUC_CONST;
#define MOSERIAL_RECEIVE_PROGRESS_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialogPrivate))
void moserial_receive_progress_dialog_show (moserialReceiveProgressDialog* self);
gboolean moserial_receive_progress_dialog_hide (moserialReceiveProgressDialog* self);
void moserial_receive_progress_dialog_updateStatus (moserialReceiveProgressDialog* self, GObject* o, const gchar* newStatus);
void moserial_receive_progress_dialog_cancel (moserialReceiveProgressDialog* self, GObject* o);
moserialReceiveProgressDialog* moserial_receive_progress_dialog_new (void);
moserialReceiveProgressDialog* moserial_receive_progress_dialog_construct (GType object_type);
static GObject * moserial_receive_progress_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _moserial_receive_progress_dialog_cancel_gtk_button_clicked (GtkButton* _sender, gpointer self);
static gboolean _moserial_receive_progress_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static void moserial_receive_progress_dialog_finalize (GObject * obj);


void moserial_receive_progress_dialog_show (moserialReceiveProgressDialog* self) {
	GtkDialog* _tmp0_;
	GtkLabel* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->dialog;
	gtk_widget_show_all ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->status;
	gtk_label_set_text (_tmp1_, "");
}


gboolean moserial_receive_progress_dialog_hide (moserialReceiveProgressDialog* 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;
}


void moserial_receive_progress_dialog_updateStatus (moserialReceiveProgressDialog* self, GObject* o, const gchar* newStatus) {
	GtkLabel* _tmp0_;
	const gchar* _tmp1_;
	GtkProgressBar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (o != NULL);
	g_return_if_fail (newStatus != NULL);
	_tmp0_ = self->priv->status;
	_tmp1_ = newStatus;
	gtk_label_set_text (_tmp0_, _tmp1_);
	_tmp2_ = self->priv->progressBar;
	gtk_progress_bar_pulse (_tmp2_);
}


void moserial_receive_progress_dialog_cancel (moserialReceiveProgressDialog* self, GObject* o) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (o != NULL);
	g_signal_emit (self, moserial_receive_progress_dialog_signals[MOSERIAL_RECEIVE_PROGRESS_DIALOG_TRANSFER_CANCELED_SIGNAL], 0);
}


moserialReceiveProgressDialog* moserial_receive_progress_dialog_construct (GType object_type) {
	moserialReceiveProgressDialog * self = NULL;
	self = (moserialReceiveProgressDialog*) g_object_new (object_type, NULL);
	return self;
}


moserialReceiveProgressDialog* moserial_receive_progress_dialog_new (void) {
	return moserial_receive_progress_dialog_construct (MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG);
}


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


static void _moserial_receive_progress_dialog_cancel_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	moserial_receive_progress_dialog_cancel ((moserialReceiveProgressDialog*) self, _sender);
}


static gboolean _moserial_receive_progress_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self) {
	gboolean result;
	result = moserial_receive_progress_dialog_hide ((moserialReceiveProgressDialog*) self);
	return result;
}


static GObject * moserial_receive_progress_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	moserialReceiveProgressDialog * self;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_;
	GtkBuilder* _tmp1_;
	GObject* _tmp2_;
	GtkDialog* _tmp3_;
	GtkBuilder* _tmp4_;
	GObject* _tmp5_;
	GtkButton* _tmp6_;
	GtkButton* _tmp7_;
	GtkBuilder* _tmp8_;
	GObject* _tmp9_;
	GtkLabel* _tmp10_;
	GtkBuilder* _tmp11_;
	GObject* _tmp12_;
	GtkProgressBar* _tmp13_;
	GtkDialog* _tmp14_;
	parent_class = G_OBJECT_CLASS (moserial_receive_progress_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialog);
	_tmp0_ = gtk_builder_new_from_resource (UIROOT "receive_progress.ui");
	builder = _tmp0_;
	_tmp1_ = builder;
	_tmp2_ = gtk_builder_get_object (_tmp1_, "receive_progress_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_, "receive_progress_cancel");
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->cancelButton);
	self->priv->cancelButton = _tmp6_;
	_tmp7_ = self->priv->cancelButton;
	g_signal_connect_object (_tmp7_, "clicked", (GCallback) _moserial_receive_progress_dialog_cancel_gtk_button_clicked, self, 0);
	_tmp8_ = builder;
	_tmp9_ = gtk_builder_get_object (_tmp8_, "receive_statusbox");
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_label_get_type (), GtkLabel));
	_g_object_unref0 (self->priv->status);
	self->priv->status = _tmp10_;
	_tmp11_ = builder;
	_tmp12_ = gtk_builder_get_object (_tmp11_, "receive_progressbar");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_progress_bar_get_type (), GtkProgressBar));
	_g_object_unref0 (self->priv->progressBar);
	self->priv->progressBar = _tmp13_;
	_tmp14_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp14_, "delete-event", (GCallback) _moserial_receive_progress_dialog_hide_gtk_widget_delete_event, self, 0);
	_g_object_unref0 (builder);
	return obj;
}


static void moserial_receive_progress_dialog_class_init (moserialReceiveProgressDialogClass * klass) {
	moserial_receive_progress_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (moserialReceiveProgressDialogPrivate));
	G_OBJECT_CLASS (klass)->constructor = moserial_receive_progress_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = moserial_receive_progress_dialog_finalize;
	moserial_receive_progress_dialog_signals[MOSERIAL_RECEIVE_PROGRESS_DIALOG_TRANSFER_CANCELED_SIGNAL] = g_signal_new ("transfer-canceled", MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void moserial_receive_progress_dialog_instance_init (moserialReceiveProgressDialog * self) {
	self->priv = MOSERIAL_RECEIVE_PROGRESS_DIALOG_GET_PRIVATE (self);
}


static void moserial_receive_progress_dialog_finalize (GObject * obj) {
	moserialReceiveProgressDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_RECEIVE_PROGRESS_DIALOG, moserialReceiveProgressDialog);
	_g_object_unref0 (self->priv->dialog);
	_g_object_unref0 (self->priv->cancelButton);
	_g_object_unref0 (self->priv->status);
	_g_object_unref0 (self->priv->progressBar);
	G_OBJECT_CLASS (moserial_receive_progress_dialog_parent_class)->finalize (obj);
}


GType moserial_receive_progress_dialog_get_type (void) {
	static volatile gsize moserial_receive_progress_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&moserial_receive_progress_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (moserialReceiveProgressDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) moserial_receive_progress_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (moserialReceiveProgressDialog), 0, (GInstanceInitFunc) moserial_receive_progress_dialog_instance_init, NULL };
		GType moserial_receive_progress_dialog_type_id;
		moserial_receive_progress_dialog_type_id = g_type_register_static (G_TYPE_OBJECT, "moserialReceiveProgressDialog", &g_define_type_info, 0);
		g_once_init_leave (&moserial_receive_progress_dialog_type_id__volatile, moserial_receive_progress_dialog_type_id);
	}
	return moserial_receive_progress_dialog_type_id__volatile;
}



