soylent r180 - trunk/src



Author: treitter
Date: Mon Jun 23 05:54:23 2008
New Revision: 180
URL: http://svn.gnome.org/viewvc/soylent?rev=180&view=rev

Log:
cut out some more obsolete functions

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 05:54:23 2008
@@ -78,27 +78,10 @@
 static gboolean soylent_browser_person_selected_email_menu_update_cb
                                                 (GtkMenuToolButton *btntb_email,
                                                  gpointer user_data);
-static gboolean soylent_browser_person_apply_edits_from_widgets_switch
-                                                          (gpointer key,
-                                                           gpointer value,
-                                                           gpointer user_data);
-static gboolean soylent_browser_person_set_field_from_widget
-                                                      (gpointer e_contact_field,
-                                                       gpointer widget_name,
-                                                       gpointer user_data);
 static gboolean soylent_browser_person_set_mail_fields_from_widgets 
                                                       (gpointer e_contact_field,
                                                        gpointer widget_name,
                                                        gpointer user_data);
-static gboolean soylent_browser_person_set_im_field_e_vcard
-                                                      (SoylentBrowser* browser,
-                                                       EContact* e_contact,
-                                                       const gchar* widget_name,
-                                                       const gchar* value);
-
-static gboolean soylent_browser_person_set_field_email (EContact *e_contact,
-                                                        guint email_pos,
-                                                        gchar *contents_new);
 static gboolean soylent_browser_person_set_field_simple
                                                 (EContact *e_contact,
                                                  EContactField e_contact_field,
@@ -1194,9 +1177,6 @@
 
   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;
@@ -1315,17 +1295,12 @@
         {
           gchar *widget_name = NULL;
 
-          /* FIXME: these are special-cased for mail fields due to the way
-           * soylent_browser_person_apply_edits_from_widgets_switch() works;
-           * un-special-case this */
-          /* FIXME: pull what's useful from this function tree and make this
-           * section in this function its own simple function (like
-           * soylent_browser_person_view_prep_changes_im() ; call it here */
           widget_name = g_strdup_printf ("mail_%s", CONTEXT_STRS[context]);
-          retval &= soylent_browser_person_apply_edits_from_widgets_switch
-                                                              (widget_name,
-                                                               &e_contact_field,
-                                                               browser);
+          retval &= soylent_browser_person_set_mail_fields_from_widgets
+                                                            (widget_name,
+                                                             &e_contact_field,
+                                                             browser);
+
           g_free (widget_name);
         }
     }
@@ -2117,126 +2092,6 @@
   return retval;
 }
 
