/* SendProgressDialog.c generated by valac 0.34.4, the Vala compiler
 * generated from SendProgressDialog.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 <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include <gdk/gdk.h>


#define MOSERIAL_TYPE_SEND_PROGRESS_DIALOG (moserial_send_progress_dialog_get_type ())
#define MOSERIAL_SEND_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialog))
#define MOSERIAL_SEND_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialogClass))
#define MOSERIAL_IS_SEND_PROGRESS_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG))
#define MOSERIAL_IS_SEND_PROGRESS_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG))
#define MOSERIAL_SEND_PROGRESS_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialogClass))

typedef struct _moserialSendProgressDialog moserialSendProgressDialog;
typedef struct _moserialSendProgressDialogClass moserialSendProgressDialogClass;
typedef struct _moserialSendProgressDialogPrivate moserialSendProgressDialogPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _moserialSendProgressDialog {
	GObject parent_instance;
	moserialSendProgressDialogPrivate * priv;
};

struct _moserialSendProgressDialogClass {
	GObjectClass parent_class;
};

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


static gpointer moserial_send_progress_dialog_parent_class = NULL;

GType moserial_send_progress_dialog_get_type (void) G_GNUC_CONST;
#define MOSERIAL_SEND_PROGRESS_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialogPrivate))
enum  {
	MOSERIAL_SEND_PROGRESS_DIALOG_DUMMY_PROPERTY
};
void moserial_send_progress_dialog_show (moserialSendProgressDialog* self);
gboolean moserial_send_progress_dialog_hide (moserialSendProgressDialog* self);
void moserial_send_progress_dialog_updateStatus (moserialSendProgressDialog* self, GObject* o, const gchar* newStatus);
void moserial_send_progress_dialog_cancel (moserialSendProgressDialog* self, GObject* o);
moserialSendProgressDialog* moserial_send_progress_dialog_new (void);
moserialSendProgressDialog* moserial_send_progress_dialog_construct (GType object_type);
static GObject * moserial_send_progress_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void _moserial_send_progress_dialog_cancel_gtk_button_clicked (GtkButton* _sender, gpointer self);
static gboolean _moserial_send_progress_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self);
static void moserial_send_progress_dialog_finalize (GObject* obj);


void moserial_send_progress_dialog_show (moserialSendProgressDialog* self) {
	GtkDialog* _tmp0_ = NULL;
	GtkLabel* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->dialog;
	gtk_widget_show_all ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->status;
	_tmp2_ = _ ("Waiting for remote host");
	gtk_label_set_text (_tmp1_, _tmp2_);
}


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


void moserial_send_progress_dialog_updateStatus (moserialSendProgressDialog* self, GObject* o, const gchar* newStatus) {
	GtkLabel* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkProgressBar* _tmp2_ = NULL;
	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_send_progress_dialog_cancel (moserialSendProgressDialog* self, GObject* o) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (o != NULL);
	g_signal_emit_by_name (self, "transfer-canceled");
}


moserialSendProgressDialog* moserial_send_progress_dialog_construct (GType object_type) {
	moserialSendProgressDialog * self = NULL;
	self = (moserialSendProgressDialog*) g_object_new (object_type, NULL);
	return self;
}


moserialSendProgressDialog* moserial_send_progress_dialog_new (void) {
	return moserial_send_progress_dialog_construct (MOSERIAL_TYPE_SEND_PROGRESS_DIALOG);
}


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


static void _moserial_send_progress_dialog_cancel_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	moserial_send_progress_dialog_cancel ((moserialSendProgressDialog*) self, _sender);
}


static gboolean _moserial_send_progress_dialog_hide_gtk_widget_delete_event (GtkWidget* _sender, GdkEventAny* event, gpointer self) {
	gboolean result;
	result = moserial_send_progress_dialog_hide ((moserialSendProgressDialog*) self);
	return result;
}


static GObject * moserial_send_progress_dialog_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	moserialSendProgressDialog * self;
	GtkBuilder* builder = NULL;
	GtkBuilder* _tmp0_ = NULL;
	GtkBuilder* _tmp1_ = NULL;
	GtkBuilder* _tmp2_ = NULL;
	GObject* _tmp3_ = NULL;
	GtkDialog* _tmp4_ = NULL;
	GtkBuilder* _tmp5_ = NULL;
	GObject* _tmp6_ = NULL;
	GtkButton* _tmp7_ = NULL;
	GtkButton* _tmp8_ = NULL;
	GtkBuilder* _tmp9_ = NULL;
	GObject* _tmp10_ = NULL;
	GtkLabel* _tmp11_ = NULL;
	GtkBuilder* _tmp12_ = NULL;
	GObject* _tmp13_ = NULL;
	GtkProgressBar* _tmp14_ = NULL;
	GtkDialog* _tmp15_ = NULL;
	GError * _inner_error_ = NULL;
	parent_class = G_OBJECT_CLASS (moserial_send_progress_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialog);
	_tmp0_ = gtk_builder_new ();
	builder = _tmp0_;
	_tmp1_ = builder;
	gtk_builder_add_from_resource (_tmp1_, UIROOT "send_progress_dialog.ui", &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (builder);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
	}
	_tmp2_ = builder;
	_tmp3_ = gtk_builder_get_object (_tmp2_, "send_progress_dialog");
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_dialog_get_type (), GtkDialog));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp4_;
	_tmp5_ = builder;
	_tmp6_ = gtk_builder_get_object (_tmp5_, "send_progress_cancel");
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_button_get_type (), GtkButton));
	_g_object_unref0 (self->priv->cancelButton);
	self->priv->cancelButton = _tmp7_;
	_tmp8_ = self->priv->cancelButton;
	g_signal_connect_object (_tmp8_, "clicked", (GCallback) _moserial_send_progress_dialog_cancel_gtk_button_clicked, self, 0);
	_tmp9_ = builder;
	_tmp10_ = gtk_builder_get_object (_tmp9_, "send_statusbox");
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_label_get_type (), GtkLabel));
	_g_object_unref0 (self->priv->status);
	self->priv->status = _tmp11_;
	_tmp12_ = builder;
	_tmp13_ = gtk_builder_get_object (_tmp12_, "send_progressbar");
	_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_progress_bar_get_type (), GtkProgressBar));
	_g_object_unref0 (self->priv->progressBar);
	self->priv->progressBar = _tmp14_;
	_tmp15_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp15_, "delete-event", (GCallback) _moserial_send_progress_dialog_hide_gtk_widget_delete_event, self, 0);
	_g_object_unref0 (builder);
	return obj;
}


static void moserial_send_progress_dialog_class_init (moserialSendProgressDialogClass * klass) {
	moserial_send_progress_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (moserialSendProgressDialogPrivate));
	G_OBJECT_CLASS (klass)->constructor = moserial_send_progress_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = moserial_send_progress_dialog_finalize;
	g_signal_new ("transfer_canceled", MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}


static void moserial_send_progress_dialog_instance_init (moserialSendProgressDialog * self) {
	self->priv = MOSERIAL_SEND_PROGRESS_DIALOG_GET_PRIVATE (self);
}


static void moserial_send_progress_dialog_finalize (GObject* obj) {
	moserialSendProgressDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, MOSERIAL_TYPE_SEND_PROGRESS_DIALOG, moserialSendProgressDialog);
	_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_send_progress_dialog_parent_class)->finalize (obj);
}


GType moserial_send_progress_dialog_get_type (void) {
	static volatile gsize moserial_send_progress_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&moserial_send_progress_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (moserialSendProgressDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) moserial_send_progress_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (moserialSendProgressDialog), 0, (GInstanceInitFunc) moserial_send_progress_dialog_instance_init, NULL };
		GType moserial_send_progress_dialog_type_id;
		moserial_send_progress_dialog_type_id = g_type_register_static (G_TYPE_OBJECT, "moserialSendProgressDialog", &g_define_type_info, 0);
		g_once_init_leave (&moserial_send_progress_dialog_type_id__volatile, moserial_send_progress_dialog_type_id);
	}
	return moserial_send_progress_dialog_type_id__volatile;
}



