soylent r88 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r88 - trunk/src
- Date: Sun, 2 Mar 2008 21:30:52 +0000 (GMT)
Author: treitter
Date: Sun Mar 2 21:30:52 2008
New Revision: 88
URL: http://svn.gnome.org/viewvc/soylent?rev=88&view=rev
Log:
>From now on, assume that if we can load the Glade file, glade_xml_get_widget() will always succeed (assuming we gave a valid widget name). This simplifies a lot of the code
Modified:
trunk/src/soylent-browser-person-view.c
trunk/src/soylent-browser-person-view.h
trunk/src/soylent-browser.c
Modified: trunk/src/soylent-browser-person-view.c
==============================================================================
--- trunk/src/soylent-browser-person-view.c (original)
+++ trunk/src/soylent-browser-person-view.c Sun Mar 2 21:30:52 2008
@@ -166,7 +166,6 @@
{
gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
- GladeXML *wtree = NULL;
const GList *i = NULL;
GList *e_uids = NULL;
@@ -204,22 +203,18 @@
}
}
- /* Hide the "Delete person?" dialog whether or not we actually deleted them;
- * it shouldn't stick around (especially since it's modal) */
- wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- GtkWidget *dia_delete_person_confirm = NULL;
+ /* Hide the "Delete person?" dialog whether or not we actually deleted them;
+ * it shouldn't stick around (especially since it's modal) */
+ {
+ GladeXML *wtree = NULL;
+ GtkWidget *dia_delete_person_confirm = NULL;
- dia_delete_person_confirm = glade_xml_get_widget
+ wtree = soylent_browser_get_widget_tree (browser);
+ dia_delete_person_confirm = glade_xml_get_widget
(wtree,
"dia_delete_person_confirm");
- gtk_widget_hide (dia_delete_person_confirm);
- }
- else
- {
- g_critical ("failed to get 'Delete person?' dialog widget\n");
- }
+ gtk_widget_hide (dia_delete_person_confirm);
+ }
g_list_free (e_uids);
@@ -243,25 +238,10 @@
browser = (SoylentBrowser*) user_data;
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- dia_delete_person_confirm = glade_xml_get_widget
- (wtree,
- "dia_delete_person_confirm");
- if (dia_delete_person_confirm
- && GTK_IS_DIALOG (dia_delete_person_confirm))
- {
- gtk_widget_show (dia_delete_person_confirm);
- }
- else
- {
- g_critical ("failed to get 'Delete person?' dialog widget");
- }
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
- }
+ dia_delete_person_confirm = glade_xml_get_widget
+ (wtree,
+ "dia_delete_person_confirm");
+ gtk_widget_show (dia_delete_person_confirm);
return retval;
}
@@ -277,24 +257,18 @@
gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
GladeXML *wtree = NULL;
+ GtkWidget *dia_delete_person = NULL;
g_return_val_if_fail (user_data != NULL, retval);
/* FIXME: when SoylentBrowser is a GObject, check SOYLENT_IS_BROWSER */
browser = (SoylentBrowser*) user_data;
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- GtkWidget *dia_delete_person = NULL;
- dia_delete_person = glade_xml_get_widget (wtree,
- "dia_delete_person_confirm");
- if (dia_delete_person)
- {
- gtk_widget_hide (dia_delete_person);
- retval = TRUE;
- }
- }
+ dia_delete_person = glade_xml_get_widget (wtree, "dia_delete_person_confirm");
+ gtk_widget_hide (dia_delete_person);
+
+ retval = TRUE;
return retval;
}
@@ -421,25 +395,10 @@
*/
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- btntb = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree,
- "btntb_email"));
- if (btntb && GTK_IS_MENU_TOOL_BUTTON (btntb))
- {
- retval = soylent_browser_person_action_email_menu_tool_button_cb
- (btntb,
- browser);
- }
- else
- {
- g_critical ("failed to get the Email button widget");
- }
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
- }
+
+ btntb = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree, "btntb_email"));
+ retval = soylent_browser_person_action_email_menu_tool_button_cb (btntb,
+ browser);
return retval;
}
@@ -482,24 +441,9 @@
*/
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- btntb = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree, "btntb_chat"));
- if (btntb && GTK_IS_MENU_TOOL_BUTTON (btntb))
- {
- retval = soylent_browser_person_action_chat_menu_tool_button_cb
- (btntb,
- browser);
- }
- else
- {
- g_critical ("failed to get the Chat button widget");
- }
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
- }
+ btntb = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree, "btntb_chat"));
+ retval = soylent_browser_person_action_chat_menu_tool_button_cb (btntb,
+ browser);
return retval;
}
@@ -528,19 +472,12 @@
*/
wtree = soylent_browser_get_widget_tree (browser);
- g_return_val_if_fail (wtree != NULL, retval);
- g_return_val_if_fail (GLADE_IS_XML (wtree), retval);
-
btn_delete_people = glade_xml_get_widget (wtree, "btn_delete_people");
btn_edit_person = glade_xml_get_widget (wtree, "btn_edit_person");
btntb_email = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree,
"btntb_email"));
btntb_chat = GTK_MENU_TOOL_BUTTON (glade_xml_get_widget (wtree,
"btntb_chat"));
- g_return_val_if_fail (btn_delete_people != NULL, retval);
- g_return_val_if_fail (btn_edit_person != NULL, retval);
- g_return_val_if_fail (btntb_email != NULL, retval);
- g_return_val_if_fail (btntb_chat != NULL, retval);
selected_people = gtk_icon_view_get_selected_items (iv);
if (selected_people && selected_people->data)
@@ -623,48 +560,56 @@
return retval;
}
-/* Create a new SoylentPerson and matching EContact in e-d-s */
-int
+/* Create a new SoylentPerson and matching EContact in e-d-s
+ *
+ * Return TRUE for success, FALSE for any failure. */
+gboolean
soylent_browser_person_action_new_person_cb (GtkButton *btn, gpointer user_data)
{
- int retval = -1;
+ gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
- GError *error_add = NULL;
GladeXML *wtree = NULL;
GtkIconView *iv_people = NULL;
- browser = (SoylentBrowser *) user_data;
+ g_return_val_if_fail (user_data != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (user_data), NULL);
+ */
+
+ browser = (SoylentBrowser*) user_data;
wtree = soylent_browser_get_widget_tree (browser);
- iv_people = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
+ iv_people = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
gtk_icon_view_unselect_all (iv_people);
#ifdef HAVE_CONTACTS_APP
{
gchar *command_line = NULL;
+ GError *error_add = NULL;
command_line = g_strdup_printf ("contacts --new-contact");
g_spawn_command_line_async (command_line, &error_add);
- if (error_add)
+ if (!error_add)
{
- g_warning ("Failed to launch Contacts to add a new Person: %s",
- error_add->message);
- g_clear_error (&error_add);
+ retval = TRUE;
}
else
{
- retval = 0;
+ g_warning ("Failed to launch Contacts to add a new Person: %s",
+ error_add->message);
+ g_clear_error (&error_add);
}
g_free (command_line);
}
#else
{
- EBook *e_book = NULL;
+ EBook *e_book = NULL;
EBookView *e_book_view = NULL;
EContact *e_contact = NULL;
cb_data_pre_person *pre_person_to_match = NULL;
+ GError *error_add = NULL;
e_book = soylent_browser_get_e_book (browser);
e_book_view = soylent_browser_get_e_book_view (browser);
@@ -683,18 +628,18 @@
G_CALLBACK (soylent_browser_person_new_edit_cb),
pre_person_to_match);
- if (!e_book_add_contact (e_book, e_contact, &error_add))
+ if (e_book_add_contact (e_book, e_contact, &error_add))
{
- g_warning ("Failed to create a new contact: %s", error_add->message);
- g_clear_error (&error_add);
+ retval = TRUE;
}
else
{
- retval = 0;
+ g_warning ("Failed to create a new contact: %s", error_add->message);
+ g_clear_error (&error_add);
}
}
#endif /* HAVE_CONTACTS_APP */
-
+
return retval;
}
@@ -747,8 +692,9 @@
GtkComboBox *cbox_type_phone = NULL;
gchar *param_val_lc = NULL;
- cbox_type_phone = GTK_COMBO_BOX (glade_xml_get_widget (wtree,
- "cbox_detail_type_phone"));
+ cbox_type_phone = GTK_COMBO_BOX (glade_xml_get_widget
+ (wtree,
+ "cbox_detail_type_phone"));
param_val_lc = gtk_combo_box_get_active_text (cbox_type_phone);
param_val = g_ascii_strup (param_val_lc, -1);
@@ -770,8 +716,9 @@
gchar *param_val_menu = NULL;
guint i;
- cbox_type_web = GTK_COMBO_BOX (glade_xml_get_widget (wtree,
- "cbox_detail_type_web"));
+ cbox_type_web = GTK_COMBO_BOX (glade_xml_get_widget
+ (wtree,
+ "cbox_detail_type_web"));
param_val_menu = gtk_combo_box_get_active_text (cbox_type_web);
for (i = 0; menu_strs[i] != NULL; i++)
@@ -839,8 +786,13 @@
gboolean
cbox_detail_add_setup (SoylentBrowser *browser)
{
+ const gchar *cbox_names[] = {"cbox_detail_domain", "cbox_detail_proto",
+ "cbox_detail_type", "cbox_detail_type_phone",
+ "cbox_detail_type_web",};
gboolean retval = FALSE;
GladeXML *wtree = NULL;
+ GtkComboBox *cbox_cur = NULL;
+ guint i = 0;
g_return_val_if_fail (browser != NULL, retval);
/* FIXME: uncomment once SoylentBrowser is a GObject:
@@ -851,33 +803,21 @@
retval = TRUE;
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
+
+ /* Glade lets us set these values, but they aren't honored */
+ for (i = 0; i < (sizeof (cbox_names) / sizeof (const gchar*)); i++)
{
- const gchar *cbox_names[] = {"cbox_detail_domain", "cbox_detail_proto",
- "cbox_detail_type", "cbox_detail_type_phone",
- "cbox_detail_type_web",};
- GtkComboBox *cbox_cur = NULL;
- guint i = 0;
-
- /* Glade lets us set these values, but they aren't honored */
- for (i = 0; i < (sizeof (cbox_names) / sizeof (const gchar*)); i++)
- {
- cbox_cur = GTK_COMBO_BOX (glade_xml_get_widget (wtree,
- cbox_names[i]));
- if (cbox_cur && GTK_IS_COMBO_BOX (cbox_cur))
- {
- gtk_combo_box_set_active(cbox_cur, 0);
- }
- else
- {
- g_critical ("failed to get combo box widget: %s", cbox_names[i]);
- retval = FALSE;
- }
+ cbox_cur = GTK_COMBO_BOX (glade_xml_get_widget (wtree,
+ cbox_names[i]));
+ if (cbox_cur && GTK_IS_COMBO_BOX (cbox_cur))
+ {
+ gtk_combo_box_set_active(cbox_cur, 0);
+ }
+ else
+ {
+ g_critical ("failed to get combo box widget: %s", cbox_names[i]);
+ retval = FALSE;
}
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
}
return retval;
@@ -1022,15 +962,9 @@
*/
wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
- {
- window_person_view = (glade_xml_get_widget (wtree, "window_person_view"));
- if (window_person_view && GTK_IS_WIDGET (window_person_view))
- {
- gtk_widget_hide (window_person_view);
- retval = TRUE;
- }
- }
+ window_person_view = (glade_xml_get_widget (wtree, "window_person_view"));
+ gtk_widget_hide (window_person_view);
+ retval = TRUE;
return retval;
}
Modified: trunk/src/soylent-browser-person-view.h
==============================================================================
--- trunk/src/soylent-browser-person-view.h (original)
+++ trunk/src/soylent-browser-person-view.h Sun Mar 2 21:30:52 2008
@@ -37,7 +37,7 @@
gboolean soylent_browser_person_view_save_finalize_cb (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
-int soylent_browser_person_action_new_person_cb (GtkButton *btn,
+gboolean soylent_browser_person_action_new_person_cb (GtkButton *btn,
gpointer user_data);
gboolean soylent_browser_person_action_delete_selected_cb (GtkButton *btn,
gpointer user_data);
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Sun Mar 2 21:30:52 2008
@@ -357,34 +357,28 @@
g_return_val_if_fail (type_data != NULL, retval);
g_return_val_if_fail (context != NULL, retval);
- wtree = soylent_browser_get_widget_tree (browser);
- if (wtree && GLADE_IS_XML (wtree))
+ wtree = browser->main_window;
+
+ if (subcontext)
{
- if (subcontext)
- {
- widget_str = g_strdup_printf ("%s_person_%s_%s_%s", type_widget,
- type_data, context, subcontext);
- }
- else
- {
- widget_str = g_strdup_printf ("%s_person_%s_%s", type_widget,
- type_data, context);
- }
+ widget_str = g_strdup_printf ("%s_person_%s_%s_%s", type_widget,
+ type_data, context, subcontext);
+ }
+ else
+ {
+ widget_str = g_strdup_printf ("%s_person_%s_%s", type_widget,
+ type_data, context);
+ }
- if (widget_str)
- {
- retval = glade_xml_get_widget (wtree, widget_str);
+ if (widget_str)
+ {
+ retval = glade_xml_get_widget (wtree, widget_str);
- g_free (widget_str);
- }
- else
- {
- g_warning ("failed to allocate a widget string");
- }
+ g_free (widget_str);
}
else
{
- g_critical ("SoylentBrowser's widget tree is invalid");
+ g_warning ("failed to allocate a widget string");
}
return retval;
@@ -513,38 +507,23 @@
*/
wtree = browser->main_window;
- if (wtree && GLADE_IS_XML (wtree))
+ icon_view = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
+ selected_people = gtk_icon_view_get_selected_items (icon_view);
+ /* TODO: use gtk_icon_view_selected_foreach () */
+ for (i = 0, l = selected_people; l != NULL; l = g_list_next (l))
{
- icon_view = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
- if (icon_view)
- {
- selected_people = gtk_icon_view_get_selected_items (icon_view);
+ GtkTreePath *path = NULL;
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+ gchar *e_uid = NULL;
- /* TODO: use gtk_icon_view_selected_foreach () */
- for (i = 0, l = selected_people; l != NULL; l = g_list_next (l))
- {
- GtkTreePath *path = NULL;
- GtkTreeModel *model = NULL;
- GtkTreeIter iter;
- gchar *e_uid = NULL;
+ path = (GtkTreePath *) l->data;
+ model = gtk_icon_view_get_model(icon_view);
- path = (GtkTreePath *) l->data;
- model = gtk_icon_view_get_model(icon_view);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, PEOPLE_COL_UID, &e_uid, -1);
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, PEOPLE_COL_UID, &e_uid, -1);
-
- retval = g_list_prepend (retval, g_strdup (e_uid));
- }
- }
- else
- {
- g_critical ("failed to get main icon view widget");
- }
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
+ retval = g_list_prepend (retval, g_strdup (e_uid));
}
return retval;
@@ -614,6 +593,8 @@
GladeXML *wtree = NULL;
GtkTreeIter iter;
gchar *e_uid = NULL;
+ GtkIconView *icon_view = NULL;
+ GList *selected_people = NULL;
g_return_val_if_fail (browser != NULL, retval);
/* FIXME: uncomment once SoylentBrowser is a GObject:
@@ -621,59 +602,40 @@
*/
wtree = browser->main_window;
- if (wtree && GLADE_IS_XML (wtree))
+ icon_view = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
+ selected_people = gtk_icon_view_get_selected_items (icon_view);
+ if (selected_people)
{
- GtkIconView *icon_view = NULL;
+ GtkTreePath *path = NULL;
- icon_view = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
- if (icon_view && GTK_IS_ICON_VIEW (icon_view))
+ path = (GtkTreePath*) selected_people->data;
+ if (path)
{
- GList *selected_people = NULL;
+ GtkTreeModel *model = NULL;
- selected_people = gtk_icon_view_get_selected_items (icon_view);
- if (selected_people)
+ model = gtk_icon_view_get_model (icon_view);
+ if (model)
{
- GtkTreePath *path = NULL;
-
- path = (GtkTreePath*) selected_people->data;
- if (path)
- {
- GtkTreeModel *model = NULL;
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_model_get (model, &iter, PEOPLE_COL_UID, &e_uid, -1);
- model = gtk_icon_view_get_model (icon_view);
- if (model)
- {
- gtk_tree_model_get_iter (model, &iter, path);
- gtk_tree_model_get (model, &iter, PEOPLE_COL_UID, &e_uid,
- -1);
-
- /* FIXME: this doesn't distinguish between memory
- * allocation failure and the "nobody is selected" case */
- retval = g_strdup (e_uid);
- if (!retval)
- {
- g_warning ("failed to duplicate person's e-d-s UID");
- }
- }
- }
- else
+ /* FIXME: this doesn't distinguish between memory allocation
+ * failure and the "nobody is selected" case */
+ retval = g_strdup (e_uid);
+ if (!retval)
{
- g_warning ("selected people have a NULL GtkTreePath");
+ g_warning ("failed to duplicate person's e-d-s UID");
}
}
- else
- {
- /* nobody is selected */
- }
}
else
{
- g_critical ("main icon view widget is invalid");
+ g_warning ("selected people have a NULL GtkTreePath");
}
}
else
{
- g_critical ("SoylentBrowser's widget tree is invalid");
+ /* nobody is selected */
}
return retval;
@@ -1023,51 +985,41 @@
retval);
wtree = browser->main_window;
- if (wtree && GLADE_IS_XML (wtree))
- {
- sw_people = glade_xml_get_widget (wtree, "sw_people");
- window_person_view = glade_xml_get_widget (wtree, "window_person_view");
- img_person_view = glade_xml_get_widget (wtree, "img_person_view");
- icon_entry_person = glade_xml_get_widget (wtree, "icon_entry_person");
- hbox_detail_new = glade_xml_get_widget (wtree, "hbox_detail_new");
- hs_detail_new = glade_xml_get_widget (wtree, "hs_detail_new");
- btn_detail_add = glade_xml_get_widget (wtree, "btn_detail_add");
-
- browser->view_mode = mode;
- switch (browser->view_mode)
- {
- case SB_PEOPLE_VIEW_MODE_BROWSE:
- gtk_widget_set_sensitive (btn_detail_add, FALSE);
-
- gtk_widget_show (sw_people);
- gtk_widget_hide (window_person_view);
-
- retval = TRUE;
- break;
- case SB_PEOPLE_VIEW_MODE_EDIT:
- /*
- gtk_widget_hide (sw_people);
- */
- gtk_widget_show (window_person_view);
- gtk_widget_show (img_person_view);
-
- gtk_widget_hide (icon_entry_person);
- gtk_widget_show (hbox_detail_new);
- gtk_widget_show (hs_detail_new);
-
- retval = TRUE;
- break;
- default:
- /* the g_return_val_if_fail() mode check above should prevent us
- * from reaching this block */
- g_warning ("invalid SoylentBrowser mode (you should never get this "
- "warning)");
- break;
- }
- }
- else
- {
- g_critical ("SoylentBrowser's widget tree is invalid");
+ sw_people = glade_xml_get_widget (wtree, "sw_people");
+ window_person_view = glade_xml_get_widget (wtree, "window_person_view");
+ img_person_view = glade_xml_get_widget (wtree, "img_person_view");
+ icon_entry_person = glade_xml_get_widget (wtree, "icon_entry_person");
+ hbox_detail_new = glade_xml_get_widget (wtree, "hbox_detail_new");
+ hs_detail_new = glade_xml_get_widget (wtree, "hs_detail_new");
+ btn_detail_add = glade_xml_get_widget (wtree, "btn_detail_add");
+
+ browser->view_mode = mode;
+ switch (browser->view_mode)
+ {
+ case SB_PEOPLE_VIEW_MODE_BROWSE:
+ gtk_widget_set_sensitive (btn_detail_add, FALSE);
+
+ gtk_widget_show (sw_people);
+ gtk_widget_hide (window_person_view);
+
+ retval = TRUE;
+ break;
+ case SB_PEOPLE_VIEW_MODE_EDIT:
+ gtk_widget_show (window_person_view);
+ gtk_widget_show (img_person_view);
+
+ gtk_widget_hide (icon_entry_person);
+ gtk_widget_show (hbox_detail_new);
+ gtk_widget_show (hs_detail_new);
+
+ retval = TRUE;
+ break;
+ default:
+ /* the g_return_val_if_fail() mode check above should prevent us from
+ * reaching this block */
+ g_warning ("invalid SoylentBrowser mode (you should never get this "
+ "warning)");
+ break;
}
return retval;
@@ -1082,6 +1034,8 @@
{
gboolean retval = FALSE;
GladeXML *wtree = NULL;
+ GtkIconView *iv_people = NULL;
+ GtkTreeModel *model = NULL;
g_return_val_if_fail (browser != NULL, retval);
/* FIXME: uncomment once SoylentBrowser is a GObject:
@@ -1093,57 +1047,38 @@
*/
wtree = browser->main_window;
- if (wtree && GLADE_IS_XML (wtree))
+ iv_people = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
+ model = gtk_icon_view_get_model (iv_people);
+ if (model)
{
- GtkIconView *iv_people = NULL;
+ GtkTreeIter *icon_view_iter = NULL;
- iv_people = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
- if (iv_people && GTK_IS_ICON_VIEW (iv_people))
+ icon_view_iter = soylent_person_get_icon_view_iter (person);
+ if (icon_view_iter)
{
- GtkTreeModel *model = NULL;
-
- model = gtk_icon_view_get_model (iv_people);
- if (model)
- {
- GtkTreeIter *icon_view_iter = NULL;
-
- icon_view_iter = soylent_person_get_icon_view_iter (person);
- if (icon_view_iter)
- {
- GtkTreePath *path = NULL;
-
- path = gtk_tree_model_get_path (model, icon_view_iter);
- gtk_icon_view_select_path (iv_people, path);
-
- if (scroll)
- {
- /* minimal-distance scroll; don't bother with alignment */
- gtk_icon_view_scroll_to_path (iv_people, path, FALSE, 0,
- 0);
- }
+ GtkTreePath *path = NULL;
- gtk_tree_path_free (path);
+ path = gtk_tree_model_get_path (model, icon_view_iter);
+ gtk_icon_view_select_path (iv_people, path);
- retval = TRUE;
- }
- else
- {
- g_critical ("icon view iterator is NULL");
- }
- }
- else
+ if (scroll)
{
- g_critical ("icon view's model is NULL");
+ /* minimal-distance scroll; don't bother with alignment */
+ gtk_icon_view_scroll_to_path (iv_people, path, FALSE, 0, 0);
}
+
+ gtk_tree_path_free (path);
+
+ retval = TRUE;
}
else
{
- g_critical ("SoylentBrowser's main icon view is invalid");
+ g_critical ("icon view iterator is NULL");
}
}
else
{
- g_critical ("SoylentBrowser's widget tree is invalid");
+ g_critical ("icon view's model is NULL");
}
return retval;
@@ -1159,6 +1094,7 @@
{
gboolean retval = FALSE;
GtkIconView *icon_view = NULL;
+ GtkListStore *model = NULL;
g_return_val_if_fail (browser != NULL, retval);
/* FIXME: uncomment once SoylentBrowser is a GObject:
@@ -1170,107 +1106,95 @@
*/
icon_view = GTK_ICON_VIEW (glade_xml_get_widget (browser->main_window,
- "iv_people"));
- if (icon_view && GTK_IS_ICON_VIEW (icon_view))
+ "iv_people"));
+ model = GTK_LIST_STORE (gtk_icon_view_get_model (icon_view));
+ if (model)
{
- GtkListStore *model = NULL;
+ gchar *name_display = NULL;
- model = GTK_LIST_STORE (gtk_icon_view_get_model (icon_view));
- if (model)
+ name_display = soylent_person_get_display_name_with_presence (person);
+ if (name_display)
{
- gchar *name_display = NULL;
+ EContact *e_contact = NULL;
- name_display = soylent_person_get_display_name_with_presence (person);
- if (name_display)
+ e_contact = soylent_person_get_e_contact (person);
+ if (e_contact && E_IS_CONTACT (e_contact))
{
- EContact *e_contact = NULL;
+ const gchar *e_uid = NULL;
- e_contact = soylent_person_get_e_contact (person);
- if (e_contact && E_IS_CONTACT (e_contact))
+ e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
+ if (e_uid)
{
- const gchar *e_uid = NULL;
+ GdkPixbuf *avatar_pixbuf = NULL;
+ GtkTreeIter *icon_view_iter = NULL;
- e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
- if (e_uid)
- {
- GdkPixbuf *avatar_pixbuf = NULL;
- GtkTreeIter *icon_view_iter = NULL;
-
- avatar_pixbuf = soylent_person_get_avatar
+ avatar_pixbuf = soylent_person_get_avatar
(person,
browser->icon_width_max,
browser->icon_height_max);
- if (!avatar_pixbuf)
- {
- avatar_pixbuf = browser->icon_stock_person;
- }
+ if (!avatar_pixbuf)
+ {
+ avatar_pixbuf = browser->icon_stock_person;
+ }
- icon_view_iter = soylent_person_get_icon_view_iter
- (person);
- if (icon_view_iter)
+ icon_view_iter = soylent_person_get_icon_view_iter (person);
+ if (icon_view_iter)
+ {
+ if (icon_view_iter->stamp == SP_ITER_UNSET)
{
- if (icon_view_iter->stamp == SP_ITER_UNSET)
- {
- gtk_list_store_insert_with_values
+ gtk_list_store_insert_with_values
(model, icon_view_iter, 0,
PEOPLE_COL_NAME, name_display,
PEOPLE_COL_UID, e_uid,
PEOPLE_COL_PHOTO, avatar_pixbuf,
-1);
- }
- else
- {
- gtk_list_store_set
- (model, icon_view_iter,
- /* XXX - for some reason, if we
- * don't set the uid here again,
- * the UID stored can get
- * corrupted */
- PEOPLE_COL_UID, e_uid,
- PEOPLE_COL_NAME, name_display,
- PEOPLE_COL_PHOTO, avatar_pixbuf,
- -1);
- }
-
- g_free (name_display);
-
- /* FIXME: handle this memory management */
- /*
- if (avatar_pixbuf_needs_unref)
- g_object_unref (avatar_pixbuf);
- */
- retval = TRUE;
}
else
{
- g_critical ("failed to get main icon view's "
- "iterator");
+ gtk_list_store_set (model, icon_view_iter,
+ /* XXX - for some reason, if we
+ * don't set the uid here again,
+ * the UID stored can get corrupted
+ * */
+ PEOPLE_COL_UID, e_uid,
+ PEOPLE_COL_NAME, name_display,
+ PEOPLE_COL_PHOTO, avatar_pixbuf,
+ -1);
}
+
+ g_free (name_display);
+
+ /* FIXME: handle this memory management */
+ /*
+ if (avatar_pixbuf_needs_unref)
+ g_object_unref (avatar_pixbuf);
+ */
+ retval = TRUE;
}
else
{
- g_warning ("failed to get EContact's UID");
+ g_critical ("failed to get main icon view's iterator");
}
}
else
{
- g_warning ("person's EContact is invalid");
+ g_warning ("failed to get EContact's UID");
}
}
else
{
- g_warning ("failed to get display name for person");
+ g_warning ("person's EContact is invalid");
}
}
else
{
- g_critical ("main icon view's model is invalid");
+ g_warning ("failed to get display name for person");
}
}
else
{
- g_critical ("failed to get main icon view widget");
+ g_critical ("main icon view's model is invalid");
}
return retval;
@@ -1534,6 +1458,7 @@
{
gboolean retval = FALSE;
GladeXML *wtree = NULL;
+ GtkListStore *list_store = NULL;
g_return_val_if_fail (browser != NULL, retval);
/* FIXME: uncomment once SoylentBrowser is a GObject:
@@ -1541,63 +1466,46 @@
*/
wtree = browser->main_window;
- if (wtree && GLADE_IS_XML (wtree))
+
+ list_store = gtk_list_store_new (NUM_PEOPLE_COLS, G_TYPE_STRING,
+ G_TYPE_STRING, GDK_TYPE_PIXBUF);
+ if (list_store && GTK_IS_LIST_STORE (list_store))
{
+ GtkComboBox *cbox_presence = NULL;
GtkIconView *icon_view = NULL;
icon_view = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
- if (icon_view && GTK_IS_ICON_VIEW (icon_view))
- {
- GtkListStore *list_store = NULL;
-
- list_store = gtk_list_store_new (NUM_PEOPLE_COLS, G_TYPE_STRING,
- G_TYPE_STRING, GDK_TYPE_PIXBUF);
- if (list_store && GTK_IS_LIST_STORE (list_store))
- {
- GtkComboBox *cbox_presence = NULL;
- /* Configure the main icon view */
- gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (list_store));
- gtk_icon_view_set_text_column (icon_view, PEOPLE_COL_NAME);
- gtk_icon_view_set_pixbuf_column (icon_view, PEOPLE_COL_PHOTO);
- gtk_tree_sortable_set_sort_column_id
- ((GtkTreeSortable*) list_store,
- PEOPLE_COL_NAME,
- GTK_SORT_ASCENDING);
- gtk_tree_sortable_set_sort_func
+ /* Configure the main icon view */
+ gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (list_store));
+ gtk_icon_view_set_text_column (icon_view, PEOPLE_COL_NAME);
+ gtk_icon_view_set_pixbuf_column (icon_view, PEOPLE_COL_PHOTO);
+ gtk_tree_sortable_set_sort_column_id ((GtkTreeSortable*) list_store,
+ PEOPLE_COL_NAME,
+ GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_func
((GtkTreeSortable*) list_store,
PEOPLE_COL_NAME,
soylent_browser_compare_people_by_icon_iter,
NULL, NULL);
-
- /* XXX - Glade lets us set these values, but they aren't honored
- * */
- cbox_presence = GTK_COMBO_BOX (glade_xml_get_widget
- (wtree, "cbox_presence"));
- if (cbox_presence && GTK_IS_COMBO_BOX (cbox_presence))
- {
- gtk_combo_box_set_active (cbox_presence, 0);
+
+ /* XXX - Glade lets us set these values, but they aren't honored */
+ cbox_presence = GTK_COMBO_BOX (glade_xml_get_widget (wtree,
+ "cbox_presence"));
+ if (cbox_presence && GTK_IS_COMBO_BOX (cbox_presence))
+ {
+ gtk_combo_box_set_active (cbox_presence, 0);
- retval = cbox_detail_add_setup (browser);
- }
- else
- {
- g_critical ("failed to get presence combo box");
- }
- }
- else
- {
- g_critical ("failed to allocate memory");
- }
+ retval = cbox_detail_add_setup (browser);
}
else
{
- g_critical ("failed to get main icon view widget");
+ g_critical ("failed to get presence combo box");
}
}
else
{
- g_critical ("SoylentBrowser's widget tree is invalid");
+ g_critical ("failed to allocate memory");
}
return retval;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]