/* passphrase-prompt.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from passphrase-prompt.vala, do not modify */

/*
 * Seahorse
 *
 * Copyright (C) 2003 Jacob Perkins
 * Copyright (C) 2004 - 2006 Stefan Walter
 * Copyright (C) 2011 Collabora Ltd.
 * Copyright (C) 2017 Niels De Graef
 *
 * This program 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.
 *
 * This program 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 this program; if not, see
 * <http://www.gnu.org/licenses/>.
 */
/* TODO move these into a namespace or class*/

#include "seahorse-common.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <ui/gcr-ui.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>

#define SEAHORSE_PASSPHRASE_PROMPT_HIG_SMALL 6
#define SEAHORSE_PASSPHRASE_PROMPT_HIG_LARGE 12
#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

enum  {
	SEAHORSE_PASSPHRASE_PROMPT_0_PROPERTY,
	SEAHORSE_PASSPHRASE_PROMPT_NUM_PROPERTIES
};
static GParamSpec* seahorse_passphrase_prompt_properties[SEAHORSE_PASSPHRASE_PROMPT_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 _SeahorsePassphrasePromptPrivate {
	GtkEntry* secure_entry;
	GtkEntry* confirm_entry;
	GtkCheckButton* check_option;
	gboolean keyboard_grabbed;
};

static gint SeahorsePassphrasePrompt_private_offset;
static gpointer seahorse_passphrase_prompt_parent_class = NULL;

static gchar* seahorse_passphrase_prompt_utf8_validate (SeahorsePassphrasePrompt* self,
                                                 const gchar* text);
static void seahorse_passphrase_prompt_confirm_callback (SeahorsePassphrasePrompt* self,
                                                  GtkWidget* widget);
static void _seahorse_passphrase_prompt_confirm_callback_gtk_entry_activate (GtkEntry* _sender,
                                                                      gpointer self);
static void seahorse_passphrase_prompt_entry_changed (SeahorsePassphrasePrompt* self,
                                               GtkEditable* editable);
static void _seahorse_passphrase_prompt_entry_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                     gpointer self);
static void __lambda14_ (SeahorsePassphrasePrompt* self);
static void ___lambda14__gtk_entry_activate (GtkEntry* _sender,
                                      gpointer self);
static gboolean seahorse_passphrase_prompt_grab_keyboard (SeahorsePassphrasePrompt* self,
                                                   GtkWidget* win,
                                                   GdkEvent* event);
static gboolean _seahorse_passphrase_prompt_grab_keyboard_gtk_widget_map_event (GtkWidget* _sender,
                                                                         GdkEventAny* event,
                                                                         gpointer self);
static gboolean seahorse_passphrase_prompt_ungrab_keyboard (SeahorsePassphrasePrompt* self,
                                                     GtkWidget* win,
                                                     GdkEvent* event);
static gboolean _seahorse_passphrase_prompt_ungrab_keyboard_gtk_widget_unmap_event (GtkWidget* _sender,
                                                                             GdkEventAny* event,
                                                                             gpointer self);
static gboolean seahorse_passphrase_prompt_window_state_changed (SeahorsePassphrasePrompt* self,
                                                          GtkWidget* win,
                                                          GdkEventWindowState* event);
static gboolean _seahorse_passphrase_prompt_window_state_changed_gtk_widget_window_state_event (GtkWidget* _sender,
                                                                                         GdkEventWindowState* event,
                                                                                         gpointer self);
static gboolean seahorse_passphrase_prompt_key_press (SeahorsePassphrasePrompt* self,
                                               GtkWidget* widget,
                                               GdkEventKey* event);
static gboolean _seahorse_passphrase_prompt_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                           GdkEventKey* event,
                                                                           gpointer self);
static void seahorse_passphrase_prompt_finalize (GObject * obj);
static GType seahorse_passphrase_prompt_get_type_once (void);

static inline gpointer
seahorse_passphrase_prompt_get_instance_private (SeahorsePassphrasePrompt* self)
{
	return G_STRUCT_MEMBER_P (self, SeahorsePassphrasePrompt_private_offset);
}

