soylent r176 - trunk/src



Author: treitter
Date: Mon Jun 23 03:58:20 2008
New Revision: 176
URL: http://svn.gnome.org/viewvc/soylent?rev=176&view=rev

Log:
move and rename prep_changes_im to better fit in with the recent changes

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 Jun 23 03:58:20 2008
@@ -50,9 +50,6 @@
 
 static gboolean soylent_browser_person_view_editor_hide
                                                       (SoylentBrowser *browser);
-static gboolean soylent_browser_person_view_prep_changes_im
-                                                      (SoylentBrowser *browser,
-                                                       EContact *e_contact);
 static gboolean soylent_browser_person_view_save_changes (GtkWidget *widget,
                                                           gpointer user_data);
 static gboolean soylent_browser_person_edit_save_scroll_cb
@@ -1150,112 +1147,6 @@
 }
 #endif
 
-/* Add modified and new IM fields to the EContact (but do not commit) */
-static gboolean
-soylent_browser_person_view_prep_changes_im (SoylentBrowser *browser,
-                                             EContact *e_contact)
-{
-  gboolean retval = FALSE;
-  GladeXML *wtree = NULL;
-  guint context = CONTEXT_FIRST;
-  GList *pre_save_list_im = NULL;
-  GList *l = NULL;
-
-  g_return_val_if_fail (browser, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-
-  wtree = soylent_browser_get_widget_tree (browser);
-
-  retval = TRUE;
-
-  /* FIXME: build up GList(s) of pre_save_im_t* as necessary for each of
-   * the IM fields, then dump them into the contact all at once. Don't bother
-   * with soylent_browser_person_apply_edits_from_widgets_switch() */
-  for (context = CONTEXT_IM_FIRST; context <= CONTEXT_IM_LAST; context++)
-    {
-      guint im_field_pos = 0;
-
-      for (im_field_pos = 0;
-           im_field_pos < IM_FIELDS_PER_CONTEXT;
-           im_field_pos++)
-        {
-          GtkHBox *hbox_im = NULL;
-          GtkEntry *entry_im = NULL;
-          gchar *hbox_name = NULL;
-          gchar *label_name = NULL;
-          gchar *entry_name = NULL;
-
-          hbox_name = g_strdup_printf ("hbox_person_im_%s_%d",
-                                       CONTEXT_STRS[context], im_field_pos + 1);
-          label_name = g_strdup_printf ("label_person_im_%s_%d",
-                                        CONTEXT_STRS[context],
-                                        im_field_pos + 1);
-          entry_name = g_strdup_printf ("entry_person_im_%s_%d",
-                                        CONTEXT_STRS[context],
-                                        im_field_pos + 1);
-          entry_im = GTK_ENTRY (glade_xml_get_widget (wtree, entry_name));
-          hbox_im = GTK_HBOX (glade_xml_get_widget (wtree, hbox_name));
-          if (GTK_WIDGET_VISIBLE(hbox_im))
-            {
-              GtkLabel *label = NULL;
-              const gchar *label_text = NULL;
-              gchar *proto_name_lc = NULL;
-              gchar *field_name = NULL;
-              pre_save_im_t *pre_save_im = NULL;
-              gchar *value = NULL;
-
-              label = GTK_LABEL (glade_xml_get_widget (wtree, label_name)); 
-              label_text = gtk_label_get_text (label);
-              proto_name_lc = g_ascii_strdown (label_text, strlen (label_text));
-              field_name = g_strdup_printf ("im_%s", proto_name_lc);
-
-              value = g_strdup (gtk_entry_get_text (entry_im));
-
-              pre_save_im = g_new (pre_save_im_t, 1);
-              pre_save_im->context = context;
-              /* FIXME: actually use the correct IM field, based on proto */
-              pre_save_im->e_contact_field = e_contact_field_id (field_name);
-              pre_save_im->value = value;
-              pre_save_list_im = g_list_prepend (pre_save_list_im, pre_save_im);
-
-              e_contact_set_attributes (e_contact, pre_save_im->e_contact_field,
-                                        NULL);
-
-              g_free (proto_name_lc);
-              g_free (field_name);
-            }
-
-          g_free (hbox_name);
-          g_free (entry_name);
-          g_free (label_name);
-        }
-    }
-
-  /* Traverse in reverse order to preserve order from the editor */
-  for (l = g_list_last (pre_save_list_im); l; l = g_list_previous (l))
-    {
-      pre_save_im_t *fields_im = NULL;
-
-      fields_im = l->data;
-      if (fields_im->value && !g_str_equal (fields_im->value, ""))
-        {
-          e_vcard_attr_list_prepend_value (e_contact,
-                                           fields_im->e_contact_field,
-                                           CONTEXT_STRS[fields_im->context],
-                                           fields_im->value);
-        }
-    }
-
-  /* FIXME: go through pre_save_list_im and g_free all datas' value field, each
-   * struct */
-
-  g_list_free (pre_save_list_im);
-
-  return retval;
-}
-
 /* Add name field changes to selected EContact (but do not commit) */
 static gboolean
 soylent_browser_person_view_save_changes_prep_name (SoylentBrowser *browser,
@@ -1431,6 +1322,112 @@
   return retval;
 }
 
+/* Add modified and new IM fields to the EContact (but do not commit) */
+static gboolean
+soylent_browser_person_view_save_changes_prep_im (SoylentBrowser *browser,
+                                                  EContact *e_contact)
+{
+  gboolean retval = FALSE;
+  GladeXML *wtree = NULL;
+  guint context = CONTEXT_FIRST;
+  GList *pre_save_list_im = NULL;
+  GList *l = NULL;
+
+  g_return_val_if_fail (browser, retval);
+  /* FIXME: uncomment once SoylentBrowser is a GObject:
+  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
+   */
+
+  wtree = soylent_browser_get_widget_tree (browser);
+
+  retval = TRUE;
+
+  /* FIXME: build up GList(s) of pre_save_im_t* as necessary for each of
+   * the IM fields, then dump them into the contact all at once. Don't bother
+   * with soylent_browser_person_apply_edits_from_widgets_switch() */
+  for (context = CONTEXT_IM_FIRST; context <= CONTEXT_IM_LAST; context++)
+    {
+      guint im_field_pos = 0;
+
+      for (im_field_pos = 0;
+           im_field_pos < IM_FIELDS_PER_CONTEXT;
+           im_field_pos++)
+        {
+          GtkHBox *hbox_im = NULL;
+          GtkEntry *entry_im = NULL;
+          gchar *hbox_name = NULL;
+          gchar *label_name = NULL;
+          gchar *entry_name = NULL;
+
+          hbox_name = g_strdup_printf ("hbox_person_im_%s_%d",
+                                       CONTEXT_STRS[context], im_field_pos + 1);
+          label_name = g_strdup_printf ("label_person_im_%s_%d",
+                                        CONTEXT_STRS[context],
+                                        im_field_pos + 1);
+          entry_name = g_strdup_printf ("entry_person_im_%s_%d",
+                                        CONTEXT_STRS[context],
+                                        im_field_pos + 1);
+          entry_im = GTK_ENTRY (glade_xml_get_widget (wtree, entry_name));
+          hbox_im = GTK_HBOX (glade_xml_get_widget (wtree, hbox_name));
+          if (GTK_WIDGET_VISIBLE(hbox_im))
+            {
+              GtkLabel *label = NULL;
+              const gchar *label_text = NULL;
+              gchar *proto_name_lc = NULL;
+              gchar *field_name = NULL;
+              pre_save_im_t *pre_save_im = NULL;
+              gchar *value = NULL;
+
+              label = GTK_LABEL (glade_xml_get_widget (wtree, label_name)); 
+              label_text = gtk_label_get_text (label);
+              proto_name_lc = g_ascii_strdown (label_text, strlen (label_text));
+              field_name = g_strdup_printf ("im_%s", proto_name_lc);
+
+              value = g_strdup (gtk_entry_get_text (entry_im));
+
+              pre_save_im = g_new (pre_save_im_t, 1);
+              pre_save_im->context = context;
+              /* FIXME: actually use the correct IM field, based on proto */
+              pre_save_im->e_contact_field = e_contact_field_id (field_name);
+              pre_save_im->value = value;
+              pre_save_list_im = g_list_prepend (pre_save_list_im, pre_save_im);
+
+              e_contact_set_attributes (e_contact, pre_save_im->e_contact_field,
+                                        NULL);
+
+              g_free (proto_name_lc);
+              g_free (field_name);
+            }
+
+          g_free (hbox_name);
+          g_free (entry_name);
+          g_free (label_name);
+        }
+    }
+
+  /* Traverse in reverse order to preserve order from the editor */
+  for (l = g_list_last (pre_save_list_im); l; l = g_list_previous (l))
+    {
+      pre_save_im_t *fields_im = NULL;
+
+      fields_im = l->data;
+      if (fields_im->value && !g_str_equal (fields_im->value, ""))
+        {
+          e_vcard_attr_list_prepend_value (e_contact,
+                                           fields_im->e_contact_field,
+                                           CONTEXT_STRS[fields_im->context],
+                                           fields_im->value);
+        }
+    }
+
+  /* FIXME: go through pre_save_list_im and g_free all datas' value field, each
+   * struct */
+
+  g_list_free (pre_save_list_im);
+
+  return retval;
+}
+
 /* Save unsaved changes to the person's details
  *
  * Return TRUE for success, FALSE for any failure. */
@@ -1472,12 +1469,7 @@
                                                E_CONTACT_FIELDS_WEB,
                                                CONTEXT_LIST_WEB);
 
-  soylent_browser_person_view_prep_changes_im (browser, e_contact);
-  /* FIXME: un-hardcode this; handle all types */
-  /*
-  use eds_im_field_id_to_vcard_attr (field_id)); for the IM fields
-  e_vcard_remove_attributes (e_contact, "X-JABBER");
-  */
+  soylent_browser_person_view_save_changes_prep_im (browser, e_contact);
 
   for (context = CONTEXT_FIRST, e_contact_field = E_CONTACT_FIRST_ADDRESS_ID;
        (context <= CONTEXT_LAST)



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