/* rygel-preferences-dialog.c generated by valac 0.30.0, 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 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 <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>
#include <rygel-core.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_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_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;
#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_user_config_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))
enum  {
	RYGEL_PREFERENCES_DIALOG_DUMMY_PROPERTY
};
#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);
RygelUserConfig* rygel_user_config_get_default (GError** error);
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_ = NULL;
	GMainLoop* _tmp1_ = NULL;
	_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_ = NULL;
	GMainLoop* _tmp1_ = NULL;
	_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_ = NULL;
	RygelWritableUserConfig* _tmp2_ = NULL;
	GtkBuilder* _tmp3_ = NULL;
	GtkBuilder* _tmp4_ = NULL;
	GtkBuilder* _tmp5_ = NULL;
	GObject* _tmp6_ = NULL;
	GtkWindow* _tmp7_ = NULL;
	GtkWindow* _tmp8_ = NULL;
	GtkBuilder* _tmp9_ = NULL;
	GObject* _tmp10_ = NULL;
	GtkSwitch* _tmp11_ = NULL;
	GtkSwitch* _tmp12_ = NULL;
	GtkWindow* _tmp13_ = NULL;
	GtkSwitch* _tmp14_ = NULL;
	RygelWritableUserConfig* _tmp15_ = NULL;
	gboolean _tmp16_ = FALSE;
	GeeArrayList* _tmp17_ = NULL;
	RygelNetworkPrefSection* _tmp18_ = NULL;
	GtkBuilder* _tmp19_ = NULL;
	RygelWritableUserConfig* _tmp20_ = NULL;
	RygelNetworkPrefSection* _tmp21_ = NULL;
	GeeArrayList* _tmp22_ = NULL;
	GeeArrayList* _tmp23_ = NULL;
	GtkBuilder* _tmp24_ = NULL;
	RygelWritableUserConfig* _tmp25_ = NULL;
	RygelMediaPrefSection* _tmp26_ = NULL;
	RygelMediaPrefSection* _tmp27_ = NULL;
	GtkSwitch* _tmp28_ = NULL;
	GtkWindow* _tmp29_ = NULL;
	GtkBuilder* _tmp30_ = NULL;
	GObject* _tmp31_ = NULL;
	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;
	_tmp16_ = rygel_writable_user_config_is_upnp_enabled (_tmp15_);
	gtk_switch_set_active (_tmp14_, _tmp16_);
	_tmp17_ = gee_array_list_new (RYGEL_TYPE_PREFERENCES_SECTION, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->sections);
	self->priv->sections = _tmp17_;
	_tmp19_ = self->priv->builder;
	_tmp20_ = self->priv->config;
	_tmp21_ = rygel_network_pref_section_new (_tmp19_, _tmp20_, &_inner_error_);
	_tmp18_ = _tmp21_;
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (_tmp0_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp22_ = self->priv->sections;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp22_, (RygelPreferencesSection*) _tmp18_);
	_tmp23_ = self->priv->sections;
	_tmp24_ = self->priv->builder;
	_tmp25_ = self->priv->config;
	_tmp26_ = rygel_media_pref_section_new (_tmp24_, _tmp25_);
	_tmp27_ = _tmp26_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp23_, (RygelPreferencesSection*) _tmp27_);
	_g_object_unref0 (_tmp27_);
	rygel_preferences_dialog_on_upnp_switch_toggled (self);
	_tmp28_ = self->priv->upnp_check;
	g_signal_connect_object ((GObject*) _tmp28_, "notify::active", (GCallback) ___lambda8__g_object_notify, self, 0);
	_tmp29_ = self->priv->dialog;
	g_signal_connect_object ((GtkWidget*) _tmp29_, "delete-event", (GCallback) ___lambda9__gtk_widget_delete_event, self, 0);
	_tmp30_ = self->priv->builder;
	_tmp31_ = gtk_builder_get_object (_tmp30_, RYGEL_PREFERENCES_DIALOG_CLOSE_BUTTON);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_TYPE (_tmp31_, gtk_button_get_type ()) ? ((GtkButton*) _tmp31_) : NULL, "clicked", (GCallback) ___lambda10__gtk_button_clicked, self, 0);
	_g_object_unref0 (_tmp18_);
	_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_ = NULL;
	GMainLoop* _tmp1_ = NULL;
	GMainLoop* _tmp2_ = NULL;
	GtkWindow* _tmp3_ = NULL;
	RygelWritableUserConfig* _tmp4_ = NULL;
	GtkSwitch* _tmp5_ = NULL;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	RygelWritableUserConfig* _tmp20_ = NULL;
	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_ = NULL;
		GeeArrayList* _tmp9_ = NULL;
		gint _section_size = 0;
		GeeArrayList* _tmp10_ = NULL;
		gint _tmp11_ = 0;
		gint _tmp12_ = 0;
		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 ((GeeCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_section_size = _tmp12_;
		_section_index = -1;
		while (TRUE) {
			gint _tmp13_ = 0;
			gint _tmp14_ = 0;
			gint _tmp15_ = 0;
			RygelPreferencesSection* section = NULL;
			GeeArrayList* _tmp16_ = NULL;
			gint _tmp17_ = 0;
			gpointer _tmp18_ = NULL;
			RygelPreferencesSection* _tmp19_ = NULL;
			_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_ = NULL;
		RygelPreferencesDialog* dialog = NULL;
		RygelPreferencesDialog* _tmp2_ = NULL;
		RygelPreferencesDialog* _tmp3_ = NULL;
		_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_ = NULL;
		const gchar* _tmp5_ = NULL;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = _ ("Failed to create preferences dialog: %s");
		_tmp5_ = err->message;
		g_error (_tmp4_, _tmp5_);
		_g_error_free0 (err);
	}
	__finally0:
	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 0;
	}
	result = 0;
	return result;
}


int main (int argc, char ** argv) {
#if !GLIB_CHECK_VERSION (2,35,0)
	g_type_init ();
#endif
	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_ = NULL;
		GeeArrayList* _tmp1_ = NULL;
		gint _section_size = 0;
		GeeArrayList* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		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 ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_section_size = _tmp4_;
		_section_index = -1;
		while (TRUE) {
			gint _tmp5_ = 0;
			gint _tmp6_ = 0;
			gint _tmp7_ = 0;
			RygelPreferencesSection* section = NULL;
			GeeArrayList* _tmp8_ = NULL;
			gint _tmp9_ = 0;
			gpointer _tmp10_ = NULL;
			RygelPreferencesSection* _tmp11_ = NULL;
			GtkSwitch* _tmp12_ = NULL;
			gboolean _tmp13_ = FALSE;
			gboolean _tmp14_ = FALSE;
			_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;
}