static void
_seahorse_passphrase_prompt_confirm_callback_gtk_entry_activate (GtkEntry* _sender,
                                                                 gpointer self)
{
	seahorse_passphrase_prompt_confirm_callback ((SeahorsePassphrasePrompt*) self, _sender);
}

static void
_seahorse_passphrase_prompt_entry_changed_gtk_editable_changed (GtkEditable* _sender,
                                                                gpointer self)
{
	seahorse_passphrase_prompt_entry_changed ((SeahorsePassphrasePrompt*) self, _sender);
}

static void
__lambda14_ (SeahorsePassphrasePrompt* self)
{
	GtkWidget* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = gtk_dialog_get_widget_for_response ((GtkDialog*) self, (gint) GTK_RESPONSE_ACCEPT);
	_tmp1_ = gtk_widget_get_sensitive (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		gtk_dialog_response ((GtkDialog*) self, (gint) GTK_RESPONSE_ACCEPT);
	}
}

static void
___lambda14__gtk_entry_activate (GtkEntry* _sender,
                                 gpointer self)
{
	__lambda14_ ((SeahorsePassphrasePrompt*) self);
}

static gboolean
_seahorse_passphrase_prompt_grab_keyboard_gtk_widget_map_event (GtkWidget* _sender,
                                                                GdkEventAny* event,
                                                                gpointer self)
{
	gboolean result;
	result = seahorse_passphrase_prompt_grab_keyboard ((SeahorsePassphrasePrompt*) self, _sender, event);
	return result;
}

static gboolean
_seahorse_passphrase_prompt_ungrab_keyboard_gtk_widget_unmap_event (GtkWidget* _sender,
                                                                    GdkEventAny* event,
                                                                    gpointer self)
{
	gboolean result;
	result = seahorse_passphrase_prompt_ungrab_keyboard ((SeahorsePassphrasePrompt*) self, _sender, event);
	return result;
}

static gboolean
_seahorse_passphrase_prompt_window_state_changed_gtk_widget_window_state_event (GtkWidget* _sender,
                                                                                GdkEventWindowState* event,
                                                                                gpointer self)
{
	gboolean result;
	result = seahorse_passphrase_prompt_window_state_changed ((SeahorsePassphrasePrompt*) self, _sender, event);
	return result;
}

static gboolean
_seahorse_passphrase_prompt_key_press_gtk_widget_key_press_event (GtkWidget* _sender,
                                                                  GdkEventKey* event,
                                                                  gpointer self)
{
	gboolean result;
	result = seahorse_passphrase_prompt_key_press ((SeahorsePassphrasePrompt*) self, _sender, event);
	return result;
}

