/* rygel-media-pref-section.c generated by valac 0.28.0.2-022b, 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 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 <gee.h>
#include <gtk/gtk.h>
#include <rygel-core.h>
#include <gio/gio.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_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;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (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 __g_slist_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_slist_free__g_object_unref0_ (var), NULL)))
#define _gtk_tree_row_reference_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_row_reference_free (var), NULL)))
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_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);
#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 gpointer rygel_media_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_media_pref_section_get_type (void) G_GNUC_CONST;
#define RYGEL_MEDIA_PREF_SECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_MEDIA_PREF_SECTION, RygelMediaPrefSectionPrivate))
enum  {
	RYGEL_MEDIA_PREF_SECTION_DUMMY_PROPERTY
};
#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"
RygelMediaPrefSection* rygel_media_pref_section_new (GtkBuilder* builder, RygelWritableUserConfig* config);
RygelMediaPrefSection* rygel_media_pref_section_construct (GType object_type, GtkBuilder* builder, RygelWritableUserConfig* config);
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);
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 void _g_slist_free__g_object_unref0_ (GSList* self);
static void _gtk_tree_path_free0_ (gpointer var);
static void _g_list_free__gtk_tree_path_free0_ (GList* self);
static void rygel_media_pref_section_finalize (GObject* obj);


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


static void rygel_media_pref_section_real_set_sensitivity (RygelPreferencesSection* base, gboolean sensitivity) {
	RygelMediaPrefSection * self;
	gboolean _tmp13_ = FALSE;
	self = (RygelMediaPrefSection*) base;
	{
		GeeArrayList* _widget_list = NULL;
		GeeArrayList* _tmp0_ = NULL;
		GeeArrayList* _tmp1_ = NULL;
		gint _widget_size = 0;
		GeeArrayList* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		gint _widget_index = 0;
		_tmp0_ = self->priv->widgets;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_widget_list = _tmp1_;
		_tmp2_ = _widget_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_widget_size = _tmp4_;
		_widget_index = -1;
		while (TRUE) {
			gint _tmp5_ = 0;
			gint _tmp6_ = 0;
			gint _tmp7_ = 0;
			GtkWidget* widget = NULL;
			GeeArrayList* _tmp8_ = NULL;
			gint _tmp9_ = 0;
			gpointer _tmp10_ = NULL;
			GtkWidget* _tmp11_ = NULL;
			gboolean _tmp12_ = FALSE;
			_tmp5_ = _widget_index;
			_widget_index = _tmp5_ + 1;
			_tmp6_ = _widget_index;
			_tmp7_ = _widget_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _widget_list;
			_tmp9_ = _widget_index;
			_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _tmp9_);
			widget = (GtkWidget*) _tmp10_;
			_tmp11_ = widget;
			_tmp12_ = sensitivity;
			gtk_widget_set_sensitive (_tmp11_, _tmp12_);
			_g_object_unref0 (widget);
		}
		_g_object_unref0 (_widget_list);
	}
	_tmp13_ = sensitivity;
	if (_tmp13_) {
		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 void _g_slist_free__g_object_unref0_ (GSList* self) {
	g_slist_foreach (self, (GFunc) _g_object_unref0_, NULL);
	g_slist_free (self);
}


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


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_media_pref_section_on_remove_button_clicked (RygelMediaPrefSection* 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->liststore;
				_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->liststore;
			_tmp27_ = path;
			gtk_tree_model_get_iter ((GtkTreeModel*) _tmp26_, &_tmp28_, _tmp27_);
			iter = _tmp28_;
			_tmp29_ = self->priv->liststore;
			_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 gchar* rygel_media_pref_section_get_real_uri (RygelMediaPrefSection* self, const gchar* uri) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = uri;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("@MUSIC@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp4_ = NULL;
				gchar* _tmp5_ = NULL;
				_tmp4_ = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
				_tmp5_ = g_strdup (_tmp4_);
				result = _tmp5_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("@VIDEOS@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp6_ = NULL;
				gchar* _tmp7_ = NULL;
				_tmp6_ = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
				_tmp7_ = g_strdup (_tmp6_);
				result = _tmp7_;
				return result;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("@PICTURES@")))) {
		switch (0) {
			default:
			{
				const gchar* _tmp8_ = NULL;
				gchar* _tmp9_ = NULL;
				_tmp8_ = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
				_tmp9_ = g_strdup (_tmp8_);
				result = _tmp9_;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				const gchar* _tmp10_ = NULL;
				gchar* _tmp11_ = NULL;
				_tmp10_ = uri;
				_tmp11_ = g_strdup (_tmp10_);
				result = _tmp11_;
				return result;
			}
		}
	}
}


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


static void rygel_media_pref_section_on_tree_selection_changed (RygelMediaPrefSection* 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_media_pref_section_class_init (RygelMediaPrefSectionClass * klass) {
	rygel_media_pref_section_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelMediaPrefSectionPrivate));
	((RygelPreferencesSectionClass *) klass)->save = rygel_media_pref_section_real_save;
	((RygelPreferencesSectionClass *) klass)->set_sensitivity = 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) {
	self->priv = RYGEL_MEDIA_PREF_SECTION_GET_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);
}


GType rygel_media_pref_section_get_type (void) {
	static volatile gsize rygel_media_pref_section_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_pref_section_type_id__volatile)) {
		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);
		g_once_init_leave (&rygel_media_pref_section_type_id__volatile, rygel_media_pref_section_type_id);
	}
	return rygel_media_pref_section_type_id__volatile;
}



