soylent r77 - trunk/src



Author: treitter
Date: Wed Feb 13 06:27:32 2008
New Revision: 77
URL: http://svn.gnome.org/viewvc/soylent?rev=77&view=rev

Log:
use some trickery to cram more signal setup functions into the widget_signal_args_t mold (cutting about 200 net lines of redundant code)

Modified:
   trunk/src/soylent-browser.c
   trunk/src/soylent-utils.h

Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c	(original)
+++ trunk/src/soylent-browser.c	Wed Feb 13 06:27:32 2008
@@ -75,21 +75,9 @@
                                                EmpathyContact *empathy_contact);
 
 static gboolean soylent_browser_widget_setup (SoylentBrowser *browser);
-static gboolean soylent_browser_simple_signals_setup (SoylentBrowser *browser);
-static void soylent_browser_person_info_avatar_signals_setup
-                                                      (SoylentBrowser *browser);
-static gboolean soylent_browser_person_info_email_signals_setup
-                                                      (SoylentBrowser *browser);
-static gboolean soylent_browser_person_info_phone_signals_setup
-                                                      (SoylentBrowser *browser);
-static gboolean soylent_browser_person_info_im_signals_setup
-                                                      (SoylentBrowser *browser);
-static gboolean soylent_browser_person_info_web_signals_setup
-                                                      (SoylentBrowser *browser);
+static gboolean soylent_browser_widget_signals_setup (SoylentBrowser *browser);
 static gboolean soylent_browser_person_info_mail_signals_setup
                                                       (SoylentBrowser *browser);
-static void soylent_browser_person_info_signals_setup
-                                                      (SoylentBrowser *browser);
 static gboolean soylent_browser_person_detail_add_signals_setup
                                                       (SoylentBrowser *browser);
 static gboolean soylent_browser_signals_setup (SoylentBrowser *browser);
@@ -1626,46 +1614,136 @@
  *
  * Return TRUE for success, for FALSE for any failure */
 static gboolean
-soylent_browser_simple_signals_setup (SoylentBrowser *browser)
+soylent_browser_widget_signals_setup (SoylentBrowser *browser)
 {
+  /* XXX: this is dangerously close to being "clever", but it's better than a
+   * bunch of similar-but-different functions */
   widget_signal_args_t signal_handlers[] =
     {
       /* Main app window */
-      {"window_main", "delete-event", soylent_browser_delete_cb, browser},
+      {"window_main", "delete-event", soylent_browser_delete_cb, CB_DATA_SIMPLE,
+       browser},
 
       /* People icons in main icon view */
       {"iv_people", "selection-changed",
-       soylent_browser_person_selection_changed_cb, browser},
+       soylent_browser_person_selection_changed_cb, CB_DATA_SIMPLE, browser},
       {"iv_people", "item_activated", soylent_browser_person_icon_activated_cb,
-       browser},
+       CB_DATA_SIMPLE, browser},
 
       /* Set Online Presence combo box */
-      {"cbox_presence", "changed", soylent_browser_presence_set_cb, browser},
+      {"cbox_presence", "changed", soylent_browser_presence_set_cb,
+       CB_DATA_SIMPLE, browser},
 
       /* Person action buttons */
       {"btn_new_person", "clicked", soylent_browser_person_action_new_person_cb,
-       browser},
+       CB_DATA_SIMPLE, browser},
       {"btn_delete_people", "clicked",
-       soylent_browser_person_action_delete_selected_cb, browser},
+       soylent_browser_person_action_delete_selected_cb, CB_DATA_SIMPLE,
+       browser},
       {"btn_edit_person", "clicked",
-       soylent_browser_person_action_edit_selected_cb, browser},
+       soylent_browser_person_action_edit_selected_cb, CB_DATA_SIMPLE, browser},
       {"btntb_email", "clicked",
-       soylent_browser_person_action_email_menu_tool_button_cb, browser},
+       soylent_browser_person_action_email_menu_tool_button_cb, CB_DATA_SIMPLE,
+       browser},
       {"btntb_chat", "clicked",
-       soylent_browser_person_action_chat_menu_tool_button_cb, browser},
-
-      /* Adding new details to a person */
-      {"cbox_detail_domain", "changed", cbox_detail_type_update, browser},
-      {"entry_detail_add", "changed", btn_detail_add_update, browser},
-      {"btn_detail_add", "clicked", commit_detail_add, browser},
+       soylent_browser_person_action_chat_menu_tool_button_cb, CB_DATA_SIMPLE,
+       browser},
 
