/* preferences-page-video.c generated by valac 0.35.5, the Vala compiler
 * generated from preferences-page-video.vala, do not modify */

/* This file is part of GNOME Games. License: GPLv3*/

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


#define GAMES_TYPE_PREFERENCES_PAGE (games_preferences_page_get_type ())
#define GAMES_PREFERENCES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPage))
#define GAMES_IS_PREFERENCES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE))
#define GAMES_PREFERENCES_PAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GAMES_TYPE_PREFERENCES_PAGE, GamesPreferencesPageIface))

typedef struct _GamesPreferencesPage GamesPreferencesPage;
typedef struct _GamesPreferencesPageIface GamesPreferencesPageIface;

#define GAMES_TYPE_PREFERENCES_PAGE_VIDEO (games_preferences_page_video_get_type ())
#define GAMES_PREFERENCES_PAGE_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideo))
#define GAMES_PREFERENCES_PAGE_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideoClass))
#define GAMES_IS_PREFERENCES_PAGE_VIDEO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_PAGE_VIDEO))
#define GAMES_IS_PREFERENCES_PAGE_VIDEO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_PAGE_VIDEO))
#define GAMES_PREFERENCES_PAGE_VIDEO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideoClass))

typedef struct _GamesPreferencesPageVideo GamesPreferencesPageVideo;
typedef struct _GamesPreferencesPageVideoClass GamesPreferencesPageVideoClass;
typedef struct _GamesPreferencesPageVideoPrivate GamesPreferencesPageVideoPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GAMES_TYPE_PREFERENCES_SWITCH_ITEM (games_preferences_switch_item_get_type ())
#define GAMES_PREFERENCES_SWITCH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAMES_TYPE_PREFERENCES_SWITCH_ITEM, GamesPreferencesSwitchItem))
#define GAMES_PREFERENCES_SWITCH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAMES_TYPE_PREFERENCES_SWITCH_ITEM, GamesPreferencesSwitchItemClass))
#define GAMES_IS_PREFERENCES_SWITCH_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAMES_TYPE_PREFERENCES_SWITCH_ITEM))
#define GAMES_IS_PREFERENCES_SWITCH_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAMES_TYPE_PREFERENCES_SWITCH_ITEM))
#define GAMES_PREFERENCES_SWITCH_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GAMES_TYPE_PREFERENCES_SWITCH_ITEM, GamesPreferencesSwitchItemClass))

typedef struct _GamesPreferencesSwitchItem GamesPreferencesSwitchItem;
typedef struct _GamesPreferencesSwitchItemClass GamesPreferencesSwitchItemClass;

struct _GamesPreferencesPageIface {
	GTypeInterface parent_iface;
	const gchar* (*get_title) (GamesPreferencesPage* self);
};

struct _GamesPreferencesPageVideo {
	GtkBin parent_instance;
	GamesPreferencesPageVideoPrivate * priv;
};

struct _GamesPreferencesPageVideoClass {
	GtkBinClass parent_class;
};

struct _GamesPreferencesPageVideoPrivate {
	gchar* _filter_active;
	gchar** filter_display_names;
	gint filter_display_names_length1;
	gint _filter_display_names_size_;
	gchar** filter_names;
	gint filter_names_length1;
	gint _filter_names_size_;
	GtkListBox* filter_list_box;
	GSettings* settings;
};


static gpointer games_preferences_page_video_parent_class = NULL;
static GamesPreferencesPageIface * games_preferences_page_video_games_preferences_page_parent_iface = NULL;

