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

/*
 * This file is part of gitg
 *
 * Copyright (C) 2012 - Jesse van den Kieboom
 *
 * 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 <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"

#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_CREATE_BRANCH_DIALOG (gitg_create_branch_dialog_get_type ())
#define GITG_CREATE_BRANCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialog))
#define GITG_CREATE_BRANCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialogClass))
#define GITG_IS_CREATE_BRANCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_CREATE_BRANCH_DIALOG))
#define GITG_IS_CREATE_BRANCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_CREATE_BRANCH_DIALOG))
#define GITG_CREATE_BRANCH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialogClass))

typedef struct _GitgCreateBranchDialog GitgCreateBranchDialog;
typedef struct _GitgCreateBranchDialogClass GitgCreateBranchDialogClass;
typedef struct _GitgCreateBranchDialogPrivate GitgCreateBranchDialogPrivate;
enum  {
	GITG_CREATE_BRANCH_DIALOG_0_PROPERTY,
	GITG_CREATE_BRANCH_DIALOG_NEW_BRANCH_NAME_PROPERTY,
	GITG_CREATE_BRANCH_DIALOG_CHECKOUT_CREATED_PROPERTY,
	GITG_CREATE_BRANCH_DIALOG_NUM_PROPERTIES
};
static GParamSpec* gitg_create_branch_dialog_properties[GITG_CREATE_BRANCH_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 _GitgCreateBranchDialog {
	GtkDialog parent_instance;
	GitgCreateBranchDialogPrivate * priv;
};

struct _GitgCreateBranchDialogClass {
	GtkDialogClass parent_class;
};

struct _GitgCreateBranchDialogPrivate {
	GtkButton* d_button_create;
	GtkEntry* d_entry_branch_name;
	GtkCheckButton* d_checkout_created;
	GSettings* d_settings;
};

static gint GitgCreateBranchDialog_private_offset;
static gpointer gitg_create_branch_dialog_parent_class = NULL;

VALA_EXTERN GType gitg_create_branch_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgCreateBranchDialog, g_object_unref)
VALA_EXTERN GitgCreateBranchDialog* gitg_create_branch_dialog_new (GtkWindow* parent);
VALA_EXTERN GitgCreateBranchDialog* gitg_create_branch_dialog_construct (GType object_type,
                                                             GtkWindow* parent);
VALA_EXTERN gchar* gitg_create_branch_dialog_get_new_branch_name (GitgCreateBranchDialog* self);
VALA_EXTERN gboolean gitg_create_branch_dialog_get_checkout_created (GitgCreateBranchDialog* self);
static GObject * gitg_create_branch_dialog_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _gitg_create_branch_dialog___lambda116_ (GitgCreateBranchDialog* self);
static void __gitg_create_branch_dialog___lambda116__gtk_editable_changed (GtkEditable* _sender,
                                                                    gpointer self);
static void gitg_create_branch_dialog_finalize (GObject * obj);
static GType gitg_create_branch_dialog_get_type_once (void);
static void _vala_gitg_create_branch_dialog_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);

static inline gpointer
gitg_create_branch_dialog_get_instance_private (GitgCreateBranchDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GitgCreateBranchDialog_private_offset);
}

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

GitgCreateBranchDialog*
gitg_create_branch_dialog_new (GtkWindow* parent)
{
	return gitg_create_branch_dialog_construct (GITG_TYPE_CREATE_BRANCH_DIALOG, parent);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

gchar*
gitg_create_branch_dialog_get_new_branch_name (GitgCreateBranchDialog* self)
{
	gchar* result;
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_entry_branch_name;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	result = _tmp3_;
	return result;
}

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

static void
_gitg_create_branch_dialog___lambda116_ (GitgCreateBranchDialog* self)
{
	GtkButton* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	_tmp0_ = self->priv->d_button_create;
	_tmp1_ = gitg_create_branch_dialog_get_new_branch_name (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, _tmp5_ != 0);
	_g_free0 (_tmp3_);
}

static void
__gitg_create_branch_dialog___lambda116__gtk_editable_changed (GtkEditable* _sender,
                                                               gpointer self)
{
	_gitg_create_branch_dialog___lambda116_ ((GitgCreateBranchDialog*) self);
}

static GObject *
gitg_create_branch_dialog_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgCreateBranchDialog * self;
	GSettings* _tmp0_;
	GSettings* _tmp1_;
	GtkCheckButton* _tmp2_;
	GtkEntry* _tmp3_;
	GtkButton* _tmp4_;
	parent_class = G_OBJECT_CLASS (gitg_create_branch_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialog);
	_tmp0_ = g_settings_new (APPLICATION_ID ".preferences.branch");
	_g_object_unref0 (self->priv->d_settings);
	self->priv->d_settings = _tmp0_;
	_tmp1_ = self->priv->d_settings;
	_tmp2_ = self->priv->d_checkout_created;
	g_settings_bind (_tmp1_, "checkout-created-branch", (GObject*) _tmp2_, "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
	_tmp3_ = self->priv->d_entry_branch_name;
	g_signal_connect_object ((GtkEditable*) _tmp3_, "changed", (GCallback) __gitg_create_branch_dialog___lambda116__gtk_editable_changed, self, 0);
	_tmp4_ = self->priv->d_button_create;
	gtk_window_set_default ((GtkWindow*) self, (GtkWidget*) _tmp4_);
	gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_OK);
	return obj;
}

static void
gitg_create_branch_dialog_class_init (GitgCreateBranchDialogClass * klass,
                                      gpointer klass_data)
{
	gitg_create_branch_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgCreateBranchDialog_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_create_branch_dialog_get_property;
	G_OBJECT_CLASS (klass)->constructor = gitg_create_branch_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = gitg_create_branch_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_CREATE_BRANCH_DIALOG_NEW_BRANCH_NAME_PROPERTY, gitg_create_branch_dialog_properties[GITG_CREATE_BRANCH_DIALOG_NEW_BRANCH_NAME_PROPERTY] = g_param_spec_string ("new-branch-name", "new-branch-name", "new-branch-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_CREATE_BRANCH_DIALOG_CHECKOUT_CREATED_PROPERTY, gitg_create_branch_dialog_properties[GITG_CREATE_BRANCH_DIALOG_CHECKOUT_CREATED_PROPERTY] = g_param_spec_boolean ("checkout-created", "checkout-created", "checkout-created", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/gitg/ui/gitg-create-branch-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_button_create", FALSE, GitgCreateBranchDialog_private_offset + G_STRUCT_OFFSET (GitgCreateBranchDialogPrivate, d_button_create));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_entry_branch_name", FALSE, GitgCreateBranchDialog_private_offset + G_STRUCT_OFFSET (GitgCreateBranchDialogPrivate, d_entry_branch_name));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_checkout_created", FALSE, GitgCreateBranchDialog_private_offset + G_STRUCT_OFFSET (GitgCreateBranchDialogPrivate, d_checkout_created));
}

static void
gitg_create_branch_dialog_instance_init (GitgCreateBranchDialog * self,
                                         gpointer klass)
{
	self->priv = gitg_create_branch_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
gitg_create_branch_dialog_finalize (GObject * obj)
{
	GitgCreateBranchDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialog);
	_g_object_unref0 (self->priv->d_settings);
	G_OBJECT_CLASS (gitg_create_branch_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_create_branch_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgCreateBranchDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_create_branch_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgCreateBranchDialog), 0, (GInstanceInitFunc) gitg_create_branch_dialog_instance_init, NULL };
	GType gitg_create_branch_dialog_type_id;
	gitg_create_branch_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "GitgCreateBranchDialog", &g_define_type_info, 0);
	GitgCreateBranchDialog_private_offset = g_type_add_instance_private (gitg_create_branch_dialog_type_id, sizeof (GitgCreateBranchDialogPrivate));
	return gitg_create_branch_dialog_type_id;
}

GType
gitg_create_branch_dialog_get_type (void)
{
	static gsize gitg_create_branch_dialog_type_id__once = 0;
	if (g_once_init_enter (&gitg_create_branch_dialog_type_id__once)) {
		GType gitg_create_branch_dialog_type_id;
		gitg_create_branch_dialog_type_id = gitg_create_branch_dialog_get_type_once ();
		g_once_init_leave (&gitg_create_branch_dialog_type_id__once, gitg_create_branch_dialog_type_id);
	}
	return gitg_create_branch_dialog_type_id__once;
}

static void
_vala_gitg_create_branch_dialog_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	GitgCreateBranchDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_CREATE_BRANCH_DIALOG, GitgCreateBranchDialog);
	switch (property_id) {
		case GITG_CREATE_BRANCH_DIALOG_NEW_BRANCH_NAME_PROPERTY:
		g_value_take_string (value, gitg_create_branch_dialog_get_new_branch_name (self));
		break;
		case GITG_CREATE_BRANCH_DIALOG_CHECKOUT_CREATED_PROPERTY:
		g_value_set_boolean (value, gitg_create_branch_dialog_get_checkout_created (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

