Author: mhabersack
Date: 2007-06-29 07:27:15 -0400 (Fri, 29 Jun 2007)
New Revision: 81036

Modified:
   trunk/moon/ChangeLog
   trunk/moon/desklet/desklets.cs
   trunk/moon/desklet/docs/index.xml
Log:
2007-06-29  Marek Habersack  <[EMAIL PROTECTED]>

        * desklet/desklets.cs: removed a field from ConfigStore which
        isn't needed (storageName).
        Added some docs.


Modified: trunk/moon/ChangeLog
===================================================================
--- trunk/moon/ChangeLog        2007-06-29 11:08:17 UTC (rev 81035)
+++ trunk/moon/ChangeLog        2007-06-29 11:27:15 UTC (rev 81036)
@@ -1,3 +1,9 @@
+2007-06-29  Marek Habersack  <[EMAIL PROTECTED]>
+
+       * desklet/desklets.cs: removed a field from ConfigStore which
+       isn't needed (storageName).
+       Added some docs.
+
 2007-06-29  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * tools/mopen.cs: Use a new drag-and-move system that make use of

Modified: trunk/moon/desklet/desklets.cs
===================================================================
--- trunk/moon/desklet/desklets.cs      2007-06-29 11:08:17 UTC (rev 81035)
+++ trunk/moon/desklet/desklets.cs      2007-06-29 11:27:15 UTC (rev 81036)
@@ -40,7 +40,6 @@
        {
                string deskletName;
                int deskletInstance;
-               string storageName;
                
                /// <summary>
                ///   Desklet name
@@ -64,16 +63,12 @@
                public int DeskletInstance {
                        get { return deskletInstance; }
                }
-
-               protected string StorageName {
-                       get { return storageName; }
-               }
                                
                protected ConfigStorage () : this (null, -1)
                {}
                
                /// <summary>
-               ///   Construct new storage class using the specified desklet 
name
+               ///   Construct new storage object using the specified desklet 
name
                /// </summary>
                /// <param name="deskletName">The desklet name</param>
                /// <remarks>
@@ -84,7 +79,7 @@
                {}
 
                /// <summary>
-               ///   Construct new storage class using the specified desklet 
name and instance number.
+               ///   Construct new storage object using the specified desklet 
name and instance number.
                /// </summary>
                /// <param name="deskletName">The desklet name</param>
                /// <param name="deskletInstance">The desklet instance 
number</param>
@@ -100,19 +95,19 @@
                {
                        this.deskletName = deskletName;
                        this.deskletInstance = deskletInstance;
-
-                       if (deskletInstance >= 0)
-                               storageName = String.Format ("{0}_{1}", 
deskletName, deskletInstance);
-                       else
-                               storageName = deskletName;
                }
 
-               protected void CheckValid ()
+               /// <summary>
+               ///   Check if the internal state of the storage object is valid
+               /// </summary>
+               /// <remarks>
+               ///   This method should be called at the start of every public 
method, to ensure
+               ///   that the object state is correct.
+               /// </remarks>
+               protected virtual void CheckValid ()
                {
                        if (String.IsNullOrEmpty (deskletName))
                                throw new ApplicationException ("DeskletName 
must not be empty");
-                       if (String.IsNullOrEmpty (storageName))
-                               throw new ApplicationException ("No storage 
name specified");
                }
                
                /// <summary>
@@ -166,6 +161,9 @@
                public abstract object RetrieveCommon (string name);            
        }
 
+       /// <summary>
+       ///   Config store implementation using the GNOME GConf backend
+       /// </summary>
        public class GConfConfigStorage : ConfigStorage {
                readonly string baseKeyPath = "/apps/mono/desklets";
                
@@ -174,6 +172,10 @@
                string keyPathCommon;
                string keyPathInstance;
 
+               /// <summary>
+               ///   GConf path to the common desklet storage area. This 
configuration area is shared
+               ///   among all the instances of the desklet.
+               /// </summary>
                public string KeyPathCommon {
                        get {
                                if (keyPathCommon == null)
@@ -183,6 +185,10 @@
                        }
                }
 
+               /// <summary>
+               ///   GConf path to the instance desklet storage area. This 
configuration area is private
+               ///   for each desklet instance.
+               /// </summary>
                public string KeyPathInstance {
                        get {
                                if (keyPathInstance == null)
@@ -196,15 +202,46 @@
                        }
                }
 
+               /// <summary>
+               ///   Construct new GConf storage object using the specified 
desklet name
+               /// </summary>
+               /// <param name="deskletName">The desklet name</param>
+               /// <remarks>
+               ///   You should make sure your desklet name is unique. It 
might be a good idea to
+               ///   use the common desklet name concatenated with a GUID (or 
UUID) value.
+               /// </remarks>
                public GConfConfigStorage (string deskletName) : this 
(deskletName, -1)
                {}
 
+               /// <summary>
+               ///   Construct new GConf storage object using the specified 
desklet name and instance number.
+               /// </summary>
+               /// <param name="deskletName">The desklet name</param>
+               /// <param name="deskletInstance">The desklet instance 
number</param>
+               /// <remarks>
+               ///   If your desklet can exist in several instances, and each 
of them might have a
+               ///   different configuration, you should use different 
instance number for each copy
+               ///   of the desklet, thus separating their configuration 
storage.
+               ///
+               ///   You should make sure your desklet name is unique. It 
might be a good idea to
+               ///   use the common desklet name concatenated with a GUID (or 
UUID) value.
+               /// </remarks>
                public GConfConfigStorage (string deskletName, int 
deskletInstance)
                        : base (deskletName, deskletInstance)
                {
                        client = new GConf.Client ();
                }
-               
+
+               /// <summary>
+               ///    Stores the named configuration item with the specified 
value.
+               /// </summary>
+               /// <param name="name">Item name</param>
+               /// <param name="value">Item value</param>
+               /// <remarks>
+               ///   This method will store the item in the desklet instance 
config
+               ///   storage area. GConf path 
/apps/mono/desklets/DESKLET_NAME/DESKLET_INSTANCE_NUMBER is
+               ///   used as the storage base.
+               /// </remarks>
                public override void Store (string name, object value)
                {
                        CheckValid ();
@@ -212,14 +249,36 @@
                        string key = String.Format ("{0}/{1}", KeyPathInstance, 
name);
                        client.Set (key, value);
                }
-               
+
+               /// <summary>
+               ///    Stores the named configuration item with the specified 
value.
+               /// </summary>
+               /// <param name="name">Item name</param>
+               /// <param name="value">Item value</param>
+               /// <remarks>
+               ///   This method will store the item in the desklet common 
config
+               ///   storage area. GConf path 
/apps/mono/desklets/DESKLET_NAME/ is
+               ///   used as the storage base.
+               /// </remarks>
                public override void StoreCommon (string name, object value)
                {
                        string key = String.Format ("{0}/{1}", KeyPathCommon, 
name);
                        client.Set (key, value);
                        CheckValid ();
                }
-               
+
+               /// <summary>
+               ///    Retrieves the named configuration item from the storage 
media.
+               /// </summary>
+               /// <param name="name">Item name</param>
+               /// <remarks>
+               ///    This method retrieves the item from the desklet instance 
config
+               ///    storage area. GConf path 
/apps/mono/desklets/DESKLET_NAME/DESKLET_INSTANCE_NUMBER is
+               ///    used as the storage base.
+               /// </remarks>
+               /// <returns>
+               ///   The requested item's value or null if not found
+               /// </returns>
                public override object Retrieve (string name)
                {
                        CheckValid ();
@@ -234,7 +293,19 @@
                        
                        return ret;
                }
-               
+
+               /// <summary>
+               ///    Retrieves the named configuration item from the storage 
media.
+               /// </summary>
+               /// <param name="name">Item name</param>
+               /// <remarks>
+               ///    This method retrieves the item from the desklet common 
config
+               ///    storage area. GConf path 
/apps/mono/desklets/DESKLET_NAME/ is
+               ///   used as the storage base.
+               /// </remarks>
+               /// <returns>
+               ///   The requested item's value or null if not found
+               /// </returns>
                public override object RetrieveCommon (string name)
                {
                        CheckValid ();

Modified: trunk/moon/desklet/docs/index.xml
===================================================================
--- trunk/moon/desklet/docs/index.xml   2007-06-29 11:08:17 UTC (rev 81035)
+++ trunk/moon/desklet/docs/index.xml   2007-06-29 11:27:15 UTC (rev 81036)
@@ -15,7 +15,7 @@
     <Namespace Name="Mono.Desklets">
       <Type Name="ConfigStorage" />
       <Type Name="Desklet" />
-      <Type Name="GconfConfigStorage" />
+      <Type Name="GConfConfigStorage" />
     </Namespace>
   </Types>
   <Title>desklets</Title>

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to