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

/*
 * Copyright (C) 2009 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 <gee.h>
#include <gtk/gtk.h>
#include <gio/gio.h>

#define RYGEL_MEDIA_PREF_SECTION_NAME "MediaExport"
#define RYGEL_MEDIA_PREF_SECTION_URIS_KEY "uris"
#define RYGEL_MEDIA_PREF_SECTION_URIS_TEXTVIEW RYGEL_MEDIA_PREF_SECTION_URIS_KEY "-treeview"
#define RYGEL_MEDIA_PREF_SECTION_URIS_LISTSTORE RYGEL_MEDIA_PREF_SECTION_URIS_KEY "-liststore"
#define RYGEL_MEDIA_PREF_SECTION_URIS_DIALOG RYGEL_MEDIA_PREF_SECTION_URIS_KEY "-dialog"
#define RYGEL_MEDIA_PREF_SECTION_ADD_BUTTON "add-button"
#define RYGEL_MEDIA_PREF_SECTION_REMOVE_BUTTON "remove-button"
#define RYGEL_MEDIA_PREF_SECTION_TREE_SELECTION "treeview-selection"
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#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_MEDIA_PREF_SECTION (rygel_media_pref_section_get_type ())
#define RYGEL_MEDIA_PREF_SECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_PREF_SECTION, RygelMediaPrefSection))
#define RYGEL_MEDIA_PREF_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_PREF_SECTION, RygelMediaPrefSectionClass))
#define RYGEL_IS_MEDIA_PREF_SECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_PREF_SECTION))
#define RYGEL_IS_MEDIA_PREF_SECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_PREF_SECTION))
#define RYGEL_MEDIA_PREF_SECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_PREF_SECTION, RygelMediaPrefSectionClass))

typedef struct _RygelMediaPrefSection RygelMediaPrefSection;
typedef struct _RygelMediaPrefSectionClass RygelMediaPrefSectionClass;
typedef struct _RygelMediaPrefSectionPrivate RygelMediaPrefSectionPrivate;
enum  {
	RYGEL_MEDIA_PREF_SECTION_0_PROPERTY,
	RYGEL_MEDIA_PREF_SECTION_NUM_PROPERTIES
};
static GParamSpec* rygel_media_pref_section_properties[RYGEL_MEDIA_PREF_SECTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __vala_GtkTreeRowReference_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreeRowReference_free (var), NULL)))
#define __vala_GtkTreePath_free0(var) ((var == NULL) ? NULL : (var = (_vala_GtkTreePath_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 _RygelMediaPrefSection {
	RygelPreferencesSection parent_instance;
	RygelMediaPrefSectionPrivate * priv;
};

struct _RygelMediaPrefSectionClass {
	RygelPreferencesSectionClass parent_class;
};

struct _RygelMediaPrefSectionPrivate {
	GeeArrayList* widgets;
	GtkTreeView* treeview;
	GtkListStore* liststore;
	GtkTreeSelection* tree_selection;
	GtkFileChooserDialog* dialog;
	GtkToolButton* remove_button;
};

static gint RygelMediaPrefSection_private_offset;
static gpointer rygel_media_pref_section_parent_class = NULL;

VALA_EXTERN GType rygel_preferences_section_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelPreferencesSection, g_object_unref)
VALA_EXTERN GType rygel_writable_user_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelWritableUserConfig, g_object_unref)
VALA_EXTERN GType rygel_media_pref_section_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (RygelMediaPrefSection, g_object_unref)
VALA_EXTERN void rygel_preferences_section_save (RygelPreferencesSection* self);
VALA_EXTERN void rygel_preferences_section_set_sensitivity (RygelPreferencesSection* self,
                                                gboolean sensitivity);
VALA_EXTERN RygelMediaPrefSection* rygel_media_pref_section_new (GtkBuilder* builder,
                                                     RygelWritableUserConfig* config);
VALA_EXTERN RygelMediaPrefSection* rygel_media_pref_section_construct (GType object_type,
                                                           GtkBuilder* builder,
                                                           RygelWritableUserConfig* config);
VALA_EXTERN RygelPreferencesSection* rygel_preferences_section_construct (GType object_type,
                                                              RygelWritableUserConfig* config,
                                                              const gchar* name);
static gchar* rygel_media_pref_section_get_real_uri (RygelMediaPrefSection* self,
                                              const gchar* uri);
static void rygel_media_pref_section_on_add_button_clicked (RygelMediaPrefSection* self,
                                                     GtkToolButton* button);
static void _rygel_media_pref_section_on_add_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender,
                                                                              gpointer self);
static void rygel_media_pref_section_on_remove_button_clicked (RygelMediaPrefSection* self,
                                                        GtkToolButton* button);
static void _rygel_media_pref_section_on_remove_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender,
                                                                                 gpointer self);
static void rygel_media_pref_section_on_tree_selection_changed (RygelMediaPrefSection* self);
static void _rygel_media_pref_section_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender,
                                                                                     gpointer self);
static void rygel_media_pref_section_real_save (RygelPreferencesSection* base);
static gchar* rygel_media_pref_section_uri_to_magic_variable (RygelMediaPrefSection* self,
                                                       const gchar* uri);
VALA_EXTERN void rygel_writable_user_config_set_string_list (RygelWritableUserConfig* self,
                                                 const gchar* section,
                                                 const gchar* key,
                                                 GeeArrayList* str_list);
static void rygel_media_pref_section_real_set_sensitivity (RygelPreferencesSection* base,
                                                    gboolean sensitivity);
static void _g_object_unref0_ (gpointer var);
static inline void _g_slist_free__g_object_unref0_ (GSList* self);
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_free (GtkTreePath* self);
static void __vala_GtkTreePath_free0_ (gpointer var);
static inline void _g_list_free___vala_GtkTreePath_free0_ (GList* self);
static void rygel_media_pref_section_finalize (GObject * obj);
static GType rygel_media_pref_section_get_type_once (void);

static inline gpointer
rygel_media_pref_section_get_instance_private (RygelMediaPrefSection* self)
{
	return G_STRUCT_MEMBER_P (self, RygelMediaPrefSection_private_offset);
}

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

static void
_rygel_media_pref_section_on_add_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender,
                                                                         gpointer self)
{
	rygel_media_pref_section_on_add_button_clicked ((RygelMediaPrefSection*) self, _sender);
}

static void
_rygel_media_pref_section_on_remove_button_clicked_gtk_tool_button_clicked (GtkToolButton* _sender,
                                                                            gpointer self)
{
	rygel_media_pref_section_on_remove_button_clicked ((RygelMediaPrefSection*) self, _sender);
}

static void
_rygel_media_pref_section_on_tree_selection_changed_gtk_tree_selection_changed (GtkTreeSelection* _sender,
                                                                                gpointer self)
{
	rygel_media_pref_section_on_tree_selection_changed ((RygelMediaPrefSection*) self);
}

RygelMediaPrefSection*
rygel_media_pref_section_construct (GType object_type,
                                    GtkBuilder* builder,
                                    RygelWritableUserConfig* config)
{
	RygelMediaPrefSection * self = NULL;
	GeeArrayList* _tmp0_;
	GObject* _tmp1_;
	GtkTreeView* _tmp2_;
	GtkTreeView* _tmp3_;
	GObject* _tmp4_;
	GtkListStore* _tmp5_;
	GtkListStore* _tmp6_;
	GObject* _tmp7_;
	GtkTreeSelection* _tmp8_;
	GtkTreeSelection* _tmp9_;
	GObject* _tmp10_;
	GtkFileChooserDialog* _tmp11_;
	GtkFileChooserDialog* _tmp12_;
	GeeArrayList* _tmp13_;
	GtkTreeView* _tmp14_;
	GtkFileChooserDialog* _tmp32_;
	const gchar* _tmp33_;
	GtkFileChooserDialog* _tmp34_;
	GtkToolButton* add_button = NULL;
	GObject* _tmp35_;
	GtkToolButton* _tmp36_;
	GeeArrayList* _tmp37_;
	GObject* _tmp38_;
	GtkToolButton* _tmp39_;
	GtkToolButton* _tmp40_;
	GeeArrayList* _tmp41_;
	GtkToolButton* _tmp42_;
	GtkTreeSelection* _tmp43_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (builder != NULL, NULL);
	g_return_val_if_fail (config != NULL, NULL);
	self = (RygelMediaPrefSection*) rygel_preferences_section_construct (object_type, config, RYGEL_MEDIA_PREF_SECTION_NAME);
	_tmp0_ = gee_array_list_new (gtk_widget_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->widgets);
	self->priv->widgets = _tmp0_;
	_tmp1_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_URIS_TEXTVIEW);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_tree_view_get_type (), GtkTreeView));
	_g_object_unref0 (self->priv->treeview);
	self->priv->treeview = _tmp2_;
	_tmp3_ = self->priv->treeview;
	_vala_assert (_tmp3_ != NULL, "this.treeview != null");
	_tmp4_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_URIS_LISTSTORE);
	_tmp5_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_list_store_get_type (), GtkListStore));
	_g_object_unref0 (self->priv->liststore);
	self->priv->liststore = _tmp5_;
	_tmp6_ = self->priv->liststore;
	_vala_assert (_tmp6_ != NULL, "this.liststore != null");
	_tmp7_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_TREE_SELECTION);
	_tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, gtk_tree_selection_get_type ()) ? ((GtkTreeSelection*) _tmp7_) : NULL);
	_g_object_unref0 (self->priv->tree_selection);
	self->priv->tree_selection = _tmp8_;
	_tmp9_ = self->priv->tree_selection;
	_vala_assert (_tmp9_ != NULL, "this.tree_selection != null");
	_tmp10_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_URIS_DIALOG);
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_file_chooser_dialog_get_type (), GtkFileChooserDialog));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp11_;
	_tmp12_ = self->priv->dialog;
	_vala_assert (_tmp12_ != NULL, "this.dialog != null");
	_tmp13_ = self->priv->widgets;
	_tmp14_ = self->priv->treeview;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, (GtkWidget*) _tmp14_);
	{
		GeeArrayList* uris = NULL;
		const gchar* _tmp15_;
		GeeArrayList* _tmp16_;
		_tmp15_ = ((RygelPreferencesSection*) self)->name;
		_tmp16_ = rygel_configuration_get_string_list ((RygelConfiguration*) config, _tmp15_, RYGEL_MEDIA_PREF_SECTION_URIS_KEY, &_inner_error0_);
		uris = _tmp16_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		{
			GeeArrayList* _uri_list = NULL;
			GeeArrayList* _tmp17_;
			gint _uri_size = 0;
			GeeArrayList* _tmp18_;
			gint _tmp19_;
			gint _tmp20_;
			gint _uri_index = 0;
			_tmp17_ = uris;
			_uri_list = _tmp17_;
			_tmp18_ = _uri_list;
			_tmp19_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp18_);
			_tmp20_ = _tmp19_;
			_uri_size = _tmp20_;
			_uri_index = -1;
			while (TRUE) {
				gint _tmp21_;
				gint _tmp22_;
				gchar* uri = NULL;
				GeeArrayList* _tmp23_;
				gpointer _tmp24_;
				gchar* real_uri = NULL;
				const gchar* _tmp25_;
				gchar* _tmp26_;
				GtkTreeIter iter = {0};
				GtkListStore* _tmp27_;
				GtkTreeIter _tmp28_ = {0};
				GtkListStore* _tmp29_;
				GtkTreeIter _tmp30_;
				const gchar* _tmp31_;
				_uri_index = _uri_index + 1;
				_tmp21_ = _uri_index;
				_tmp22_ = _uri_size;
				if (!(_tmp21_ < _tmp22_)) {
					break;
				}
				_tmp23_ = _uri_list;
				_tmp24_ = gee_abstract_list_get ((GeeAbstractList*) _tmp23_, _uri_index);
				uri = (gchar*) _tmp24_;
				_tmp25_ = uri;
				_tmp26_ = rygel_media_pref_section_get_real_uri (self, _tmp25_);
				real_uri = _tmp26_;
				_tmp27_ = self->priv->liststore;
				gtk_list_store_append (_tmp27_, &_tmp28_);
				iter = _tmp28_;
				_tmp29_ = self->priv->liststore;
				_tmp30_ = iter;
				_tmp31_ = real_uri;
				gtk_list_store_set (_tmp29_, &_tmp30_, 0, _tmp31_, -1, -1);
				_g_free0 (real_uri);
				_g_free0 (uri);
			}
		}
		_g_object_unref0 (uris);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	_tmp32_ = self->priv->dialog;
	_tmp33_ = g_get_home_dir ();
	gtk_file_chooser_set_current_folder ((GtkFileChooser*) _tmp32_, _tmp33_);
	_tmp34_ = self->priv->dialog;
	gtk_file_chooser_set_show_hidden ((GtkFileChooser*) _tmp34_, FALSE);
	_tmp35_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_ADD_BUTTON);
	_tmp36_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp35_, gtk_tool_button_get_type ()) ? ((GtkToolButton*) _tmp35_) : NULL);
	add_button = _tmp36_;
	g_signal_connect_object (add_button, "clicked", (GCallback) _rygel_media_pref_section_on_add_button_clicked_gtk_tool_button_clicked, self, 0);
	_tmp37_ = self->priv->widgets;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp37_, (GtkWidget*) add_button);
	_tmp38_ = gtk_builder_get_object (builder, RYGEL_MEDIA_PREF_SECTION_REMOVE_BUTTON);
	_tmp39_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp38_, gtk_tool_button_get_type ()) ? ((GtkToolButton*) _tmp38_) : NULL);
	_g_object_unref0 (self->priv->remove_button);
	self->priv->remove_button = _tmp39_;
	_tmp40_ = self->priv->remove_button;
	g_signal_connect_object (_tmp40_, "clicked", (GCallback) _rygel_media_pref_section_on_remove_button_clicked_gtk_tool_button_clicked, self, 0);
	_tmp41_ = self->priv->widgets;
	_tmp42_ = self->priv->remove_button;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp41_, (GtkWidget*) _tmp42_);
	rygel_media_pref_section_on_tree_selection_changed (self);
	_tmp43_ = self->priv->tree_selection;
	g_signal_connect_object (_tmp43_, "changed", (GCallback) _rygel_media_pref_section_on_tree_selection_changed_gtk_tree_selection_changed, self, 0);
	_g_object_unref0 (add_button);
	return self;
}

RygelMediaPrefSection*
rygel_media_pref_section_new (GtkBuilder* builder,
                              RygelWritableUserConfig* config)
{
	return rygel_media_pref_section_construct (RYGEL_TYPE_MEDIA_PREF_SECTION, builder, config);
}

static void
rygel_media_pref_section_real_save (RygelPreferencesSection* base)
{
	RygelMediaPrefSection * self;
	GtkTreeIter iter = {0};
	GeeArrayList* uri_list = NULL;
	GeeArrayList* _tmp0_;
	GtkListStore* _tmp1_;
	GtkTreeIter _tmp2_ = {0};
	gboolean _tmp3_;
	RygelWritableUserConfig* _tmp14_;
	const gchar* _tmp15_;
	GeeArrayList* _tmp16_;
	self = (RygelMediaPrefSection*) base;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	uri_list = _tmp0_;
	_tmp1_ = self->priv->liststore;
	_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;
				const gchar* _tmp10_;
				gchar* _tmp11_;
				GeeArrayList* _tmp12_;
				const gchar* _tmp13_;
				if (!_tmp4_) {
					GtkListStore* _tmp5_;
					gboolean _tmp6_;
					_tmp5_ = self->priv->liststore;
					_tmp6_ = gtk_tree_model_iter_next ((GtkTreeModel*) _tmp5_, &iter);
					if (!_tmp6_) {
						break;
					}
				}
				_tmp4_ = FALSE;
				_tmp7_ = self->priv->liststore;
				_tmp8_ = iter;
				gtk_tree_model_get ((GtkTreeModel*) _tmp7_, &_tmp8_, 0, &_tmp9_, -1, -1);
				_g_free0 (uri);
				uri = _tmp9_;
				_tmp10_ = uri;
				_tmp11_ = rygel_media_pref_section_uri_to_magic_variable (self, _tmp10_);
				_g_free0 (uri);
				uri = _tmp11_;
				_tmp12_ = uri_list;
				_tmp13_ = uri;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, _tmp13_);
				_g_free0 (uri);
			}
		}
	}
	_tmp14_ = ((RygelPreferencesSection*) self)->config;
	_tmp15_ = ((RygelPreferencesSection*) self)->name;
	_tmp16_ = uri_list;
	rygel_writable_user_config_set_string_list (_tmp14_, _tmp15_, RYGEL_MEDIA_PREF_SECTION_URIS_KEY, _tmp16_);
	_g_object_unref0 (uri_list);
}

static void
rygel_media_pref_section_real_set_sensitivity (RygelPreferencesSection* base,
                                               gboolean sensitivity)
{
	RygelMediaPrefSection * self;
	self = (RygelMediaPrefSection*) base;
	{
		GeeArrayList* _widget_list = NULL;
		GeeArrayList* _tmp0_;
		gint _widget_size = 0;
		GeeArrayList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _widget_index = 0;
		_tmp0_ = self->priv->widgets;
		_widget_list = _tmp0_;
		_tmp1_ = _widget_list;
		_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_widget_size = _tmp3_;
		_widget_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			GtkWidget* widget = NULL;
			GeeArrayList* _tmp6_;
			gpointer _tmp7_;
			GtkWidget* _tmp8_;
			_widget_index = _widget_index + 1;
			_tmp4_ = _widget_index;
			_tmp5_ = _widget_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _widget_list;
			_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, _widget_index);
			widget = (GtkWidget*) _tmp7_;
			_tmp8_ = widget;
			gtk_widget_set_sensitive (_tmp8_, sensitivity);
			_g_object_unref0 (widget);
		}
	}
	if (sensitivity) {
		rygel_media_pref_section_on_tree_selection_changed (self);
	}
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_slist_free__g_object_unref0_ (GSList* self)
{
	g_slist_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

static void
rygel_media_pref_section_on_add_button_clicked (RygelMediaPrefSection* self,
                                                GtkToolButton* button)
{
	GtkFileChooserDialog* _tmp0_;
	GtkFileChooserDialog* _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (button != NULL);
	_tmp0_ = self->priv->dialog;
	if (gtk_dialog_run ((GtkDialog*) _tmp0_) == ((gint) GTK_RESPONSE_OK)) {
		GtkTreeIter iter = {0};
		GSList* dirs = NULL;
		GtkFileChooserDialog* _tmp1_;
		GSList* _tmp2_;
		GSList* _tmp3_;
		_tmp1_ = self->priv->dialog;
		_tmp2_ = gtk_file_chooser_get_files ((GtkFileChooser*) _tmp1_);
		dirs = _tmp2_;
		_tmp3_ = dirs;
		{
			GSList* dir_collection = NULL;
			GSList* dir_it = NULL;
			dir_collection = _tmp3_;
			for (dir_it = dir_collection; dir_it != NULL; dir_it = dir_it->next) {
				GFile* _tmp4_;
				GFile* dir = NULL;
				_tmp4_ = _g_object_ref0 ((GFile*) dir_it->data);
				dir = _tmp4_;
				{
					gchar* path = NULL;
					GFile* _tmp5_;
					gchar* _tmp6_;
					const gchar* _tmp7_;
					GtkListStore* _tmp10_;
					GtkTreeIter _tmp11_ = {0};
					GtkListStore* _tmp12_;
					GtkTreeIter _tmp13_;
					const gchar* _tmp14_;
					_tmp5_ = dir;
					_tmp6_ = g_file_get_path (_tmp5_);
					path = _tmp6_;
					_tmp7_ = path;
					if (_tmp7_ == NULL) {
						GFile* _tmp8_;
						gchar* _tmp9_;
						_tmp8_ = dir;
						_tmp9_ = g_file_get_uri (_tmp8_);
						_g_free0 (path);
						path = _tmp9_;
					}
					_tmp10_ = self->priv->liststore;
					gtk_list_store_append (_tmp10_, &_tmp11_);
					iter = _tmp11_;
					_tmp12_ = self->priv->liststore;
					_tmp13_ = iter;
					_tmp14_ = path;
					gtk_list_store_set (_tmp12_, &_tmp13_, 0, _tmp14_, -1, -1);
					_g_free0 (path);
					_g_object_unref0 (dir);
				}
			}
		}
		(dirs == NULL) ? NULL : (dirs = (_g_slist_free__g_object_unref0_ (dirs), NULL));
	}
	_tmp15_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp15_);
}

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_free (GtkTreePath* self)
{
	g_boxed_free (gtk_tree_path_get_type (), self);
}

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_media_pref_section_on_remove_button_clicked (RygelMediaPrefSection* 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->liststore;
				_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_;
		gint _row_ref_size = 0;
		GeeArrayList* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		gint _row_ref_index = 0;
		_tmp13_ = row_refs;
		_row_ref_list = _tmp13_;
		_tmp14_ = _row_ref_list;
		_tmp15_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp14_);
		_tmp16_ = _tmp15_;
		_row_ref_size = _tmp16_;
		_row_ref_index = -1;
		while (TRUE) {
			gint _tmp17_;
			gint _tmp18_;
			GtkTreeRowReference* row_ref = NULL;
			GeeArrayList* _tmp19_;
			gpointer _tmp20_;
			GtkTreeIter iter = {0};
			GtkTreePath* path = NULL;
			GtkTreeRowReference* _tmp21_;
			GtkTreePath* _tmp22_;
			GtkListStore* _tmp23_;
			GtkTreePath* _tmp24_;
			GtkTreeIter _tmp25_ = {0};
			GtkListStore* _tmp26_;
			_row_ref_index = _row_ref_index + 1;
			_tmp17_ = _row_ref_index;
			_tmp18_ = _row_ref_size;
			if (!(_tmp17_ < _tmp18_)) {
				break;
			}
			_tmp19_ = _row_ref_list;
			_tmp20_ = gee_abstract_list_get ((GeeAbstractList*) _tmp19_, _row_ref_index);
			row_ref = (GtkTreeRowReference*) _tmp20_;
			_tmp21_ = row_ref;
			_tmp22_ = gtk_tree_row_reference_get_path (_tmp21_);
			path = _tmp22_;
			_tmp23_ = self->priv->liststore;
			_tmp24_ = path;
			gtk_tree_model_get_iter ((GtkTreeModel*) _tmp23_, &_tmp25_, _tmp24_);
			iter = _tmp25_;
			_tmp26_ = self->priv->liststore;
			gtk_list_store_remove (_tmp26_, &iter);
			__vala_GtkTreePath_free0 (path);
			__vala_GtkTreeRowReference_free0 (row_ref);
		}
	}
	_g_object_unref0 (row_refs);
	(rows == NULL) ? NULL : (rows = (_g_list_free___vala_GtkTreePath_free0_ (rows), NULL));
	_g_object_unref0 (selection);
}

static gchar*
rygel_media_pref_section_get_real_uri (RygelMediaPrefSection* self,
                                       const gchar* uri)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("@MUSIC@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp3_;
				gchar* _tmp4_;
				_tmp3_ = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
				_tmp4_ = g_strdup (_tmp3_);
				result = _tmp4_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("@VIDEOS@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp5_;
				gchar* _tmp6_;
				_tmp5_ = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
				_tmp6_ = g_strdup (_tmp5_);
				result = _tmp6_;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("@PICTURES@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp7_;
				gchar* _tmp8_;
				_tmp7_ = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
				_tmp8_ = g_strdup (_tmp7_);
				result = _tmp8_;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				gchar* _tmp9_;
				_tmp9_ = g_strdup (uri);
				result = _tmp9_;
				return result;
			}
		}
	}
}

static gchar*
rygel_media_pref_section_uri_to_magic_variable (RygelMediaPrefSection* self,
                                                const gchar* uri)
{
	const gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
	if (g_strcmp0 (uri, _tmp0_) == 0) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("@MUSIC@");
		result = _tmp1_;
		return result;
	} else {
		const gchar* _tmp2_;
		_tmp2_ = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
		if (g_strcmp0 (uri, _tmp2_) == 0) {
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("@VIDEOS@");
			result = _tmp3_;
			return result;
		} else {
			const gchar* _tmp4_;
			_tmp4_ = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
			if (g_strcmp0 (uri, _tmp4_) == 0) {
				gchar* _tmp5_;
				_tmp5_ = g_strdup ("@PICTURES@");
				result = _tmp5_;
				return result;
			} else {
				gchar* _tmp6_;
				_tmp6_ = g_strdup (uri);
				result = _tmp6_;
				return result;
			}
		}
	}
}

static void
rygel_media_pref_section_on_tree_selection_changed (RygelMediaPrefSection* 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_media_pref_section_class_init (RygelMediaPrefSectionClass * klass,
                                     gpointer klass_data)
{
	rygel_media_pref_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelMediaPrefSection_private_offset);
	((RygelPreferencesSectionClass *) klass)->save = (void (*) (RygelPreferencesSection*)) rygel_media_pref_section_real_save;
	((RygelPreferencesSectionClass *) klass)->set_sensitivity = (void (*) (RygelPreferencesSection*, gboolean)) rygel_media_pref_section_real_set_sensitivity;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_pref_section_finalize;
}

static void
rygel_media_pref_section_instance_init (RygelMediaPrefSection * self,
                                        gpointer klass)
{
	self->priv = rygel_media_pref_section_get_instance_private (self);
}

static void
rygel_media_pref_section_finalize (GObject * obj)
{
	RygelMediaPrefSection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_MEDIA_PREF_SECTION, RygelMediaPrefSection);
	_g_object_unref0 (self->priv->widgets);
	_g_object_unref0 (self->priv->treeview);
	_g_object_unref0 (self->priv->liststore);
	_g_object_unref0 (self->priv->tree_selection);
	_g_object_unref0 (self->priv->dialog);
	_g_object_unref0 (self->priv->remove_button);
	G_OBJECT_CLASS (rygel_media_pref_section_parent_class)->finalize (obj);
}

static GType
rygel_media_pref_section_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelMediaPrefSectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_pref_section_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaPrefSection), 0, (GInstanceInitFunc) rygel_media_pref_section_instance_init, NULL };
	GType rygel_media_pref_section_type_id;
	rygel_media_pref_section_type_id = g_type_register_static (RYGEL_TYPE_PREFERENCES_SECTION, "RygelMediaPrefSection", &g_define_type_info, 0);
	RygelMediaPrefSection_private_offset = g_type_add_instance_private (rygel_media_pref_section_type_id, sizeof (RygelMediaPrefSectionPrivate));
	return rygel_media_pref_section_type_id;
}

GType
rygel_media_pref_section_get_type (void)
{
	static volatile gsize rygel_media_pref_section_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_pref_section_type_id__once)) {
		GType rygel_media_pref_section_type_id;
		rygel_media_pref_section_type_id = rygel_media_pref_section_get_type_once ();
		g_once_init_leave (&rygel_media_pref_section_type_id__once, rygel_media_pref_section_type_id);
	}
	return rygel_media_pref_section_type_id__once;
}