-      /* "Save Changes?" dialog */
+      /* "Delete Person?" dialog */
       {"btn_delete_person_cancel", "clicked", 
-       soylent_browser_person_action_delete_selected_hide_dialog_cb, browser,},
+       soylent_browser_person_action_delete_selected_hide_dialog_cb,
+       CB_DATA_SIMPLE, browser,},
       {"btn_delete_person_confirm", "clicked", 
-       soylent_browser_person_action_delete_selected_finalize_cb, browser},
+       soylent_browser_person_action_delete_selected_finalize_cb,
+       CB_DATA_SIMPLE, browser},
       {"dia_delete_person_confirm", "delete-event", gtk_widget_hide_on_delete,
+       CB_DATA_SIMPLE, browser},
+
+      /* Automatically save changes when closing the Person Details window */
+      {"window_person_view", "delete-event",
+       soylent_browser_person_view_save_finalize_cb, CB_DATA_SIMPLE, browser},
+
+      /* Adding new details to a person */
+      {"cbox_detail_domain", "changed", cbox_detail_type_update, CB_DATA_SIMPLE,
+       browser},
+      {"entry_detail_add", "changed", btn_detail_add_update, CB_DATA_SIMPLE,
        browser},
+      {"btn_detail_add", "clicked", commit_detail_add, CB_DATA_SIMPLE, browser},
+
+      /*
+       * Editing existing Person Details
+       */
+      /* Name */
+      {"entry_person_name", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_FULL_NAME},
+
+      /* Avatar */
+      /* TODO: set up avatar editing */
+
+      /* Email addresses */
+      {"entry_person_email_1", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_EMAIL_1},
+      {"entry_person_email_2", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_EMAIL_2},
+      {"entry_person_email_3", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_EMAIL_3},
+      {"entry_person_email_4", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_EMAIL_4},
+
+      /* Phone numbers */
+      {"entry_person_phone_home", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_PHONE_HOME},
+      {"entry_person_phone_work", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_PHONE_BUSINESS},
+      {"entry_person_phone_cell", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_PHONE_MOBILE},
+
+      /* XXX: pretty arbitrary and extremely noisy */
+      /* Instant messenger */
+      /*   home */
+      {"entry_person_im_home_1", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_2", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_3", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_4", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_5", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_6", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_7", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_home_8", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      /*   work */
+      {"entry_person_im_work_1", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_2", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_3", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_4", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_5", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_6", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_7", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+      {"entry_person_im_work_8", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) CB_DATA_FIELD_IM},
+
+      /* Web URLs */
+      {"entry_person_web_homepage", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_HOMEPAGE_URL},
+      {"entry_person_web_blog", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_BLOG_URL},
+      {"entry_person_web_calendar", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_CALENDAR_URI},
+      {"entry_person_web_video", "changed", entry_changed_e_contact,
+       CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD, (void*) E_CONTACT_VIDEO_URL},
     };
   gboolean retval = FALSE;
   GladeXML *wtree = NULL;
