/* rygel-network-pref-section.c generated by valac 0.44.9, 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.1 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 library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <glib-object.h>
#include <glib.h>
#include <rygel-core.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <libgupnp/gupnp.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_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;
enum  {
	RYGEL_NETWORK_PREF_SECTION_0_PROPERTY,
	RYGEL_NETWORK_PREF_SECTION_NUM_PROPERTIES
};
static GParamSpec* rygel_network_pref_section_properties[RYGEL_NETWORK_PREF_SECTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define __vala_GtkTreePath_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreePath_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 __vala_GtkTreeRowReference_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreeRowReference_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (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 gint RygelNetworkPrefSection_private_offset;
static gpointer rygel_network_pref_section_parent_class = NULL;

GType rygel_preferences_section_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelPreferencesSection, g_object_unref)
GType rygel_writable_user_config_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelWritableUserConfig, g_object_unref)
GType rygel_network_pref_section_get_type (void) G_GNUC_CONST;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelNetworkPrefSection, g_object_unref)
#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 __lambda6_ (RygelNetworkPrefSection* self,
                 const gchar* path,
                 const gchar* new_);
static void ___lambda6__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 __lambda7_ (RygelNetworkPrefSection* self);
static void _vala_GtkTreePath_free (GtkTreePath* self);
static void ___lambda7__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 GtkTreeRowReference* _vala_GtkTreeRowReference_copy (GtkTreeRowReference* self);
static void _vala_GtkTreeRowReference_free (GtkTreeRowReference* self);
static GtkTreePath* _vala_GtkTreePath_copy (GtkTreePath* self);
static void __vala_GtkTreePath_free0_ (gpointer var);
static inline void _g_list_free___vala_GtkTreePath_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 inline gpointer
rygel_network_pref_section_get_instance_private (RygelNetworkPrefSection* self)
{
	return G_STRUCT_MEMBER_P (self, RygelNetworkPrefSection_private_offset);
}

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

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

static void
___lambda6__gtk_cell_renderer_text_edited (GtkCellRendererText* _sender,
                                           const gchar* path,
                                           const gchar* new_text,
                                           gpointer self)
{
	__lambda6_ ((RygelNetworkPrefSection*) 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 ((RygelNetworkPrefSection*) self, _sender);
}

static void
_vala_GtkTreePath_free (GtkTreePath* self)
{
	g_boxed_free (gtk_tree_path_get_type (), self);
}

static void
__lambda7_ (RygelNetworkPrefSection* self)
{
	GtkTreeIter iter = {0};
	GtkListStore* _tmp0_;
	GtkTreeIter _tmp1_ = {0};
	GtkTreePath* path = NULL;
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_;
	GtkTreePath* _tmp4_;
	GtkTreeView* _tmp5_;
	GtkTreeView* _tmp6_;
	GtkTreeViewColumn* _tmp7_;
	GtkTreeView* _tmp8_;
	_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_);
	__vala_GtkTreePath_free0 (path);
}

static void
___lambda7__gtk_tool_button_clicked (GtkToolButton* _sender,
                                     gpointer self)
{
	__lambda7_ ((RygelNetworkPrefSection*) 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 ((RygelNetworkPrefSection*) 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 ((RygelNetworkPrefSection*) 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 ((RygelNetworkPrefSection*) self);
}

RygelNetworkPrefSection*
rygel_network_pref_section_construct (GType object_type,
                                      GtkBuilder* builder,
                                      RygelWritableUserConfig* config,
                                      GError** error)
{
	RygelNetworkPrefSection * self = NULL;
	GObject* _tmp0_;
	GtkListStore* _tmp1_;
	GtkListStore* _tmp2_;
	GObject* _tmp3_;
	GtkListStore* _tmp4_;
	GtkListStore* _tmp5_;
	GObject* _tmp6_;
	GtkTreeSelection* _tmp7_;
	GtkCellRendererCombo* renderer = NULL;
	GObject* _tmp8_;
	GtkCellRendererCombo* _tmp9_;
	GObject* _tmp10_;
	GtkTreeView* _tmp11_;
	GObject* _tmp12_;
	GtkToolButton* _tmp13_;
	GtkToolButton* _tmp14_;
	GtkToolButton* add_button = NULL;
	GObject* _tmp15_;
	GtkToolButton* _tmp16_;
	GObject* _tmp17_;
	GtkGrid* _tmp18_;
	GUPnPContextManager* _tmp19_;
	GUPnPContextManager* _tmp28_;
	GUPnPContextManager* _tmp29_;
	GtkTreeSelection* _tmp30_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (builder != NULL, NULL);
	g_return_val_if_fail (config != NULL, NULL);
	self = (RygelNetworkPrefSection*) rygel_preferences_section_construct (object_type, config, "general");
	_tmp0_ = gtk_builder_get_object (builder, RYGEL_NETWORK_PREF_SECTION_IFACE_STORE);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_list_store_get_type ()) ? ((GtkListStore*) _tmp0_) : NULL);
	_g_object_unref0 (self->priv->iface_store);
	self->priv->iface_store = _tmp1_;
	_tmp2_ = self->priv->iface_store;
	_vala_assert (_tmp2_ != NULL, "this.iface_store != null");
	_tmp3_ = gtk_builder_get_object (builder, RYGEL_NETWORK_PREF_SECTION_NETWORKS_STORE);
	_tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gtk_list_store_get_type ()) ? ((GtkListStore*) _tmp3_) : NULL);
	_g_object_unref0 (self->priv->networks_store);
	self->priv->networks_store = _tmp4_;
	_tmp5_ = self->priv->networks_store;
	_vala_assert (_tmp5_ != NULL, "this.networks_store != null");
	_tmp6_ = gtk_builder_get_object (builder, RYGEL_NETWORK_PREF_SECTION_TREE_SELECTION);
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp6_, gtk_tree_selection_get_type ()) ? ((GtkTreeSelection*) _tmp6_) : NULL);
	_g_object_unref0 (self->priv->tree_selection);
	self->priv->tree_selection = _tmp7_;
	_tmp8_ = gtk_builder_get_object (builder, "cellrenderertext2");
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, gtk_cell_renderer_combo_get_type ()) ? ((GtkCellRendererCombo*) _tmp8_) : NULL);
	renderer = _tmp9_;
	g_signal_connect_object ((GtkCellRendererText*) renderer, "edited", (GCallback) ___lambda6__gtk_cell_renderer_text_edited, self, 0);
	_tmp10_ = gtk_builder_get_object (builder, RYGEL_NETWORK_PREF_SECTION_TREEVIEW);
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, gtk_tree_view_get_type ()) ? ((GtkTreeView*) _tmp10_) : NULL);
	_g_object_unref0 (self->priv->treeview);
	self->priv->treeview = _tmp11_;
	_tmp12_ = gtk_builder_get_object (builder, "network-remove-button");
	_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, gtk_tool_button_get_type ()) ? ((GtkToolButton*) _tmp12_) : NULL);
	_g_object_unref0 (self->priv->remove_button);
	self->priv->remove_button = _tmp13_;
	_tmp14_ = self->priv->remove_button;
	g_signal_connect_object (_tmp14_, "clicked", (GCallback) _rygel_network_pref_section_on_remove_button_clicked_gtk_tool_button_clicked, self, 0);
	_tmp15_ = gtk_builder_get_object (builder, "network-add-button");
	_tmp16_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, gtk_tool_button_get_type ()) ? ((GtkToolButton*) _tmp15_) : NULL);
	add_button = _tmp16_;
	g_signal_connect_object (add_button, "clicked", (GCallback) ___lambda7__gtk_tool_button_clicked, self, 0);
	_tmp17_ = gtk_builder_get_object (builder, "grid4");
	_tmp18_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp17_, gtk_grid_get_type ()) ? ((GtkGrid*) _tmp17_) : NULL);
	_g_object_unref0 (self->priv->grid);
	self->priv->grid = _tmp18_;
	_tmp19_ = gupnp_context_manager_create ((guint) 0);
	_g_object_unref0 (self->priv->context_manager);
	self->priv->context_manager = _tmp19_;
	{
		gchar** interfaces = NULL;
		gchar** _tmp20_;
		gchar** _tmp21_;
		gint interfaces_length1;
		gint _interfaces_size_;
		_tmp21_ = _tmp20_ = rygel_configuration_get_interfaces ((RygelConfiguration*) config, &_inner_error0_);
		interfaces = _tmp21_;
		interfaces_length1 = _vala_array_length (_tmp20_);
		_interfaces_size_ = interfaces_length1;
		if (G_UNLIKELY (_inner_error0_ != 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 < iface_collection_length1; iface_it = iface_it + 1) {
				gchar* _tmp22_;
				gchar* iface = NULL;
				_tmp22_ = g_strdup (iface_collection[iface_it]);
				iface = _tmp22_;
				{
					GtkTreeIter iter = {0};
					GtkListStore* _tmp23_;
					GtkTreeIter _tmp24_ = {0};
					GtkListStore* _tmp25_;
					GtkTreeIter _tmp26_;
					const gchar* _tmp27_;
					_tmp23_ = self->priv->networks_store;
					gtk_list_store_append (_tmp23_, &_tmp24_);
					iter = _tmp24_;
					_tmp25_ = self->priv->networks_store;
					_tmp26_ = iter;
					_tmp27_ = iface;
					gtk_list_store_set (_tmp25_, &_tmp26_, 0, _tmp27_, -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_error0_;
		_inner_error0_ = NULL;
		_g_error_free0 (err);
	}
	__finally9:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (add_button);
		_g_object_unref0 (renderer);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp28_ = self->priv->context_manager;
	g_signal_connect_object (_tmp28_, "context-available", (GCallback) _rygel_network_pref_section_on_context_available_gupnp_context_manager_context_available, self, 0);
	_tmp29_ = self->priv->context_manager;
	g_signal_connect_object (_tmp29_, "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);
	_tmp30_ = self->priv->tree_selection;
	g_signal_connect_object (_tmp30_, "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_;
	GtkListStore* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_;
	RygelWritableUserConfig* _tmp12_;
	GeeArrayList* _tmp13_;
	self = (RygelNetworkPrefSection*) base;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) 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) {
				gchar* uri = NULL;
				GtkListStore* _tmp7_;
				GtkTreeIter _tmp8_;
				gchar* _tmp9_ = NULL;
				GeeArrayList* _tmp10_;
				const gchar* _tmp11_;
				if (!_tmp4_) {
					GtkListStore* _tmp5_;
					gboolean _tmp6_;
					_tmp5_ = self->priv->networks_store;
					_tmp6_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp5_, &iter);
					if (!_tmp6_) {
						break;
					}
				}
				_tmp4_ = FALSE;
				_tmp7_ = self->priv->networks_store;
				_tmp8_ = iter;
				gtk_tree_model_get ((GtkTreeModel*) _tmp7_, &_tmp8_, 0, &_tmp9_, -1, -1);
				_g_free0 (uri);
				uri = _tmp9_;
				_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_;
	self = (RygelNetworkPrefSection*) base;
	_tmp0_ = self->priv->grid;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp0_, sensitivity);
}

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

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

static GtkTreeRowReference*
_vala_GtkTreeRowReference_copy (GtkTreeRowReference* self)
{
	return g_boxed_copy (gtk_tree_row_reference_get_type (), self);
}

static void
_vala_GtkTreeRowReference_free (GtkTreeRowReference* self)
{
	g_boxed_free (gtk_tree_row_reference_get_type (), self);
}

static GtkTreePath*
_vala_GtkTreePath_copy (GtkTreePath* self)
{
	return g_boxed_copy (gtk_tree_path_get_type (), self);
}

static gpointer
__vala_GtkTreePath_copy0 (gpointer self)
{
	return self ? _vala_GtkTreePath_copy (self) : NULL;
}

static void
__vala_GtkTreePath_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (_vala_GtkTreePath_free (var), NULL));
}

static inline void
_g_list_free___vala_GtkTreePath_free0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) __vala_GtkTreePath_free0_);
}

static void
rygel_network_pref_section_on_remove_button_clicked (RygelNetworkPrefSection* self,
                                                     GtkToolButton* button)
{
	GtkTreeSelection* selection = NULL;
	GtkTreeView* _tmp0_;
	GtkTreeSelection* _tmp1_;
	GtkTreeSelection* _tmp2_;
	GList* rows = NULL;
	GtkTreeSelection* _tmp3_;
	GList* _tmp4_;
	GeeArrayList* row_refs = NULL;
	GeeArrayList* _tmp5_;
	GList* _tmp6_;
	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) _vala_GtkTreeRowReference_copy, (GDestroyNotify) _vala_GtkTreeRowReference_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_;
			GtkTreePath* row = NULL;
			_tmp7_ = __vala_GtkTreePath_copy0 ((GtkTreePath*) row_it->data);
			row = _tmp7_;
			{
				GeeArrayList* _tmp8_;
				GtkListStore* _tmp9_;
				GtkTreePath* _tmp10_;
				GtkTreeRowReference* _tmp11_;
				GtkTreeRowReference* _tmp12_;
				_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_);
				__vala_GtkTreeRowReference_free0 (_tmp12_);
				__vala_GtkTreePath_free0 (row);
			}
		}
	}
	{
		GeeArrayList* _row_ref_list = NULL;
		GeeArrayList* _tmp13_;
		GeeArrayList* _tmp14_;
		gint _row_ref_size = 0;
		GeeArrayList* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		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 ((GeeAbstractCollection*) _tmp15_);
		_tmp17_ = _tmp16_;
		_row_ref_size = _tmp17_;
		_row_ref_index = -1;
		while (TRUE) {
			GtkTreeRowReference* row_ref = NULL;
			GeeArrayList* _tmp18_;
			gpointer _tmp19_;
			GtkTreeIter iter = {0};
			GtkTreePath* path = NULL;
			GtkTreeRowReference* _tmp20_;
			GtkTreePath* _tmp21_;
			GtkListStore* _tmp22_;
			GtkTreePath* _tmp23_;
			GtkTreeIter _tmp24_ = {0};
			GtkListStore* _tmp25_;
			_row_ref_index = _row_ref_index + 1;
			if (!(_row_ref_index < _row_ref_size)) {
				break;
			}
			_tmp18_ = _row_ref_list;
			_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp18_, _row_ref_index);
			row_ref = (GtkTreeRowReference*) _tmp19_;
			_tmp20_ = row_ref;
			_tmp21_ = gtk_tree_row_reference_get_path (_tmp20_);
			path = _tmp21_;
			_tmp22_ = self->priv->networks_store;
			_tmp23_ = path;
			gtk_tree_model_get_iter ((GtkTreeModel*) _tmp22_, &_tmp24_, _tmp23_);
			iter = _tmp24_;
			_tmp25_ = self->priv->networks_store;
			gtk_list_store_remove (_tmp25_, &iter);
			__vala_GtkTreePath_free0 (path);
			__vala_GtkTreeRowReference_free0 (row_ref);
		}
		_g_object_unref0 (_row_ref_list);
	}
	_g_object_unref0 (row_refs);
	(rows == NULL) ? NULL : (rows = (_g_list_free___vala_GtkTreePath_free0_ (rows), NULL));
	_g_object_unref0 (selection);
}

static gboolean
rygel_network_pref_section_find_interface (RygelNetworkPrefSection* self,
                                           const gchar* iface,
                                           GtkTreeIter* iter)
{
	GtkTreeIter _vala_iter = {0};
	GtkListStore* model = NULL;
	GtkListStore* _tmp0_;
	GtkListStore* _tmp1_;
	gboolean more = FALSE;
	GtkListStore* _tmp2_;
	GtkTreeIter _tmp3_ = {0};
	gboolean _tmp4_;
	gchar* name = NULL;
	gboolean result = FALSE;
	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) {
		GtkListStore* _tmp5_;
		GtkTreeIter _tmp6_;
		const gchar* _tmp7_;
		GtkListStore* _tmp8_;
		gboolean _tmp9_;
		if (!more) {
			break;
		}
		_tmp5_ = model;
		_tmp6_ = _vala_iter;
		gtk_tree_model_get ((GtkTreeModel*) _tmp5_, &_tmp6_, 0, &name, -1, -1);
		_tmp7_ = name;
		if (g_strcmp0 (_tmp7_, iface) == 0) {
			break;
		}
		_tmp8_ = model;
		_tmp9_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp8_, &_vala_iter);
		more = _tmp9_;
	}
	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_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->tree_selection;
	if (gtk_tree_selection_get_selected (_tmp0_, NULL, NULL)) {
		GtkToolButton* _tmp1_;
		_tmp1_ = self->priv->remove_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp1_, TRUE);
	} else {
		GtkToolButton* _tmp2_;
		_tmp2_ = self->priv->remove_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp2_, FALSE);
	}
}

static void
rygel_network_pref_section_class_init (RygelNetworkPrefSectionClass * klass,
                                       gpointer klass_data)
{
	rygel_network_pref_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelNetworkPrefSection_private_offset);
	((RygelPreferencesSectionClass *) klass)->save = (void (*) (RygelPreferencesSection*)) rygel_network_pref_section_real_save;
	((RygelPreferencesSectionClass *) klass)->set_sensitivity = (void (*) (RygelPreferencesSection*, gboolean)) 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,
                                          gpointer klass)
{
	self->priv = rygel_network_pref_section_get_instance_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);
		RygelNetworkPrefSection_private_offset = g_type_add_instance_private (rygel_network_pref_section_type_id, sizeof (RygelNetworkPrefSectionPrivate));
		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;
}

