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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 2 -*- */
/*
    This file is part of Déjà Dup.
    © 2009 Michael Terry <mike@mterry.name>

    Déjà Dup 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.

    Déjà Dup 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 Déjà Dup.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>


#define DEJA_DUP_TYPE_BUTTON_CONNECT (deja_dup_button_connect_get_type ())
#define DEJA_DUP_BUTTON_CONNECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DEJA_DUP_TYPE_BUTTON_CONNECT, DejaDupButtonConnect))
#define DEJA_DUP_BUTTON_CONNECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DEJA_DUP_TYPE_BUTTON_CONNECT, DejaDupButtonConnectClass))
#define DEJA_DUP_IS_BUTTON_CONNECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DEJA_DUP_TYPE_BUTTON_CONNECT))
#define DEJA_DUP_IS_BUTTON_CONNECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DEJA_DUP_TYPE_BUTTON_CONNECT))
#define DEJA_DUP_BUTTON_CONNECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DEJA_DUP_TYPE_BUTTON_CONNECT, DejaDupButtonConnectClass))

typedef struct _DejaDupButtonConnect DejaDupButtonConnect;
typedef struct _DejaDupButtonConnectClass DejaDupButtonConnectClass;
typedef struct _DejaDupButtonConnectPrivate DejaDupButtonConnectPrivate;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _DejaDupButtonConnect {
	GtkButton parent_instance;
	DejaDupButtonConnectPrivate * priv;
};

struct _DejaDupButtonConnectClass {
	GtkButtonClass parent_class;
};


static gpointer deja_dup_button_connect_parent_class = NULL;

GType deja_dup_button_connect_get_type (void);
enum  {
	DEJA_DUP_BUTTON_CONNECT_DUMMY_PROPERTY
};
void deja_dup_button_connect_run_connect_server_dialog (GtkWindow* parent);
DejaDupButtonConnect* deja_dup_button_connect_new (void);
DejaDupButtonConnect* deja_dup_button_connect_construct (GType object_type);
GtkWindow* deja_dup_get_topwindow (GtkWidget* w);
static void _lambda0_ (GtkButton* b, DejaDupButtonConnect* self);
static void __lambda0__gtk_button_clicked (GtkButton* _sender, gpointer self);
static GObject * deja_dup_button_connect_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);



void deja_dup_button_connect_run_connect_server_dialog (GtkWindow* parent) {
	GError * _inner_error_;
	_inner_error_ = NULL;
	{
		g_spawn_command_line_async ("nautilus-connect-server", &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError * e;
		e = _inner_error_;
		_inner_error_ = NULL;
		{
			GtkMessageDialog* dlg;
			dlg = g_object_ref_sink ((GtkMessageDialog*) gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _ ("Could not open connection dialog")));
			gtk_message_dialog_format_secondary_text (dlg, "%s", e->message, NULL);
			gtk_dialog_run ((GtkDialog*) dlg);
			gtk_object_destroy ((GtkObject*) dlg);
			_g_error_free0 (e);
			_g_object_unref0 (dlg);
		}
	}
	__finally0:
	if (_inner_error_ != NULL) {
		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_);
		return;
	}
}


DejaDupButtonConnect* deja_dup_button_connect_construct (GType object_type) {
	DejaDupButtonConnect * self;
	self = g_object_newv (object_type, 0, NULL);
	return self;
}


DejaDupButtonConnect* deja_dup_button_connect_new (void) {
	return deja_dup_button_connect_construct (DEJA_DUP_TYPE_BUTTON_CONNECT);
}


static void _lambda0_ (GtkButton* b, DejaDupButtonConnect* self) {
	GtkWindow* _tmp0_;
	g_return_if_fail (b != NULL);
	deja_dup_button_connect_run_connect_server_dialog (_tmp0_ = deja_dup_get_topwindow ((GtkWidget*) self));
	_g_object_unref0 (_tmp0_);
}


static void __lambda0__gtk_button_clicked (GtkButton* _sender, gpointer self) {
	_lambda0_ (_sender, self);
}


static GObject * deja_dup_button_connect_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	DejaDupButtonConnect * self;
	parent_class = G_OBJECT_CLASS (deja_dup_button_connect_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = DEJA_DUP_BUTTON_CONNECT (obj);
	{
		g_object_set ((GObject*) self, "use-underline", TRUE, "label", _ ("Connect to _Server…"), NULL);
		g_signal_connect_object ((GtkButton*) self, "clicked", (GCallback) __lambda0__gtk_button_clicked, self, 0);
	}
	return obj;
}


static void deja_dup_button_connect_class_init (DejaDupButtonConnectClass * klass) {
	deja_dup_button_connect_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->constructor = deja_dup_button_connect_constructor;
}


static void deja_dup_button_connect_instance_init (DejaDupButtonConnect * self) {
}


GType deja_dup_button_connect_get_type (void) {
	static volatile gsize deja_dup_button_connect_type_id__volatile = 0;
	if (g_once_init_enter (&deja_dup_button_connect_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (DejaDupButtonConnectClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) deja_dup_button_connect_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DejaDupButtonConnect), 0, (GInstanceInitFunc) deja_dup_button_connect_instance_init, NULL };
		GType deja_dup_button_connect_type_id;
		deja_dup_button_connect_type_id = g_type_register_static (GTK_TYPE_BUTTON, "DejaDupButtonConnect", &g_define_type_info, 0);
		g_once_init_leave (&deja_dup_button_connect_type_id__volatile, deja_dup_button_connect_type_id);
	}
	return deja_dup_button_connect_type_id__volatile;
}