@@ -1688,332 +1766,61 @@
     {
       gboolean connect_retval = FALSE;
       widget_signal_args_t cur_args = signal_handlers[i];
-
-      connect_retval = widget_signal_connect (wtree, cur_args.widget_name,
-                                              cur_args.signal_name,
-                                              cur_args.callback,
-                                              cur_args.user_data);
-      if (!connect_retval)
-        {
-          g_critical ("failed to set up signal handler for widget %s::%s\n",
-                      cur_args.widget_name, cur_args.signal_name);
-          retval = FALSE;
-        }
-    }
-
-  return retval;
-}
-
-/* Hook up handlers for peoples' existing image edits */
-static void
-soylent_browser_person_info_avatar_signals_setup (SoylentBrowser *browser)
-{
-  /* TODO */
-}
-
-/* Hook up handlers for edits to peoples' existing email addresses
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_info_email_signals_setup (SoylentBrowser *browser)
-{
-  gboolean retval = FALSE;
-  GladeXML *wtree = NULL;
-  guint i = 0;
-
-  g_return_val_if_fail (browser != NULL, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-
-  wtree = browser->main_window;
-
-  /* invert usual logic to simplify the loop below */
-  retval = TRUE;
-
-  for (i = 0; i < MAX_GUI_EMAIL; i++)
-    {
-      gboolean connect_retval = FALSE;
-      const gchar *signal_name = "changed";
-      const GCallback callback = G_CALLBACK (entry_changed_e_contact);
-      gchar *widget_name = NULL;
-      cb_entry_changed_e_contact *cb_data = NULL;
-
-      widget_name = g_strdup_printf ("entry_person_email_%c", '1' + i);
-
-      cb_data = g_new0 (cb_entry_changed_e_contact, 1);
-      if (cb_data)
-        {
-          cb_data->browser = browser;
-          cb_data->widget_name = widget_name;
-          cb_data->field = g_new0 (EContactField, 1);
-          if (cb_data->field)
-            {
-              *(cb_data->field) = E_CONTACT_EMAIL_1 + i;
-
-              /* FIXME - use a version which uses g_signal_connect_data so we
-               * can eventually free each instance of cb_data */
-              connect_retval = widget_signal_connect (wtree, widget_name,
-                                                      signal_name, callback,
-                                                      cb_data);
-            }
-        }
-
-      if (connect_retval)
-        {
-          /* success */
-        }
-      else
-        {
-          g_critical ("failed to set up signal handler for widget "
-                      "%s::%s\n", widget_name, signal_name);
-
-          retval = FALSE;
-
-          if (cb_data)
-            {
-              g_free (cb_data->field);
-              g_free (cb_data);
-            }
-          g_free (widget_name);
-        }
-    }
-
-  return retval;
-}
-
-/* Hook up handlers for edits to peoples' existing phone numbers 
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_info_phone_signals_setup (SoylentBrowser *browser)
-{
-  const guint CONTEXT_POS_HOME = 0;
-  const guint NUM_CONTEXT = 3;
-  gboolean retval = FALSE;
-  GladeXML *wtree = NULL;
-  guint i = 0;
-
-  g_return_val_if_fail (browser != NULL, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-
-  wtree = browser->main_window;
-
-  /* invert usual logic to simplify the loop below */
-  retval = TRUE;
-
-  for (i = CONTEXT_POS_HOME; i < NUM_CONTEXT; i++)
-    {
-      /* TODO: factor this out somewhere else, if possible */
-      const gchar *context_list[] = {"home", "work", "cell",};
-      const guint e_contact_fields[] = {E_CONTACT_PHONE_BUSINESS,
-                                        E_CONTACT_PHONE_HOME,
-                                        E_CONTACT_PHONE_MOBILE,};
-      const gchar *signal_name = "changed";
-      const GCallback callback = G_CALLBACK (entry_changed_e_contact);
-      gboolean connect_retval = FALSE;
-      gchar *widget_name = NULL;
       cb_entry_changed_e_contact *cb_data = NULL;
 
-      widget_name = g_strdup_printf ("entry_person_phone_%s",
-                                     context_list[i]);
-
-      cb_data = g_new0 (cb_entry_changed_e_contact, 1);
-      if (cb_data)
-        {
-          cb_data->browser = browser;
-          cb_data->widget_name = widget_name;
-          cb_data->field = g_new0 (EContactField, 1);
-          if (cb_data->field)
-            {
-              *(cb_data->field) = e_contact_fields[i];
-
-              /* FIXME - use a version which uses g_signal_connect_data so we
-               * can eventually free each instance of cb_data */
-              connect_retval = widget_signal_connect (wtree, widget_name,
-                                                      signal_name, callback,
-                                                      cb_data);
-            }
-        }
-
-      if (connect_retval)
-        {
-          /* success */
-        }
-      else
+      switch (cur_args.cb_data_type)
         {
-          g_critical ("failed to set up signal handler for widget "
-                      "%s::%s\n", widget_name, signal_name);
-
-          retval = FALSE;
-
-          if (cb_data)
-            {
-              g_free (cb_data->field);
-              g_free (cb_data);
-            }
-          g_free (widget_name);
-        }
-    }
-
-  return retval;
-}
-
-/* Hook up handlers for edits to peoples' existing IM names
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_info_im_signals_setup (SoylentBrowser *browser)
-{
-  const guint NUM_CONTEXT = 2;
-  gboolean retval = FALSE;
-  GladeXML *wtree = NULL;
-  guint i = 0;
-  guint j = 0;
-
-  g_return_val_if_fail (browser != NULL, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-
-  wtree = browser->main_window;
-
-  /* invert usual logic to simplify the loop below */
-  retval = TRUE;
-
-  for (i = 0; i < NUM_CONTEXT; i++)
-  {
-    for (j = 0; j < IM_FIELDS_PER_CONTEXT; j++)
-      {
-        /* TODO: factor this out somewhere else, if possible */
-        const gchar *context_list[] = {"home", "work",};
-        const gchar *signal_name = "changed";
-        const GCallback callback = G_CALLBACK (entry_changed_e_contact);
-        gboolean connect_retval = FALSE;
-        gchar *widget_name = NULL;
-        cb_entry_changed_e_contact *cb_data = NULL;
-
-        widget_name = g_strdup_printf ("entry_person_im_%s_%c",
-                                       context_list[i], '1' + j);
-
-        cb_data = g_new0 (cb_entry_changed_e_contact, 1);
-        if (cb_data)
-          {
-            cb_data->browser = browser;
-            cb_data->widget_name = widget_name;
-            /* Allocate dynamic memory for this field, since it's assumed to be
-             * dynamically-allocated later on */
-            cb_data->field = g_new0 (EContactField, 1);
-            if (cb_data->field)
+          case CB_DATA_SIMPLE:
+            connect_retval = widget_signal_connect (wtree, cur_args.widget_name,
+                                                    cur_args.signal_name,
+                                                    cur_args.callback,
+                                                    cur_args.user_data);
+            break;
+          case CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD:
+            cb_data = g_new0 (cb_entry_changed_e_contact, 1);
+            if (cb_data)
               {
-                *(cb_data->field) = CB_DATA_FIELD_IM;
-
-                /* FIXME - use a version which uses g_signal_connect_data so we
-                 * can eventually free each instance of cb_data */
-                connect_retval = widget_signal_connect (wtree, widget_name,
-                                                        signal_name, callback,
-                                                        cb_data);
+                cb_data->browser = browser;
+                cb_data->widget_name = cur_args.widget_name;
+                cb_data->field = g_new0 (EContactField, 1);
+                if (cb_data->field)
+                  {
+                    *(cb_data->field) = (EContactField) cur_args.user_data;
+
+                    /* FIXME - use a version which uses g_signal_connect_data so
+                     * we can eventually free each instance of cb_data */
+                    connect_retval = widget_signal_connect
+                                                          (wtree,
+                                                           cur_args.widget_name,
+                                                           cur_args.signal_name,
+                                                           cur_args.callback,
+                                                           cb_data);
+                  }
               }
-          }
 
-        if (connect_retval)
-          {
-            /* success */
-          }
-        else
-          {
-            g_critical ("failed to set up signal handler for widget "
-                        "%s::%s\n", widget_name, signal_name);
-
-            retval = FALSE;
-
-            if (cb_data)
+            if (!connect_retval)
               {
-                g_free (cb_data->field);
-                g_free (cb_data);
+                if (cb_data)
+                  {
+                    g_free (cb_data->field);
+                    g_free (cb_data);
+                  }
+                /*
+                g_free (widget_name);
+                */
               }
-            g_free (widget_name);
-          }
-      }
-  }
-
-  return retval;
-}
-
-/* Hook up handlers for edits to peoples' existing Web URLS
- *
- * Return TRUE for success, FALSE for any failure. */
-static gboolean
-soylent_browser_person_info_web_signals_setup (SoylentBrowser *browser)
-{
-  gboolean retval = FALSE;
-  const guint NUM_TYPE = 4;
-  GladeXML *wtree = NULL;
-  guint i = 0;
-
-  g_return_val_if_fail (browser != NULL, retval);
-  /* FIXME: uncomment once SoylentBrowser is a GObject:
-  g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), retval);
-   */
-
-  wtree = browser->main_window;
-
-  /* invert usual logic to simplify the loop below */
-  retval = TRUE;
-
-  for (i = 0; i < NUM_TYPE; i++)
-    {
-      /* TODO: factor this out somewhere else, if possible */
-      const gchar *type_list[] = {"homepage", "blog", "calendar", "video",};
-      const guint e_contact_fields[] = {E_CONTACT_HOMEPAGE_URL,
-                                        E_CONTACT_BLOG_URL,
-                                        E_CONTACT_CALENDAR_URI,
-                                        E_CONTACT_VIDEO_URL,};
-      const gchar *signal_name = "changed";
-      const GCallback callback = G_CALLBACK (entry_changed_e_contact);
-      gboolean connect_retval = FALSE;
-      gchar *widget_name = NULL;
-      cb_entry_changed_e_contact *cb_data = NULL;
-
-      widget_name = g_strdup_printf ("entry_person_web_%s", type_list[i]);
-
-      cb_data = g_new0 (cb_entry_changed_e_contact, 1);
-      if (cb_data)
-        {
-          cb_data->browser = browser;
-          cb_data->widget_name = widget_name;
-          cb_data->field = g_new0 (EContactField, 1);
-          if (cb_data->field)
-            {
-              *(cb_data->field) = e_contact_fields[i];
-
-              /* FIXME - use a version which uses g_signal_connect_data so we
-               * can eventually free each instance of cb_data */
-              connect_retval = widget_signal_connect (wtree, widget_name,
-                                                      signal_name, callback,
-                                                      cb_data);
-            }
-        }
-
-      if (connect_retval)
-        {
-          /* success */
-        }
-      else
-        {
-          g_critical ("failed to set up signal handler for widget "
-                      "%s::%s\n", widget_name, signal_name);
-
-          retval = FALSE;
+          break;
+          default:
+            g_critical ("unhandled signal setup cb_data_t: %d\n",
+                        cur_args.cb_data_type);
+            break;
 
-          if (cb_data)
+          if (!connect_retval)
             {
-              g_free (cb_data->field);
-              g_free (cb_data);
+              g_critical ("failed to set up signal handler for widget %s::%s\n",
+                          cur_args.widget_name, cur_args.signal_name);
+              retval = FALSE;
             }
-          g_free (widget_name);
         }
     }
 
@@ -2158,43 +1965,6 @@
   return retval;
 }
 