GType games_preferences_page_get_type (void) G_GNUC_CONST;
GType games_preferences_page_video_get_type (void) G_GNUC_CONST;
#define GAMES_PREFERENCES_PAGE_VIDEO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideoPrivate))
enum  {
	GAMES_PREFERENCES_PAGE_VIDEO_DUMMY_PROPERTY,
	GAMES_PREFERENCES_PAGE_VIDEO_TITLE,
	GAMES_PREFERENCES_PAGE_VIDEO_FILTER_ACTIVE
};
static void games_preferences_page_video_filter_list_box_row_activated (GamesPreferencesPageVideo* self, GtkListBoxRow* row_item);
void games_preferences_page_video_set_filter_active (GamesPreferencesPageVideo* self, const gchar* value);
static void _games_preferences_page_video_filter_list_box_row_activated_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self);
GamesPreferencesPageVideo* games_preferences_page_video_new (void);
GamesPreferencesPageVideo* games_preferences_page_video_construct (GType object_type);
const gchar* games_preferences_page_video_get_filter_active (GamesPreferencesPageVideo* self);
GType games_preferences_switch_item_get_type (void) G_GNUC_CONST;
void games_preferences_switch_item_switch_activate (GamesPreferencesSwitchItem* self);
void games_preferences_switch_item_switch_deactivate (GamesPreferencesSwitchItem* self);
static GObject * games_preferences_page_video_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
GamesPreferencesSwitchItem* games_preferences_switch_item_new (const gchar* name);
GamesPreferencesSwitchItem* games_preferences_switch_item_construct (GType object_type, const gchar* name);
static void games_preferences_page_video_finalize (GObject * obj);
const gchar* games_preferences_page_get_title (GamesPreferencesPage* self);
static void _vala_games_preferences_page_video_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_games_preferences_page_video_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static void games_preferences_page_video_filter_list_box_row_activated (GamesPreferencesPageVideo* self, GtkListBoxRow* row_item) {
	gchar** _tmp0_;
	gint _tmp0__length1;
	GtkListBoxRow* _tmp1_;
	gint _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (row_item != NULL);
	_tmp0_ = self->priv->filter_names;
	_tmp0__length1 = self->priv->filter_names_length1;
	_tmp1_ = row_item;
	_tmp2_ = gtk_list_box_row_get_index (_tmp1_);
	_tmp3_ = _tmp0_[_tmp2_];
	games_preferences_page_video_set_filter_active (self, _tmp3_);
}


static void _games_preferences_page_video_filter_list_box_row_activated_gtk_list_box_row_activated (GtkListBox* _sender, GtkListBoxRow* row, gpointer self) {
	games_preferences_page_video_filter_list_box_row_activated ((GamesPreferencesPageVideo*) self, row);
}


GamesPreferencesPageVideo* games_preferences_page_video_construct (GType object_type) {
	GamesPreferencesPageVideo * self = NULL;
	self = (GamesPreferencesPageVideo*) g_object_new (object_type, NULL);
	return self;
}


GamesPreferencesPageVideo* games_preferences_page_video_new (void) {
	return games_preferences_page_video_construct (GAMES_TYPE_PREFERENCES_PAGE_VIDEO);
}


static const gchar* games_preferences_page_video_real_get_title (GamesPreferencesPage* base) {
	const gchar* result;
	GamesPreferencesPageVideo* self;
	self = (GamesPreferencesPageVideo*) base;
	result = _ ("Video");
	return result;
}


const gchar* games_preferences_page_video_get_filter_active (GamesPreferencesPageVideo* self) {
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_filter_active;
	result = _tmp0_;
	return result;
}


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


void games_preferences_page_video_set_filter_active (GamesPreferencesPageVideo* self, const gchar* value) {
	g_return_if_fail (self != NULL);
	if (g_strcmp0 (value, games_preferences_page_video_get_filter_active (self)) != 0) {
		const gchar* _tmp17_;
		gchar* _tmp18_;
		{
			gint i;
			i = 0;
			{
				gboolean _tmp0_;
				_tmp0_ = TRUE;
				while (TRUE) {
					gint _tmp2_;
					gchar** _tmp3_;
					gint _tmp3__length1;
					GtkListBoxRow* row_item;
					GtkListBox* _tmp4_;
					gint _tmp5_;
					GtkListBoxRow* _tmp6_;
					GtkListBoxRow* _tmp7_;
					GamesPreferencesSwitchItem* switch_item;
					GtkListBoxRow* _tmp8_;
					GtkWidget* _tmp9_;
					GamesPreferencesSwitchItem* _tmp10_;
					const gchar* _tmp11_;
					gchar** _tmp12_;
					gint _tmp12__length1;
					gint _tmp13_;
					const gchar* _tmp14_;
					if (!_tmp0_) {
						gint _tmp1_;
						_tmp1_ = i;
						i = _tmp1_ + 1;
					}
					_tmp0_ = FALSE;
					_tmp2_ = i;
					_tmp3_ = self->priv->filter_names;
					_tmp3__length1 = self->priv->filter_names_length1;
					if (!(_tmp2_ < _tmp3__length1)) {
						break;
					}
					_tmp4_ = self->priv->filter_list_box;
					_tmp5_ = i;
					_tmp6_ = gtk_list_box_get_row_at_index (_tmp4_, _tmp5_);
					_tmp7_ = _g_object_ref0 (_tmp6_);
					row_item = _tmp7_;
					_tmp8_ = row_item;
					_tmp9_ = gtk_bin_get_child ((GtkBin*) _tmp8_);
					_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GAMES_TYPE_PREFERENCES_SWITCH_ITEM, GamesPreferencesSwitchItem));
					switch_item = _tmp10_;
					_tmp11_ = value;
					_tmp12_ = self->priv->filter_names;
					_tmp12__length1 = self->priv->filter_names_length1;
					_tmp13_ = i;
					_tmp14_ = _tmp12_[_tmp13_];
					if (g_strcmp0 (_tmp11_, _tmp14_) == 0) {
						GamesPreferencesSwitchItem* _tmp15_;
						_tmp15_ = switch_item;
						games_preferences_switch_item_switch_activate (_tmp15_);
					} else {
						GamesPreferencesSwitchItem* _tmp16_;
						_tmp16_ = switch_item;
						games_preferences_switch_item_switch_deactivate (_tmp16_);
					}
					_g_object_unref0 (switch_item);
					_g_object_unref0 (row_item);
				}
			}
		}
		_tmp17_ = value;
		_tmp18_ = g_strdup (_tmp17_);
		_g_free0 (self->priv->_filter_active);
		self->priv->_filter_active = _tmp18_;
		g_object_notify ((GObject *) self, "filter-active");
	}
}


