/* gitg-clone-dialog.c generated by valac 0.56.19, the Vala compiler
 * generated from gitg-clone-dialog.vala, do not modify */

/*
 * This file is part of gitg
 *
 * Copyright (C) 2013 - Ignacio Casal Quinteiro
 *
 * gitg 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 2 of the License, or
 * (at your option) any later version.
 *
 * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "config.h"
#include <gio/gio.h>
#include <glib/gi18n-lib.h>

#define GITG_CLONE_DIALOG_version VERSION
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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 GITG_TYPE_CLONE_DIALOG (gitg_clone_dialog_get_type ())
#define GITG_CLONE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_CLONE_DIALOG, GitgCloneDialog))
#define GITG_CLONE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_CLONE_DIALOG, GitgCloneDialogClass))
#define GITG_IS_CLONE_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_CLONE_DIALOG))
#define GITG_IS_CLONE_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_CLONE_DIALOG))
#define GITG_CLONE_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_CLONE_DIALOG, GitgCloneDialogClass))

typedef struct _GitgCloneDialog GitgCloneDialog;
typedef struct _GitgCloneDialogClass GitgCloneDialogClass;
typedef struct _GitgCloneDialogPrivate GitgCloneDialogPrivate;
enum  {
	GITG_CLONE_DIALOG_0_PROPERTY,
	GITG_CLONE_DIALOG_IS_BARE_PROPERTY,
	GITG_CLONE_DIALOG_LOCATION_PROPERTY,
	GITG_CLONE_DIALOG_URL_PROPERTY,
	GITG_CLONE_DIALOG_NUM_PROPERTIES
};
static GParamSpec* gitg_clone_dialog_properties[GITG_CLONE_DIALOG_NUM_PROPERTIES];
typedef struct _Block55Data Block55Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GitgCloneDialog {
	GtkDialog parent_instance;
	GitgCloneDialogPrivate * priv;
};

struct _GitgCloneDialogClass {
	GtkDialogClass parent_class;
};

struct _GitgCloneDialogPrivate {
	GtkEntry* d_entry_url;
	GtkFileChooserButton* d_button_location;
	GtkCheckButton* d_bare_repository;
};

struct _Block55Data {
	int _ref_count_;
	GitgCloneDialog* self;
	GSettings* main_settings;
};

static gint GitgCloneDialog_private_offset;
static gpointer gitg_clone_dialog_parent_class = NULL;

VALA_EXTERN GType gitg_clone_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgCloneDialog, g_object_unref)
VALA_EXTERN GitgCloneDialog* gitg_clone_dialog_new (GtkWindow* parent);
VALA_EXTERN GitgCloneDialog* gitg_clone_dialog_construct (GType object_type,
                                              GtkWindow* parent);
VALA_EXTERN gboolean gitg_clone_dialog_get_is_bare (GitgCloneDialog* self);
VALA_EXTERN GFile* gitg_clone_dialog_get_location (GitgCloneDialog* self);
VALA_EXTERN const gchar* gitg_clone_dialog_get_url (GitgCloneDialog* self);
static GObject * gitg_clone_dialog_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static Block55Data* block55_data_ref (Block55Data* _data55_);
static void block55_data_unref (void * _userdata_);
static void _gitg_clone_dialog___lambda181_ (Block55Data* _data55_,
                                      GtkFileChooser* c);
static void __gitg_clone_dialog___lambda181__gtk_file_chooser_selection_changed (GtkFileChooser* _sender,
                                                                          gpointer self);
static void _gitg_clone_dialog___lambda182_ (GitgCloneDialog* self,
                                      GtkEditable* e);
static void __gitg_clone_dialog___lambda182__gtk_editable_changed (GtkEditable* _sender,
                                                            gpointer self);
static void gitg_clone_dialog_finalize (GObject * obj);
static GType gitg_clone_dialog_get_type_once (void);
static void _vala_gitg_clone_dialog_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
gitg_clone_dialog_get_instance_private (GitgCloneDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GitgCloneDialog_private_offset);
}

GitgCloneDialog*
gitg_clone_dialog_construct (GType object_type,
                             GtkWindow* parent)
{
	GitgCloneDialog * self = NULL;
	self = (GitgCloneDialog*) g_object_new (object_type, "use-header-bar", 1, NULL);
	if (parent != NULL) {
		gtk_window_set_transient_for ((GtkWindow*) self, parent);
	}
	return self;
}

GitgCloneDialog*
gitg_clone_dialog_new (GtkWindow* parent)
{
	return gitg_clone_dialog_construct (GITG_TYPE_CLONE_DIALOG, parent);
}

gboolean
gitg_clone_dialog_get_is_bare (GitgCloneDialog* self)
{
	gboolean result;
	GtkCheckButton* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->d_bare_repository;
	_tmp1_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

GFile*
gitg_clone_dialog_get_location (GitgCloneDialog* self)
{
	GFile* result;
	GtkFileChooserButton* _tmp0_;
	GFile* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_button_location;
	_tmp1_ = gtk_file_chooser_get_file ((GtkFileChooser*) _tmp0_);
	result = _tmp1_;
	return result;
}

const gchar*
gitg_clone_dialog_get_url (GitgCloneDialog* self)
{
	const gchar* result;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_entry_url;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	result = _tmp1_;
	return result;
}

static Block55Data*
block55_data_ref (Block55Data* _data55_)
{
	g_atomic_int_inc (&_data55_->_ref_count_);
	return _data55_;
}

static void
block55_data_unref (void * _userdata_)
{
	Block55Data* _data55_;
	_data55_ = (Block55Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data55_->_ref_count_)) {
		GitgCloneDialog* self;
		self = _data55_->self;
		_g_object_unref0 (_data55_->main_settings);
		_g_object_unref0 (self);
		g_slice_free (Block55Data, _data55_);
	}
}

static void
_gitg_clone_dialog___lambda181_ (Block55Data* _data55_,
                                 GtkFileChooser* c)
{
	GitgCloneDialog* self;
	GSettings* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	self = _data55_->self;
	g_return_if_fail (c != NULL);
	_tmp0_ = _data55_->main_settings;
	_tmp1_ = gtk_file_chooser_get_file (c);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_file_get_path (_tmp2_);
	_tmp4_ = _tmp3_;
	g_settings_set_string (_tmp0_, "clone-directory", _tmp4_);
	_g_free0 (_tmp4_);
	_g_object_unref0 (_tmp2_);
}

static void
__gitg_clone_dialog___lambda181__gtk_file_chooser_selection_changed (GtkFileChooser* _sender,
                                                                     gpointer self)
{
	_gitg_clone_dialog___lambda181_ (self, _sender);
}

static void
_gitg_clone_dialog___lambda182_ (GitgCloneDialog* self,
                                 GtkEditable* e)
{
	gchar* tooltip_text = NULL;
	gchar* icon_name = NULL;
	gboolean is_valid = FALSE;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkEntry* _tmp5_;
	const gchar* _tmp6_;
	GtkEntry* _tmp7_;
	const gchar* _tmp8_;
	g_return_if_fail (e != NULL);
	tooltip_text = NULL;
	icon_name = NULL;
	_tmp0_ = self->priv->d_entry_url;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	is_valid = g_strcmp0 (_tmp2_, "") != 0;
	if (!is_valid) {
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp3_ = g_strdup ("dialog-warning-symbolic");
		_g_free0 (icon_name);
		icon_name = _tmp3_;
		_tmp4_ = g_strdup (_ ("The URL introduced is not supported"));
		_g_free0 (tooltip_text);
		tooltip_text = _tmp4_;
	}
	_tmp5_ = self->priv->d_entry_url;
	_tmp6_ = icon_name;
	gtk_entry_set_icon_from_icon_name (_tmp5_, GTK_ENTRY_ICON_SECONDARY, _tmp6_);
	_tmp7_ = self->priv->d_entry_url;
	_tmp8_ = tooltip_text;
	gtk_entry_set_icon_tooltip_text (_tmp7_, GTK_ENTRY_ICON_SECONDARY, _tmp8_);
	gtk_dialog_set_response_sensitive ((GtkDialog*) self, (gint) GTK_RESPONSE_OK, is_valid);
	_g_free0 (icon_name);
	_g_free0 (tooltip_text);
}

static void
__gitg_clone_dialog___lambda182__gtk_editable_changed (GtkEditable* _sender,
                                                       gpointer self)
{
	_gitg_clone_dialog___lambda182_ ((GitgCloneDialog*) self, _sender);
}

static GObject *
gitg_clone_dialog_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgCloneDialog * self;
	Block55Data* _data55_;
	GSettings* _tmp0_;
	gchar* default_dir = NULL;
	GSettings* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkFileChooserButton* _tmp6_;
	const gchar* _tmp7_;
	GtkFileChooserButton* _tmp8_;
	GtkEntry* _tmp9_;
	parent_class = G_OBJECT_CLASS (gitg_clone_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_CLONE_DIALOG, GitgCloneDialog);
	_data55_ = g_slice_new0 (Block55Data);
	_data55_->_ref_count_ = 1;
	_data55_->self = g_object_ref (self);
	_tmp0_ = g_settings_new (APPLICATION_ID ".preferences.main");
	_data55_->main_settings = _tmp0_;
	gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_OK);
	_tmp1_ = _data55_->main_settings;
	_tmp2_ = g_settings_get_string (_tmp1_, "clone-directory");
	default_dir = _tmp2_;
	_tmp3_ = default_dir;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = g_get_home_dir ();
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (default_dir);
		default_dir = _tmp5_;
	}
	_tmp6_ = self->priv->d_button_location;
	_tmp7_ = default_dir;
	gtk_file_chooser_set_current_folder ((GtkFileChooser*) _tmp6_, _tmp7_);
	_tmp8_ = self->priv->d_button_location;
	g_signal_connect_data ((GtkFileChooser*) _tmp8_, "selection-changed", (GCallback) __gitg_clone_dialog___lambda181__gtk_file_chooser_selection_changed, block55_data_ref (_data55_), (GClosureNotify) block55_data_unref, 0);
	_tmp9_ = self->priv->d_entry_url;
	g_signal_connect_object ((GtkEditable*) _tmp9_, "changed", (GCallback) __gitg_clone_dialog___lambda182__gtk_editable_changed, self, 0);
	_g_free0 (default_dir);
	block55_data_unref (_data55_);
	_data55_ = NULL;
	return obj;
}

static void
gitg_clone_dialog_class_init (GitgCloneDialogClass * klass,
                              gpointer klass_data)
{
	gitg_clone_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgCloneDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_clone_dialog_get_property;
	G_OBJECT_CLASS (klass)->constructor = gitg_clone_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = gitg_clone_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_CLONE_DIALOG_IS_BARE_PROPERTY, gitg_clone_dialog_properties[GITG_CLONE_DIALOG_IS_BARE_PROPERTY] = g_param_spec_boolean ("is-bare", "is-bare", "is-bare", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_CLONE_DIALOG_LOCATION_PROPERTY, gitg_clone_dialog_properties[GITG_CLONE_DIALOG_LOCATION_PROPERTY] = g_param_spec_object ("location", "location", "location", g_file_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_CLONE_DIALOG_URL_PROPERTY, gitg_clone_dialog_properties[GITG_CLONE_DIALOG_URL_PROPERTY] = g_param_spec_string ("url", "url", "url", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/gitg/ui/gitg-clone-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "entry_url", FALSE, GitgCloneDialog_private_offset + G_STRUCT_OFFSET (GitgCloneDialogPrivate, d_entry_url));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "button_location", FALSE, GitgCloneDialog_private_offset + G_STRUCT_OFFSET (GitgCloneDialogPrivate, d_button_location));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "bare_repository", FALSE, GitgCloneDialog_private_offset + G_STRUCT_OFFSET (GitgCloneDialogPrivate, d_bare_repository));
}

static void
gitg_clone_dialog_instance_init (GitgCloneDialog * self,
                                 gpointer klass)
{
	self->priv = gitg_clone_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
gitg_clone_dialog_finalize (GObject * obj)
{
	GitgCloneDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_CLONE_DIALOG, GitgCloneDialog);
	G_OBJECT_CLASS (gitg_clone_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_clone_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgCloneDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_clone_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgCloneDialog), 0, (GInstanceInitFunc) gitg_clone_dialog_instance_init, NULL };
	GType gitg_clone_dialog_type_id;
	gitg_clone_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "GitgCloneDialog", &g_define_type_info, 0);
	GitgCloneDialog_private_offset = g_type_add_instance_private (gitg_clone_dialog_type_id, sizeof (GitgCloneDialogPrivate));
	return gitg_clone_dialog_type_id;
}

GType
gitg_clone_dialog_get_type (void)
{
	static gsize gitg_clone_dialog_type_id__once = 0;
	if (g_once_init_enter (&gitg_clone_dialog_type_id__once)) {
		GType gitg_clone_dialog_type_id;
		gitg_clone_dialog_type_id = gitg_clone_dialog_get_type_once ();
		g_once_init_leave (&gitg_clone_dialog_type_id__once, gitg_clone_dialog_type_id);
	}
	return gitg_clone_dialog_type_id__once;
}

static void
_vala_gitg_clone_dialog_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	GitgCloneDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_CLONE_DIALOG, GitgCloneDialog);
	switch (property_id) {
		case GITG_CLONE_DIALOG_IS_BARE_PROPERTY:
		g_value_set_boolean (value, gitg_clone_dialog_get_is_bare (self));
		break;
		case GITG_CLONE_DIALOG_LOCATION_PROPERTY:
		g_value_take_object (value, gitg_clone_dialog_get_location (self));
		break;
		case GITG_CLONE_DIALOG_URL_PROPERTY:
		g_value_set_string (value, gitg_clone_dialog_get_url (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