-/* Hook up handlers for all the people-detail-editing-related widgets */
-static void
-soylent_browser_person_info_signals_setup (SoylentBrowser *browser)
-{
-  GladeXML *wtree = NULL;
-  GtkEntry *entry_name = NULL;
-  GtkWidget *window_person_view = NULL;
-  cb_entry_changed_e_contact *cb_data = NULL;
-
-  wtree = browser->main_window;
-  entry_name = GTK_ENTRY (glade_xml_get_widget (wtree, "entry_person_name"));
-  window_person_view = glade_xml_get_widget (wtree, "window_person_view");
-
-  cb_data = g_new0 (cb_entry_changed_e_contact, 1);
-  cb_data->browser = browser;
-  cb_data->widget_name = g_strdup ("entry_person_name");
-  cb_data->field = g_new0 (EContactField, 1);
-  *(cb_data->field) = E_CONTACT_FULL_NAME;
-
-  g_signal_connect (G_OBJECT (entry_name), "changed",
-                    G_CALLBACK (entry_changed_e_contact), cb_data);
-
-  g_signal_connect (G_OBJECT (window_person_view), "delete-event",
-                    G_CALLBACK (soylent_browser_person_view_save_finalize_cb),
-                    browser);
-
-  /* FIXME: factor these a little more, and push their contents into this
-   * function; use an array like in *_simple_signals_setup() */
-  /* FIXME: check these return values */
-  soylent_browser_person_info_avatar_signals_setup (browser);
-  soylent_browser_person_info_email_signals_setup  (browser);
-  soylent_browser_person_info_phone_signals_setup  (browser);
-  soylent_browser_person_info_im_signals_setup     (browser);
-  soylent_browser_person_info_web_signals_setup    (browser);
-  soylent_browser_person_info_mail_signals_setup   (browser);
-}
-
 /* Hook up handlers for all the people-related widgets (overview)
  *
  * Return TRUE for complete success, FALSE otherwise. */