static GObject * games_preferences_page_video_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	GamesPreferencesPageVideo * self;
	gchar** _tmp0_;
	gint _tmp0__length1;
	GSettings* _tmp6_;
	GSettings* _tmp7_;
	parent_class = G_OBJECT_CLASS (games_preferences_page_video_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideo);
	_tmp0_ = self->priv->filter_display_names;
	_tmp0__length1 = self->priv->filter_display_names_length1;
	{
		gchar** filter_display_name_collection = NULL;
		gint filter_display_name_collection_length1 = 0;
		gint _filter_display_name_collection_size_ = 0;
		gint filter_display_name_it = 0;
		filter_display_name_collection = _tmp0_;
		filter_display_name_collection_length1 = _tmp0__length1;
		for (filter_display_name_it = 0; filter_display_name_it < _tmp0__length1; filter_display_name_it = filter_display_name_it + 1) {
			gchar* _tmp1_;
			gchar* filter_display_name = NULL;
			_tmp1_ = g_strdup (filter_display_name_collection[filter_display_name_it]);
			filter_display_name = _tmp1_;
			{
				GamesPreferencesSwitchItem* switch_item;
				const gchar* _tmp2_;
				GamesPreferencesSwitchItem* _tmp3_;
				GtkListBox* _tmp4_;
				GamesPreferencesSwitchItem* _tmp5_;
				_tmp2_ = filter_display_name;
				_tmp3_ = games_preferences_switch_item_new (_tmp2_);
				g_object_ref_sink (_tmp3_);
				switch_item = _tmp3_;
				_tmp4_ = self->priv->filter_list_box;
				_tmp5_ = switch_item;
				gtk_container_add ((GtkContainer*) _tmp4_, (GtkWidget*) _tmp5_);
				_g_object_unref0 (switch_item);
				_g_free0 (filter_display_name);
			}
		}
	}
	_tmp6_ = g_settings_new ("org.gnome.Games");
	_g_object_unref0 (self->priv->settings);
	self->priv->settings = _tmp6_;
	_tmp7_ = self->priv->settings;
	g_settings_bind (_tmp7_, "video-filter", (GObject*) self, "filter-active", G_SETTINGS_BIND_DEFAULT);
	return obj;
}


static void games_preferences_page_video_class_init (GamesPreferencesPageVideoClass * klass) {
	gint GamesPreferencesPageVideo_private_offset;
	games_preferences_page_video_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (GamesPreferencesPageVideoPrivate));
	G_OBJECT_CLASS (klass)->get_property = _vala_games_preferences_page_video_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_games_preferences_page_video_set_property;
	G_OBJECT_CLASS (klass)->constructor = games_preferences_page_video_constructor;
	G_OBJECT_CLASS (klass)->finalize = games_preferences_page_video_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_PAGE_VIDEO_TITLE, g_param_spec_string ("title", "title", "title", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GAMES_PREFERENCES_PAGE_VIDEO_FILTER_ACTIVE, g_param_spec_string ("filter-active", "filter-active", "filter-active", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	GamesPreferencesPageVideo_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/preferences-page-video.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "filter_list_box", FALSE, GamesPreferencesPageVideo_private_offset + G_STRUCT_OFFSET (GamesPreferencesPageVideoPrivate, filter_list_box));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "filter_list_box_row_activated", G_CALLBACK(_games_preferences_page_video_filter_list_box_row_activated_gtk_list_box_row_activated));
}


