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

/*
 * This file is part of gitg
 *
 * Copyright (C) 2025 - Alberto Fanjul
 *
 * 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 "libgitg.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <libgit2-glib/ggit.h>
#include <gee.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_PUSH_DIALOG (gitg_push_dialog_get_type ())
#define GITG_PUSH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_PUSH_DIALOG, GitgPushDialog))
#define GITG_PUSH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_PUSH_DIALOG, GitgPushDialogClass))
#define GITG_IS_PUSH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_PUSH_DIALOG))
#define GITG_IS_PUSH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_PUSH_DIALOG))
#define GITG_PUSH_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_PUSH_DIALOG, GitgPushDialogClass))

typedef struct _GitgPushDialog GitgPushDialog;
typedef struct _GitgPushDialogClass GitgPushDialogClass;
typedef struct _GitgPushDialogPrivate GitgPushDialogPrivate;
enum  {
	GITG_PUSH_DIALOG_0_PROPERTY,
	GITG_PUSH_DIALOG_SMART_PROPERTY,
	GITG_PUSH_DIALOG_LOCAL_REF_PROPERTY,
	GITG_PUSH_DIALOG_REMOTE_NAME_PROPERTY,
	GITG_PUSH_DIALOG_REMOTE_REF_NAME_PROPERTY,
	GITG_PUSH_DIALOG_REMOTE_REF_PROPERTY,
	GITG_PUSH_DIALOG_FORCE_PROPERTY,
	GITG_PUSH_DIALOG_SET_UPSTREAM_PROPERTY,
	GITG_PUSH_DIALOG_NUM_PROPERTIES
};
static GParamSpec* gitg_push_dialog_properties[GITG_PUSH_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))
#define __vala_GgitOId_free0(var) ((var == NULL) ? NULL : (var = (_vala_GgitOId_free (var), NULL)))
typedef struct _Block81Data Block81Data;

struct _GitgPushDialog {
	GtkDialog parent_instance;
	GitgPushDialogPrivate * priv;
};

struct _GitgPushDialogClass {
	GtkDialogClass parent_class;
};

struct _GitgPushDialogPrivate {
	GtkButton* d_button_push;
	GtkEntry* d_local_ref;
	GtkComboBoxText* d_remote_name;
	GtkComboBoxText* d_remote_ref_name;
	GtkRadioButton* d_local_ref_tag;
	GtkRadioButton* d_local_ref_branch;
	GtkRadioButton* d_local_ref_commit;
	GtkRadioButton* d_remote_ref_tag;
	GtkRadioButton* d_remote_ref_branch;
	GtkRadioButton* d_remote_ref_custom;
	GtkCheckButton* d_force;
	GtkCheckButton* d_upstream;
	GtkCheckButton* d_smart;
	GtkButton* d_button_restart;
	GitgRepository* d_repository;
	GObject* d_reference;
	GitgRef* d_remote_reference;
};

struct _Block81Data {
	int _ref_count_;
	GitgPushDialog* self;
	gchar* remote_selected;
};

static gint GitgPushDialog_private_offset;
static gpointer gitg_push_dialog_parent_class = NULL;

VALA_EXTERN GType gitg_push_dialog_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GitgPushDialog, g_object_unref)
static void gitg_push_dialog_input_changed (GitgPushDialog* self);
VALA_EXTERN gchar* gitg_push_dialog_get_remote_name (GitgPushDialog* self);
VALA_EXTERN gchar* gitg_push_dialog_get_remote_ref_name (GitgPushDialog* self);
VALA_EXTERN GitgPushDialog* gitg_push_dialog_new (GtkWindow* parent,
                                      GitgRepository* repository,
                                      GObject* reference,
                                      gboolean smart);
VALA_EXTERN GitgPushDialog* gitg_push_dialog_construct (GType object_type,
                                            GtkWindow* parent,
                                            GitgRepository* repository,
                                            GObject* reference,
                                            gboolean smart);
static void _vala_GgitOId_free (GgitOId* self);
static void gitg_push_dialog_update_smart (GitgPushDialog* self);
static void _gitg_push_dialog_update_smart_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                               gpointer self);
static void gitg_push_dialog_real_show (GtkWidget* base);
static void gitg_push_dialog_update_remote_entries (GitgPushDialog* self);
static void gitg_push_dialog_update_force (GitgPushDialog* self);
VALA_EXTERN gboolean gitg_push_dialog_get_smart (GitgPushDialog* self);
static gchar** _vala_array_dup20 (gchar** self,
                           gssize length);
static void gitg_push_dialog_update_remote_ref_entries (GitgPushDialog* self);
static Block81Data* block81_data_ref (Block81Data* _data81_);
static void block81_data_unref (void * _userdata_);
static gint ___lambda222_ (Block81Data* _data81_,
                    const gchar* name);
static gint ____lambda222__ggit_references_name_callback (const gchar* name,
                                                   gpointer self);
VALA_EXTERN void gitg_push_dialog_set_smart (GitgPushDialog* self,
                                 gboolean value);
VALA_EXTERN gchar* gitg_push_dialog_get_local_ref (GitgPushDialog* self);
VALA_EXTERN gchar* gitg_push_dialog_get_remote_ref (GitgPushDialog* self);
VALA_EXTERN gboolean gitg_push_dialog_get_force (GitgPushDialog* self);
VALA_EXTERN gboolean gitg_push_dialog_get_set_upstream (GitgPushDialog* self);
static GObject * gitg_push_dialog_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _gitg_push_dialog_input_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                            gpointer self);
static void _gitg_push_dialog_update_remote_ref_entries_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                        gpointer self);
static void _gitg_push_dialog_update_remote_ref_entries_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                            gpointer self);
static void _gitg_push_dialog_update_remote_entries_gtk_button_clicked (GtkButton* _sender,
                                                                 gpointer self);
static void _gitg_push_dialog_update_force_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                               gpointer self);
static void gitg_push_dialog_finalize (GObject * obj);
static GType gitg_push_dialog_get_type_once (void);
static void _vala_gitg_push_dialog_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_gitg_push_dialog_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static inline gpointer
gitg_push_dialog_get_instance_private (GitgPushDialog* self)
{
	return G_STRUCT_MEMBER_P (self, GitgPushDialog_private_offset);
}

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

static void
gitg_push_dialog_input_changed (GitgPushDialog* self)
{
	gboolean _tmp0_ = FALSE;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	gboolean full_info_filled = FALSE;
	gboolean _tmp8_ = FALSE;
	GtkRadioButton* _tmp9_;
	gboolean _tmp10_;
	gboolean _tmp11_;
	gboolean push_from_to_branches = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp1_ = gitg_push_dialog_get_remote_name (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_ != NULL;
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp5_ = gitg_push_dialog_get_remote_ref_name (self);
		_tmp6_ = _tmp5_;
		_tmp7_ = _tmp6_;
		_tmp0_ = g_strcmp0 (_tmp7_, "") != 0;
		_g_free0 (_tmp7_);
	} else {
		_tmp0_ = FALSE;
	}
	full_info_filled = _tmp0_;
	gtk_dialog_set_response_sensitive ((GtkDialog*) self, (gint) GTK_RESPONSE_OK, full_info_filled);
	_tmp9_ = self->priv->d_local_ref_branch;
	_tmp10_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_) {
		GtkRadioButton* _tmp12_;
		gboolean _tmp13_;
		gboolean _tmp14_;
		_tmp12_ = self->priv->d_remote_ref_branch;
		_tmp13_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp8_ = _tmp14_;
	} else {
		_tmp8_ = FALSE;
	}
	push_from_to_branches = _tmp8_;
	if (push_from_to_branches) {
		gboolean remote_is_upstream_branch = FALSE;
		GitgRef* r = NULL;
		GObject* _tmp15_;
		GitgRef* _tmp16_;
		GitgRef* _tmp17_;
		gboolean _tmp33_ = FALSE;
		GtkCheckButton* _tmp34_;
		remote_is_upstream_branch = FALSE;
		_tmp15_ = self->priv->d_reference;
		_tmp16_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, GITG_TYPE_REF) ? ((GitgRef*) _tmp15_) : NULL);
		r = _tmp16_;
		_tmp17_ = r;
		if (_tmp17_ != NULL) {
			GitgRef* _tmp18_;
			_tmp18_ = r;
			if (ggit_ref_is_branch ((GgitRef*) _tmp18_)) {
				GitgBranch* branch = NULL;
				GitgRef* _tmp19_;
				GitgBranch* _tmp20_;
				_tmp19_ = r;
				_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp19_, GITG_TYPE_BRANCH) ? ((GitgBranch*) _tmp19_) : NULL);
				branch = _tmp20_;
				{
					GitgRef* upstream = NULL;
					GitgBranch* _tmp21_;
					GitgRef* _tmp22_;
					GitgRef* _tmp23_;
					GitgParsedRefName* _tmp24_;
					GitgParsedRefName* _tmp25_;
					GitgParsedRefName* _tmp26_;
					gchar* _tmp27_;
					gchar* _tmp28_;
					gchar* _tmp29_;
					gchar* _tmp30_;
					gchar* _tmp31_;
					gchar* _tmp32_;
					_tmp21_ = branch;
					_tmp22_ = gitg_branch_get_upstream (_tmp21_, &_inner_error0_);
					upstream = _tmp22_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp23_ = upstream;
					_tmp24_ = gitg_ref_get_parsed_name (_tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = _tmp25_;
					_tmp27_ = gitg_parsed_ref_name_get_remote_branch (_tmp26_);
					_tmp28_ = _tmp27_;
					_tmp29_ = _tmp28_;
					_tmp30_ = gitg_push_dialog_get_remote_ref_name (self);
					_tmp31_ = _tmp30_;
					_tmp32_ = _tmp31_;
					remote_is_upstream_branch = g_strcmp0 (_tmp29_, _tmp32_) == 0;
					_g_free0 (_tmp32_);
					_g_free0 (_tmp29_);
					_g_object_unref0 (_tmp26_);
					_g_object_unref0 (upstream);
				}
				goto __finally0;
				__catch0_g_error:
				{
					g_clear_error (&_inner_error0_);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (branch);
					_g_object_unref0 (r);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
				_g_object_unref0 (branch);
			}
		}
		if (full_info_filled) {
			_tmp33_ = !remote_is_upstream_branch;
		} else {
			_tmp33_ = FALSE;
		}
		_tmp34_ = self->priv->d_upstream;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp34_, _tmp33_);
		_g_object_unref0 (r);
	}
}

static void
_vala_GgitOId_free (GgitOId* self)
{
	g_boxed_free (ggit_oid_get_type (), self);
}

static void
_gitg_push_dialog_update_smart_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                          gpointer self)
{
	gitg_push_dialog_update_smart ((GitgPushDialog*) self);
}

GitgPushDialog*
gitg_push_dialog_construct (GType object_type,
                            GtkWindow* parent,
                            GitgRepository* repository,
                            GObject* reference,
                            gboolean smart)
{
	GitgPushDialog * self = NULL;
	GObject* _tmp1_;
	GitgRef* r = NULL;
	GObject* _tmp2_;
	GitgRef* _tmp3_;
	GitgRef* _tmp4_;
	GtkCheckButton* _tmp33_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (reference != NULL, NULL);
	self = (GitgPushDialog*) g_object_new (object_type, "use-header-bar", 1, "smart", smart, NULL);
	if (parent != NULL) {
		gtk_window_set_transient_for ((GtkWindow*) self, parent);
	}
	if (repository != NULL) {
		GitgRepository* _tmp0_;
		_tmp0_ = _g_object_ref0 (repository);
		_g_object_unref0 (self->priv->d_repository);
		self->priv->d_repository = _tmp0_;
	}
	_tmp1_ = _g_object_ref0 (reference);
	_g_object_unref0 (self->priv->d_reference);
	self->priv->d_reference = _tmp1_;
	_tmp2_ = self->priv->d_reference;
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GITG_TYPE_REF) ? ((GitgRef*) _tmp2_) : NULL);
	r = _tmp3_;
	_tmp4_ = r;
	if (_tmp4_ != NULL) {
		GtkEntry* _tmp5_;
		GitgRef* _tmp6_;
		GitgParsedRefName* _tmp7_;
		GitgParsedRefName* _tmp8_;
		GitgParsedRefName* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		GitgRef* _tmp13_;
		_tmp5_ = self->priv->d_local_ref;
		_tmp6_ = r;
		_tmp7_ = gitg_ref_get_parsed_name (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = _tmp8_;
		_tmp10_ = gitg_parsed_ref_name_get_shortname (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = _tmp11_;
		gtk_entry_set_text (_tmp5_, _tmp12_);
		_g_free0 (_tmp12_);
		_g_object_unref0 (_tmp9_);
		_tmp13_ = r;
		if (ggit_ref_is_branch ((GgitRef*) _tmp13_)) {
			GitgBranch* branch = NULL;
			GitgRef* _tmp14_;
			GitgBranch* _tmp15_;
			GtkRadioButton* _tmp20_;
			_tmp14_ = r;
			_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp14_, GITG_TYPE_BRANCH) ? ((GitgBranch*) _tmp14_) : NULL);
			branch = _tmp15_;
			{
				GitgRef* upstream = NULL;
				GitgBranch* _tmp16_;
				GitgRef* _tmp17_;
				GitgRef* _tmp18_;
				GitgRef* _tmp19_;
				_tmp16_ = branch;
				_tmp17_ = gitg_branch_get_upstream (_tmp16_, &_inner_error0_);
				upstream = _tmp17_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp18_ = upstream;
				_tmp19_ = _g_object_ref0 (_tmp18_);
				_g_object_unref0 (self->priv->d_remote_reference);
				self->priv->d_remote_reference = _tmp19_;
				_g_object_unref0 (upstream);
			}
			goto __finally0;
			__catch0_g_error:
			{
				g_clear_error (&_inner_error0_);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (branch);
				_g_object_unref0 (r);
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return NULL;
			}
			_tmp20_ = self->priv->d_local_ref_branch;
			gtk_toggle_button_set_active ((GtkToggleButton*) _tmp20_, TRUE);
			_g_object_unref0 (branch);
		} else {
			GitgRef* _tmp21_;
			_tmp21_ = r;
			if (ggit_ref_is_tag ((GgitRef*) _tmp21_)) {
				GtkRadioButton* _tmp22_;
				_tmp22_ = self->priv->d_local_ref_tag;
				gtk_toggle_button_set_active ((GtkToggleButton*) _tmp22_, TRUE);
			} else {
				GtkRadioButton* _tmp23_;
				_tmp23_ = self->priv->d_local_ref_commit;
				gtk_toggle_button_set_active ((GtkToggleButton*) _tmp23_, TRUE);
			}
		}
	} else {
		GitgCommit* commit = NULL;
		GObject* _tmp24_;
		GitgCommit* _tmp25_;
		GtkEntry* _tmp26_;
		GitgCommit* _tmp27_;
		GgitOId* _tmp28_;
		GgitOId* _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		GtkRadioButton* _tmp32_;
		_tmp24_ = self->priv->d_reference;
		_tmp25_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp24_, GITG_TYPE_COMMIT) ? ((GitgCommit*) _tmp24_) : NULL);
		commit = _tmp25_;
		_tmp26_ = self->priv->d_local_ref;
		_tmp27_ = commit;
		_tmp28_ = ggit_object_get_id ((GgitObject*) _tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = ggit_oid_to_string (_tmp29_);
		_tmp31_ = _tmp30_;
		gtk_entry_set_text (_tmp26_, _tmp31_);
		_g_free0 (_tmp31_);
		__vala_GgitOId_free0 (_tmp29_);
		_tmp32_ = self->priv->d_local_ref_commit;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp32_, TRUE);
		_g_object_unref0 (commit);
	}
	_tmp33_ = self->priv->d_smart;
	g_signal_connect_object ((GtkToggleButton*) _tmp33_, "toggled", (GCallback) _gitg_push_dialog_update_smart_gtk_toggle_button_toggled, self, 0);
	_g_object_unref0 (r);
	return self;
}

GitgPushDialog*
gitg_push_dialog_new (GtkWindow* parent,
                      GitgRepository* repository,
                      GObject* reference,
                      gboolean smart)
{
	return gitg_push_dialog_construct (GITG_TYPE_PUSH_DIALOG, parent, repository, reference, smart);
}

static void
gitg_push_dialog_real_show (GtkWidget* base)
{
	GitgPushDialog * self;
	self = (GitgPushDialog*) base;
	GTK_WIDGET_CLASS (gitg_push_dialog_parent_class)->show ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_dialog_get_type (), GtkDialog));
	gitg_push_dialog_update_remote_entries (self);
}

static void
gitg_push_dialog_update_force (GitgPushDialog* self)
{
	GtkStyleContext* ctx = NULL;
	GtkButton* _tmp0_;
	GtkStyleContext* _tmp1_;
	GtkStyleContext* _tmp2_;
	GtkCheckButton* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_button_push;
	_tmp1_ = gtk_widget_get_style_context ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	ctx = _tmp2_;
	_tmp3_ = self->priv->d_force;
	_tmp4_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		GtkStyleContext* _tmp6_;
		GtkStyleContext* _tmp7_;
		_tmp6_ = ctx;
		gtk_style_context_remove_class (_tmp6_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
		_tmp7_ = ctx;
		gtk_style_context_add_class (_tmp7_, GTK_STYLE_CLASS_DESTRUCTIVE_ACTION);
	} else {
		GtkStyleContext* _tmp8_;
		GtkStyleContext* _tmp9_;
		_tmp8_ = ctx;
		gtk_style_context_remove_class (_tmp8_, GTK_STYLE_CLASS_DESTRUCTIVE_ACTION);
		_tmp9_ = ctx;
		gtk_style_context_add_class (_tmp9_, GTK_STYLE_CLASS_SUGGESTED_ACTION);
	}
	_g_object_unref0 (ctx);
}

static void
gitg_push_dialog_update_smart (GitgPushDialog* self)
{
	g_return_if_fail (self != NULL);
	gitg_push_dialog_update_remote_entries (self);
}

static gchar**
_vala_array_dup20 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
gitg_push_dialog_update_remote_entries (GitgPushDialog* self)
{
	GitgRef* r = NULL;
	GObject* _tmp0_;
	GitgRef* _tmp1_;
	GitgRef* _tmp2_;
	GtkComboBoxText* _tmp9_;
	gchar** remotes = NULL;
	GitgRepository* _tmp10_;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint remotes_length1;
	gint _remotes_size_;
	GitgRef* _tmp17_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_reference;
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GITG_TYPE_REF) ? ((GitgRef*) _tmp0_) : NULL);
	r = _tmp1_;
	_tmp2_ = r;
	if (_tmp2_ != NULL) {
		GitgRef* _tmp3_;
		_tmp3_ = r;
		if (ggit_ref_is_branch ((GgitRef*) _tmp3_)) {
			GtkRadioButton* _tmp4_;
			_tmp4_ = self->priv->d_remote_ref_branch;
			gtk_toggle_button_set_active ((GtkToggleButton*) _tmp4_, TRUE);
		} else {
			GitgRef* _tmp5_;
			_tmp5_ = r;
			if (ggit_ref_is_tag ((GgitRef*) _tmp5_)) {
				GtkRadioButton* _tmp6_;
				_tmp6_ = self->priv->d_remote_ref_tag;
				gtk_toggle_button_set_active ((GtkToggleButton*) _tmp6_, TRUE);
			} else {
				GtkRadioButton* _tmp7_;
				_tmp7_ = self->priv->d_remote_ref_custom;
				gtk_toggle_button_set_active ((GtkToggleButton*) _tmp7_, TRUE);
			}
		}
	} else {
		GtkRadioButton* _tmp8_;
		_tmp8_ = self->priv->d_remote_ref_custom;
		gtk_toggle_button_set_active ((GtkToggleButton*) _tmp8_, TRUE);
	}
	_tmp9_ = self->priv->d_remote_name;
	gtk_combo_box_text_remove_all (_tmp9_);
	_tmp10_ = self->priv->d_repository;
	_tmp12_ = _tmp11_ = ggit_repository_list_remotes ((GgitRepository*) _tmp10_, &_inner_error0_);
	remotes = _tmp12_;
	remotes_length1 = _vala_array_length (_tmp11_);
	_remotes_size_ = remotes_length1;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (r);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	{
		gchar** remote_name_collection = NULL;
		gint remote_name_collection_length1 = 0;
		gint _remote_name_collection_size_ = 0;
		gint remote_name_it = 0;
		remote_name_collection = remotes;
		remote_name_collection_length1 = remotes_length1;
		for (remote_name_it = 0; remote_name_it < remote_name_collection_length1; remote_name_it = remote_name_it + 1) {
			gchar* _tmp13_;
			gchar* remote_name = NULL;
			_tmp13_ = g_strdup (remote_name_collection[remote_name_it]);
			remote_name = _tmp13_;
			{
				GtkComboBoxText* _tmp14_;
				const gchar* _tmp15_;
				const gchar* _tmp16_;
				_tmp14_ = self->priv->d_remote_name;
				_tmp15_ = remote_name;
				_tmp16_ = remote_name;
				gtk_combo_box_text_append (_tmp14_, _tmp15_, _tmp16_);
				_g_free0 (remote_name);
			}
		}
	}
	_tmp17_ = self->priv->d_remote_reference;
	if (_tmp17_ != NULL) {
		GtkComboBoxText* _tmp18_;
		GitgRef* _tmp19_;
		GitgParsedRefName* _tmp20_;
		GitgParsedRefName* _tmp21_;
		GitgParsedRefName* _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		_tmp18_ = self->priv->d_remote_name;
		_tmp19_ = self->priv->d_remote_reference;
		_tmp20_ = gitg_ref_get_parsed_name (_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp22_ = _tmp21_;
		_tmp23_ = gitg_parsed_ref_name_get_remote_name (_tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		gtk_combo_box_set_active_id ((GtkComboBox*) _tmp18_, _tmp25_);
		_g_free0 (_tmp25_);
		_g_object_unref0 (_tmp22_);
	} else {
		gboolean _tmp26_ = FALSE;
		gboolean _tmp27_;
		gboolean _tmp28_;
		_tmp27_ = gitg_push_dialog_get_smart (self);
		_tmp28_ = _tmp27_;
		if (_tmp28_) {
			_tmp26_ = remotes_length1 == 1;
		} else {
			_tmp26_ = FALSE;
		}
		if (_tmp26_) {
			GtkComboBoxText* _tmp29_;
			const gchar* _tmp30_;
			_tmp29_ = self->priv->d_remote_name;
			_tmp30_ = remotes[0];
			gtk_combo_box_set_active_id ((GtkComboBox*) _tmp29_, _tmp30_);
		} else {
			gboolean _tmp31_ = FALSE;
			gboolean _tmp32_;
			gboolean _tmp33_;
			_tmp32_ = gitg_push_dialog_get_smart (self);
			_tmp33_ = _tmp32_;
			if (_tmp33_) {
				_tmp31_ = remotes_length1 > 1;
			} else {
				_tmp31_ = FALSE;
			}
			if (_tmp31_) {
				{
					gchar* main_remote = NULL;
					GitgRepository* _tmp34_;
					gchar* _tmp35_;
					GeeArrayList* gremotes = NULL;
					gchar** _tmp36_;
					gint _tmp36__length1;
					GeeArrayList* _tmp37_;
					GeeArrayList* _tmp38_;
					const gchar* _tmp39_;
					_tmp34_ = self->priv->d_repository;
					_tmp35_ = gitg_utils_get_config_value (_tmp34_, "gitg.main-remote", "origin");
					main_remote = _tmp35_;
					_tmp36_ = (remotes != NULL) ? _vala_array_dup20 (remotes, remotes_length1) : remotes;
					_tmp36__length1 = remotes_length1;
					_tmp37_ = gee_array_list_new_wrap (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp36_, _tmp36__length1, NULL, NULL, NULL);
					gremotes = _tmp37_;
					_tmp38_ = gremotes;
					_tmp39_ = main_remote;
					if (gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp38_, _tmp39_)) {
						GtkComboBoxText* _tmp40_;
						const gchar* _tmp41_;
						_tmp40_ = self->priv->d_remote_name;
						_tmp41_ = main_remote;
						gtk_combo_box_set_active_id ((GtkComboBox*) _tmp40_, _tmp41_);
					}
					_g_object_unref0 (gremotes);
					_g_free0 (main_remote);
				}
				goto __finally0;
				__catch0_g_error:
				{
					g_clear_error (&_inner_error0_);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					remotes = (_vala_array_free (remotes, remotes_length1, (GDestroyNotify) g_free), NULL);
					_g_object_unref0 (r);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
			}
		}
	}
	remotes = (_vala_array_free (remotes, remotes_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (r);
}

static Block81Data*
block81_data_ref (Block81Data* _data81_)
{
	g_atomic_int_inc (&_data81_->_ref_count_);
	return _data81_;
}

static void
block81_data_unref (void * _userdata_)
{
	Block81Data* _data81_;
	_data81_ = (Block81Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data81_->_ref_count_)) {
		GitgPushDialog* self;
		self = _data81_->self;
		_g_free0 (_data81_->remote_selected);
		_g_object_unref0 (self);
		g_slice_free (Block81Data, _data81_);
	}
}

static gint
___lambda222_ (Block81Data* _data81_,
               const gchar* name)
{
	GitgPushDialog* self;
	GitgRef* reference = NULL;
	GtkRadioButton* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp31_ = FALSE;
	GtkRadioButton* _tmp32_;
	gboolean _tmp33_;
	gboolean _tmp34_;
	GError* _inner_error0_ = NULL;
	gint result;
	self = _data81_->self;
	g_return_val_if_fail (name != NULL, -1);
	{
		GitgRef* _tmp0_ = NULL;
		GitgRepository* _tmp1_;
		GitgRef* _tmp2_;
		GitgRef* _tmp3_;
		GgitRefType type = 0;
		GitgRef* _tmp4_;
		_tmp1_ = self->priv->d_repository;
		_tmp2_ = gitg_repository_lookup_reference (_tmp1_, name, &_inner_error0_);
		_tmp0_ = _tmp2_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp3_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (reference);
		reference = _tmp3_;
		_tmp4_ = reference;
		type = ggit_ref_get_reference_type ((GgitRef*) _tmp4_);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = 0;
		_g_object_unref0 (reference);
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp5_ = -1;
		_g_object_unref0 (reference);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp5_;
	}
	_tmp6_ = self->priv->d_remote_ref_branch;
	_tmp7_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp6_);
	_tmp8_ = _tmp7_;
	if (_tmp8_) {
		gboolean _tmp9_ = FALSE;
		gboolean _tmp10_ = FALSE;
		GitgRef* _tmp11_;
		gchar* remote_ref = NULL;
		GitgRef* _tmp21_;
		GitgParsedRefName* _tmp22_;
		GitgParsedRefName* _tmp23_;
		GitgParsedRefName* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		GtkComboBoxText* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		_tmp11_ = reference;
		if (!ggit_ref_is_remote ((GgitRef*) _tmp11_)) {
			_tmp10_ = TRUE;
		} else {
			GitgRef* _tmp12_;
			_tmp12_ = reference;
			_tmp10_ = ggit_ref_get_reference_type ((GgitRef*) _tmp12_) == GGIT_REF_SYMBOLIC;
		}
		if (_tmp10_) {
			_tmp9_ = TRUE;
		} else {
			GitgRef* _tmp13_;
			GitgParsedRefName* _tmp14_;
			GitgParsedRefName* _tmp15_;
			GitgParsedRefName* _tmp16_;
			gchar* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			const gchar* _tmp20_;
			_tmp13_ = reference;
			_tmp14_ = gitg_ref_get_parsed_name (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = _tmp15_;
			_tmp17_ = gitg_parsed_ref_name_get_remote_name (_tmp16_);
			_tmp18_ = _tmp17_;
			_tmp19_ = _tmp18_;
			_tmp20_ = _data81_->remote_selected;
			_tmp9_ = g_strcmp0 (_tmp19_, _tmp20_) != 0;
			_g_free0 (_tmp19_);
			_g_object_unref0 (_tmp16_);
		}
		if (_tmp9_) {
			result = 0;
			_g_object_unref0 (reference);
			return result;
		}
		_tmp21_ = reference;
		_tmp22_ = gitg_ref_get_parsed_name (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = _tmp23_;
		_tmp25_ = gitg_parsed_ref_name_get_remote_branch (_tmp24_);
		_tmp26_ = _tmp25_;
		_tmp27_ = _tmp26_;
		_g_object_unref0 (_tmp24_);
		remote_ref = _tmp27_;
		_tmp28_ = self->priv->d_remote_ref_name;
		_tmp29_ = remote_ref;
		_tmp30_ = remote_ref;
		gtk_combo_box_text_append (_tmp28_, _tmp29_, _tmp30_);
		_g_free0 (remote_ref);
	}
	_tmp32_ = self->priv->d_remote_ref_tag;
	_tmp33_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp32_);
	_tmp34_ = _tmp33_;
	if (_tmp34_) {
		GitgRef* _tmp35_;
		_tmp35_ = reference;
		_tmp31_ = ggit_ref_is_tag ((GgitRef*) _tmp35_);
	} else {
		_tmp31_ = FALSE;
	}
	if (_tmp31_) {
		gchar* remote_ref = NULL;
		GitgRef* _tmp36_;
		GitgParsedRefName* _tmp37_;
		GitgParsedRefName* _tmp38_;
		GitgParsedRefName* _tmp39_;
		gchar* _tmp40_;
		gchar* _tmp41_;
		gchar* _tmp42_;
		GtkComboBoxText* _tmp43_;
		const gchar* _tmp44_;
		const gchar* _tmp45_;
		_tmp36_ = reference;
		_tmp37_ = gitg_ref_get_parsed_name (_tmp36_);
		_tmp38_ = _tmp37_;
		_tmp39_ = _tmp38_;
		_tmp40_ = gitg_parsed_ref_name_get_shortname (_tmp39_);
		_tmp41_ = _tmp40_;
		_tmp42_ = _tmp41_;
		_g_object_unref0 (_tmp39_);
		remote_ref = _tmp42_;
		_tmp43_ = self->priv->d_remote_ref_name;
		_tmp44_ = remote_ref;
		_tmp45_ = remote_ref;
		gtk_combo_box_text_append (_tmp43_, _tmp44_, _tmp45_);
		_g_free0 (remote_ref);
	}
	result = 0;
	_g_object_unref0 (reference);
	return result;
}

static gint
____lambda222__ggit_references_name_callback (const gchar* name,
                                              gpointer self)
{
	gint result;
	result = ___lambda222_ (self, name);
	return result;
}

static void
gitg_push_dialog_update_remote_ref_entries (GitgPushDialog* self)
{
	Block81Data* _data81_;
	GtkComboBoxText* _tmp0_;
	GtkEntry* entry = NULL;
	GtkComboBoxText* _tmp1_;
	GtkWidget* _tmp2_;
	GtkEntry* _tmp3_;
	GtkEntry* _tmp4_;
	GtkComboBoxText* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	const gchar* _tmp8_;
	GitgRef* _tmp10_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_data81_ = g_slice_new0 (Block81Data);
	_data81_->_ref_count_ = 1;
	_data81_->self = g_object_ref (self);
	_tmp0_ = self->priv->d_remote_ref_name;
	gtk_combo_box_text_remove_all (_tmp0_);
	_tmp1_ = self->priv->d_remote_ref_name;
	_tmp2_ = gtk_bin_get_child ((GtkBin*) _tmp1_);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_entry_get_type ()) ? ((GtkEntry*) _tmp2_) : NULL);
	entry = _tmp3_;
	_tmp4_ = entry;
	gtk_entry_set_text (_tmp4_, "");
	_tmp5_ = self->priv->d_remote_name;
	_tmp6_ = gtk_combo_box_get_active_id ((GtkComboBox*) _tmp5_);
	_tmp7_ = g_strdup (_tmp6_);
	_data81_->remote_selected = _tmp7_;
	_tmp8_ = _data81_->remote_selected;
	if (_tmp8_ == NULL) {
		_g_object_unref0 (entry);
		block81_data_unref (_data81_);
		_data81_ = NULL;
		return;
	}
	{
		GitgRepository* _tmp9_;
		_tmp9_ = self->priv->d_repository;
		ggit_repository_references_foreach_name ((GgitRepository*) _tmp9_, ____lambda222__ggit_references_name_callback, _data81_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (entry);
		block81_data_unref (_data81_);
		_data81_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_tmp10_ = self->priv->d_remote_reference;
	if (_tmp10_ != NULL) {
		GtkComboBoxText* _tmp11_;
		GitgRef* _tmp12_;
		GitgParsedRefName* _tmp13_;
		GitgParsedRefName* _tmp14_;
		GitgParsedRefName* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp11_ = self->priv->d_remote_ref_name;
		_tmp12_ = self->priv->d_remote_reference;
		_tmp13_ = gitg_ref_get_parsed_name (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = gitg_parsed_ref_name_get_remote_branch (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_;
		gtk_combo_box_set_active_id ((GtkComboBox*) _tmp11_, _tmp18_);
		_g_free0 (_tmp18_);
		_g_object_unref0 (_tmp15_);
	} else {
		gboolean _tmp19_;
		gboolean _tmp20_;
		_tmp19_ = gitg_push_dialog_get_smart (self);
		_tmp20_ = _tmp19_;
		if (_tmp20_) {
			GitgRef* r = NULL;
			GObject* _tmp21_;
			GitgRef* _tmp22_;
			GitgRef* _tmp23_;
			_tmp21_ = self->priv->d_reference;
			_tmp22_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp21_, GITG_TYPE_REF) ? ((GitgRef*) _tmp21_) : NULL);
			r = _tmp22_;
			_tmp23_ = r;
			if (_tmp23_ != NULL) {
				gboolean _tmp24_ = FALSE;
				GitgRef* _tmp25_;
				_tmp25_ = r;
				if (ggit_ref_is_branch ((GgitRef*) _tmp25_)) {
					_tmp24_ = TRUE;
				} else {
					GitgRef* _tmp26_;
					_tmp26_ = r;
					_tmp24_ = ggit_ref_is_tag ((GgitRef*) _tmp26_);
				}
				if (_tmp24_) {
					GtkEntry* _tmp27_;
					GitgRef* _tmp28_;
					GitgParsedRefName* _tmp29_;
					GitgParsedRefName* _tmp30_;
					GitgParsedRefName* _tmp31_;
					gchar* _tmp32_;
					gchar* _tmp33_;
					gchar* _tmp34_;
					_tmp27_ = entry;
					_tmp28_ = r;
					_tmp29_ = gitg_ref_get_parsed_name (_tmp28_);
					_tmp30_ = _tmp29_;
					_tmp31_ = _tmp30_;
					_tmp32_ = gitg_parsed_ref_name_get_shortname (_tmp31_);
					_tmp33_ = _tmp32_;
					_tmp34_ = _tmp33_;
					gtk_entry_set_text (_tmp27_, _tmp34_);
					_g_free0 (_tmp34_);
					_g_object_unref0 (_tmp31_);
				}
			}
			_g_object_unref0 (r);
		}
	}
	_g_object_unref0 (entry);
	block81_data_unref (_data81_);
	_data81_ = NULL;
}

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

void
gitg_push_dialog_set_smart (GitgPushDialog* self,
                            gboolean value)
{
	GtkCheckButton* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->d_smart;
	gtk_toggle_button_set_active ((GtkToggleButton*) _tmp0_, value);
	g_object_notify_by_pspec ((GObject *) self, gitg_push_dialog_properties[GITG_PUSH_DIALOG_SMART_PROPERTY]);
}

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_push_dialog_get_local_ref (GitgPushDialog* 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_local_ref;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	result = _tmp3_;
	return result;
}

gchar*
gitg_push_dialog_get_remote_name (GitgPushDialog* self)
{
	gchar* result;
	GtkComboBoxText* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_remote_name;
	_tmp1_ = gtk_combo_box_text_get_active_text (_tmp0_);
	result = _tmp1_;
	return result;
}

gchar*
gitg_push_dialog_get_remote_ref_name (GitgPushDialog* self)
{
	gchar* result;
	GtkComboBoxText* _tmp0_;
	gchar* _tmp1_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->d_remote_ref_name;
	_tmp1_ = gtk_combo_box_text_get_active_text (_tmp0_);
	result = _tmp1_;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

gchar*
gitg_push_dialog_get_remote_ref (GitgPushDialog* self)
{
	gchar* result;
	gchar* prefix = NULL;
	gchar* _tmp0_;
	gchar* remote_name = NULL;
	GtkComboBoxText* _tmp1_;
	gchar* _tmp2_;
	GtkRadioButton* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	prefix = _tmp0_;
	_tmp1_ = self->priv->d_remote_ref_name;
	_tmp2_ = gtk_combo_box_text_get_active_text (_tmp1_);
	remote_name = _tmp2_;
	_tmp3_ = self->priv->d_remote_ref_branch;
	_tmp4_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		gchar* _tmp6_;
		_tmp6_ = g_strdup ("refs/heads/");
		_g_free0 (prefix);
		prefix = _tmp6_;
	} else {
		GtkRadioButton* _tmp7_;
		gboolean _tmp8_;
		gboolean _tmp9_;
		_tmp7_ = self->priv->d_remote_ref_tag;
		_tmp8_ = gtk_toggle_button_get_active ((GtkToggleButton*) _tmp7_);
		_tmp9_ = _tmp8_;
		if (_tmp9_) {
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("refs/tags/");
			_g_free0 (prefix);
			prefix = _tmp10_;
		}
	}
	_tmp11_ = prefix;
	_tmp12_ = string_to_string (_tmp11_);
	_tmp13_ = remote_name;
	_tmp14_ = string_to_string (_tmp13_);
	_tmp15_ = g_strconcat (_tmp12_, _tmp14_, NULL);
	result = _tmp15_;
	_g_free0 (remote_name);
	_g_free0 (prefix);
	return result;
}

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

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

static void
_gitg_push_dialog_input_changed_gtk_combo_box_changed (GtkComboBox* _sender,
                                                       gpointer self)
{
	gitg_push_dialog_input_changed ((GitgPushDialog*) self);
}

static void
_gitg_push_dialog_update_remote_ref_entries_gtk_combo_box_changed (GtkComboBox* _sender,
                                                                   gpointer self)
{
	gitg_push_dialog_update_remote_ref_entries ((GitgPushDialog*) self);
}

static void
_gitg_push_dialog_update_remote_ref_entries_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                                       gpointer self)
{
	gitg_push_dialog_update_remote_ref_entries ((GitgPushDialog*) self);
}

static void
_gitg_push_dialog_update_remote_entries_gtk_button_clicked (GtkButton* _sender,
                                                            gpointer self)
{
	gitg_push_dialog_update_remote_entries ((GitgPushDialog*) self);
}

static void
_gitg_push_dialog_update_force_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                          gpointer self)
{
	gitg_push_dialog_update_force ((GitgPushDialog*) self);
}

static GObject *
gitg_push_dialog_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GitgPushDialog * self;
	GtkComboBoxText* _tmp0_;
	GtkComboBoxText* _tmp1_;
	GtkComboBoxText* _tmp2_;
	GtkRadioButton* _tmp3_;
	GtkRadioButton* _tmp4_;
	GtkRadioButton* _tmp5_;
	GtkButton* _tmp6_;
	GtkCheckButton* _tmp7_;
	GtkButton* _tmp8_;
	parent_class = G_OBJECT_CLASS (gitg_push_dialog_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_PUSH_DIALOG, GitgPushDialog);
	_tmp0_ = self->priv->d_remote_name;
	g_signal_connect_object ((GtkComboBox*) _tmp0_, "changed", (GCallback) _gitg_push_dialog_input_changed_gtk_combo_box_changed, self, 0);
	_tmp1_ = self->priv->d_remote_ref_name;
	g_signal_connect_object ((GtkComboBox*) _tmp1_, "changed", (GCallback) _gitg_push_dialog_input_changed_gtk_combo_box_changed, self, 0);
	_tmp2_ = self->priv->d_remote_name;
	g_signal_connect_object ((GtkComboBox*) _tmp2_, "changed", (GCallback) _gitg_push_dialog_update_remote_ref_entries_gtk_combo_box_changed, self, 0);
	_tmp3_ = self->priv->d_remote_ref_branch;
	g_signal_connect_object ((GtkToggleButton*) _tmp3_, "toggled", (GCallback) _gitg_push_dialog_update_remote_ref_entries_gtk_toggle_button_toggled, self, 0);
	_tmp4_ = self->priv->d_remote_ref_tag;
	g_signal_connect_object ((GtkToggleButton*) _tmp4_, "toggled", (GCallback) _gitg_push_dialog_update_remote_ref_entries_gtk_toggle_button_toggled, self, 0);
	_tmp5_ = self->priv->d_remote_ref_custom;
	g_signal_connect_object ((GtkToggleButton*) _tmp5_, "toggled", (GCallback) _gitg_push_dialog_update_remote_ref_entries_gtk_toggle_button_toggled, self, 0);
	_tmp6_ = self->priv->d_button_restart;
	g_signal_connect_object (_tmp6_, "clicked", (GCallback) _gitg_push_dialog_update_remote_entries_gtk_button_clicked, self, 0);
	_tmp7_ = self->priv->d_force;
	g_signal_connect_object ((GtkToggleButton*) _tmp7_, "toggled", (GCallback) _gitg_push_dialog_update_force_gtk_toggle_button_toggled, self, 0);
	_tmp8_ = self->priv->d_button_push;
	gtk_window_set_default ((GtkWindow*) self, (GtkWidget*) _tmp8_);
	gtk_dialog_set_default_response ((GtkDialog*) self, (gint) GTK_RESPONSE_OK);
	return obj;
}

static void
gitg_push_dialog_class_init (GitgPushDialogClass * klass,
                             gpointer klass_data)
{
	gitg_push_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GitgPushDialog_private_offset);
	((GtkWidgetClass *) klass)->show = (void (*) (GtkWidget*)) gitg_push_dialog_real_show;
	G_OBJECT_CLASS (klass)->get_property = _vala_gitg_push_dialog_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gitg_push_dialog_set_property;
	G_OBJECT_CLASS (klass)->constructor = gitg_push_dialog_constructor;
	G_OBJECT_CLASS (klass)->finalize = gitg_push_dialog_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_SMART_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_SMART_PROPERTY] = g_param_spec_boolean ("smart", "smart", "smart", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_LOCAL_REF_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_LOCAL_REF_PROPERTY] = g_param_spec_string ("local-ref", "local-ref", "local-ref", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_REMOTE_NAME_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_REMOTE_NAME_PROPERTY] = g_param_spec_string ("remote-name", "remote-name", "remote-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_REMOTE_REF_NAME_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_REMOTE_REF_NAME_PROPERTY] = g_param_spec_string ("remote-ref-name", "remote-ref-name", "remote-ref-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_REMOTE_REF_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_REMOTE_REF_PROPERTY] = g_param_spec_string ("remote-ref", "remote-ref", "remote-ref", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_FORCE_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_FORCE_PROPERTY] = g_param_spec_boolean ("force", "force", "force", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GITG_PUSH_DIALOG_SET_UPSTREAM_PROPERTY, gitg_push_dialog_properties[GITG_PUSH_DIALOG_SET_UPSTREAM_PROPERTY] = g_param_spec_boolean ("set-upstream", "set-upstream", "set-upstream", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/gitg/ui/gitg-push-dialog.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_button_push", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_button_push));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_local_ref", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_local_ref));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_remote_name", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_remote_name));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_remote_ref_name", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_remote_ref_name));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_local_ref_tag", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_local_ref_tag));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_local_ref_branch", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_local_ref_branch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_local_ref_commit", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_local_ref_commit));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_remote_ref_tag", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_remote_ref_tag));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_remote_ref_branch", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_remote_ref_branch));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_remote_ref_custom", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_remote_ref_custom));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_force", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_force));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_upstream", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_upstream));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_smart", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_smart));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "d_button_restart", FALSE, GitgPushDialog_private_offset + G_STRUCT_OFFSET (GitgPushDialogPrivate, d_button_restart));
}

static void
gitg_push_dialog_instance_init (GitgPushDialog * self,
                                gpointer klass)
{
	self->priv = gitg_push_dialog_get_instance_private (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
gitg_push_dialog_finalize (GObject * obj)
{
	GitgPushDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_PUSH_DIALOG, GitgPushDialog);
	_g_object_unref0 (self->priv->d_repository);
	_g_object_unref0 (self->priv->d_reference);
	_g_object_unref0 (self->priv->d_remote_reference);
	G_OBJECT_CLASS (gitg_push_dialog_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gitg_push_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GitgPushDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_push_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GitgPushDialog), 0, (GInstanceInitFunc) gitg_push_dialog_instance_init, NULL };
	GType gitg_push_dialog_type_id;
	gitg_push_dialog_type_id = g_type_register_static (gtk_dialog_get_type (), "GitgPushDialog", &g_define_type_info, 0);
	GitgPushDialog_private_offset = g_type_add_instance_private (gitg_push_dialog_type_id, sizeof (GitgPushDialogPrivate));
	return gitg_push_dialog_type_id;
}

GType
gitg_push_dialog_get_type (void)
{
	static gsize gitg_push_dialog_type_id__once = 0;
	if (g_once_init_enter (&gitg_push_dialog_type_id__once)) {
		GType gitg_push_dialog_type_id;
		gitg_push_dialog_type_id = gitg_push_dialog_get_type_once ();
		g_once_init_leave (&gitg_push_dialog_type_id__once, gitg_push_dialog_type_id);
	}
	return gitg_push_dialog_type_id__once;
}

static void
_vala_gitg_push_dialog_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GitgPushDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_PUSH_DIALOG, GitgPushDialog);
	switch (property_id) {
		case GITG_PUSH_DIALOG_SMART_PROPERTY:
		g_value_set_boolean (value, gitg_push_dialog_get_smart (self));
		break;
		case GITG_PUSH_DIALOG_LOCAL_REF_PROPERTY:
		g_value_take_string (value, gitg_push_dialog_get_local_ref (self));
		break;
		case GITG_PUSH_DIALOG_REMOTE_NAME_PROPERTY:
		g_value_take_string (value, gitg_push_dialog_get_remote_name (self));
		break;
		case GITG_PUSH_DIALOG_REMOTE_REF_NAME_PROPERTY:
		g_value_take_string (value, gitg_push_dialog_get_remote_ref_name (self));
		break;
		case GITG_PUSH_DIALOG_REMOTE_REF_PROPERTY:
		g_value_take_string (value, gitg_push_dialog_get_remote_ref (self));
		break;
		case GITG_PUSH_DIALOG_FORCE_PROPERTY:
		g_value_set_boolean (value, gitg_push_dialog_get_force (self));
		break;
		case GITG_PUSH_DIALOG_SET_UPSTREAM_PROPERTY:
		g_value_set_boolean (value, gitg_push_dialog_get_set_upstream (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gitg_push_dialog_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	GitgPushDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GITG_TYPE_PUSH_DIALOG, GitgPushDialog);
	switch (property_id) {
		case GITG_PUSH_DIALOG_SMART_PROPERTY:
		gitg_push_dialog_set_smart (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