@@ -2202,7 +1972,7 @@
 soylent_browser_signals_setup (SoylentBrowser *browser)
 {
   gboolean retval = FALSE;
-  gboolean simple_signals_retval = FALSE;
+  gboolean widget_signals_retval = FALSE;
   GladeXML *wtree = NULL;
 
   g_return_val_if_fail (browser != NULL, retval);
@@ -2213,10 +1983,10 @@
   wtree = browser->main_window;
 
   /* FIXME: check this return value, etc. */
-  simple_signals_retval = soylent_browser_simple_signals_setup (browser);
+  widget_signals_retval = soylent_browser_widget_signals_setup (browser);
 
-  /* FIXME: simplify these like simple_signals_setup, above */
-  soylent_browser_person_info_signals_setup       (browser);
+  /* FIXME: simplify these like widget_signals_setup, above */
+  soylent_browser_person_info_mail_signals_setup  (browser);
   soylent_browser_person_detail_add_signals_setup (browser);
 
   /* FIXME: only set this if everything above succeeds */

Modified: trunk/src/soylent-utils.h
==============================================================================
--- trunk/src/soylent-utils.h	(original)
+++ trunk/src/soylent-utils.h	Wed Feb 13 06:27:32 2008
@@ -35,12 +35,22 @@
  * of -1 gets promoted to 4294967295U on 32-bit arches). */
 #define ARRAY_LEN(x) ((sizeof (x)) / sizeof (x[0]))
 
+typedef enum cb_data_tag cb_data_t;
+enum cb_data_tag
+{
+  FIRST_CB_DATA,
+  CB_DATA_SIMPLE,
+  CB_DATA_COMPLEX_FROM_E_CONTACT_FIELD,
+  LAST_CB_DATA,
+};
+
 typedef struct widget_signal_args_tag widget_signal_args_t;
 struct widget_signal_args_tag
 {
   gchar *widget_name;
   gchar *signal_name;
   gpointer callback;
+  cb_data_t cb_data_type;
   gpointer user_data;
 };
 



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