[rygel] ui: Fix initial set-up
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] ui: Fix initial set-up
- Date: Sat, 28 Apr 2012 17:12:28 +0000 (UTC)
commit 4ab1d1f905f38b17cf162c6b34b763a40a292b4e
Author: Jens Georg <mail jensge org>
Date: Thu Apr 12 18:09:09 2012 +0200
ui: Fix initial set-up
For the UPnP enable/disable setting, check if we're using the global or
a local settings file. Otherwise the autostart file is never linked.
src/ui/rygel-preferences-dialog.vala | 4 +---
src/ui/rygel-writable-user-config.vala | 23 +++++++++++++++++++----
2 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/src/ui/rygel-preferences-dialog.vala b/src/ui/rygel-preferences-dialog.vala
index de01eae..6eb8bc0 100644
--- a/src/ui/rygel-preferences-dialog.vala
+++ b/src/ui/rygel-preferences-dialog.vala
@@ -52,9 +52,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
this.dialog.set_icon_from_file (ICON);
- try {
- this.upnp_check.active = this.config.get_upnp_enabled ();
- } catch (GLib.Error err) {}
+ this.upnp_check.active = this.config.is_upnp_enabled ();
this.sections = new ArrayList<PreferencesSection> ();
this.sections.add (new NetworkPrefSection (this.builder, this.config));
diff --git a/src/ui/rygel-writable-user-config.vala b/src/ui/rygel-writable-user-config.vala
index f6158d8..f0217f2 100644
--- a/src/ui/rygel-writable-user-config.vala
+++ b/src/ui/rygel-writable-user-config.vala
@@ -30,19 +30,34 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig {
private const string RYGEL_PATH = "/org/gnome/Rygel1";
private const string RYGEL_INTERFACE = "org.gnome.Rygel1";
+ private string user_config;
+
public WritableUserConfig () throws Error {
var path = Path.build_filename (Environment.get_user_config_dir (),
CONFIG_FILE);
base (path);
+
+ this.user_config = path;
+ }
+
+ public bool is_upnp_enabled () {
+ try {
+ var file = File.new_for_path (this.user_config);
+ if (file.query_exists ()) {
+ return this.get_upnp_enabled ();
+ }
+
+ return false;
+ } catch (Error error) {
+ return false;
+ }
}
public void set_upnp_enabled (bool value) {
bool enabled = false;
- try {
- enabled = this.get_upnp_enabled ();
- } catch (GLib.Error err) {}
+ enabled = this.is_upnp_enabled ();
if (value != enabled) {
this.enable_upnp (value);
@@ -177,7 +192,7 @@ public class Rygel.WritableUserConfig : Rygel.UserConfig {
this.set_bool ("general", UPNP_ENABLED_KEY, true);
} else {
// Stop service only if already running
- if (this.get_upnp_enabled ()) {
+ if (this.is_upnp_enabled ()) {
// Create proxy to Rygel
DBusInterface rygel_proxy = Bus.get_proxy_sync
(BusType.SESSION,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]