static void games_preferences_page_video_games_preferences_page_interface_init (GamesPreferencesPageIface * iface) {
	games_preferences_page_video_games_preferences_page_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_title = games_preferences_page_video_real_get_title;
}


static void games_preferences_page_video_instance_init (GamesPreferencesPageVideo * self) {
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	self->priv = GAMES_PREFERENCES_PAGE_VIDEO_GET_PRIVATE (self);
	_tmp0_ = g_strdup (_ ("Smooth"));
	_tmp1_ = g_strdup (_ ("Sharp"));
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	self->priv->filter_display_names = _tmp2_;
	self->priv->filter_display_names_length1 = 2;
	self->priv->_filter_display_names_size_ = self->priv->filter_display_names_length1;
	_tmp3_ = g_strdup ("smooth");
	_tmp4_ = g_strdup ("sharp");
	_tmp5_ = g_new0 (gchar*, 2 + 1);
	_tmp5_[0] = _tmp3_;
	_tmp5_[1] = _tmp4_;
	self->priv->filter_names = _tmp5_;
	self->priv->filter_names_length1 = 2;
	self->priv->_filter_names_size_ = self->priv->filter_names_length1;
	gtk_widget_init_template (GTK_WIDGET (self));
}


static void games_preferences_page_video_finalize (GObject * obj) {
	GamesPreferencesPageVideo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideo);
	_g_free0 (self->priv->_filter_active);
	self->priv->filter_display_names = (_vala_array_free (self->priv->filter_display_names, self->priv->filter_display_names_length1, (GDestroyNotify) g_free), NULL);
	self->priv->filter_names = (_vala_array_free (self->priv->filter_names, self->priv->filter_names_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (self->priv->filter_list_box);
	_g_object_unref0 (self->priv->settings);
	G_OBJECT_CLASS (games_preferences_page_video_parent_class)->finalize (obj);
}


GType games_preferences_page_video_get_type (void) {
	static volatile gsize games_preferences_page_video_type_id__volatile = 0;
	if (g_once_init_enter (&games_preferences_page_video_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (GamesPreferencesPageVideoClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) games_preferences_page_video_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GamesPreferencesPageVideo), 0, (GInstanceInitFunc) games_preferences_page_video_instance_init, NULL };
		static const GInterfaceInfo games_preferences_page_info = { (GInterfaceInitFunc) games_preferences_page_video_games_preferences_page_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType games_preferences_page_video_type_id;
		games_preferences_page_video_type_id = g_type_register_static (gtk_bin_get_type (), "GamesPreferencesPageVideo", &g_define_type_info, 0);
		g_type_add_interface_static (games_preferences_page_video_type_id, GAMES_TYPE_PREFERENCES_PAGE, &games_preferences_page_info);
		g_once_init_leave (&games_preferences_page_video_type_id__volatile, games_preferences_page_video_type_id);
	}
	return games_preferences_page_video_type_id__volatile;
}


static void _vala_games_preferences_page_video_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	GamesPreferencesPageVideo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideo);
	switch (property_id) {
		case GAMES_PREFERENCES_PAGE_VIDEO_TITLE:
		g_value_set_string (value, games_preferences_page_get_title ((GamesPreferencesPage*) self));
		break;
		case GAMES_PREFERENCES_PAGE_VIDEO_FILTER_ACTIVE:
		g_value_set_string (value, games_preferences_page_video_get_filter_active (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_games_preferences_page_video_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	GamesPreferencesPageVideo * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GAMES_TYPE_PREFERENCES_PAGE_VIDEO, GamesPreferencesPageVideo);
	switch (property_id) {
		case GAMES_PREFERENCES_PAGE_VIDEO_FILTER_ACTIVE:
		games_preferences_page_video_set_filter_active (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int 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, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



