/* rygel-network-pref-section.c generated by valac 0.22.0.18-aa6c, the Vala compiler
 * generated from rygel-network-pref-section.vala, do not modify */

/*
 * Copyright (C) 2009,2011 Nokia Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Rygel 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <libgupnp/gupnp.h>
#include <rygel-core.h>
#include <gee.h>
#include <libgssdp/gssdp.h>


#define RYGEL_TYPE_PREFERENCES_SECTION (rygel_preferences_section_get_type ())
#define RYGEL_PREFERENCES_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_PREFERENCES_SECTION, RygelPreferencesSection))
#define RYGEL_PREFERENCES_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_PREFERENCES_SECTION, RygelPreferencesSectionClass))
#define RYGEL_IS_PREFERENCES_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_PREFERENCES_SECTION))
#define RYGEL_IS_PREFERENCES_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_PREFERENCES_SECTION))
#define RYGEL_PREFERENCES_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_PREFERENCES_SECTION, RygelPreferencesSectionClass))

typedef struct _RygelPreferencesSection RygelPreferencesSection;
typedef struct _RygelPreferencesSectionClass RygelPreferencesSectionClass;
typedef struct _RygelPreferencesSectionPrivate RygelPreferencesSectionPrivate;

#define RYGEL_TYPE_USER_CONFIG (rygel_user_config_get_type ())
#define RYGEL_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_USER_CONFIG, RygelUserConfig))
#define RYGEL_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_USER_CONFIG, RygelUserConfigClass))
#define RYGEL_IS_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_USER_CONFIG))
#define RYGEL_IS_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_USER_CONFIG))
#define RYGEL_USER_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_USER_CONFIG, RygelUserConfigClass))

typedef struct _RygelUserConfig RygelUserConfig;
typedef struct _RygelUserConfigClass RygelUserConfigClass;

#define RYGEL_TYPE_WRITABLE_USER_CONFIG (rygel_writable_user_config_get_type ())
#define RYGEL_WRITABLE_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_WRITABLE_USER_CONFIG, RygelWritableUserConfig))
#define RYGEL_WRITABLE_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_WRITABLE_USER_CONFIG, RygelWritableUserConfigClass))
#define RYGEL_IS_WRITABLE_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_WRITABLE_USER_CONFIG))
#define RYGEL_IS_WRITABLE_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_WRITABLE_USER_CONFIG))
#define RYGEL_WRITABLE_USER_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_WRITABLE_USER_CONFIG, RygelWritableUserConfigClass))

typedef struct _RygelWritableUserConfig RygelWritableUserConfig;
typedef struct _RygelWritableUserConfigClass RygelWritableUserConfigClass;

#define RYGEL_TYPE_NETWORK_PREF_SECTION (rygel_network_pref_section_get_type ())
#define RYGEL_NETWORK_PREF_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_NETWORK_PREF_SECTION, RygelNetworkPrefSection))
#define RYGEL_NETWORK_PREF_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_NETWORK_PREF_SECTION, RygelNetworkPrefSectionClass))
#define RYGEL_IS_NETWORK_PREF_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_NETWORK_PREF_SECTION))
#define RYGEL_IS_NETWORK_PREF_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_NETWORK_PREF_SECTION))
#define RYGEL_NETWORK_PREF_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_NETWORK_PREF_SECTION, RygelNetworkPrefSectionClass))

typedef struct _RygelNetworkPrefSection RygelNetworkPrefSection;
typedef struct _RygelNetworkPrefSectionClass RygelNetworkPrefSectionClass;
typedef struct _RygelNetworkPrefSectionPrivate RygelNetworkPrefSectionPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _gtk_tree_row_reference_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_row_reference_free (var), NULL)))
#define __g_list_free__gtk_tree_path_free0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__gtk_tree_path_free0_ (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _RygelPreferencesSection {
	GObject parent_instance;
	RygelPreferencesSectionPrivate * priv;
	RygelWritableUserConfig* config;
	gchar* name;
};

struct _RygelPreferencesSectionClass {
	GObjectClass parent_class;
	void (*save) (RygelPreferencesSection* self);
	void (*set_sensitivity) (RygelPreferencesSection* self, gboolean sensitivity);
};

struct _RygelNetworkPrefSection {
	RygelPreferencesSection parent_instance;
	RygelNetworkPrefSectionPrivate * priv;
};

struct _RygelNetworkPrefSectionClass {
	RygelPreferencesSectionClass parent_class;
};

struct _RygelNetworkPrefSectionPrivate {
	GtkListStore* iface_store;
	GtkListStore* networks_store;
	GtkTreeView* treeview;
	GtkTreeSelection* tree_selection;
	GtkGrid* grid;
	GtkToolButton* remove_button;
	GUPnPContextManager* context_manager;
};


static gpointer rygel_network_pref_section_parent_class = NULL;

GType rygel_preferences_section_get_type (void) G_GNUC_CONST;
GType rygel_user_config_get_type (void) G_GNUC_CONST;
GType rygel_writable_user_config_get_type (void) G_GNUC_CONST;
GType rygel_network_pref_section_get_type (void) G_GNUC_CONST;
#define RYGEL_NETWORK_PREF_SECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_NETWORK_PREF_SECTION, RygelNetworkPrefSectionPrivate))
enum  {
	RYGEL_NETWORK_PREF_SECTION_DUMMY_PROPERTY
};
#define RYGEL_NETWORK_PREF_SECTION_IFACE_STORE "iface-liststore"
#define RYGEL_NETWORK_PREF_SECTION_NETWORKS_STORE "networks-liststore"
#define RYGEL_NETWORK_PREF_SECTION_TREEVIEW "networks-treeview"
#define RYGEL_NETWORK_PREF_SECTION_TREE_SELECTION "networks-tree-selection"
RygelNetworkPrefSection* rygel_network_pref_section_new (GtkBuilder* builder, RygelWritableUserConfig* config, GError** error);
RygelNetworkPrefSection* rygel_network_pref_section_construct (GType object_type, GtkBuilder* builder, RygelWritableUserConfig* config, GError** error);
RygelPreferencesSection* rygel_preferences_section_construct (GType object_type, RygelWritableUserConfig* config, const gchar* name);
static void __lambda4_ (RygelNetworkPrefSection* self, const gchar* path, const gchar* new_);
static void ___lambda4__gtk_cell_renderer_text_edited (GtkCellRendererText* _sender, const gchar* path, const gchar* new_text, gpointer self);
static void rygel_network_pref_section_on_remove_button_clicked (RygelNetworkPrefSection* self, GtkToolButton* button);
static void _rygel_network_pref_section_on_remove_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
static void __lambda5_ (RygelNetworkPrefSection* self);
static void ___lambda5__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self);
static void rygel_network_pref_section_on_context_available (RygelNetworkPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context);
static void _rygel_network_pref_section_on_context_available_gupnp_context_manager_context_available (GUPnPContextManager* _sender, GUPnPContext* context, gpointer self);
static void rygel_network_pref_section_on_context_unavailable (RygelNetworkPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context);
static void _rygel_network_pref_section_on_context_unavailable_gupnp_context_manager_context_unavailable (GUPnPContextManager* _sender, GUPnPContext* context, gpointer self);
static void rygel_network_pref_section_on_tree_selection_changed (RygelNetworkPrefSection* self);
static void _rygel_network_pref_section_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self);
static void rygel_network_pref_section_real_save (RygelPreferencesSection* base);
void rygel_writable_user_config_set_string_list (RygelWritableUserConfig* self, const gchar* section, const gchar* key, GeeArrayList* str_list);
static void rygel_network_pref_section_real_set_sensitivity (RygelPreferencesSection* base, gboolean sensitivity);
static gboolean rygel_network_pref_section_find_interface (RygelNetworkPrefSection* self, const gchar* iface, GtkTreeIter* iter);
static void _gtk_tree_path_free0_ (gpointer var);
static void _g_list_free__gtk_tree_path_free0_ (GList* self);
static void rygel_network_pref_section_finalize (GObject* obj);
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 gint _vala_array_length (gpointer array);


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


static void __lambda4_ (RygelNetworkPrefSection* self, const gchar* path, const gchar* new_) {
	GtkTreeIter iter = {0};
	GtkListStore* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	GtkListStore* _tmp3_ = NULL;
	GtkTreeIter _tmp4_ = {0};
	const gchar* _tmp5_ = NULL;
	g_return_if_fail (path != NULL);
	g_return_if_fail (new_ != NULL);
	_tmp0_ = self->priv->networks_store;
	_tmp1_ = path;
	gtk_tree_model_get_iter_from_string ((GtkTreeModel*) _tmp0_, &_tmp2_, _tmp1_);
	iter = _tmp2_;
	_tmp3_ = self->priv->networks_store;
	_tmp4_ = iter;
	_tmp5_ = new_;
	gtk_list_store_set (_tmp3_, &_tmp4_, 0, _tmp5_, -1);
}


static void ___lambda4__gtk_cell_renderer_text_edited (GtkCellRendererText* _sender, const gchar* path, const gchar* new_text, gpointer self) {
	__lambda4_ (self, path, new_text);
}


static void _rygel_network_pref_section_on_remove_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
	rygel_network_pref_section_on_remove_button_clicked (self, _sender);
}


static void __lambda5_ (RygelNetworkPrefSection* self) {
	GtkTreeIter iter = {0};
	GtkListStore* _tmp0_ = NULL;
	GtkTreeIter _tmp1_ = {0};
	GtkTreePath* path = NULL;
	GtkListStore* _tmp2_ = NULL;
	GtkTreeIter _tmp3_ = {0};
	GtkTreePath* _tmp4_ = NULL;
	GtkTreeView* _tmp5_ = NULL;
	GtkTreeView* _tmp6_ = NULL;
	GtkTreeViewColumn* _tmp7_ = NULL;
	GtkTreeView* _tmp8_ = NULL;
	_tmp0_ = self->priv->networks_store;
	gtk_list_store_append (_tmp0_, &_tmp1_);
	iter = _tmp1_;
	_tmp2_ = self->priv->networks_store;
	_tmp3_ = iter;
	_tmp4_ = gtk_tree_model_get_path ((GtkTreeModel*) _tmp2_, &_tmp3_);
	path = _tmp4_;
	_tmp5_ = self->priv->treeview;
	_tmp6_ = self->priv->treeview;
	_tmp7_ = gtk_tree_view_get_column (_tmp6_, 0);
	gtk_tree_view_set_cursor (_tmp5_, path, _tmp7_, TRUE);
	_tmp8_ = self->priv->treeview;
	gtk_widget_grab_focus ((GtkWidget*) _tmp8_);
	_gtk_tree_path_free0 (path);
}


static void ___lambda5__gtk_tool_button_clicked (GtkToolButton* _sender, gpointer self) {
	__lambda5_ (self);
}


static void _rygel_network_pref_section_on_context_available_gupnp_context_manager_context_available (GUPnPContextManager* _sender, GUPnPContext* context, gpointer self) {
	rygel_network_pref_section_on_context_available (self, _sender, context);
}


static void _rygel_network_pref_section_on_context_unavailable_gupnp_context_manager_context_unavailable (GUPnPContextManager* _sender, GUPnPContext* context, gpointer self) {
	rygel_network_pref_section_on_context_unavailable (self, _sender, context);
}


static void _rygel_network_pref_section_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender, gpointer self) {
	rygel_network_pref_section_on_tree_selection_changed (self);
}


RygelNetworkPrefSection* rygel_network_pref_section_construct (GType object_type, GtkBuilder* builder, RygelWritableUserConfig* config, GError** error) {
	RygelNetworkPrefSection * self = NULL;
	RygelWritableUserConfig* _tmp0_ = NULL;
	GtkBuilder* _tmp1_ = NULL;
	GObject* _tmp2_ = NULL;
	GtkListStore* _tmp3_ = NULL;
	GtkListStore* _tmp4_ = NULL;
	GtkBuilder* _tmp5_ = NULL;
	GObject* _tmp6_ = NULL;
	GtkListStore* _tmp7_ = NULL;
	GtkListStore* _tmp8_ = NULL;
	GtkBuilder* _tmp9_ = NULL;
	GObject* _tmp10_ = NULL;
	GtkTreeSelection* _tmp11_ = NULL;
	GtkCellRendererCombo* renderer = NULL;
	GtkBuilder* _tmp12_ = NULL;
	GObject* _tmp13_ = NULL;
	GtkCellRendererCombo* _tmp14_ = NULL;
	GtkBuilder* _tmp15_ = NULL;
	GObject* _tmp16_ = NULL;
	GtkTreeView* _tmp17_ = NULL;
	GtkBuilder* _tmp18_ = NULL;
	GObject* _tmp19_ = NULL;
	GtkToolButton* _tmp20_ = NULL;
	GtkToolButton* _tmp21_ = NULL;
	GtkToolButton* add_button = NULL;
	GtkBuilder* _tmp22_ = NULL;
	GObject* _tmp23_ = NULL;
	GtkToolButton* _tmp24_ = NULL;
	GtkBuilder* _tmp25_ = NULL;
	GObject* _tmp26_ = NULL;
	GtkGrid* _tmp27_ = NULL;
	GUPnPContextManager* _tmp28_ = NULL;
	GUPnPContextManager* _tmp38_ = NULL;
	GUPnPContextManager* _tmp39_ = NULL;
	GtkTreeSelection* _tmp40_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (builder != NULL, NULL);
	g_return_val_if_fail (config != NULL, NULL);
	_tmp0_ = config;
	self = (RygelNetworkPrefSection*) rygel_preferences_section_construct (object_type, _tmp0_, "general");
	_tmp1_ = builder;
	_tmp2_ = gtk_builder_get_object (_tmp1_, RYGEL_NETWORK_PREF_SECTION_IFACE_STORE);
	_tmp3_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp2_) : NULL);
	_g_object_unref0 (self->priv->iface_store);
	self->priv->iface_store = _tmp3_;
	_tmp4_ = self->priv->iface_store;
	_vala_assert (_tmp4_ != NULL, "this.iface_store != null");
	_tmp5_ = builder;
	_tmp6_ = gtk_builder_get_object (_tmp5_, RYGEL_NETWORK_PREF_SECTION_NETWORKS_STORE);
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, GTK_TYPE_LIST_STORE) ? ((GtkListStore*) _tmp6_) : NULL);
	_g_object_unref0 (self->priv->networks_store);
	self->priv->networks_store = _tmp7_;
	_tmp8_ = self->priv->networks_store;
	_vala_assert (_tmp8_ != NULL, "this.networks_store != null");
	_tmp9_ = builder;
	_tmp10_ = gtk_builder_get_object (_tmp9_, RYGEL_NETWORK_PREF_SECTION_TREE_SELECTION);
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, GTK_TYPE_TREE_SELECTION) ? ((GtkTreeSelection*) _tmp10_) : NULL);
	_g_object_unref0 (self->priv->tree_selection);
	self->priv->tree_selection = _tmp11_;
	_tmp12_ = builder;
	_tmp13_ = gtk_builder_get_object (_tmp12_, "cellrenderertext2");
	_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, GTK_TYPE_CELL_RENDERER_COMBO) ? ((GtkCellRendererCombo*) _tmp13_) : NULL);
	renderer = _tmp14_;
	g_signal_connect_object ((GtkCellRendererText*) renderer, "edited", (GCallback) ___lambda4__gtk_cell_renderer_text_edited, self, 0);
	_tmp15_ = builder;
	_tmp16_ = gtk_builder_get_object (_tmp15_, RYGEL_NETWORK_PREF_SECTION_TREEVIEW);
	_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp16_, GTK_TYPE_TREE_VIEW) ? ((GtkTreeView*) _tmp16_) : NULL);
	_g_object_unref0 (self->priv->treeview);
	self->priv->treeview = _tmp17_;
	_tmp18_ = builder;
	_tmp19_ = gtk_builder_get_object (_tmp18_, "network-remove-button");
	_tmp20_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp19_, GTK_TYPE_TOOL_BUTTON) ? ((GtkToolButton*) _tmp19_) : NULL);
	_g_object_unref0 (self->priv->remove_button);
	self->priv->remove_button = _tmp20_;
	_tmp21_ = self->priv->remove_button;
	g_signal_connect_object (_tmp21_, "clicked", (GCallback) _rygel_network_pref_section_on_remove_button_clicked_gtk_tool_button_clicked, self, 0);
	_tmp22_ = builder;
	_tmp23_ = gtk_builder_get_object (_tmp22_, "network-add-button");
	_tmp24_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp23_, GTK_TYPE_TOOL_BUTTON) ? ((GtkToolButton*) _tmp23_) : NULL);
	add_button = _tmp24_;
	g_signal_connect_object (add_button, "clicked", (GCallback) ___lambda5__gtk_tool_button_clicked, self, 0);
	_tmp25_ = builder;
	_tmp26_ = gtk_builder_get_object (_tmp25_, "grid4");
	_tmp27_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp26_, GTK_TYPE_GRID) ? ((GtkGrid*) _tmp26_) : NULL);
	_g_object_unref0 (self->priv->grid);
	self->priv->grid = _tmp27_;
	_tmp28_ = gupnp_context_manager_create ((guint) 0);
	_g_object_unref0 (self->priv->context_manager);
	self->priv->context_manager = _tmp28_;
	{
		gchar** interfaces = NULL;
		RygelWritableUserConfig* _tmp29_ = NULL;
		gchar** _tmp30_ = NULL;
		gchar** _tmp31_ = NULL;
		gint interfaces_length1 = 0;
		gint _interfaces_size_ = 0;
		_tmp29_ = config;
		_tmp31_ = _tmp30_ = rygel_configuration_get_interfaces ((RygelConfiguration*) _tmp29_, &_inner_error_);
		interfaces = _tmp31_;
		interfaces_length1 = _vala_array_length (_tmp30_);
		_interfaces_size_ = interfaces_length1;
		if (_inner_error_ != NULL) {
			goto __catch9_g_error;
		}
		{
			gchar** iface_collection = NULL;
			gint iface_collection_length1 = 0;
			gint _iface_collection_size_ = 0;
			gint iface_it = 0;
			iface_collection = interfaces;
			iface_collection_length1 = interfaces_length1;
			for (iface_it = 0; iface_it < interfaces_length1; iface_it = iface_it + 1) {
				gchar* _tmp32_ = NULL;
				gchar* iface = NULL;
				_tmp32_ = g_strdup (iface_collection[iface_it]);
				iface = _tmp32_;
				{
					GtkTreeIter iter = {0};
					GtkListStore* _tmp33_ = NULL;
					GtkTreeIter _tmp34_ = {0};
					GtkListStore* _tmp35_ = NULL;
					GtkTreeIter _tmp36_ = {0};
					const gchar* _tmp37_ = NULL;
					_tmp33_ = self->priv->networks_store;
					gtk_list_store_append (_tmp33_, &_tmp34_);
					iter = _tmp34_;
					_tmp35_ = self->priv->networks_store;
					_tmp36_ = iter;
					_tmp37_ = iface;
					gtk_list_store_set (_tmp35_, &_tmp36_, 0, _tmp37_, -1);
					_g_free0 (iface);
				}
			}
		}
		interfaces = (_vala_array_free (interfaces, interfaces_length1, (GDestroyNotify) g_free), NULL);
	}
	goto __finally9;
	__catch9_g_error:
	{
		GError* err = NULL;
		err = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (err);
	}
	__finally9:
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (add_button);
		_g_object_unref0 (renderer);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp38_ = self->priv->context_manager;
	g_signal_connect_object (_tmp38_, "context-available", (GCallback) _rygel_network_pref_section_on_context_available_gupnp_context_manager_context_available, self, 0);
	_tmp39_ = self->priv->context_manager;
	g_signal_connect_object (_tmp39_, "context-unavailable", (GCallback) _rygel_network_pref_section_on_context_unavailable_gupnp_context_manager_context_unavailable, self, 0);
	rygel_network_pref_section_on_tree_selection_changed (self);
	_tmp40_ = self->priv->tree_selection;
	g_signal_connect_object (_tmp40_, "changed", (GCallback) _rygel_network_pref_section_on_tree_selection_changed_gtk_tree_selection_changed, self, 0);
	_g_object_unref0 (add_button);
	_g_object_unref0 (renderer);
	return self;
}


RygelNetworkPrefSection* rygel_network_pref_section_new (GtkBuilder* builder, RygelWritableUserConfig* config, GError** error) {
	return rygel_network_pref_section_construct (RYGEL_TYPE_NETWORK_PREF_SECTION, builder, config, error);
}


static void rygel_network_pref_section_real_save (RygelPreferencesSection* base) {
	RygelNetworkPrefSection * self;
	GtkTreeIter iter = {0};
	GeeArrayList* uri_list = NULL;
	GeeArrayList* _tmp0_ = NULL;
	GtkListStore* _tmp1_ = NULL;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_ = FALSE;
	RygelWritableUserConfig* _tmp12_ = NULL;
	GeeArrayList* _tmp13_ = NULL;
	self = (RygelNetworkPrefSection*) base;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	uri_list = _tmp0_;
	_tmp1_ = self->priv->networks_store;
	_tmp3_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp1_, &_tmp2_);
	iter = _tmp2_;
	if (_tmp3_) {
		{
			gboolean _tmp4_ = FALSE;
			_tmp4_ = TRUE;
			while (TRUE) {
				gboolean _tmp5_ = FALSE;
				gchar* uri = NULL;
				GtkListStore* _tmp8_ = NULL;
				GtkTreeIter _tmp9_ = {0};
				GeeArrayList* _tmp10_ = NULL;
				const gchar* _tmp11_ = NULL;
				_tmp5_ = _tmp4_;
				if (!_tmp5_) {
					GtkListStore* _tmp6_ = NULL;
					gboolean _tmp7_ = FALSE;
					_tmp6_ = self->priv->networks_store;
					_tmp7_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp6_, &iter);
					if (!_tmp7_) {
						break;
					}
				}
				_tmp4_ = FALSE;
				_tmp8_ = self->priv->networks_store;
				_tmp9_ = iter;
				gtk_tree_model_get ((GtkTreeModel*) _tmp8_, &_tmp9_, 0, &uri, -1, -1);
				_tmp10_ = uri_list;
				_tmp11_ = uri;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp11_);
				_g_free0 (uri);
			}
		}
	}
	_tmp12_ = ((RygelPreferencesSection*) self)->config;
	_tmp13_ = uri_list;
	rygel_writable_user_config_set_string_list (_tmp12_, "general", "interface", _tmp13_);
	_g_object_unref0 (uri_list);
}


static void rygel_network_pref_section_real_set_sensitivity (RygelPreferencesSection* base, gboolean sensitivity) {
	RygelNetworkPrefSection * self;
	GtkGrid* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	self = (RygelNetworkPrefSection*) base;
	_tmp0_ = self->priv->grid;
	_tmp1_ = sensitivity;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, _tmp1_);
}


static void rygel_network_pref_section_on_context_available (RygelNetworkPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context) {
	GtkTreeIter iter = {0};
	GUPnPContext* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GtkTreeIter _tmp3_ = {0};
	gboolean _tmp4_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (manager != NULL);
	g_return_if_fail (context != NULL);
	_tmp0_ = context;
	_tmp1_ = gssdp_client_get_interface ((GSSDPClient*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp4_ = rygel_network_pref_section_find_interface (self, _tmp2_, &_tmp3_);
	iter = _tmp3_;
	if (!_tmp4_) {
		GtkListStore* _tmp5_ = NULL;
		GtkTreeIter _tmp6_ = {0};
		GtkListStore* _tmp7_ = NULL;
		GtkTreeIter _tmp8_ = {0};
		GUPnPContext* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		const gchar* _tmp11_ = NULL;
		_tmp5_ = self->priv->iface_store;
		gtk_list_store_append (_tmp5_, &_tmp6_);
		iter = _tmp6_;
		_tmp7_ = self->priv->iface_store;
		_tmp8_ = iter;
		_tmp9_ = context;
		_tmp10_ = gssdp_client_get_interface ((GSSDPClient*) _tmp9_);
		_tmp11_ = _tmp10_;
		gtk_list_store_set (_tmp7_, &_tmp8_, 0, _tmp11_, -1);
	}
}


static void rygel_network_pref_section_on_context_unavailable (RygelNetworkPrefSection* self, GUPnPContextManager* manager, GUPnPContext* context) {
	GtkTreeIter iter = {0};
	GUPnPContext* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GtkTreeIter _tmp3_ = {0};
	gboolean _tmp4_ = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (manager != NULL);
	g_return_if_fail (context != NULL);
	_tmp0_ = context;
	_tmp1_ = gssdp_client_get_interface ((GSSDPClient*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp4_ = rygel_network_pref_section_find_interface (self, _tmp2_, &_tmp3_);
	iter = _tmp3_;
	if (_tmp4_) {
		GtkListStore* _tmp5_ = NULL;
		GtkTreeIter _tmp6_ = {0};
		_tmp5_ = self->priv->iface_store;
		_tmp6_ = iter;
		gtk_list_store_remove (_tmp5_, &_tmp6_);
	}
}


static gpointer _gtk_tree_path_copy0 (gpointer self) {
	return self ? gtk_tree_path_copy (self) : NULL;
}


static void _gtk_tree_path_free0_ (gpointer var) {
	(var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL));
}


static void _g_list_free__gtk_tree_path_free0_ (GList* self) {
	g_list_foreach (self, (GFunc) _gtk_tree_path_free0_, NULL);
	g_list_free (self);
}


static void rygel_network_pref_section_on_remove_button_clicked (RygelNetworkPrefSection* self, GtkToolButton* button) {
	GtkTreeSelection* selection = NULL;
	GtkTreeView* _tmp0_ = NULL;
	GtkTreeSelection* _tmp1_ = NULL;
	GtkTreeSelection* _tmp2_ = NULL;
	GList* rows = NULL;
	GtkTreeSelection* _tmp3_ = NULL;
	GList* _tmp4_ = NULL;
	GeeArrayList* row_refs = NULL;
	GeeArrayList* _tmp5_ = NULL;
	GList* _tmp6_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->treeview;
	_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	selection = _tmp2_;
	_tmp3_ = selection;
	_tmp4_ = gtk_tree_selection_get_selected_rows (_tmp3_, NULL);
	rows = _tmp4_;
	_tmp5_ = gee_array_list_new (gtk_tree_row_reference_get_type (), (GBoxedCopyFunc) gtk_tree_row_reference_copy, gtk_tree_row_reference_free, NULL, NULL, NULL);
	row_refs = _tmp5_;
	_tmp6_ = rows;
	{
		GList* row_collection = NULL;
		GList* row_it = NULL;
		row_collection = _tmp6_;
		for (row_it = row_collection; row_it != NULL; row_it = row_it->next) {
			GtkTreePath* _tmp7_ = NULL;
			GtkTreePath* row = NULL;
			_tmp7_ = _gtk_tree_path_copy0 ((GtkTreePath*) row_it->data);
			row = _tmp7_;
			{
				GeeArrayList* _tmp8_ = NULL;
				GtkListStore* _tmp9_ = NULL;
				GtkTreePath* _tmp10_ = NULL;
				GtkTreeRowReference* _tmp11_ = NULL;
				GtkTreeRowReference* _tmp12_ = NULL;
				_tmp8_ = row_refs;
				_tmp9_ = self->priv->networks_store;
				_tmp10_ = row;
				_tmp11_ = gtk_tree_row_reference_new ((GtkTreeModel*) _tmp9_, _tmp10_);
				_tmp12_ = _tmp11_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, _tmp12_);
				_gtk_tree_row_reference_free0 (_tmp12_);
				_gtk_tree_path_free0 (row);
			}
		}
	}
	{
		GeeArrayList* _row_ref_list = NULL;
		GeeArrayList* _tmp13_ = NULL;
		GeeArrayList* _tmp14_ = NULL;
		gint _row_ref_size = 0;
		GeeArrayList* _tmp15_ = NULL;
		gint _tmp16_ = 0;
		gint _tmp17_ = 0;
		gint _row_ref_index = 0;
		_tmp13_ = row_refs;
		_tmp14_ = _g_object_ref0 (_tmp13_);
		_row_ref_list = _tmp14_;
		_tmp15_ = _row_ref_list;
		_tmp16_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp15_);
		_tmp17_ = _tmp16_;
		_row_ref_size = _tmp17_;
		_row_ref_index = -1;
		while (TRUE) {
			gint _tmp18_ = 0;
			gint _tmp19_ = 0;
			gint _tmp20_ = 0;
			GtkTreeRowReference* row_ref = NULL;
			GeeArrayList* _tmp21_ = NULL;
			gint _tmp22_ = 0;
			gpointer _tmp23_ = NULL;
			GtkTreeIter iter = {0};
			GtkTreePath* path = NULL;
			const GtkTreeRowReference* _tmp24_ = NULL;
			GtkTreePath* _tmp25_ = NULL;
			GtkListStore* _tmp26_ = NULL;
			GtkTreePath* _tmp27_ = NULL;
			GtkTreeIter _tmp28_ = {0};
			GtkListStore* _tmp29_ = NULL;
			GtkTreeIter _tmp30_ = {0};
			_tmp18_ = _row_ref_index;
			_row_ref_index = _tmp18_ + 1;
			_tmp19_ = _row_ref_index;
			_tmp20_ = _row_ref_size;
			if (!(_tmp19_ < _tmp20_)) {
				break;
			}
			_tmp21_ = _row_ref_list;
			_tmp22_ = _row_ref_index;
			_tmp23_ = gee_abstract_list_get ((GeeAbstractList*) _tmp21_, _tmp22_);
			row_ref = (GtkTreeRowReference*) _tmp23_;
			_tmp24_ = row_ref;
			_tmp25_ = gtk_tree_row_reference_get_path (_tmp24_);
			path = _tmp25_;
			_tmp26_ = self->priv->networks_store;
			_tmp27_ = path;
			gtk_tree_model_get_iter ((GtkTreeModel*) _tmp26_, &_tmp28_, _tmp27_);
			iter = _tmp28_;
			_tmp29_ = self->priv->networks_store;
			_tmp30_ = iter;
			gtk_list_store_remove (_tmp29_, &_tmp30_);
			_gtk_tree_path_free0 (path);
			_gtk_tree_row_reference_free0 (row_ref);
		}
		_g_object_unref0 (_row_ref_list);
	}
	_g_object_unref0 (row_refs);
	__g_list_free__gtk_tree_path_free0_0 (rows);
	_g_object_unref0 (selection);
}


static gboolean rygel_network_pref_section_find_interface (RygelNetworkPrefSection* self, const gchar* iface, GtkTreeIter* iter) {
	GtkTreeIter _vala_iter = {0};
	gboolean result = FALSE;
	GtkListStore* model = NULL;
	GtkListStore* _tmp0_ = NULL;
	GtkListStore* _tmp1_ = NULL;
	gboolean more = FALSE;
	GtkListStore* _tmp2_ = NULL;
	GtkTreeIter _tmp3_ = {0};
	gboolean _tmp4_ = FALSE;
	gchar* name = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (iface != NULL, FALSE);
	_tmp0_ = self->priv->iface_store;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	model = _tmp1_;
	_tmp2_ = model;
	_tmp4_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp2_, &_tmp3_);
	_vala_iter = _tmp3_;
	more = _tmp4_;
	name = NULL;
	while (TRUE) {
		gboolean _tmp5_ = FALSE;
		GtkListStore* _tmp6_ = NULL;
		GtkTreeIter _tmp7_ = {0};
		const gchar* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		GtkListStore* _tmp10_ = NULL;
		gboolean _tmp11_ = FALSE;
		_tmp5_ = more;
		if (!_tmp5_) {
			break;
		}
		_tmp6_ = model;
		_tmp7_ = _vala_iter;
		gtk_tree_model_get ((GtkTreeModel*) _tmp6_, &_tmp7_, 0, &name, -1, -1);
		_tmp8_ = name;
		_tmp9_ = iface;
		if (g_strcmp0 (_tmp8_, _tmp9_) == 0) {
			break;
		}
		_tmp10_ = model;
		_tmp11_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp10_, &_vala_iter);
		more = _tmp11_;
	}
	result = more;
	_g_free0 (name);
	_g_object_unref0 (model);
	if (iter) {
		*iter = _vala_iter;
	}
	return result;
}


static void rygel_network_pref_section_on_tree_selection_changed (RygelNetworkPrefSection* self) {
	GtkTreeSelection* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tree_selection;
	_tmp1_ = gtk_tree_selection_get_selected (_tmp0_, NULL, NULL);
	if (_tmp1_) {
		GtkToolButton* _tmp2_ = NULL;
		_tmp2_ = self->priv->remove_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, TRUE);
	} else {
		GtkToolButton* _tmp3_ = NULL;
		_tmp3_ = self->priv->remove_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp3_, FALSE);
	}
}


static void rygel_network_pref_section_class_init (RygelNetworkPrefSectionClass * klass) {
	rygel_network_pref_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelNetworkPrefSectionPrivate));
	RYGEL_PREFERENCES_SECTION_CLASS (klass)->save = rygel_network_pref_section_real_save;
	RYGEL_PREFERENCES_SECTION_CLASS (klass)->set_sensitivity = rygel_network_pref_section_real_set_sensitivity;
	G_OBJECT_CLASS (klass)->finalize = rygel_network_pref_section_finalize;
}


static void rygel_network_pref_section_instance_init (RygelNetworkPrefSection * self) {
	self->priv = RYGEL_NETWORK_PREF_SECTION_GET_PRIVATE (self);
}


static void rygel_network_pref_section_finalize (GObject* obj) {
	RygelNetworkPrefSection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_NETWORK_PREF_SECTION, RygelNetworkPrefSection);
	_g_object_unref0 (self->priv->iface_store);
	_g_object_unref0 (self->priv->networks_store);
	_g_object_unref0 (self->priv->treeview);
	_g_object_unref0 (self->priv->tree_selection);
	_g_object_unref0 (self->priv->grid);
	_g_object_unref0 (self->priv->remove_button);
	_g_object_unref0 (self->priv->context_manager);
	G_OBJECT_CLASS (rygel_network_pref_section_parent_class)->finalize (obj);
}


GType rygel_network_pref_section_get_type (void) {
	static volatile gsize rygel_network_pref_section_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_network_pref_section_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelNetworkPrefSectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_network_pref_section_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelNetworkPrefSection), 0, (GInstanceInitFunc) rygel_network_pref_section_instance_init, NULL };
		GType rygel_network_pref_section_type_id;
		rygel_network_pref_section_type_id = g_type_register_static (RYGEL_TYPE_PREFERENCES_SECTION, "RygelNetworkPrefSection", &g_define_type_info, 0);
		g_once_init_leave (&rygel_network_pref_section_type_id__volatile, rygel_network_pref_section_type_id);
	}
	return rygel_network_pref_section_type_id__volatile;
}


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


static gint _vala_array_length (gpointer array) {
	int length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}



