/* search-bar.c generated by valac 0.36.6.6-c7bee, the Vala compiler
 * generated from search-bar.vala, do not modify */

/* This file is part of GNOME Games. License: GPL-3.0+.*/

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


#define GAMES_TYPE_SEARCH_BAR (games_search_bar_get_type ())
#define GAMES_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_SEARCH_BAR, GamesSearchBar))
#define GAMES_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_SEARCH_BAR, GamesSearchBarClass))
#define GAMES_IS_SEARCH_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_SEARCH_BAR))
#define GAMES_IS_SEARCH_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_SEARCH_BAR))
#define GAMES_SEARCH_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_SEARCH_BAR, GamesSearchBarClass))

typedef struct _GamesSearchBar GamesSearchBar;
typedef struct _GamesSearchBarClass GamesSearchBarClass;
typedef struct _GamesSearchBarPrivate GamesSearchBarPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GamesSearchBar {
	GtkSearchBar parent_instance;
	GamesSearchBarPrivate * priv;
};

struct _GamesSearchBarClass {
	GtkSearchBarClass parent_class;
};

struct _GamesSearchBarPrivate {
	gchar* _text;
	GtkSearchEntry* entry;
};


static gpointer games_search_bar_parent_class = NULL;

GType games_search_bar_get_type (void) G_GNUC_CONST;
#define GAMES_SEARCH_BAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_SEARCH_BAR, GamesSearchBarPrivate))
enum  {
	GAMES_SEARCH_BAR_0_PROPERTY,
	GAMES_SEARCH_BAR_TEXT_PROPERTY
};
static void games_search_bar_on_search_changed (GamesSearchBar* self);
static void games_search_bar_set_text (GamesSearchBar* self, const gchar* value);
static void _games_search_bar_on_search_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender, gpointer self);
static void games_search_bar_on_search_activated (GamesSearchBar* self);
static void _games_search_bar_on_search_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self);
GamesSearchBar* games_search_bar_new (void);
GamesSearchBar* games_search_bar_construct (GType object_type);
const gchar* games_search_bar_get_text (GamesSearchBar* self);
static void games_search_bar_finalize (GObject * obj);
static void _vala_games_search_bar_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_games_search_bar_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


static void games_search_bar_on_search_changed (GamesSearchBar* self) {
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = _tmp1_;
	games_search_bar_set_text (self, _tmp2_);
}


static void _games_search_bar_on_search_changed_gtk_search_entry_search_changed (GtkSearchEntry* _sender, gpointer self) {
	games_search_bar_on_search_changed ((GamesSearchBar*) self);
}


static void games_search_bar_on_search_activated (GamesSearchBar* self) {
	GtkSearchEntry* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->entry;
	_tmp1_ = gtk_entry_get_text ((GtkEntry*) _tmp0_);
	_tmp2_ = _tmp1_;
	games_search_bar_set_text (self, _tmp2_);
}


static void _games_search_bar_on_search_activated_gtk_entry_activate (GtkEntry* _sender, gpointer self) {
	games_search_bar_on_search_activated ((GamesSearchBar*) self);
}


GamesSearchBar* games_search_bar_construct (GType object_type) {
	GamesSearchBar * self = NULL;
	self = (GamesSearchBar*) g_object_new (object_type, NULL);
	return self;
}


GamesSearchBar* games_search_bar_new (void) {
	return games_search_bar_construct (GAMES_TYPE_SEARCH_BAR);
}


const gchar* games_search_bar_get_text (GamesSearchBar* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}


static void games_search_bar_set_text (GamesSearchBar* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	if (g_strcmp0 (value, games_search_bar_get_text (self)) != 0) {
		const gchar* _tmp0_;
		gchar* _tmp1_;
		_tmp0_ = value;
		_tmp1_ = g_strdup (_tmp0_);
		_g_free0 (self->priv->_text);
		self->priv->_text = _tmp1_;
		g_object_notify ((GObject *) self, "text");
	}
}


static void games_search_bar_class_init (GamesSearchBarClass * klass) {
	gint GamesSearchBar_private_offset;
	games_search_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesSearchBarPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_games_search_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_search_bar_set_property;
	G_OBJECT_CLASS (klass)->finalize = games_search_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_SEARCH_BAR_TEXT_PROPERTY, g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	GamesSearchBar_private_offset = g_type_class_get_instance_private_offset (klass);
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Games/ui/search-bar.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "entry", FALSE, GamesSearchBar_private_offset + G_STRUCT_OFFSET (GamesSearchBarPrivate, entry));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_search_changed", G_CALLBACK(_games_search_bar_on_search_changed_gtk_search_entry_search_changed));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_search_activated", G_CALLBACK(_games_search_bar_on_search_activated_gtk_entry_activate));
}


static void games_search_bar_instance_init (GamesSearchBar * self) {
	self->priv = GAMES_SEARCH_BAR_GET_PRIVATE (self);
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void games_search_bar_finalize (GObject * obj) {
	GamesSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_SEARCH_BAR, GamesSearchBar);
	_g_free0 (self->priv->_text);
	_g_object_unref0 (self->priv->entry);
	G_OBJECT_CLASS (games_search_bar_parent_class)->finalize (obj);
}


GType games_search_bar_get_type (void) {
	static volatile gsize games_search_bar_type_id__volatile = 0;
	if (g_once_init_enter (&games_search_bar_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesSearchBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_search_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesSearchBar), 0, (GInstanceInitFunc) games_search_bar_instance_init, NULL };
		GType games_search_bar_type_id;
		games_search_bar_type_id = g_type_register_static (gtk_search_bar_get_type (), "GamesSearchBar", &g_define_type_info, 0);
		g_once_init_leave (&games_search_bar_type_id__volatile, games_search_bar_type_id);
	}
	return games_search_bar_type_id__volatile;
}


static void _vala_games_search_bar_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GamesSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_SEARCH_BAR, GamesSearchBar);
	switch (property_id) {
		case GAMES_SEARCH_BAR_TEXT_PROPERTY:
		g_value_set_string (value, games_search_bar_get_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_games_search_bar_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GamesSearchBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_SEARCH_BAR, GamesSearchBar);
	switch (property_id) {
		case GAMES_SEARCH_BAR_TEXT_PROPERTY:
		games_search_bar_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



