soylent r146 - trunk/src



Author: treitter
Date: Mon May 26 06:04:21 2008
New Revision: 146
URL: http://svn.gnome.org/viewvc/soylent?rev=146&view=rev

Log:
save name and email addresses in new editor style

Modified:
   trunk/src/soylent-browser-person-view.c

Modified: trunk/src/soylent-browser-person-view.c
==============================================================================
--- trunk/src/soylent-browser-person-view.c	(original)
+++ trunk/src/soylent-browser-person-view.c	Mon May 26 06:04:21 2008
@@ -1281,8 +1281,66 @@
   /* FIXME FIXME FIXME: for all the multi-value fields, apply all changes at
    * once via e-d-s' multi-value setting functions, for performance reasons */
 
-  /* FIXME: handle name field */
-  /* FIXME: handle email fields */
+  /* Prep the name field (and its multiple vCard fields) for saving */
+  {
+    gchar *contents_new = NULL;
+    GtkEntry *entry_name = NULL;
+
+    entry_name = GTK_ENTRY (glade_xml_get_widget (wtree, "entry_person_name")); 
+
+    contents_new = g_strdup (gtk_entry_get_text (entry_name));
+    /* Ensure name is set to something useful, to prevent blanking the name the
+     * first time it's edited */
+    if (contents_new && !g_str_equal (contents_new, ""))
+      {
+        soylent_browser_person_set_field_simple (e_contact, E_CONTACT_FULL_NAME,
+                                                 contents_new);
+      }
+
+    g_free (contents_new);
+  }
+
+  /* Prep the email fields for saving */
+  {
+    gchar *contents_new = NULL;
+    guint email_num = 1;
+
+    for (email_num = 1; email_num <= MAX_GUI_EMAIL; email_num++)
+      {
+        gchar *entry_str = NULL;
+        GtkHBox *hbox_email = NULL;
+
+        entry_str = g_strdup_printf ("hbox_person_email_%d", email_num); 
+        hbox_email = GTK_HBOX (glade_xml_get_widget (wtree, entry_str)); 
+        g_free (entry_str);
+
+        /* By convention, the hbox is only visible if there's something useful
+         * in it */
+        if (GTK_WIDGET_VISIBLE (hbox_email))
+          {
+            GtkEntry *entry_email = NULL;
+
+            entry_str = g_strdup_printf ("entry_person_email_%d", email_num); 
+            entry_email = GTK_ENTRY (glade_xml_get_widget (wtree, entry_str)); 
+            g_free (entry_str);
+
+            contents_new = g_strdup (gtk_entry_get_text (entry_email));
+
+            /* Ensure name is set to something useful, to prevent blanking the
+             * name the first time it's edited */
+            if (contents_new && !g_str_equal (contents_new, ""))
+              {
+                soylent_browser_person_set_field_simple
+                                          (e_contact,
+                                           (E_CONTACT_EMAIL_1 - 1 + email_num),
+                                           contents_new);
+              }
+
+            g_free (contents_new);
+          }
+      }
+  }
+
   /* FIXME: handle phone fields */
   /* FIXME: handle web address fields */
 



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