soylent r72 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r72 - trunk/src
- Date: Mon, 11 Feb 2008 01:23:12 +0000 (GMT)
Author: treitter
Date: Mon Feb 11 01:23:11 2008
New Revision: 72
URL: http://svn.gnome.org/viewvc/soylent?rev=72&view=rev
Log:
simplify soylent_browser_person_info_im_signals_setup
Modified:
trunk/src/soylent-browser.c
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Mon Feb 11 01:23:11 2008
@@ -82,7 +82,7 @@
(SoylentBrowser *browser);
static gboolean soylent_browser_person_info_phone_signals_setup
(SoylentBrowser *browser);
-static void soylent_browser_person_info_im_signals_setup
+static gboolean soylent_browser_person_info_im_signals_setup
(SoylentBrowser *browser);
static void soylent_browser_person_info_web_signals_setup
(SoylentBrowser *browser);
@@ -1840,45 +1840,75 @@
return retval;
}
-/* Hook up handlers for edits to peoples' existing IM names */
-static void
+/* 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;
- const gchar *context_list[] = {"home", "work",};
+ gboolean retval = FALSE;
GladeXML *wtree = NULL;
- guint context = 0;
- guint fieldnum = 0;
+ 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;
- for (context = 0; context < NUM_CONTEXT; context++)
+ /* invert usual logic to simplify the loop below */
+ retval = TRUE;
+
+ for (i = 0; i < NUM_CONTEXT; i++)
{
- for (fieldnum = 0; fieldnum < IM_FIELDS_PER_CONTEXT; fieldnum++)
+ 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;
- GtkEntry *entry_im = NULL;
cb_entry_changed_e_contact *cb_data = NULL;
widget_name = g_strdup_printf ("entry_person_im_%s_%c",
- context_list[context], '1' + fieldnum);
- entry_im = GTK_ENTRY (glade_xml_get_widget (wtree, widget_name));
+ context_list[i], '1' + j);
cb_data = g_new0 (cb_entry_changed_e_contact, 1);
cb_data->browser = browser;
cb_data->widget_name = widget_name;
- /*
- * FIXME: it's kinda dumb to have to allocate this, just to avoid a
- * double-free later (since we'll never use this); but it beats
- * having two sets of pending_edits structs and processing functions
- */
+ /* Allocate dynamic memory for this field, since it's assumed to be
+ * dynamically-allocated later on */
cb_data->field = g_new0 (EContactField, 1);
*(cb_data->field) = CB_DATA_FIELD_IM;
- g_signal_connect (G_OBJECT (entry_im), "changed",
- G_CALLBACK (entry_changed_e_contact), cb_data);
+ if (cb_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, widget_name,
+ signal_name, callback,
+ cb_data);
+
+ if (!connect_retval)
+ {
+ g_critical ("failed to set up signal handler for widget "
+ "%s::%s\n", widget_name, signal_name);
+ retval = FALSE;
+ }
+ }
+ else
+ {
+ g_critical ("failed to set up callback data for widget %s::%s\n",
+ widget_name, signal_name);
+ }
}
}
+
+ return retval;
}
/* Hook up handlers for edits to peoples' existing Web URLS */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]