soylent r46 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r46 - trunk/src
- Date: Sun, 13 Jan 2008 00:54:41 +0000 (GMT)
Author: treitter
Date: Sun Jan 13 00:54:41 2008
New Revision: 46
URL: http://svn.gnome.org/viewvc/soylent?rev=46&view=rev
Log:
Fix some mis-merges in the last commit. *cough*
Modified:
trunk/src/soylent-browser.c
trunk/src/soylent-browser.h
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Sun Jan 13 00:54:41 2008
@@ -939,15 +939,17 @@
return retval;
}
-
/* FIXME: this is vestigial - split it into two functions (show and hide the
* edit window) */
/* Set the main section of the window to browseable icons or a single-person
- * detail editor */
-void
+ * detail editor
+ *
+ * Return TRUE for success, FALSE for any failure */
+gboolean
soylent_browser_view_set_mode (SoylentBrowser *browser,
soylent_browser_people_view_mode mode)
{
+ gboolean retval = FALSE;
GladeXML *wtree = NULL;
GtkWidget *sw_people = NULL;
GtkWidget *window_person_view = NULL;
@@ -957,88 +959,63 @@
GtkWidget *hs_detail_new = NULL;
GtkWidget *btn_detail_add = NULL;
- wtree = browser->main_window;
- 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);
- 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);
- break;
- default:
- g_warning ("should never get here");
- break;
- }
-}
-
-# if 0
-gint
-soylent_browser_person_select (SoylentBrowser *browser, SoylentPerson *person,
- gboolean scroll)
-{
- gint retval = -1;
+ g_return_val_if_fail (browser != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), NULL);
+ */
+ g_return_val_if_fail (SOYLENT_BROWSER_PEOPLE_VIEW_MODE_IS_VALID (mode),
+ retval);
- if (browser)
+ wtree = browser->main_window;
+ if (wtree)
{
- if (person)
- {
- GladeXML *wtree = NULL;
- GtkIconView *iv_people = NULL;
- GtkTreeModel *model = NULL;
- GtkTreePath *path = NULL;
- GtkTreeIter *icon_view_iter = NULL;
-
- wtree = browser->main_window;
- iv_people = GTK_ICON_VIEW (glade_xml_get_widget (wtree, "iv_people"));
- model = gtk_icon_view_get_model (iv_people);
- icon_view_iter = soylent_person_get_icon_view_iter (person);
- path = gtk_tree_model_get_path (model, icon_view_iter);
+ 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");
- gtk_icon_view_select_path (iv_people, path);
+ browser->view_mode = mode;
+ switch (browser->view_mode)
+ {
+ case SB_PEOPLE_VIEW_MODE_BROWSE:
+ gtk_widget_set_sensitive (btn_detail_add, FALSE);
- if (scroll)
- {
- /* minimal-distance scroll; don't bother with alignment */
- gtk_icon_view_scroll_to_path (iv_people, path, FALSE, 0, 0);
+ 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 = 0;
- }
- else
- {
- g_warning ("soylent_browser_person_select: invalid Person");
+ 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_warning ("soylent_browser_person_select: invalid Browser");
+ g_warning ("SoylentBrowser's widget tree is invalid");
}
return retval;
}
-#endif
/* Visually select the given person in the browser's main view.
*
@@ -1118,274 +1095,6 @@
/* Update the visual representation of the given SoylentPerson in the given
* SoylentBrowser */
-#if 0
-gboolean
-soylent_browser_update_person_icon (SoylentBrowser *browser,
- SoylentPerson *person)
-{
- GtkIconView *iconview = NULL;
- GtkListStore *model = NULL;
- const gchar *name_display_base = NULL;
- gchar *name_display_final = NULL;
- const gchar *e_uid = NULL;
- EContactPhoto *photo = NULL;
- GdkPixbuf *avatar_pixbuf = NULL;
- gboolean avatar_pixbuf_needs_unref = FALSE;
- EContact *e_contact = NULL;
- SoylentPresence presence = SP_PRESENCE_UNSET;
- GtkTreeIter *icon_view_iter = NULL;
-
- if (!browser || !person)
- {
- g_warning ("%s:%d: NULL browser or person", __FILE__, __LINE__);
- return FALSE;
- }
-
- e_contact = soylent_person_get_e_contact (person);
- /* FIXME: make sure e_contact is non-NULL, and IS_ECONTACT */
- e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
-
- iconview = GTK_ICON_VIEW (glade_xml_get_widget (browser->main_window,
- "iv_people"));
- g_assert (iconview);
-
- model = GTK_LIST_STORE (gtk_icon_view_get_model (iconview));
- name_display_base = display_name_from_e_contact (e_contact);
-
- presence = soylent_person_get_presence (person);
- switch (presence)
- {
- case SP_PRESENCE_AVAILABLE:
- /* TODO: indicate idleness eventually */
- case SP_PRESENCE_IDLE:
- name_display_final = g_strdup_printf ("%s [*]", name_display_base);
- break;
- case SP_PRESENCE_BUSY:
- /* TODO: indicate idleness eventually */
- case SP_PRESENCE_IDLE_BUSY:
- name_display_final = g_strdup_printf ("%s [...]", name_display_base);
- break;
- case SP_PRESENCE_OFFLINE:
- name_display_final = g_strdup (name_display_base);
- break;
- default:
- name_display_final = g_strdup (name_display_base);
- break;
- }
-
- photo = e_contact_get (e_contact, E_CONTACT_PHOTO);
- if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED)
- {
- avatar_pixbuf = gdk_pixbuf_from_inline_photo (photo,
- browser->icon_width_max,
- browser->icon_height_max);
- }
- else
- {
- GList *live_contacts = NULL;
-
- live_contacts = soylent_person_get_live_contacts (person);
- if (live_contacts)
- {
- GList *c = NULL;
- EmpathyContact *empathy_contact = NULL;
-
- for (c = live_contacts;
- c && c->data && EMPATHY_IS_CONTACT (c->data) && !avatar_pixbuf;
- c = g_list_next (c))
- {
- empathy_contact = EMPATHY_CONTACT (c->data);
- avatar_pixbuf = empathy_pixbuf_avatar_from_contact_scaled
- (empathy_contact,
- browser->icon_width_max,
- browser->icon_height_max);
- }
-
- if (avatar_pixbuf)
- {
- avatar_pixbuf_needs_unref = TRUE;
- }
- }
- }
-
- if (!avatar_pixbuf)
- {
- avatar_pixbuf = browser->icon_stock_person;
- }
-
- icon_view_iter = soylent_person_get_icon_view_iter (person);
- if (icon_view_iter->stamp == SP_ITER_UNSET)
- {
- gtk_list_store_insert_with_values (model, icon_view_iter, 0,
- PEOPLE_COL_NAME, name_display_final,
- 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_final,
- PEOPLE_COL_PHOTO, avatar_pixbuf, -1);
- }
-
- g_free (name_display_final);
-
- if (avatar_pixbuf_needs_unref)
- g_object_unref (avatar_pixbuf);
-
- return TRUE;
-}
-#endif
-
-#if 0
-/* Update the visual representation of the given SoylentPerson in the given
- * SoylentBrowser */
-gboolean
-soylent_browser_update_person_icon (SoylentBrowser *browser,
- SoylentPerson *person)
-{
- GtkIconView *iconview = NULL;
- GtkListStore *model = NULL;
- /*
- const gchar *name_display_base = NULL;
- */
- gchar *name_display = NULL;
- const gchar *e_uid = NULL;
- /*
- EContactPhoto *photo = NULL;
- */
- GdkPixbuf *avatar_pixbuf = NULL;
- /*
- gboolean avatar_pixbuf_needs_unref = FALSE;
- */
- EContact *e_contact = NULL;
- /*
- SoylentPresence presence = SP_PRESENCE_UNSET;
- */
- GtkTreeIter *icon_view_iter = NULL;
-
- if (!browser || !person)
- {
- g_warning ("%s:%d: NULL browser or person", __FILE__, __LINE__);
- return FALSE;
- }
-
- e_contact = soylent_person_get_e_contact (person);
- /* FIXME: make sure e_contact is non-NULL, and IS_ECONTACT */
- e_uid = e_contact_get_const (e_contact, E_CONTACT_UID);
-
- iconview = GTK_ICON_VIEW (glade_xml_get_widget (browser->main_window,
- "iv_people"));
- g_assert (iconview);
-
- model = GTK_LIST_STORE (gtk_icon_view_get_model (iconview));
-
-#if 0
- name_display_base = display_name_from_e_contact (e_contact);
-
- presence = soylent_person_get_presence (person);
- switch (presence)
- {
- case SP_PRESENCE_AVAILABLE:
- /* TODO: indicate idleness eventually */
- case SP_PRESENCE_IDLE:
- name_display_final = g_strdup_printf ("%s [*]", name_display_base);
- break;
- case SP_PRESENCE_BUSY:
- /* TODO: indicate idleness eventually */
- case SP_PRESENCE_IDLE_BUSY:
- name_display_final = g_strdup_printf ("%s [...]", name_display_base);
- break;
- case SP_PRESENCE_OFFLINE:
- name_display_final = g_strdup (name_display_base);
- break;
- default:
- name_display_final = g_strdup (name_display_base);
- break;
- }
-#endif
- name_display = soylent_browser_person_get_display_name_with_presence (person);
-
-#if 0
- photo = e_contact_get (e_contact, E_CONTACT_PHOTO);
- if (photo && photo->type == E_CONTACT_PHOTO_TYPE_INLINED)
- {
- avatar_pixbuf = gdk_pixbuf_from_inline_photo (photo,
- browser->icon_width_max,
- browser->icon_height_max);
- }
- else
- {
- GList *live_contacts = NULL;
-
- live_contacts = soylent_person_get_live_contacts (person);
- if (live_contacts)
- {
- GList *c = NULL;
- EmpathyContact *empathy_contact = NULL;
-
- for (c = live_contacts;
- c && c->data && EMPATHY_IS_CONTACT (c->data) && !avatar_pixbuf;
- c = g_list_next (c))
- {
- empathy_contact = EMPATHY_CONTACT (c->data);
- avatar_pixbuf = empathy_pixbuf_avatar_from_contact_scaled
- (empathy_contact,
- browser->icon_width_max,
- browser->icon_height_max);
- }
-
- if (avatar_pixbuf)
- {
- avatar_pixbuf_needs_unref = TRUE;
- }
- }
- }
-#endif
-
- avatar_pixbuf = soylent_person_get_avatar (person, browser->icon_width_max,
- browser->icon_height_max);
-
- if (!avatar_pixbuf)
- {
- avatar_pixbuf = browser->icon_stock_person;
- }
-
- icon_view_iter = soylent_person_get_icon_view_iter (person);
- if (icon_view_iter->stamp == SP_ITER_UNSET)
- {
- 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);
- */
-
- return TRUE;
-}
-#endif
-
-/* Update the visual representation of the given SoylentPerson in the given
- * SoylentBrowser */
gboolean
soylent_browser_update_person_icon (SoylentBrowser *browser,
SoylentPerson *person)
@@ -1509,117 +1218,6 @@
return retval;
}
-#if 0
-/* FIXME: break this up into multiple functions */
-/* Update the visual representation of the given SoylentPerson in the given
- * SoylentBrowser */
-gboolean
-soylent_browser_update_person_icon (SoylentBrowser *browser,
- SoylentPerson *person)
-{
- gboolean retval = FALSE;
- GtkIconView *icon_view = NULL;
-
- g_return_val_if_fail (browser != NULL, retval);
- /* FIXME: uncomment once SoylentBrowser is a GObject:
- g_return_val_if_fail (SOYLENT_IS_BROWSER (browser), NULL);
- */
- g_return_val_if_fail (person != NULL, retval);
- /* FIXME: uncomment once SoylentPerson is a GObject:
- g_return_val_if_fail (SOYLENT_IS_PERSON (person), NULL);
- */
-
- icon_view = GTK_ICON_VIEW (glade_xml_get_widget (browser->main_window,
- "iv_people"));
- if (icon_view && GTK_IS_ICON_VIEW (icon_view))
- {
- GtkListStore *model = NULL;
-
- model = GTK_LIST_STORE (gtk_icon_view_get_model (icon_view));
- if (model)
- {
- gchar *name_display = NULL;
-
- name_display = soylent_browser_person_get_display_name_with_presence
- (person);
- if (name_display)
- {
- EContact *e_contact = NULL;
-
- e_contact = soylent_person_get_e_contact (person);
- if (e_contact && E_IS_CONTACT (e_contact))
- {
- const gchar *e_uid = NULL;
- GdkPixbuf *avatar_pixbuf = NULL;
- GtkTreeIter *icon_view_iter = NULL;
- avatar_pixbuf = soylent_person_get_avatar
- (person,
- browser->icon_width_max,
- browser->icon_height_max);
- if (!avatar_pixbuf)
- {
- avatar_pixbuf = browser->icon_stock_person;
- }
-
- icon_view_iter = soylent_person_get_icon_view_iter (person);
- if (icon_view_iter->stamp == SP_ITER_UNSET)
- {
- 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);
- }
-
- /* FIXME: handle this memory management logic somewhere */
-#if 0
- if (avatar_pixbuf_needs_unref)
- {
- g_object_unref (avatar_pixbuf);
- }
-#endif
- g_free (name_display);
-
- retval = TRUE;
- }
- else
- {
- g_warning ("person's EContact is invalid");
- }
- }
- else
- {
- g_warning ("failed to get display name for person");
- }
- }
- else
- {
- g_warning ("main icon view's model is invalid");
- }
- }
- else
- {
- g_warning ("failed to get main icon view widget");
- }
-
- return retval;
-}
-#endif
-
-
/* Union the given group with the SoylentBrowser's current set of groups */
void
soylent_browser_check_add_group (SoylentBrowser *browser, const gchar *group)
Modified: trunk/src/soylent-browser.h
==============================================================================
--- trunk/src/soylent-browser.h (original)
+++ trunk/src/soylent-browser.h Sun Jan 13 00:54:41 2008
@@ -48,6 +48,11 @@
#include <libempathy/empathy-contact-list.h>
#include <libempathy-gtk/empathy-ui-utils.h>
+#define SOYLENT_BROWSER_PEOPLE_VIEW_MODE_IS_VALID(x) \
+ (1 \
+ && ((x) > FIRST_SB_PEOPLE_VIEW_MODE) \
+ && ((x) < LAST_SB_PEOPLE_VIEW_MODE))
+
typedef struct SoylentBrowser_tag SoylentBrowser;
typedef enum soylent_browser_people_view_mode_tag
soylent_browser_people_view_mode;
@@ -132,8 +137,8 @@
void soylent_browser_check_add_group (SoylentBrowser *browser,
const gchar *group);
void soylent_browser_update_view (SoylentBrowser *browser);
-void soylent_browser_view_set_mode (SoylentBrowser *browser,
- soylent_browser_people_view_mode mode);
+gboolean soylent_browser_view_set_mode (SoylentBrowser *browser,
+ soylent_browser_people_view_mode mode);
gboolean soylent_browser_person_select (SoylentBrowser *browser,
SoylentPerson *person,
gboolean scroll);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]