soylent r102 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r102 - trunk/src
- Date: Sat, 15 Mar 2008 04:48:44 +0000 (GMT)
Author: treitter
Date: Sat Mar 15 04:48:44 2008
New Revision: 102
URL: http://svn.gnome.org/viewvc/soylent?rev=102&view=rev
Log:
clean up soylent_browser_person_new_edit_cb()
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 Sat Mar 15 04:48:44 2008
@@ -36,10 +36,10 @@
(EBookView *book_view,
const GList *e_contacts,
SoylentPerson *person);
-static gint soylent_browser_person_new_edit_cb
- (EBookView *book_view,
- const GList *e_contacts,
- cb_data_pre_person *pre_person_to_match);
+static gboolean soylent_browser_person_new_edit_cb
+ (EBookView *book_view,
+ const GList *e_contacts,
+ cb_data_pre_person *pre_person_to_match);
static gboolean soylent_browser_person_action_chat_menu_shell_cb
(GtkMenuShell *menu_email,
gpointer user_data);
@@ -1567,85 +1567,68 @@
}
/* After we create this new Person, automatically select them and open an edit
- * window for them */
-static gint
+ * window for them
+ *
+ * Return TRUE for success, FALSE for any failure. */
+static gboolean
soylent_browser_person_new_edit_cb (EBookView *book_view,
const GList *e_contacts,
cb_data_pre_person *pre_person_to_match)
{
- gint retval = -1;
+ gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
EContact *e_contact = NULL;
SoylentPerson *person = NULL;
+ g_return_val_if_fail (e_contacts != NULL, retval);
+ g_return_val_if_fail (pre_person_to_match != NULL, retval);
+
+ /* FIXME: once SoylentBrowser is a GObject, also check SOYLENT_IS_BROWSER */
browser = pre_person_to_match->browser;
e_contact = pre_person_to_match->e_contact;
if (browser && e_contact && E_IS_CONTACT (e_contact))
{
- gboolean person_select_retval = FALSE;
+ const GList *l = NULL;
person = soylent_browser_get_person_from_e_contact (browser, e_contact);
- person_select_retval = soylent_browser_person_select (browser, person,
- TRUE);
- if (person_select_retval)
- {
- if (e_contacts)
- {
- const GList *l = NULL;
+ soylent_browser_person_select (browser, person, TRUE);
- for (l = e_contacts;
- l && l->data && E_IS_CONTACT (l->data);
- l = g_list_next (l))
- {
- EContact *e_contact_cur = NULL;
- const gchar *e_uid = NULL;
- const gchar *e_uid_cur = NULL;
-
- e_contact_cur = E_CONTACT (l->data);
- e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
- e_uid_cur = e_contact_get_const (e_contact_cur,
- E_CONTACT_UID);
- /* If we've found our match */
- if (g_str_equal (e_uid, e_uid_cur))
- {
- gboolean set_mode_retval = FALSE;
+ for (l = e_contacts;
+ l && l->data && E_IS_CONTACT (l->data) && (retval == FALSE);
+ l = g_list_next (l))
+ {
+ EContact *e_contact_cur = NULL;
+ const gchar *e_uid = NULL;
+ const gchar *e_uid_cur = NULL;
+
+ e_contact_cur = E_CONTACT (l->data);
+ e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
+ e_uid_cur = e_contact_get_const (e_contact_cur, E_CONTACT_UID);
+ /* If we've found our match */
+ if (g_str_equal (e_uid, e_uid_cur))
+ {
+ gboolean set_mode_retval = FALSE;
- soylent_browser_person_view_update (browser, person);
- set_mode_retval = soylent_browser_view_set_mode
+ soylent_browser_person_view_update (browser, person);
+ set_mode_retval = soylent_browser_view_set_mode
(browser,
SB_PEOPLE_VIEW_MODE_EDIT);
- if (set_mode_retval)
- {
- retval = 0;
- }
- break;
- }
+ if (set_mode_retval)
+ {
+ retval = TRUE;
}
}
}
- else
- {
- g_warning ("soylent_browser_person_new_edit_cb: failed to select the "
- "new Person");
- }
}
else
{
- g_warning ("soylent_browser_person_new_edit_cb: invalid SoylentBrowser "
- "or EContact");
- }
-
- if (retval)
- {
- g_warning ("soylent_browser_person_new_edit_cb: error editing new "
- "Person");
+ g_warning ("invalid SoylentBrowser or EContact");
}
- g_free (pre_person_to_match);
-
g_signal_handlers_disconnect_by_func (book_view,
soylent_browser_person_new_edit_cb,
pre_person_to_match);
+ g_free (pre_person_to_match);
return retval;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]