SeahorsePassphrasePrompt*
seahorse_passphrase_prompt_construct (GType object_type,
                                      const gchar* title,
                                      const gchar* description,
                                      const gchar* prompt,
                                      const gchar* check,
                                      gboolean confirm)
{
	SeahorsePassphrasePrompt * self = NULL;
	GtkBox* wvbox = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkBox* _tmp3_;
	GtkBox* chbox = NULL;
	GtkBox* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkImage* img = NULL;
	GtkImage* _tmp7_;
	GtkImage* _tmp8_;
	GtkBox* _tmp9_;
	GtkImage* _tmp10_;
	GtkBox* box = NULL;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkBox* _tmp13_;
	GtkGrid* grid = NULL;
	GtkGrid* _tmp22_;
	GtkGrid* _tmp23_;
	GtkGrid* _tmp24_;
	GtkBox* _tmp25_;
	GtkGrid* _tmp26_;
	const gchar* _tmp44_ = NULL;
	GtkLabel* confirm_label = NULL;
	gchar* _tmp45_;
	gchar* _tmp46_;
	GtkLabel* _tmp47_;
	GtkLabel* _tmp48_;
	GtkLabel* _tmp49_;
	GtkGrid* _tmp50_;
	GtkLabel* _tmp51_;
	GcrSecureEntryBuffer* _tmp52_;
	GcrSecureEntryBuffer* _tmp53_;
	GtkEntry* _tmp54_;
	GtkEntry* _tmp55_;
	GtkEntry* _tmp56_;
	GtkEntry* _tmp57_;
	GtkGrid* _tmp58_;
	GtkEntry* _tmp59_;
	GtkGrid* _tmp65_;
	GtkButton* cancel_button = NULL;
	GtkButton* _tmp66_;
	GtkButton* _tmp67_;
	GtkButton* _tmp68_;
	GtkButton* ok_button = NULL;
	GtkButton* _tmp69_;
	GtkButton* _tmp70_;
	GtkButton* _tmp71_;
	GtkButton* _tmp72_;
	GdkWindow* _tmp73_;
	g_return_val_if_fail (prompt != NULL, NULL);
	self = (SeahorsePassphrasePrompt*) g_object_new (object_type, "title", title, "modal", TRUE, "icon-name", "dialog-password-symbolic", NULL);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, SEAHORSE_PASSPHRASE_PROMPT_HIG_LARGE * 2);
	g_object_ref_sink (_tmp0_);
	wvbox = _tmp0_;
	_tmp1_ = gtk_dialog_get_content_area ((GtkDialog*) self);
	_tmp2_ = wvbox;
	gtk_container_add ((GtkContainer*) _tmp1_, (GtkWidget*) _tmp2_);
	_tmp3_ = wvbox;
	gtk_container_set_border_width ((GtkContainer*) _tmp3_, (guint) SEAHORSE_PASSPHRASE_PROMPT_HIG_LARGE);
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, SEAHORSE_PASSPHRASE_PROMPT_HIG_LARGE);
	g_object_ref_sink (_tmp4_);
	chbox = _tmp4_;
	_tmp5_ = wvbox;
	_tmp6_ = chbox;
	gtk_box_pack_start (_tmp5_, (GtkWidget*) _tmp6_, FALSE, FALSE, (guint) 0);
	_tmp7_ = (GtkImage*) gtk_image_new_from_icon_name ("dialog-password-symbolic", (GtkIconSize) GTK_ICON_SIZE_DIALOG);
	g_object_ref_sink (_tmp7_);
	img = _tmp7_;
	_tmp8_ = img;
	gtk_misc_set_alignment ((GtkMisc*) _tmp8_, 0.0f, 0.0f);
	_tmp9_ = chbox;
	_tmp10_ = img;
	gtk_box_pack_start (_tmp9_, (GtkWidget*) _tmp10_, FALSE, FALSE, (guint) 0);
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, SEAHORSE_PASSPHRASE_PROMPT_HIG_SMALL);
	g_object_ref_sink (_tmp11_);
	box = _tmp11_;
	_tmp12_ = chbox;
	_tmp13_ = box;
	gtk_box_pack_start (_tmp12_, (GtkWidget*) _tmp13_, TRUE, TRUE, (guint) 0);
	if (description != NULL) {
		GtkLabel* desc_label = NULL;
		gchar* _tmp14_;
		gchar* _tmp15_;
		GtkLabel* _tmp16_;
		GtkLabel* _tmp17_;
		GtkLabel* _tmp18_;
		GtkLabel* _tmp19_;
		GtkBox* _tmp20_;
		GtkLabel* _tmp21_;
		_tmp14_ = seahorse_passphrase_prompt_utf8_validate (self, description);
		_tmp15_ = _tmp14_;
		_tmp16_ = (GtkLabel*) gtk_label_new (_tmp15_);
		g_object_ref_sink (_tmp16_);
		_tmp17_ = _tmp16_;
		_g_free0 (_tmp15_);
		desc_label = _tmp17_;
		_tmp18_ = desc_label;
		gtk_misc_set_alignment ((GtkMisc*) _tmp18_, 0.0f, 0.5f);
		_tmp19_ = desc_label;
		gtk_label_set_line_wrap (_tmp19_, TRUE);
		_tmp20_ = box;
		_tmp21_ = desc_label;
		gtk_box_pack_start (_tmp20_, (GtkWidget*) _tmp21_, TRUE, FALSE, (guint) 0);
		_g_object_unref0 (desc_label);
	}
	_tmp22_ = (GtkGrid*) gtk_grid_new ();
	g_object_ref_sink (_tmp22_);
	grid = _tmp22_;
	_tmp23_ = grid;
	gtk_grid_set_row_spacing (_tmp23_, (guint) SEAHORSE_PASSPHRASE_PROMPT_HIG_SMALL);
	_tmp24_ = grid;
	gtk_grid_set_column_spacing (_tmp24_, (guint) SEAHORSE_PASSPHRASE_PROMPT_HIG_LARGE);
	_tmp25_ = box;
	_tmp26_ = grid;
	gtk_box_pack_start (_tmp25_, (GtkWidget*) _tmp26_, FALSE, FALSE, (guint) 0);
	if (confirm) {
		GtkLabel* prompt_label = NULL;
		gchar* _tmp27_;
		gchar* _tmp28_;
		GtkLabel* _tmp29_;
		GtkLabel* _tmp30_;
		GtkLabel* _tmp31_;
		GtkGrid* _tmp32_;
		GtkLabel* _tmp33_;
		GcrSecureEntryBuffer* _tmp34_;
		GcrSecureEntryBuffer* _tmp35_;
		GtkEntry* _tmp36_;
		GtkEntry* _tmp37_;
		GtkEntry* _tmp38_;
		GtkEntry* _tmp39_;
		GtkEntry* _tmp40_;
		GtkGrid* _tmp41_;
		GtkEntry* _tmp42_;
		GtkEntry* _tmp43_;
		_tmp27_ = seahorse_passphrase_prompt_utf8_validate (self, prompt);
		_tmp28_ = _tmp27_;
		_tmp29_ = (GtkLabel*) gtk_label_new (_tmp28_);
		g_object_ref_sink (_tmp29_);
		_tmp30_ = _tmp29_;
		_g_free0 (_tmp28_);
		prompt_label = _tmp30_;
		_tmp31_ = prompt_label;
		gtk_misc_set_alignment ((GtkMisc*) _tmp31_, 0.0f, 0.5f);
		_tmp32_ = grid;
		_tmp33_ = prompt_label;
		gtk_grid_attach (_tmp32_, (GtkWidget*) _tmp33_, 0, 0, 1, 1);
		_tmp34_ = (GcrSecureEntryBuffer*) gcr_secure_entry_buffer_new ();
		_tmp35_ = _tmp34_;
		_tmp36_ = (GtkEntry*) gtk_entry_new_with_buffer ((GtkEntryBuffer*) _tmp35_);
		g_object_ref_sink (_tmp36_);
		_g_object_unref0 (self->priv->confirm_entry);
		self->priv->confirm_entry = _tmp36_;
		_g_object_unref0 (_tmp35_);
		_tmp37_ = self->priv->confirm_entry;
		gtk_entry_set_visibility (_tmp37_, FALSE);
		_tmp38_ = self->priv->confirm_entry;
		gtk_widget_set_size_request ((GtkWidget*) _tmp38_, 200, -1);
		_tmp39_ = self->priv->confirm_entry;
		g_signal_connect_object (_tmp39_, "activate", (GCallback) _seahorse_passphrase_prompt_confirm_callback_gtk_entry_activate, self, 0);
		_tmp40_ = self->priv->confirm_entry;
		g_signal_connect_object ((GtkEditable*) _tmp40_, "changed", (GCallback) _seahorse_passphrase_prompt_entry_changed_gtk_editable_changed, self, 0);
		_tmp41_ = grid;
		_tmp42_ = self->priv->confirm_entry;
		gtk_grid_attach (_tmp41_, (GtkWidget*) _tmp42_, 1, 0, 1, 1);
		_tmp43_ = self->priv->confirm_entry;
		gtk_widget_grab_focus ((GtkWidget*) _tmp43_);
		_g_object_unref0 (prompt_label);
	}
	if (confirm) {
		_tmp44_ = _ ("Confirm:");
	} else {
		_tmp44_ = prompt;
	}
	_tmp45_ = seahorse_passphrase_prompt_utf8_validate (self, _tmp44_);
	_tmp46_ = _tmp45_;
	_tmp47_ = (GtkLabel*) gtk_label_new (_tmp46_);
	g_object_ref_sink (_tmp47_);
	_tmp48_ = _tmp47_;
	_g_free0 (_tmp46_);
	confirm_label = _tmp48_;
	_tmp49_ = confirm_label;
	gtk_misc_set_alignment ((GtkMisc*) _tmp49_, 0.0f, 0.5f);
	_tmp50_ = grid;
	_tmp51_ = confirm_label;
	gtk_grid_attach (_tmp50_, (GtkWidget*) _tmp51_, 0, 1, 1, 1);
	_tmp52_ = (GcrSecureEntryBuffer*) gcr_secure_entry_buffer_new ();
	_tmp53_ = _tmp52_;
	_tmp54_ = (GtkEntry*) gtk_entry_new_with_buffer ((GtkEntryBuffer*) _tmp53_);
	g_object_ref_sink (_tmp54_);
	_g_object_unref0 (self->priv->secure_entry);
	self->priv->secure_entry = _tmp54_;
	_g_object_unref0 (_tmp53_);
	_tmp55_ = self->priv->secure_entry;
	gtk_widget_set_size_request ((GtkWidget*) _tmp55_, 200, -1);
	_tmp56_ = self->priv->secure_entry;
	gtk_entry_set_visibility (_tmp56_, FALSE);
	_tmp57_ = self->priv->secure_entry;
	g_signal_connect_object (_tmp57_, "activate", (GCallback) ___lambda14__gtk_entry_activate, self, 0);
	_tmp58_ = grid;
	_tmp59_ = self->priv->secure_entry;
	gtk_grid_attach (_tmp58_, (GtkWidget*) _tmp59_, 1, 1, 1, 1);
	if (confirm) {
		GtkEntry* _tmp60_;
		_tmp60_ = self->priv->secure_entry;
		g_signal_connect_object ((GtkEditable*) _tmp60_, "changed", (GCallback) _seahorse_passphrase_prompt_entry_changed_gtk_editable_changed, self, 0);
	} else {
		GtkEntry* _tmp61_;
		_tmp61_ = self->priv->secure_entry;
		gtk_widget_grab_focus ((GtkWidget*) _tmp61_);
	}
	if (check != NULL) {
		GtkCheckButton* _tmp62_;
		GtkGrid* _tmp63_;
		GtkCheckButton* _tmp64_;
		_tmp62_ = (GtkCheckButton*) gtk_check_button_new_with_mnemonic (check);
		g_object_ref_sink (_tmp62_);
		_g_object_unref0 (self->priv->check_option);
		self->priv->check_option = _tmp62_;
		_tmp63_ = grid;
		_tmp64_ = self->priv->check_option;
		gtk_grid_attach (_tmp63_, (GtkWidget*) _tmp64_, 1, 2, 1, 1);
	}
	_tmp65_ = grid;
	gtk_widget_show_all ((GtkWidget*) _tmp65_);
	_tmp66_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_Cancel"));
	g_object_ref_sink (_tmp66_);
	cancel_button = _tmp66_;
	_tmp67_ = cancel_button;
	gtk_dialog_add_action_widget ((GtkDialog*) self, (GtkWidget*) _tmp67_, (gint) GTK_RESPONSE_REJECT);
	_tmp68_ = cancel_button;
	gtk_widget_set_can_default ((GtkWidget*) _tmp68_, TRUE);
	_tmp69_ = (GtkButton*) gtk_button_new_with_mnemonic (_ ("_OK"));
	g_object_ref_sink (_tmp69_);
	ok_button = _tmp69_;
	_tmp70_ = ok_button;
	gtk_dialog_add_action_widget ((GtkDialog*) self, (GtkWidget*) _tmp70_, (gint) GTK_RESPONSE_ACCEPT);
	_tmp71_ = ok_button;
	gtk_widget_set_can_default ((GtkWidget*) _tmp71_, TRUE);
	_tmp72_ = ok_button;
	gtk_widget_grab_default ((GtkWidget*) _tmp72_);
	g_signal_connect_object ((GtkWidget*) self, "map-event", (GCallback) _seahorse_passphrase_prompt_grab_keyboard_gtk_widget_map_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "unmap-event", (GCallback) _seahorse_passphrase_prompt_ungrab_keyboard_gtk_widget_unmap_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "window-state-event", (GCallback) _seahorse_passphrase_prompt_window_state_changed_gtk_widget_window_state_event, self, 0);
	g_signal_connect_object ((GtkWidget*) self, "key-press-event", (GCallback) _seahorse_passphrase_prompt_key_press_gtk_widget_key_press_event, self, 0);
	gtk_window_set_position ((GtkWindow*) self, GTK_WIN_POS_CENTER);
	gtk_window_set_resizable ((GtkWindow*) self, FALSE);
	gtk_window_set_keep_above ((GtkWindow*) self, TRUE);
	gtk_widget_show_all ((GtkWidget*) self);
	_tmp73_ = gtk_widget_get_window ((GtkWidget*) self);
	gdk_window_focus (_tmp73_, (guint32) GDK_CURRENT_TIME);
	if (confirm) {
		seahorse_passphrase_prompt_entry_changed (self, NULL);
	}
	_g_object_unref0 (ok_button);
	_g_object_unref0 (cancel_button);
	_g_object_unref0 (confirm_label);
	_g_object_unref0 (grid);
	_g_object_unref0 (box);
	_g_object_unref0 (img);
	_g_object_unref0 (chbox);
	_g_object_unref0 (wvbox);
	return self;
}

