folks-inspect: handle Structured Names
authorRaul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
Fri, 11 Mar 2011 21:54:03 +0000 (13:54 -0800)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Fri, 11 Mar 2011 22:30:03 +0000 (14:30 -0800)
Fixes: bgo#644457 - Handle structured names

NEWS
folks/name-details.vala
tools/inspect/utils.vala

diff --git a/NEWS b/NEWS
index 55a0acd..265b44d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ Bugs fixed:
 * Bug 643954 — Add to_string () to PostalAddress class
 * Bug 643955 — Add to_string () to RoleOwner class
 * Bug 643957 — Deal handle birthday and postal-addresses.
+* Bug 644457 — Handle structured names
 
 API changes:
 * Add RoleDetails interface
index f4a42ad..7e6ce76 100644 (file)
@@ -15,7 +15,8 @@
  * along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  * Authors:
- *       Marco Barisione <marco.barisione@collabora.co.u>
+ *       Marco Barisione <marco.barisione@collabora.co.uk>
+ *       Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
  */
 
 using GLib;
@@ -162,6 +163,24 @@ public class Folks.StructuredName : Object
              this._prefixes         == "" &&
              this._suffixes         == "";
     }
+
+  /**
+   * Formatted version of the structured name.
+   *
+   * @since 0.3.UNRELEASED
+   */
+  public string to_string ()
+    {
+      /* Translators: format for the formatted structured name.
+       * Parameters (in order) are: prefixes (for the name), given name,
+       * family name, additional names and (name) suffixes */
+      var str = "%s, %s, %s, %s, %s";
+      return str.printf (this.prefixes,
+          this.given_name,
+          this.family_name,
+          this.additional_names,
+          this.suffixes);
+    }
 }
 
 /**
index f974851..12e3b17 100644 (file)
@@ -341,6 +341,14 @@ private class Folks.Inspect.Utils
 
             return output_string;
         }
+      else if (prop_name == "structured-name")
+        {
+          unowned StructuredName sn = (StructuredName) prop_value.get_object ();
+          string ret = null;
+          if (sn != null)
+            ret = sn.to_string ();
+          return ret;
+        }
 
       return Utils.transform_value_to_string (prop_value);
     }