last-exit r173 - in trunk: . gnome-keyring-sharp src



Author: bhale
Date: Mon Mar 31 23:21:36 2008
New Revision: 173
URL: http://svn.gnome.org/viewvc/last-exit?rev=173&view=rev

Log:

        Two patches from Jordan.
        Refactor Config.cs, bug #108296.
        Build gnome-keyring-sharp with WITH_DBUS, bug #517070.



Modified:
   trunk/ChangeLog
   trunk/gnome-keyring-sharp/Makefile.am
   trunk/src/Config.cs

Modified: trunk/gnome-keyring-sharp/Makefile.am
==============================================================================
--- trunk/gnome-keyring-sharp/Makefile.am	(original)
+++ trunk/gnome-keyring-sharp/Makefile.am	Mon Mar 31 23:21:36 2008
@@ -1,6 +1,15 @@
 GKS_ASSEMBLY = Gnome.Keyring.dll
 
 GKS_SRC = $(srcdir)/Gnome.Keyring/*.cs
+DIR_DBUS =  $(top_builddir)/dbus-sharp
+
+if EXTERNAL_DBUS
+DBUS_ASSEMBLIES = $(DBUS_LIBS)
+else
+DBUS_ASSEMBLIES = 				\
+	-r:$(DIR_DBUS)/NDesk.DBus.dll		\
+	-r:$(DIR_DBUS)/NDesk.DBus.GLib.dll
+endif
 
 if !EXTERNAL_GKS
 gksdir = $(pkglibdir)
@@ -10,7 +19,7 @@
 all: $(GKS_ASSEMBLY)
 
 $(GKS_ASSEMBLY): $(GKS_SRC)
-	$(MCS) -target:library -out:$@ -unsafe -r:Mono.Posix $(GKS_SRC)
+	$(MCS) -target:library -out:$@ -unsafe -r:Mono.Posix -d:WITH_DBUS $(DBUS_ASSEMBLIES) $(GKS_SRC)
 
 endif
 

Modified: trunk/src/Config.cs
==============================================================================
--- trunk/src/Config.cs	(original)
+++ trunk/src/Config.cs	Mon Mar 31 23:21:36 2008
@@ -41,39 +41,35 @@
 		
 		private string ring;
 
+		private object try_with_default (string key, object fallback)
+		{
+			object o;
+			// Check it exists, then a default if not
+			try {
+				o = config.Get (key);
+			} catch (GConf.NoSuchKeyException) {
+				config.Set (key, fallback);
+				return fallback;
+			}
+			if (o == null) {
+				return fallback;
+			} else {
+				return o;
+			}
+		}
+
 		public bool FirstRun {
-			get { 
-				object o;
-				// Check it exists, then a default if not
-				try {
-					o = config.Get (GConfFirstRun);
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfFirstRun, 
-						    (object) true);
-					return true;
-				}
-
-				if (o == null) {
-					return true;
-				} else {
-					return (bool) o;
-				}
+			get {
+				return (bool) try_with_default (GConfFirstRun,
+								(object) true);
 			}
 			set { config.Set (GConfFirstRun, (object) value); }
 		}
 
 		public string Username {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfUsername);
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfUsername, 
-						    (object) "username");
-					return "username";
-				}
-
-				return (string) o; 
+			get {
+				return (string) try_with_default (GConfUsername,
+								  (object) "username");
 			}
 			set { config.Set (GConfUsername, (object) value); }
 		}
@@ -92,106 +88,49 @@
 		}
 		
 		private string OldPassword {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfPassword);
-				} catch (GConf.NoSuchKeyException) {
-					return String.Empty;
-				}
-
-				return (string) o;
+			get {
+				return (string) try_with_default (GConfPassword,
+								  (object) String.Empty);
 			}
 			set { config.Set (GConfPassword, (object) value); }
 		}
 
 		public int Volume {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfVolume); 
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfVolume, (object) 50);
-					return 50;
-				}
-
-				return (int) o;
+			get {
+				return (int) try_with_default (GConfVolume,
+								(object) 50);
 			}
 			set { config.Set (GConfVolume, (object) value); }
 		}
 
 		public int RecommendationLevel {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfRecommendationLevel); 
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfRecommendationLevel, (object) 100);
-					return 100;
-				}
-
-				return (int) o;
+			get {
+				return (int) try_with_default (GConfRecommendationLevel,
+								(object) 100);
 			}
 			set { config.Set (GConfRecommendationLevel, (object) value); }
 		}
 
 		public bool ShowNotifications {
-			get { 
-				object o;
-				// Check it exists, then a default if not
-				try {
-					o = config.Get (GConfShowNotifications);
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfShowNotifications, 
-						    (object) true);
-					return true;
-				}
-
-				if (o == null) {
-					return true;
-				} else {
-					return (bool) o;
-				}
+			get {
+				return (bool) try_with_default (GConfShowNotifications,
+								(object) true);
 			}
             set { config.Set (GConfShowNotifications, (object) value); }
 		}
 
 		public bool ShowProgress {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfShowProgress);
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfShowProgress, 
-						    (object) false);
-					return false;
-				}
-
-				if (o == null) {
-					return false;
-				} else {
-					return (bool) o;
-				}
+			get {
+				return (bool) try_with_default (GConfShowProgress,
+								(object) false);
 			}
             		set { config.Set (GConfShowProgress, (object) value); }
 		}
 
 		public bool ShowDuration {
-			get { 
-				object o;
-				try {
-					o = config.Get (GConfShowDuration);
-				} catch (GConf.NoSuchKeyException) {
-					config.Set (GConfShowDuration,
-						    (object) false);
-					return false;
-				}
-
-				if (o == null) {
-					return false;
-				} else {
-					return (bool) o;
-				}
+			get {
+				return (bool) try_with_default (GConfShowDuration,
+								(object) false);
 			}
             		set { config.Set (GConfShowDuration, (object) value); }
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]