SeahorsePassphrasePrompt*
seahorse_passphrase_prompt_new (const gchar* title,
                                const gchar* description,
                                const gchar* prompt,
                                const gchar* check,
                                gboolean confirm)
{
	return seahorse_passphrase_prompt_construct (SEAHORSE_TYPE_PASSPHRASE_PROMPT, title, description, prompt, check, confirm);
}

SeahorsePassphrasePrompt*
seahorse_passphrase_prompt_show_dialog (const gchar* title,
                                        const gchar* description,
                                        const gchar* prompt,
                                        const gchar* check,
                                        gboolean confirm)
{
	const gchar* _tmp0_ = NULL;
	SeahorsePassphrasePrompt* _tmp1_;
	SeahorsePassphrasePrompt* result;
	_tmp0_ = prompt;
	if (_tmp0_ == NULL) {
		_tmp0_ = _ ("Password:");
	}
	_tmp1_ = seahorse_passphrase_prompt_new (title, description, _tmp0_, check, confirm);
	g_object_ref_sink (_tmp1_);
	result = _tmp1_;
	return result;
}

gchar*
seahorse_passphrase_prompt_get_text (SeahorsePassphrasePrompt* self)
{
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->secure_entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

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

static gchar*
seahorse_passphrase_prompt_utf8_validate (SeahorsePassphrasePrompt* self,
                                          const gchar* text)
{
	gchar* _result_ = NULL;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (text == NULL) {
		result = NULL;
		return result;
	}
	if (g_utf8_validate (text, (gssize) -1, NULL)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (text);
		result = _tmp0_;
		return result;
	}
	_tmp1_ = g_locale_to_utf8 (text, (gssize) -1, NULL, NULL, NULL);
	_result_ = _tmp1_;
	_tmp2_ = _result_;
	if (_tmp2_ == NULL) {
		gchar* p = NULL;
		gchar* _tmp7_;
		p = (gchar*) text;
		while (TRUE) {
			gchar* _tmp3_;
			gchar* _tmp4_ = NULL;
			gboolean _tmp5_;
			gchar* _tmp6_;
			_tmp3_ = p;
			_tmp5_ = g_utf8_validate ((const gchar*) _tmp3_, (gssize) -1, &_tmp4_);
			p = _tmp4_;
			if (!(!_tmp5_)) {
				break;
			}
			_tmp6_ = p;
			*_tmp6_ = '?';
		}
		_tmp7_ = g_strdup (text);
		_g_free0 (_result_);
		_result_ = _tmp7_;
	}
	result = _result_;
	return result;
}

static gboolean
seahorse_passphrase_prompt_key_press (SeahorsePassphrasePrompt* self,
                                      GtkWidget* widget,
                                      GdkEventKey* event)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (widget != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (event->keyval == GDK_KEY_Escape) {
		gtk_dialog_response ((GtkDialog*) self, (gint) GTK_RESPONSE_REJECT);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

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

static gboolean
seahorse_passphrase_prompt_grab_keyboard (SeahorsePassphrasePrompt* self,
                                          GtkWidget* win,
                                          GdkEvent* event)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (win != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (!self->priv->keyboard_grabbed) {
		GdkDisplay* display = NULL;
		GdkDisplay* _tmp0_;
		GdkDisplay* _tmp1_;
		GdkSeat* seat = NULL;
		GdkDisplay* _tmp2_;
		GdkSeat* _tmp3_;
		GdkSeat* _tmp4_;
		GdkGrabStatus grab_status = 0;
		GdkSeat* _tmp5_;
		GdkWindow* _tmp6_;
		_tmp0_ = gdk_display_get_default ();
		_tmp1_ = _g_object_ref0 (_tmp0_);
		display = _tmp1_;
		_tmp2_ = display;
		_tmp3_ = gdk_display_get_default_seat (_tmp2_);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		seat = _tmp4_;
		_tmp5_ = seat;
		_tmp6_ = gtk_widget_get_window (win);
		grab_status = gdk_seat_grab (_tmp5_, _tmp6_, GDK_SEAT_CAPABILITY_KEYBOARD, FALSE, NULL, event, NULL, NULL);
		if (grab_status != GDK_GRAB_SUCCESS) {
			g_message ("passphrase-prompt.vala:201: could not grab keyboard: %u", (guint) grab_status);
		}
		_g_object_unref0 (seat);
		_g_object_unref0 (display);
	}
	self->priv->keyboard_grabbed = TRUE;
	result = FALSE;
	return result;
}

static gboolean
seahorse_passphrase_prompt_ungrab_keyboard (SeahorsePassphrasePrompt* self,
                                            GtkWidget* win,
                                            GdkEvent* event)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (win != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	if (self->priv->keyboard_grabbed) {
		GdkDisplay* display = NULL;
		GdkDisplay* _tmp0_;
		GdkDisplay* _tmp1_;
		GdkSeat* seat = NULL;
		GdkDisplay* _tmp2_;
		GdkSeat* _tmp3_;
		GdkSeat* _tmp4_;
		GdkSeat* _tmp5_;
		_tmp0_ = gdk_display_get_default ();
		_tmp1_ = _g_object_ref0 (_tmp0_);
		display = _tmp1_;
		_tmp2_ = display;
		_tmp3_ = gdk_display_get_default_seat (_tmp2_);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		seat = _tmp4_;
		_tmp5_ = seat;
		gdk_seat_ungrab (_tmp5_);
		_g_object_unref0 (seat);
		_g_object_unref0 (display);
	}
	self->priv->keyboard_grabbed = FALSE;
	result = FALSE;
	return result;
}

static void
seahorse_passphrase_prompt_confirm_callback (SeahorsePassphrasePrompt* self,
                                             GtkWidget* widget)
{
	GtkEntry* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (widget != NULL);
	_tmp0_ = self->priv->secure_entry;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
}

static void
seahorse_passphrase_prompt_entry_changed (SeahorsePassphrasePrompt* self,
                                          GtkEditable* editable)
{
	GtkEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkEntry* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->secure_entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->confirm_entry;
	_tmp4_ = gtk_entry_get_text (_tmp3_);
	_tmp5_ = _tmp4_;
	gtk_dialog_set_response_sensitive ((GtkDialog*) self, (gint) GTK_RESPONSE_ACCEPT, g_strcmp0 (_tmp2_, _tmp5_) == 0);
}

static gboolean
seahorse_passphrase_prompt_window_state_changed (SeahorsePassphrasePrompt* self,
                                                 GtkWidget* win,
                                                 GdkEventWindowState* event)
{
	GdkWindowState state = 0U;
	GdkWindow* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (win != NULL, FALSE);
	g_return_val_if_fail (event != NULL, FALSE);
	_tmp0_ = gtk_widget_get_window (win);
	state = gdk_window_get_state (_tmp0_);
	if ((state & GDK_WINDOW_STATE_WITHDRAWN) == GDK_WINDOW_STATE_WITHDRAWN) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = (state & GDK_WINDOW_STATE_ICONIFIED) == GDK_WINDOW_STATE_ICONIFIED;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = (state & GDK_WINDOW_STATE_FULLSCREEN) == GDK_WINDOW_STATE_FULLSCREEN;
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (state & GDK_WINDOW_STATE_MAXIMIZED) == GDK_WINDOW_STATE_MAXIMIZED;
	}
	if (_tmp1_) {
		seahorse_passphrase_prompt_ungrab_keyboard (self, win, (GdkEvent*) event);
	} else {
		seahorse_passphrase_prompt_grab_keyboard (self, win, (GdkEvent*) event);
	}
	result = FALSE;
	return result;
}

static void
seahorse_passphrase_prompt_class_init (SeahorsePassphrasePromptClass * klass,
                                       gpointer klass_data)
{
	seahorse_passphrase_prompt_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SeahorsePassphrasePrompt_private_offset);
	G_OBJECT_CLASS (klass)->finalize = seahorse_passphrase_prompt_finalize;
}

static void
seahorse_passphrase_prompt_instance_init (SeahorsePassphrasePrompt * self,
                                          gpointer klass)
{
	self->priv = seahorse_passphrase_prompt_get_instance_private (self);
}

static void
seahorse_passphrase_prompt_finalize (GObject * obj)
{
	SeahorsePassphrasePrompt * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAHORSE_TYPE_PASSPHRASE_PROMPT, SeahorsePassphrasePrompt);
	_g_object_unref0 (self->priv->secure_entry);
	_g_object_unref0 (self->priv->confirm_entry);
	_g_object_unref0 (self->priv->check_option);
	G_OBJECT_CLASS (seahorse_passphrase_prompt_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
seahorse_passphrase_prompt_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SeahorsePassphrasePromptClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seahorse_passphrase_prompt_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeahorsePassphrasePrompt), 0, (GInstanceInitFunc) seahorse_passphrase_prompt_instance_init, NULL };
	GType seahorse_passphrase_prompt_type_id;
	seahorse_passphrase_prompt_type_id = g_type_register_static (gtk_dialog_get_type (), "SeahorsePassphrasePrompt", &g_define_type_info, 0);
	SeahorsePassphrasePrompt_private_offset = g_type_add_instance_private (seahorse_passphrase_prompt_type_id, sizeof (SeahorsePassphrasePromptPrivate));
	return seahorse_passphrase_prompt_type_id;
}

GType
seahorse_passphrase_prompt_get_type (void)
{
	static volatile gsize seahorse_passphrase_prompt_type_id__once = 0;
	if (g_once_init_enter (&seahorse_passphrase_prompt_type_id__once)) {
		GType seahorse_passphrase_prompt_type_id;
		seahorse_passphrase_prompt_type_id = seahorse_passphrase_prompt_get_type_once ();
		g_once_init_leave (&seahorse_passphrase_prompt_type_id__once, seahorse_passphrase_prompt_type_id);
	}
	return seahorse_passphrase_prompt_type_id__once;
}

