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

/* -*- Mode: Vala; indent-tabs-mode: nil; tab-width: 4 -*-
 * -*- coding: utf-8 -*-
 *
 * Copyright (C) 2011 ~ 2018 Deepin, Inc.
 *               2011 ~ 2018 Wang Yong
 *
 * Author:     Wang Yong <wangyong@deepin.com>
 * Maintainer: Wang Yong <wangyong@deepin.com>
 *
 * 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 3 of the License, or
 * 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/>.
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.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 WIDGETS_TYPE_PASSWORD_BUTTON (widgets_password_button_get_type ())
#define WIDGETS_PASSWORD_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_PASSWORD_BUTTON, WidgetsPasswordButton))
#define WIDGETS_PASSWORD_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_PASSWORD_BUTTON, WidgetsPasswordButtonClass))
#define WIDGETS_IS_PASSWORD_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_PASSWORD_BUTTON))
#define WIDGETS_IS_PASSWORD_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_PASSWORD_BUTTON))
#define WIDGETS_PASSWORD_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_PASSWORD_BUTTON, WidgetsPasswordButtonClass))

typedef struct _WidgetsPasswordButton WidgetsPasswordButton;
typedef struct _WidgetsPasswordButtonClass WidgetsPasswordButtonClass;
typedef struct _WidgetsPasswordButtonPrivate WidgetsPasswordButtonPrivate;

#define WIDGETS_TYPE_CLICK_EVENT_BOX (widgets_click_event_box_get_type ())
#define WIDGETS_CLICK_EVENT_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBox))
#define WIDGETS_CLICK_EVENT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBoxClass))
#define WIDGETS_IS_CLICK_EVENT_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX))
#define WIDGETS_IS_CLICK_EVENT_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_CLICK_EVENT_BOX))
#define WIDGETS_CLICK_EVENT_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_CLICK_EVENT_BOX, WidgetsClickEventBoxClass))

typedef struct _WidgetsClickEventBox WidgetsClickEventBox;
typedef struct _WidgetsClickEventBoxClass WidgetsClickEventBoxClass;

#define WIDGETS_TYPE_IMAGE_BUTTON (widgets_image_button_get_type ())
#define WIDGETS_IMAGE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_IMAGE_BUTTON, WidgetsImageButton))
#define WIDGETS_IMAGE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_IMAGE_BUTTON, WidgetsImageButtonClass))
#define WIDGETS_IS_IMAGE_BUTTON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_IMAGE_BUTTON))
#define WIDGETS_IS_IMAGE_BUTTON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_IMAGE_BUTTON))
#define WIDGETS_IMAGE_BUTTON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_IMAGE_BUTTON, WidgetsImageButtonClass))

typedef struct _WidgetsImageButton WidgetsImageButton;
typedef struct _WidgetsImageButtonClass WidgetsImageButtonClass;

#define WIDGETS_TYPE_ENTRY (widgets_entry_get_type ())
#define WIDGETS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_ENTRY, WidgetsEntry))
#define WIDGETS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_ENTRY, WidgetsEntryClass))
#define WIDGETS_IS_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_ENTRY))
#define WIDGETS_IS_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_ENTRY))
#define WIDGETS_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_ENTRY, WidgetsEntryClass))

typedef struct _WidgetsEntry WidgetsEntry;
typedef struct _WidgetsEntryClass WidgetsEntryClass;
enum  {
	WIDGETS_PASSWORD_BUTTON_0_PROPERTY,
	WIDGETS_PASSWORD_BUTTON_NUM_PROPERTIES
};
static GParamSpec* widgets_password_button_properties[WIDGETS_PASSWORD_BUTTON_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 _WidgetsPasswordButton {
	GtkEventBox parent_instance;
	WidgetsPasswordButtonPrivate * priv;
	GtkBox* box;
	GtkBox* button_box;
	WidgetsImageButton* hide_password_button;
	WidgetsImageButton* show_password_button;
	WidgetsEntry* entry;
	gint height;
};

struct _WidgetsPasswordButtonClass {
	GtkEventBoxClass parent_class;
};

static gpointer widgets_password_button_parent_class = NULL;

VALA_EXTERN GType widgets_password_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsPasswordButton, g_object_unref)
VALA_EXTERN GType widgets_click_event_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsClickEventBox, g_object_unref)
VALA_EXTERN GType widgets_image_button_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsImageButton, g_object_unref)
VALA_EXTERN GType widgets_entry_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsEntry, g_object_unref)
VALA_EXTERN WidgetsPasswordButton* widgets_password_button_new (void);
VALA_EXTERN WidgetsPasswordButton* widgets_password_button_construct (GType object_type);
VALA_EXTERN WidgetsEntry* widgets_entry_new (void);
VALA_EXTERN WidgetsEntry* widgets_entry_construct (GType object_type);
VALA_EXTERN WidgetsImageButton* widgets_image_button_new (const gchar* image_path,
                                              gboolean theme_button,
                                              const gchar* text,
                                              gint text_size);
VALA_EXTERN WidgetsImageButton* widgets_image_button_construct (GType object_type,
                                                    const gchar* image_path,
                                                    gboolean theme_button,
                                                    const gchar* text,
                                                    gint text_size);
VALA_EXTERN void widgets_password_button_init (WidgetsPasswordButton* self);
static void __lambda44_ (WidgetsPasswordButton* self,
                  WidgetsClickEventBox* w,
                  GdkEventButton* e);
VALA_EXTERN void widgets_password_button_show_password (WidgetsPasswordButton* self);
static void ___lambda44__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                                   GdkEventButton* event,
                                                   gpointer self);
static void __lambda45_ (WidgetsPasswordButton* self,
                  WidgetsClickEventBox* w,
                  GdkEventButton* e);
VALA_EXTERN void widgets_password_button_hide_password (WidgetsPasswordButton* self);
static void ___lambda45__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                                   GdkEventButton* event,
                                                   gpointer self);
static void __lambda46_ (WidgetsPasswordButton* self,
                  GtkEntryBuffer* buffer,
                  guint p,
                  guint nc);
static void ___lambda46__gtk_entry_buffer_deleted_text (GtkEntryBuffer* _sender,
                                                 guint position,
                                                 guint n_chars,
                                                 gpointer self);
static void __lambda47_ (WidgetsPasswordButton* self,
                  GtkEntryBuffer* buffer,
                  guint p,
                  const gchar* c,
                  guint nc);
static void ___lambda47__gtk_entry_buffer_inserted_text (GtkEntryBuffer* _sender,
                                                  guint position,
                                                  const gchar* chars,
                                                  guint n_chars,
                                                  gpointer self);
VALA_EXTERN void utils_remove_all_children (GtkContainer* container);
static void widgets_password_button_finalize (GObject * obj);
static GType widgets_password_button_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
__lambda44_ (WidgetsPasswordButton* self,
             WidgetsClickEventBox* w,
             GdkEventButton* e)
{
	g_return_if_fail (w != NULL);
	g_return_if_fail (e != NULL);
	widgets_password_button_show_password (self);
}

static void
___lambda44__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	__lambda44_ ((WidgetsPasswordButton*) self, _sender, event);
}

static void
__lambda45_ (WidgetsPasswordButton* self,
             WidgetsClickEventBox* w,
             GdkEventButton* e)
{
	g_return_if_fail (w != NULL);
	g_return_if_fail (e != NULL);
	widgets_password_button_hide_password (self);
}

static void
___lambda45__widgets_click_event_box_clicked (WidgetsClickEventBox* _sender,
                                              GdkEventButton* event,
                                              gpointer self)
{
	__lambda45_ ((WidgetsPasswordButton*) self, _sender, event);
}

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;
}

static void
__lambda46_ (WidgetsPasswordButton* self,
             GtkEntryBuffer* buffer,
             guint p,
             guint nc)
{
	gchar* entry_text = NULL;
	WidgetsEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (buffer != NULL);
	_tmp0_ = self->entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = string_strip (_tmp1_);
	entry_text = _tmp2_;
	_tmp3_ = entry_text;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		WidgetsEntry* _tmp4_;
		GtkStyleContext* _tmp5_;
		WidgetsEntry* _tmp6_;
		GtkStyleContext* _tmp7_;
		_tmp4_ = self->entry;
		_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
		gtk_style_context_remove_class (_tmp5_, "password_invisible_entry");
		_tmp6_ = self->entry;
		_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
		gtk_style_context_add_class (_tmp7_, "password_visible_entry");
	} else {
		WidgetsEntry* _tmp8_;
		_tmp8_ = self->entry;
		if (gtk_entry_get_visibility ((GtkEntry*) _tmp8_)) {
			WidgetsEntry* _tmp9_;
			GtkStyleContext* _tmp10_;
			WidgetsEntry* _tmp11_;
			GtkStyleContext* _tmp12_;
			_tmp9_ = self->entry;
			_tmp10_ = gtk_widget_get_style_context ((GtkWidget*) _tmp9_);
			gtk_style_context_remove_class (_tmp10_, "password_invisible_entry");
			_tmp11_ = self->entry;
			_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
			gtk_style_context_add_class (_tmp12_, "password_visible_entry");
		} else {
			WidgetsEntry* _tmp13_;
			GtkStyleContext* _tmp14_;
			WidgetsEntry* _tmp15_;
			GtkStyleContext* _tmp16_;
			_tmp13_ = self->entry;
			_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
			gtk_style_context_remove_class (_tmp14_, "password_visible_entry");
			_tmp15_ = self->entry;
			_tmp16_ = gtk_widget_get_style_context ((GtkWidget*) _tmp15_);
			gtk_style_context_add_class (_tmp16_, "password_invisible_entry");
		}
	}
	_g_free0 (entry_text);
}

static void
___lambda46__gtk_entry_buffer_deleted_text (GtkEntryBuffer* _sender,
                                            guint position,
                                            guint n_chars,
                                            gpointer self)
{
	__lambda46_ ((WidgetsPasswordButton*) self, _sender, position, n_chars);
}

static void
__lambda47_ (WidgetsPasswordButton* self,
             GtkEntryBuffer* buffer,
             guint p,
             const gchar* c,
             guint nc)
{
	gchar* entry_text = NULL;
	WidgetsEntry* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (buffer != NULL);
	g_return_if_fail (c != NULL);
	_tmp0_ = self->entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = string_strip (_tmp1_);
	entry_text = _tmp2_;
	_tmp3_ = entry_text;
	if (g_strcmp0 (_tmp3_, "") == 0) {
		WidgetsEntry* _tmp4_;
		GtkStyleContext* _tmp5_;
		WidgetsEntry* _tmp6_;
		GtkStyleContext* _tmp7_;
		_tmp4_ = self->entry;
		_tmp5_ = gtk_widget_get_style_context ((GtkWidget*) _tmp4_);
		gtk_style_context_remove_class (_tmp5_, "password_invisible_entry");
		_tmp6_ = self->entry;
		_tmp7_ = gtk_widget_get_style_context ((GtkWidget*) _tmp6_);
		gtk_style_context_add_class (_tmp7_, "password_visible_entry");
	} else {
		WidgetsEntry* _tmp8_;
		_tmp8_ = self->entry;
		if (gtk_entry_get_visibility ((GtkEntry*) _tmp8_)) {
			WidgetsEntry* _tmp9_;
			GtkStyleContext* _tmp10_;
			WidgetsEntry* _tmp11_;
			GtkStyleContext* _tmp12_;
			_tmp9_ = self->entry;
			_tmp10_ = gtk_widget_get_style_context ((GtkWidget*) _tmp9_);
			gtk_style_context_remove_class (_tmp10_, "password_invisible_entry");
			_tmp11_ = self->entry;
			_tmp12_ = gtk_widget_get_style_context ((GtkWidget*) _tmp11_);
			gtk_style_context_add_class (_tmp12_, "password_visible_entry");
		} else {
			WidgetsEntry* _tmp13_;
			GtkStyleContext* _tmp14_;
			WidgetsEntry* _tmp15_;
			GtkStyleContext* _tmp16_;
			_tmp13_ = self->entry;
			_tmp14_ = gtk_widget_get_style_context ((GtkWidget*) _tmp13_);
			gtk_style_context_remove_class (_tmp14_, "password_visible_entry");
			_tmp15_ = self->entry;
			_tmp16_ = gtk_widget_get_style_context ((GtkWidget*) _tmp15_);
			gtk_style_context_add_class (_tmp16_, "password_invisible_entry");
		}
	}
	_g_free0 (entry_text);
}

static void
___lambda47__gtk_entry_buffer_inserted_text (GtkEntryBuffer* _sender,
                                             guint position,
                                             const gchar* chars,
                                             guint n_chars,
                                             gpointer self)
{
	__lambda47_ ((WidgetsPasswordButton*) self, _sender, position, chars, n_chars);
}

WidgetsPasswordButton*
widgets_password_button_construct (GType object_type)
{
	WidgetsPasswordButton * self = NULL;
	GtkBox* _tmp0_;
	WidgetsEntry* _tmp1_;
	WidgetsEntry* _tmp2_;
	WidgetsEntry* _tmp3_;
	WidgetsEntry* _tmp4_;
	WidgetsEntry* _tmp5_;
	WidgetsImageButton* _tmp6_;
	WidgetsImageButton* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	WidgetsEntry* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	WidgetsImageButton* _tmp13_;
	WidgetsImageButton* _tmp14_;
	WidgetsEntry* _tmp15_;
	GtkEntryBuffer* _tmp16_;
	WidgetsEntry* _tmp17_;
	GtkEntryBuffer* _tmp18_;
	GtkBox* _tmp19_;
	self = (WidgetsPasswordButton*) g_object_new (object_type, NULL);
	gtk_event_box_set_visible_window ((GtkEventBox*) self, FALSE);
	gtk_widget_set_size_request ((GtkWidget*) self, -1, self->height);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->box);
	self->box = _tmp0_;
	_tmp1_ = widgets_entry_new ();
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->entry);
	self->entry = _tmp1_;
	_tmp2_ = self->entry;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp2_, 1);
	_tmp3_ = self->entry;
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 1);
	_tmp4_ = self->entry;
	gtk_entry_set_invisible_char ((GtkEntry*) _tmp4_, 9679U);
	_tmp5_ = self->entry;
	gtk_entry_set_input_purpose ((GtkEntry*) _tmp5_, GTK_INPUT_PURPOSE_PASSWORD);
	_tmp6_ = widgets_image_button_new ("password_show", FALSE, NULL, 12);
	g_object_ref_sink (_tmp6_);
	_g_object_unref0 (self->show_password_button);
	self->show_password_button = _tmp6_;
	_tmp7_ = widgets_image_button_new ("password_hide", FALSE, NULL, 12);
	g_object_ref_sink (_tmp7_);
	_g_object_unref0 (self->hide_password_button);
	self->hide_password_button = _tmp7_;
	_tmp8_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->button_box);
	self->button_box = _tmp8_;
	_tmp9_ = self->box;
	_tmp10_ = self->entry;
	gtk_box_pack_start (_tmp9_, (GtkWidget*) _tmp10_, TRUE, TRUE, (guint) 0);
	_tmp11_ = self->box;
	_tmp12_ = self->button_box;
	gtk_box_pack_start (_tmp11_, (GtkWidget*) _tmp12_, FALSE, FALSE, (guint) 0);
	widgets_password_button_init (self);
	_tmp13_ = self->show_password_button;
	g_signal_connect_object ((WidgetsClickEventBox*) _tmp13_, "clicked", (GCallback) ___lambda44__widgets_click_event_box_clicked, self, 0);
	_tmp14_ = self->hide_password_button;
	g_signal_connect_object ((WidgetsClickEventBox*) _tmp14_, "clicked", (GCallback) ___lambda45__widgets_click_event_box_clicked, self, 0);
	_tmp15_ = self->entry;
	_tmp16_ = gtk_entry_get_buffer ((GtkEntry*) _tmp15_);
	g_signal_connect_object (_tmp16_, "deleted-text", (GCallback) ___lambda46__gtk_entry_buffer_deleted_text, self, 0);
	_tmp17_ = self->entry;
	_tmp18_ = gtk_entry_get_buffer ((GtkEntry*) _tmp17_);
	g_signal_connect_object (_tmp18_, "inserted-text", (GCallback) ___lambda47__gtk_entry_buffer_inserted_text, self, 0);
	_tmp19_ = self->box;
	gtk_container_add ((GtkContainer*) self, (GtkWidget*) _tmp19_);
	return self;
}

WidgetsPasswordButton*
widgets_password_button_new (void)
{
	return widgets_password_button_construct (WIDGETS_TYPE_PASSWORD_BUTTON);
}

void
widgets_password_button_init (WidgetsPasswordButton* self)
{
	GtkBox* _tmp0_;
	WidgetsEntry* _tmp1_;
	GtkStyleContext* _tmp2_;
	WidgetsEntry* _tmp3_;
	GtkStyleContext* _tmp4_;
	WidgetsEntry* _tmp5_;
	GtkBox* _tmp6_;
	WidgetsImageButton* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->button_box;
	utils_remove_all_children ((GtkContainer*) _tmp0_);
	_tmp1_ = self->entry;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_remove_class (_tmp2_, "password_invisible_entry");
	_tmp3_ = self->entry;
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
	gtk_style_context_add_class (_tmp4_, "password_visible_entry");
	_tmp5_ = self->entry;
	gtk_entry_set_visibility ((GtkEntry*) _tmp5_, FALSE);
	_tmp6_ = self->button_box;
	_tmp7_ = self->show_password_button;
	gtk_box_pack_start (_tmp6_, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) self);
}

void
widgets_password_button_show_password (WidgetsPasswordButton* self)
{
	GtkBox* _tmp0_;
	WidgetsEntry* _tmp1_;
	GtkStyleContext* _tmp2_;
	WidgetsEntry* _tmp3_;
	GtkStyleContext* _tmp4_;
	WidgetsEntry* _tmp5_;
	GtkBox* _tmp6_;
	WidgetsImageButton* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->button_box;
	utils_remove_all_children ((GtkContainer*) _tmp0_);
	_tmp1_ = self->entry;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_remove_class (_tmp2_, "password_invisible_entry");
	_tmp3_ = self->entry;
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
	gtk_style_context_add_class (_tmp4_, "password_visible_entry");
	_tmp5_ = self->entry;
	gtk_entry_set_visibility ((GtkEntry*) _tmp5_, TRUE);
	_tmp6_ = self->button_box;
	_tmp7_ = self->hide_password_button;
	gtk_box_pack_start (_tmp6_, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) self);
}

void
widgets_password_button_hide_password (WidgetsPasswordButton* self)
{
	GtkBox* _tmp0_;
	WidgetsEntry* _tmp1_;
	GtkStyleContext* _tmp2_;
	WidgetsEntry* _tmp3_;
	GtkStyleContext* _tmp4_;
	WidgetsEntry* _tmp5_;
	GtkBox* _tmp6_;
	WidgetsImageButton* _tmp7_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->button_box;
	utils_remove_all_children ((GtkContainer*) _tmp0_);
	_tmp1_ = self->entry;
	_tmp2_ = gtk_widget_get_style_context ((GtkWidget*) _tmp1_);
	gtk_style_context_remove_class (_tmp2_, "password_visible_entry");
	_tmp3_ = self->entry;
	_tmp4_ = gtk_widget_get_style_context ((GtkWidget*) _tmp3_);
	gtk_style_context_add_class (_tmp4_, "password_invisible_entry");
	_tmp5_ = self->entry;
	gtk_entry_set_visibility ((GtkEntry*) _tmp5_, FALSE);
	_tmp6_ = self->button_box;
	_tmp7_ = self->show_password_button;
	gtk_box_pack_start (_tmp6_, (GtkWidget*) _tmp7_, FALSE, FALSE, (guint) 0);
	gtk_widget_show_all ((GtkWidget*) self);
}

static void
widgets_password_button_class_init (WidgetsPasswordButtonClass * klass,
                                    gpointer klass_data)
{
	widgets_password_button_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = widgets_password_button_finalize;
}

static void
widgets_password_button_instance_init (WidgetsPasswordButton * self,
                                       gpointer klass)
{
	self->height = 26;
}

static void
widgets_password_button_finalize (GObject * obj)
{
	WidgetsPasswordButton * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_PASSWORD_BUTTON, WidgetsPasswordButton);
	_g_object_unref0 (self->box);
	_g_object_unref0 (self->button_box);
	_g_object_unref0 (self->hide_password_button);
	_g_object_unref0 (self->show_password_button);
	_g_object_unref0 (self->entry);
	G_OBJECT_CLASS (widgets_password_button_parent_class)->finalize (obj);
}

static GType
widgets_password_button_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsPasswordButtonClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_password_button_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsPasswordButton), 0, (GInstanceInitFunc) widgets_password_button_instance_init, NULL };
	GType widgets_password_button_type_id;
	widgets_password_button_type_id = g_type_register_static (gtk_event_box_get_type (), "WidgetsPasswordButton", &g_define_type_info, 0);
	return widgets_password_button_type_id;
}

GType
widgets_password_button_get_type (void)
{
	static volatile gsize widgets_password_button_type_id__once = 0;
	if (g_once_init_enter (&widgets_password_button_type_id__once)) {
		GType widgets_password_button_type_id;
		widgets_password_button_type_id = widgets_password_button_get_type_once ();
		g_once_init_leave (&widgets_password_button_type_id__once, widgets_password_button_type_id);
	}
	return widgets_password_button_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

