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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2013 Timm Bäder
 *
 *  corebird 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
 *  (at your option) any later version.
 *
 *  corebird 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 corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>


#define TYPE_NEW_LIST_ENTRY (new_list_entry_get_type ())
#define NEW_LIST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_NEW_LIST_ENTRY, NewListEntry))
#define NEW_LIST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_NEW_LIST_ENTRY, NewListEntryClass))
#define IS_NEW_LIST_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_NEW_LIST_ENTRY))
#define IS_NEW_LIST_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_NEW_LIST_ENTRY))
#define NEW_LIST_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_NEW_LIST_ENTRY, NewListEntryClass))

typedef struct _NewListEntry NewListEntry;
typedef struct _NewListEntryClass NewListEntryClass;
typedef struct _NewListEntryPrivate NewListEntryPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _NewListEntry {
	GtkListBoxRow parent_instance;
	NewListEntryPrivate * priv;
};

struct _NewListEntryClass {
	GtkListBoxRowClass parent_class;
};

struct _NewListEntryPrivate {
	GtkEntry* list_name_entry;
	GtkRevealer* revealer;
};


static gpointer new_list_entry_parent_class = NULL;

GType new_list_entry_get_type (void) G_GNUC_CONST;
#define NEW_LIST_ENTRY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_NEW_LIST_ENTRY, NewListEntryPrivate))
enum  {
	NEW_LIST_ENTRY_DUMMY_PROPERTY
};
void new_list_entry_reveal (NewListEntry* self);
void new_list_entry_unreveal (NewListEntry* self);
static void new_list_entry_create_list_button_clicked_cb (NewListEntry* self);
static void _new_list_entry_create_list_button_clicked_cb_gtk_button_clicked (GtkButton* _sender, gpointer self);
NewListEntry* new_list_entry_new (void);
NewListEntry* new_list_entry_construct (GType object_type);
static void new_list_entry_finalize (GObject* obj);


void new_list_entry_reveal (NewListEntry* self) {
	GtkRevealer* _tmp0_ = NULL;
	GtkEntry* _tmp1_ = NULL;
	g_return_if_fail (IS_NEW_LIST_ENTRY (self));
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_reveal_child (_tmp0_, TRUE);
	gtk_list_box_row_set_activatable (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_list_box_row_get_type (), GtkListBoxRow), FALSE);
	_tmp1_ = self->priv->list_name_entry;
	gtk_widget_grab_focus (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_widget_get_type (), GtkWidget));
}


void new_list_entry_unreveal (NewListEntry* self) {
	GtkRevealer* _tmp0_ = NULL;
	GtkEntry* _tmp1_ = NULL;
	g_return_if_fail (IS_NEW_LIST_ENTRY (self));
	_tmp0_ = self->priv->revealer;
	gtk_revealer_set_reveal_child (_tmp0_, FALSE);
	gtk_list_box_row_set_activatable (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_list_box_row_get_type (), GtkListBoxRow), TRUE);
	_tmp1_ = self->priv->list_name_entry;
	gtk_entry_set_text (_tmp1_, "");
}


static void new_list_entry_create_list_button_clicked_cb (NewListEntry* self) {
	GtkEntry* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	g_return_if_fail (IS_NEW_LIST_ENTRY (self));
	_tmp0_ = self->priv->list_name_entry;
	_tmp1_ = gtk_entry_get_text (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_emit_by_name (self, "create-activated", _tmp2_);
}


static void _new_list_entry_create_list_button_clicked_cb_gtk_button_clicked (GtkButton* _sender, gpointer self) {
	new_list_entry_create_list_button_clicked_cb ((NewListEntry*) self);
}


NewListEntry* new_list_entry_construct (GType object_type) {
	NewListEntry * self = NULL;
	self = (NewListEntry*) g_object_new (object_type, NULL);
	return self;
}


NewListEntry* new_list_entry_new (void) {
	return new_list_entry_construct (TYPE_NEW_LIST_ENTRY);
}


static void new_list_entry_class_init (NewListEntryClass * klass) {
	gint NewListEntry_private_offset;
	new_list_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (NewListEntryPrivate));
	G_OBJECT_CLASS (klass)->finalize = new_list_entry_finalize;
	NewListEntry_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/baedert/corebird/ui/new-list-entry.ui");
	g_signal_new ("create_activated", TYPE_NEW_LIST_ENTRY, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "list_name_entry", FALSE, NewListEntry_private_offset + G_STRUCT_OFFSET (NewListEntryPrivate, list_name_entry));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "revealer", FALSE, NewListEntry_private_offset + G_STRUCT_OFFSET (NewListEntryPrivate, revealer));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "create_list_button_clicked_cb", G_CALLBACK(_new_list_entry_create_list_button_clicked_cb_gtk_button_clicked));
}


static void new_list_entry_instance_init (NewListEntry * self) {
	self->priv = NEW_LIST_ENTRY_GET_PRIVATE (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void new_list_entry_finalize (GObject* obj) {
	NewListEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_NEW_LIST_ENTRY, NewListEntry);
	_g_object_unref0 (self->priv->list_name_entry);
	_g_object_unref0 (self->priv->revealer);
	G_OBJECT_CLASS (new_list_entry_parent_class)->finalize (obj);
}


GType new_list_entry_get_type (void) {
	static volatile gsize new_list_entry_type_id__volatile = 0;
	if (g_once_init_enter (&new_list_entry_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (NewListEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) new_list_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (NewListEntry), 0, (GInstanceInitFunc) new_list_entry_instance_init, NULL };
		GType new_list_entry_type_id;
		new_list_entry_type_id = g_type_register_static (gtk_list_box_row_get_type (), "NewListEntry", &g_define_type_info, 0);
		g_once_init_leave (&new_list_entry_type_id__volatile, new_list_entry_type_id);
	}
	return new_list_entry_type_id__volatile;
}



