/* rygel-preferences-dialog.c generated by valac 0.40.8, the Vala compiler
 * generated from rygel-preferences-dialog.vala, do not modify */

/*
 * Copyright (C) 2009 Nokia Corporation.
 * Copyright (C) 2012 Openismus GmbH.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
 *                               <zeeshan.ali@nokia.com>
 *         Jens Georg <jensg@openismus.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.h>
#include <glib-object.h>
#include <rygel-core.h>
#include <gtk/gtk.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <config.h>
#include <gdk/gdk.h>
#include <locale.h>
#include <glib/gi18n-lib.h>


#define RYGEL_TYPE_PREFERENCES_DIALOG (rygel_preferences_dialog_get_type ())
#define RYGEL_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_PREFERENCES_DIALOG, RygelPreferencesDialog))
#define RYGEL_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_PREFERENCES_DIALOG, RygelPreferencesDialogClass))
#define RYGEL_IS_PREFERENCES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_PREFERENCES_DIALOG))
#define RYGEL_IS_PREFERENCES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_PREFERENCES_DIALOG))
#define RYGEL_PREFERENCES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_PREFERENCES_DIALOG, RygelPreferencesDialogClass))

typedef struct _RygelPreferencesDialog RygelPreferencesDialog;
typedef struct _RygelPreferencesDialogClass RygelPreferencesDialogClass;
typedef struct _RygelPreferencesDialogPrivate RygelPreferencesDialogPrivate;

#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_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;
enum  {
	RYGEL_PREFERENCES_DIALOG_0_PROPERTY,
	RYGEL_PREFERENCES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* rygel_preferences_dialog_properties[RYGEL_PREFERENCES_DIALOG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))

#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;

#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;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_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 _RygelPreferencesDialog {
	GObject parent_instance;
	RygelPreferencesDialogPrivate * priv;
};

struct _RygelPreferencesDialogClass {
	GObjectClass parent_class;
};

struct _RygelPreferencesDialogPrivate {
	RygelWritableUserConfig* config;
	GtkBuilder* builder;
	GtkWindow* dialog;
	GtkSwitch* upnp_check;
	GeeArrayList* sections;
	GMainLoop* loop;
};


static gpointer rygel_preferences_dialog_parent_class = NULL;

GType rygel_preferences_dialog_get_type (void) G_GNUC_CONST;
GType rygel_writable_user_config_get_type (void) G_GNUC_CONST;
GType rygel_preferences_section_get_type (void) G_GNUC_CONST;
#define RYGEL_PREFERENCES_DIALOG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_PREFERENCES_DIALOG, RygelPreferencesDialogPrivate))
#define RYGEL_PREFERENCES_DIALOG_UI_FILE DATA_DIR "/rygel-preferences.ui"
#define RYGEL_PREFERENCES_DIALOG_DIALOG "preferences-dialog"
#define RYGEL_PREFERENCES_DIALOG_ICON SMALL_ICON_DIR "/rygel.png"
#define RYGEL_PREFERENCES_DIALOG_UPNP_CHECKBUTTON "upnp-checkbutton"
#define RYGEL_PREFERENCES_DIALOG_CLOSE_BUTTON "close-button"
RygelPreferencesDialog* rygel_preferences_dialog_new (GError** error);
RygelPreferencesDialog* rygel_preferences_dialog_construct (GType object_type,
                                                            GError** error);
RygelWritableUserConfig* rygel_writable_user_config_new (GError** error);
RygelWritableUserConfig* rygel_writable_user_config_construct (GType object_type,
                                                               GError** error);
gboolean rygel_writable_user_config_is_upnp_enabled (RygelWritableUserConfig* self);
GType rygel_network_pref_section_get_type (void) G_GNUC_CONST;
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);
RygelMediaPrefSection* rygel_media_pref_section_new (GtkBuilder* builder,
                                                     RygelWritableUserConfig* config);
RygelMediaPrefSection* rygel_media_pref_section_construct (GType object_type,
                                                           GtkBuilder* builder,
                                                           RygelWritableUserConfig* config);
GType rygel_media_pref_section_get_type (void) G_GNUC_CONST;
static void rygel_preferences_dialog_on_upnp_switch_toggled (RygelPreferencesDialog* self);
static void __lambda8_ (RygelPreferencesDialog* self);
static void ___lambda8__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static gboolean __lambda9_ (RygelPreferencesDialog* self);
static gboolean ___lambda9__gtk_widget_delete_event (GtkWidget* _sender,
                                              GdkEventAny* event,
                                              gpointer self);
static void __lambda10_ (RygelPreferencesDialog* self);
static void ___lambda10__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
void rygel_preferences_dialog_run (RygelPreferencesDialog* self);
void rygel_writable_user_config_set_upnp_enabled (RygelWritableUserConfig* self,
                                                  gboolean value);
void rygel_preferences_section_save (RygelPreferencesSection* self);
void rygel_writable_user_config_save (RygelWritableUserConfig* self);
gint rygel_preferences_dialog_main (gchar** args,
                                    int args_length1);
void rygel_preferences_section_set_sensitivity (RygelPreferencesSection* self,
                                                gboolean sensitivity);
static void rygel_preferences_dialog_finalize (GObject * obj);


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


static void
__lambda8_ (RygelPreferencesDialog* self)
{
	rygel_preferences_dialog_on_upnp_switch_toggled (self);
}


static void
___lambda8__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda8_ ((RygelPreferencesDialog*) self);
}


static gboolean
__lambda9_ (RygelPreferencesDialog* self)
{
	gboolean result = FALSE;
	GtkWindow* _tmp0_;
	GMainLoop* _tmp1_;
	_tmp0_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->loop;
	g_main_loop_quit (_tmp1_);
	result = TRUE;
	return result;
}


static gboolean
___lambda9__gtk_widget_delete_event (GtkWidget* _sender,
                                     GdkEventAny* event,
                                     gpointer self)
{
	gboolean result;
	result = __lambda9_ ((RygelPreferencesDialog*) self);
	return result;
}


static void
__lambda10_ (RygelPreferencesDialog* self)
{
	GtkWindow* _tmp0_;
	GMainLoop* _tmp1_;
	_tmp0_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp0_);
	_tmp1_ = self->priv->loop;
	g_main_loop_quit (_tmp1_);
}


static void
___lambda10__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda10_ ((RygelPreferencesDialog*) self);
}


RygelPreferencesDialog*
rygel_preferences_dialog_construct (GType object_type,
                                    GError** error)
{
	RygelPreferencesDialog * self = NULL;
	RygelWritableUserConfig* _tmp0_ = NULL;
	RygelWritableUserConfig* _tmp1_;
	RygelWritableUserConfig* _tmp2_;
	GtkBuilder* _tmp3_;
	GtkBuilder* _tmp4_;
	GtkBuilder* _tmp5_;
	GObject* _tmp6_;
	GtkWindow* _tmp7_;
	GtkWindow* _tmp8_;
	GtkBuilder* _tmp9_;
	GObject* _tmp10_;
	GtkSwitch* _tmp11_;
	GtkSwitch* _tmp12_;
	GtkWindow* _tmp13_;
	GtkSwitch* _tmp14_;
	RygelWritableUserConfig* _tmp15_;
	GeeArrayList* _tmp16_;
	RygelNetworkPrefSection* _tmp17_ = NULL;
	GtkBuilder* _tmp18_;
	RygelWritableUserConfig* _tmp19_;
	RygelNetworkPrefSection* _tmp20_;
	GeeArrayList* _tmp21_;
	GeeArrayList* _tmp22_;
	GtkBuilder* _tmp23_;
	RygelWritableUserConfig* _tmp24_;
	RygelMediaPrefSection* _tmp25_;
	RygelMediaPrefSection* _tmp26_;
	GtkSwitch* _tmp27_;
	GtkWindow* _tmp28_;
	GtkBuilder* _tmp29_;
	GObject* _tmp30_;
	GError * _inner_error_ = NULL;
	self = (RygelPreferencesDialog*) g_object_new (object_type, NULL);
	_tmp1_ = rygel_writable_user_config_new (&_inner_error_);
	_tmp0_ = _tmp1_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp2_ = _tmp0_;
	_tmp0_ = NULL;
	_g_object_unref0 (self->priv->config);
	self->priv->config = _tmp2_;
	_tmp3_ = gtk_builder_new ();
	_g_object_unref0 (self->priv->builder);
	self->priv->builder = _tmp3_;
	_tmp4_ = self->priv->builder;
	gtk_builder_add_from_file (_tmp4_, RYGEL_PREFERENCES_DIALOG_UI_FILE, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp5_ = self->priv->builder;
	_tmp6_ = gtk_builder_get_object (_tmp5_, RYGEL_PREFERENCES_DIALOG_DIALOG);
	_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_window_get_type (), GtkWindow));
	_g_object_unref0 (self->priv->dialog);
	self->priv->dialog = _tmp7_;
	_tmp8_ = self->priv->dialog;
	_vala_assert (_tmp8_ != NULL, "this.dialog != null");
	_tmp9_ = self->priv->builder;
	_tmp10_ = gtk_builder_get_object (_tmp9_, RYGEL_PREFERENCES_DIALOG_UPNP_CHECKBUTTON);
	_tmp11_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_switch_get_type (), GtkSwitch));
	_g_object_unref0 (self->priv->upnp_check);
	self->priv->upnp_check = _tmp11_;
	_tmp12_ = self->priv->upnp_check;
	_vala_assert (_tmp12_ != NULL, "this.upnp_check != null");
	_tmp13_ = self->priv->dialog;
	gtk_window_set_icon_from_file (_tmp13_, RYGEL_PREFERENCES_DIALOG_ICON, &_inner_error_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp14_ = self->priv->upnp_check;
	_tmp15_ = self->priv->config;
	gtk_switch_set_active (_tmp14_, rygel_writable_user_config_is_upnp_enabled (_tmp15_));
	_tmp16_ = gee_array_list_new (RYGEL_TYPE_PREFERENCES_SECTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->sections);
	self->priv->sections = _tmp16_;
	_tmp18_ = self->priv->builder;
	_tmp19_ = self->priv->config;
	_tmp20_ = rygel_network_pref_section_new (_tmp18_, _tmp19_, &_inner_error_);
	_tmp17_ = _tmp20_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp21_ = self->priv->sections;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp21_, (RygelPreferencesSection*) _tmp17_);
	_tmp22_ = self->priv->sections;
	_tmp23_ = self->priv->builder;
	_tmp24_ = self->priv->config;
	_tmp25_ = rygel_media_pref_section_new (_tmp23_, _tmp24_);
	_tmp26_ = _tmp25_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp22_, (RygelPreferencesSection*) _tmp26_);
	_g_object_unref0 (_tmp26_);
	rygel_preferences_dialog_on_upnp_switch_toggled (self);
	_tmp27_ = self->priv->upnp_check;
	g_signal_connect_object ((GObject*) _tmp27_, "notify::active", (GCallback) ___lambda8__g_object_notify, self, 0);
	_tmp28_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp28_, "delete-event", (GCallback) ___lambda9__gtk_widget_delete_event, self, 0);
	_tmp29_ = self->priv->builder;
	_tmp30_ = gtk_builder_get_object (_tmp29_, RYGEL_PREFERENCES_DIALOG_CLOSE_BUTTON);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_TYPE (_tmp30_, gtk_button_get_type ()) ? ((GtkButton*) _tmp30_) : NULL, "clicked", (GCallback) ___lambda10__gtk_button_clicked, self, 0);
	_g_object_unref0 (_tmp17_);
	_g_object_unref0 (_tmp0_);
	return self;
}


RygelPreferencesDialog*
rygel_preferences_dialog_new (GError** error)
{
	return rygel_preferences_dialog_construct (RYGEL_TYPE_PREFERENCES_DIALOG, error);
}


void
rygel_preferences_dialog_run (RygelPreferencesDialog* self)
{
	GtkWindow* _tmp0_;
	GMainLoop* _tmp1_;
	GMainLoop* _tmp2_;
	GtkWindow* _tmp3_;
	RygelWritableUserConfig* _tmp4_;
	GtkSwitch* _tmp5_;
	gboolean _tmp6_;
	gboolean _tmp7_;
	RygelWritableUserConfig* _tmp20_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->dialog;
	gtk_widget_show ((GtkWidget*) _tmp0_);
	_tmp1_ = g_main_loop_new (NULL, FALSE);
	_g_main_loop_unref0 (self->priv->loop);
	self->priv->loop = _tmp1_;
	_tmp2_ = self->priv->loop;
	g_main_loop_run (_tmp2_);
	_tmp3_ = self->priv->dialog;
	gtk_widget_hide ((GtkWidget*) _tmp3_);
	_tmp4_ = self->priv->config;
	_tmp5_ = self->priv->upnp_check;
	_tmp6_ = gtk_switch_get_active (_tmp5_);
	_tmp7_ = _tmp6_;
	rygel_writable_user_config_set_upnp_enabled (_tmp4_, _tmp7_);
	{
		GeeArrayList* _section_list = NULL;
		GeeArrayList* _tmp8_;
		GeeArrayList* _tmp9_;
		gint _section_size = 0;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		gint _section_index = 0;
		_tmp8_ = self->priv->sections;
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_section_list = _tmp9_;
		_tmp10_ = _section_list;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_section_size = _tmp12_;
		_section_index = -1;
		while (TRUE) {
			gint _tmp13_;
			gint _tmp14_;
			gint _tmp15_;
			RygelPreferencesSection* section = NULL;
			GeeArrayList* _tmp16_;
			gint _tmp17_;
			gpointer _tmp18_;
			RygelPreferencesSection* _tmp19_;
			_tmp13_ = _section_index;
			_section_index = _tmp13_ + 1;
			_tmp14_ = _section_index;
			_tmp15_ = _section_size;
			if (!(_tmp14_ < _tmp15_)) {
				break;
			}
			_tmp16_ = _section_list;
			_tmp17_ = _section_index;
			_tmp18_ = gee_abstract_list_get ((GeeAbstractList*) _tmp16_, _tmp17_);
			section = (RygelPreferencesSection*) _tmp18_;
			_tmp19_ = section;
			rygel_preferences_section_save (_tmp19_);
			_g_object_unref0 (section);
		}
		_g_object_unref0 (_section_list);
	}
	_tmp20_ = self->priv->config;
	rygel_writable_user_config_save (_tmp20_);
}


gint
rygel_preferences_dialog_main (gchar** args,
                               int args_length1)
{
	gint result = 0;
	GError * _inner_error_ = NULL;
	setlocale (LC_ALL, "");
	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
	gtk_init (&args_length1, &args);
	{
		RygelUserConfig* _tmp0_ = NULL;
		RygelUserConfig* _tmp1_;
		RygelPreferencesDialog* dialog = NULL;
		RygelPreferencesDialog* _tmp2_;
		RygelPreferencesDialog* _tmp3_;
		_tmp1_ = rygel_user_config_get_default (&_inner_error_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch0_g_error;
		}
		rygel_meta_config_register_configuration ((RygelConfiguration*) _tmp0_);
		_tmp2_ = rygel_preferences_dialog_new (&_inner_error_);
		dialog = _tmp2_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (_tmp0_);
			goto __catch0_g_error;
		}
		_tmp3_ = dialog;
		rygel_preferences_dialog_run (_tmp3_);
		_g_object_unref0 (dialog);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		const gchar* _tmp4_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = err->message;
		g_error (_ ("Failed to create preferences dialog: %s"), _tmp4_);
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		gint _tmp5_ = -1;
		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 _tmp5_;
	}
	result = 0;
	return result;
}


int
main (int argc,
      char ** argv)
{
	return rygel_preferences_dialog_main (argv, argc);
}


static void
rygel_preferences_dialog_on_upnp_switch_toggled (RygelPreferencesDialog* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeArrayList* _section_list = NULL;
		GeeArrayList* _tmp0_;
		GeeArrayList* _tmp1_;
		gint _section_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _section_index = 0;
		_tmp0_ = self->priv->sections;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		_section_list = _tmp1_;
		_tmp2_ = _section_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_section_size = _tmp4_;
		_section_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			RygelPreferencesSection* section = NULL;
			GeeArrayList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_;
			RygelPreferencesSection* _tmp11_;
			GtkSwitch* _tmp12_;
			gboolean _tmp13_;
			gboolean _tmp14_;
			_tmp5_ = _section_index;
			_section_index = _tmp5_ + 1;
			_tmp6_ = _section_index;
			_tmp7_ = _section_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _section_list;
			_tmp9_ = _section_index;
			_tmp10_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _tmp9_);
			section = (RygelPreferencesSection*) _tmp10_;
			_tmp11_ = section;
			_tmp12_ = self->priv->upnp_check;
			_tmp13_ = gtk_switch_get_active (_tmp12_);
			_tmp14_ = _tmp13_;
			rygel_preferences_section_set_sensitivity (_tmp11_, _tmp14_);
			_g_object_unref0 (section);
		}
		_g_object_unref0 (_section_list);
	}
}


static void
rygel_preferences_dialog_class_init (RygelPreferencesDialogClass * klass)
{
	rygel_preferences_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelPreferencesDialogPrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_preferences_dialog_finalize;
}


static void
rygel_preferences_dialog_instance_init (RygelPreferencesDialog * self)
{
	self->priv = RYGEL_PREFERENCES_DIALOG_GET_PRIVATE (self);
}


static void
rygel_preferences_dialog_finalize (GObject * obj)
{
	RygelPreferencesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_PREFERENCES_DIALOG, RygelPreferencesDialog);
	_g_object_unref0 (self->priv->config);
	_g_object_unref0 (self->priv->builder);
	_g_object_unref0 (self->priv->dialog);
	_g_object_unref0 (self->priv->upnp_check);
	_g_object_unref0 (self->priv->sections);
	_g_main_loop_unref0 (self->priv->loop);
	G_OBJECT_CLASS (rygel_preferences_dialog_parent_class)->finalize (obj);
}


GType
rygel_preferences_dialog_get_type (void)
{
	static volatile gsize rygel_preferences_dialog_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_preferences_dialog_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelPreferencesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_preferences_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelPreferencesDialog), 0, (GInstanceInitFunc) rygel_preferences_dialog_instance_init, NULL };
		GType rygel_preferences_dialog_type_id;
		rygel_preferences_dialog_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelPreferencesDialog", &g_define_type_info, 0);
		g_once_init_leave (&rygel_preferences_dialog_type_id__volatile, rygel_preferences_dialog_type_id);
	}
	return rygel_preferences_dialog_type_id__volatile;
}