-/* Save edits to the current person's existing details
- *
- * Return TRUE unconditionally (to signify "remove this key/value" when used in
- * g_hash_table_foreach_remove). */
-static gboolean
-soylent_browser_person_apply_edits_from_widgets_switch (gpointer key,
-                                                        gpointer value,
-                                                        gpointer user_data)
-{
-  gboolean retval = TRUE;
-  GladeXML *wtree = NULL;
-  SoylentBrowser *browser = NULL;
-
-  g_return_val_if_fail (key, retval);
-  g_return_val_if_fail (user_data, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (user_data), retval);
-   */
- 
-  browser = (SoylentBrowser*) user_data;
-  wtree = soylent_browser_get_widget_tree (browser);
-
-  if (g_ascii_strncasecmp (key, "mail", 4) == 0)
-    {
-      soylent_browser_person_set_mail_fields_from_widgets (key, value,
-                                                           user_data);
-    }
-  else
-    {
-      soylent_browser_person_set_field_from_widget (key, value, user_data);
-    }
-
-  return retval;
-}
-
-/* Save a single-valued detail edit for the person being edited
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_set_field_from_widget (gpointer key, gpointer value,
-                                              gpointer user_data)
-{
-  gboolean retval = FALSE;
-  SoylentBrowser *browser = NULL;
-  GladeXML *wtree = NULL;
-  const gchar *widget_name = NULL;
-  EContactField e_contact_field = 0;
-  gchar *contents_new = NULL;
-  GtkWidget *widget = NULL;
-  EContact *e_contact = NULL;
-
-  g_return_val_if_fail (key, retval);
-  g_return_val_if_fail (user_data, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (user_data), retval);
-   */
-
-  browser = (SoylentBrowser*) user_data;
-  wtree = soylent_browser_get_widget_tree (browser);
-
-  widget_name = (const gchar*) key;
-  widget = glade_xml_get_widget (wtree, widget_name); 
-  e_contact_field = *((EContactField*) value);
-
-  e_contact = soylent_browser_get_selected_person_e_contact (browser);
-
-  g_return_val_if_fail (widget, retval);
-  g_return_val_if_fail (GTK_IS_ENTRY (widget) || GTK_IS_TEXT_VIEW (widget),
-                        retval);
-  g_return_val_if_fail (e_contact, retval);
-  g_return_val_if_fail (E_IS_CONTACT (e_contact), retval);
-
-  if (GTK_IS_ENTRY (widget))
-    {
-      contents_new = (gchar*) gtk_entry_get_text (GTK_ENTRY (widget));
-    }
-  else if (GTK_IS_TEXT_VIEW (widget))
-    {
-      GtkTextBuffer *buf = NULL;
-      GtkTextIter start, end;
-
-      buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget));
-      gtk_text_buffer_get_bounds (buf, &start, &end);
-      contents_new = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
-    }
-
-  if (value && (*((EContactField*) value) == CB_DATA_FIELD_IM))
-    {
-      g_debug ("Saving IM field...");
-      retval = soylent_browser_person_set_im_field_e_vcard (browser, e_contact,
-                                                            widget_name,
-                                                            contents_new);
-      g_debug ("\n");
-    }
-  else
-    {
-      gint email_pos = -1;
-
-      email_pos = e_contact_field - E_CONTACT_EMAIL_1;
-      if ((email_pos >= 0) && (email_pos < MAX_GUI_EMAIL))
-        {
-          retval = soylent_browser_person_set_field_email (e_contact, email_pos,
-                                                           contents_new);
-        }
-      else
-        {
-          retval = soylent_browser_person_set_field_simple (e_contact,
-                                                            e_contact_field,
-                                                            contents_new);
-        }
-    }
-
-  if (GTK_IS_TEXT_VIEW (widget))
-    {
-      g_free (contents_new);
-    }
-
-  return TRUE;
-}
-
 /* FIXME: convert to support multivalued mail fields/widgets */
 /* Propagate existing mailing address changes to the person-being-edited's
  * EContact
@@ -2327,150 +2182,6 @@
   return retval;
 }
 
-/* FIXME: if this changes it to "" (deletes it), find matching EmpathyContact in
- * person->contacts_live and unref it, and use an Empathy function to remove
- * (all instances, initially) of that screen name from your network-stored buddy
- * lists (eventually, when we connect IM screennames with specific user
- * accounts, we'll be able to remove them just from the specific account). Also,
- * we should use/use the equivalent of reference counting - only remove the
- * screen name if no other people include that screen name for the specific
- * account. If it doesn't exist, use an Empathy function to add it to the
- * appropriate account (if there's more than one account for the given service
- * logged in, add it to the one with context matching the group you have the
- * person in (if there's more than one valid match or they aren't in a matching
- * group, or you don't have a matching context, pop open a dialog -- shortcut to
- * this until we do group/context matching)). Then hook up the
- * "presence-changed" signal handler, and let the initial presence fetching
- * update the view, etc. (trigger it if necessary) 
- *
- * in other words, adding/editing/removing screen names causes buddy list
- * contact modifications
- *
- * XXX: we probably can't support even most of this by 0.1 */
-
-/* Set a person's IM field in their EContact on the contents of a corresponding
- * widget(s) */
-static gboolean
-soylent_browser_person_set_im_field_e_vcard (SoylentBrowser* browser,
-                                             EContact* e_contact,
-                                             const gchar* widget_name,
-                                             const gchar* value)
-{
-  gboolean retval = FALSE;
-  GladeXML *wtree = NULL;
-  GtkLabel *label = NULL;
-  const gchar *label_text = NULL;
-  gchar *proto_name_lc = NULL;
-  gchar *field_name = NULL;
-  EContactField field = 0;
-  gchar *context_str = NULL;
-  gchar *label_str = NULL;
-
-  g_debug ("in set_im_field_e_vcard()");
-  g_debug ("widget_name: %s", widget_name);
-  g_debug ("value: %s", value);
-
-  g_return_val_if_fail (browser, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-  g_return_val_if_fail (e_contact, retval);
-  g_return_val_if_fail (E_IS_CONTACT (e_contact), retval);
-  g_return_val_if_fail (widget_name, retval);
-
-  wtree = soylent_browser_get_widget_tree (browser);
-
-  g_debug ("...passed basic validation");
-
-  context_str = (gchar*) CONTEXT_STRS[CONTEXT_WORK];
-  label_str = g_strstr_len (widget_name, strlen (widget_name), "person");
-  label_str = g_strdup_printf ("label_%s", label_str);
-  label = GTK_LABEL (glade_xml_get_widget (wtree, label_str)); 
-  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);
-  field = e_contact_field_id (field_name);
-
-  context_str = (gchar*) CONTEXT_STRS[CONTEXT_WORK];
-  if (!g_strstr_len (widget_name, strlen (widget_name), context_str))
-    {
-      context_str = (gchar*) CONTEXT_STRS[CONTEXT_HOME];
-      
-      if (!g_strstr_len (widget_name, strlen (widget_name), context_str))
-        {
-          g_warning ("could not find a valid context in the widget name");
-          context_str = NULL;
-        }
-    }
-
-  if (context_str)
-    {
-      guint widget_num = 0;
-
-      /* FIXME: more error checking */
-      widget_num = g_ascii_strtoull (g_strrstr (label_str, "_") + 1, NULL, 10);
-
-      context_str = g_ascii_strup (context_str, -1);
-      g_debug ("final context: '%s'", context_str);
-      g_debug ("widget_num: '%d'", widget_num);
-      e_vcard_attr_list_set_value (e_contact, field, context_str, widget_num,
-                                   value);
-
-      retval = TRUE;
-    }
-
-  g_free (label_str);
-  g_free (proto_name_lc);
-  g_free (field_name);
-  g_free (context_str);
-
-  return retval;
-}
-
-/* Save an email address for the person being edited
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_set_field_email (EContact *e_contact,
-                                        guint email_pos,
-                                        gchar *contents_new)
-{
-  gboolean retval = FALSE;
-  GList *email_list_head = NULL;
-
-  g_return_val_if_fail (e_contact, retval);
-  g_return_val_if_fail (E_IS_CONTACT (e_contact), retval);
-  g_return_val_if_fail (email_pos >= 0, retval);
-  g_return_val_if_fail (email_pos < MAX_GUI_EMAIL, retval);
-
-  email_list_head = e_contact_get (e_contact, E_CONTACT_EMAIL);
-  if (email_list_head)
-    {
-      GList *existing_email = NULL;
-
-      existing_email = g_list_nth (email_list_head, email_pos);
-      if (existing_email)
-        {
-          /* Delete empty email addresses */
-          if (!contents_new || g_str_equal (contents_new, ""))
-            {
-              email_list_head = g_list_delete_link (email_list_head,
-                                                    existing_email);
-            }
-          else
-            {
-              existing_email->data = contents_new;
-            }
-
-          e_contact_set (e_contact, E_CONTACT_EMAIL, email_list_head);
-        }
-
-      retval = TRUE;
-    }
-
-  return retval;
-}
-
 /* Save a simple EContact field for the person being edited
  *
  * Return TRUE for success, FALSE for any failure. */



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