soylent r101 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r101 - trunk/src
- Date: Sat, 15 Mar 2008 04:37:52 +0000 (GMT)
Author: treitter
Date: Sat Mar 15 04:37:51 2008
New Revision: 101
URL: http://svn.gnome.org/viewvc/soylent?rev=101&view=rev
Log:
clean up soylent_browser_person_selected_chat_menu_update_cb(); add soylent_browser_get_selected_people()
Modified:
trunk/src/soylent-browser-person-view.c
trunk/src/soylent-browser.c
trunk/src/soylent-browser.h
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:37:51 2008
@@ -1418,7 +1418,7 @@
return retval;
}
-/* Fill the Email action MenuToolButton's menu based on the selected person
+/* Fill the Email action MenuToolButton's menu based on the selected people
*
* Return TRUE for success, FALSE for any failure. */
static gboolean
@@ -1490,7 +1490,7 @@
return retval;
}
-/* Fill the Chat action MenuToolButton's menu based on the selected person
+/* Fill the Chat action MenuToolButton's menu based on the selected people
*
* Return TRUE for success, FALSE for any failure. */
static gboolean
@@ -1500,81 +1500,67 @@
{
gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
- const GList *people = NULL;
- const GList *live_contacts = NULL;
GtkMenu *menu_chat = NULL;
- EmpathyContact *live_contact_cur = NULL;
- SoylentPerson *person = NULL;
+ GList *people = NULL;
+
+ 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), retval);
+ */
- g_return_val_if_fail (btntb_chat != NULL, retval);
+ browser = (SoylentBrowser*) user_data;
menu_chat = GTK_MENU (gtk_menu_tool_button_get_menu (btntb_chat));
- browser = (SoylentBrowser *) user_data;
- people = soylent_browser_get_selected_people_e_contact (browser);
+ /* Clear out the menutoolbutton's pull-down menu and make it insensitive */
+ gtk_container_foreach (GTK_CONTAINER (menu_chat),
+ (GtkCallback) (gtk_widget_destroy), NULL);
+ gtk_widget_set_sensitive (GTK_WIDGET (btntb_chat), FALSE);
+
+ /* TODO: support multiple people */
+ people = soylent_browser_get_selected_people (browser);
if (people)
{
- /* FIXME: we don't handle multi-person chat correctly now, so we just
- * leave the menutoolbutton empty */
if (!g_list_next (people))
{
- if (people->data)
- {
- person = soylent_browser_get_person_from_e_contact (browser,
- E_CONTACT (people->data));
- }
+ SoylentPerson *person = NULL;
- if (!person)
+ person = people->data;
+ if (person)
{
- /* FIXME: set retval as appropriate instead */
- return TRUE;
+ const GList *live_contacts = NULL;
+ EmpathyContact *live_contact_cur = NULL;
+
+
+ /* FIXME: this needs to be sync'd for presence updates, and must
+ * only contain online IM names */
+ for (live_contacts = soylent_person_get_live_contacts (person);
+ live_contacts && (live_contact_cur = live_contacts->data);
+ live_contacts = g_list_next (live_contacts))
+ {
+ GtkWidget *item = NULL;
+
+ item = gtk_menu_item_new_with_label
+ (empathy_contact_get_id (live_contact_cur));
+ g_signal_connect
+ (G_OBJECT (item), "activate",
+ G_CALLBACK
+ (soylent_browser_person_action_chat_menu_item_cb),
+ browser);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu_chat), item);
+ gtk_widget_show (GTK_WIDGET (item));
+ gtk_widget_set_sensitive (GTK_WIDGET (btntb_chat), TRUE);
+ }
}
}
else
{
- /* FIXME: set retval as appropriate instead */
- return TRUE;
+ /* TODO: implement this */
+ g_warning ("Unimplemented feature: multi-person chat");
}
}
- if (!menu_chat)
- {
- /* FIXME: set retval as appropriate instead */
- return TRUE;
- }
-
- /* Clear out the menutoolbutton's pull-down menu and make it insensitive */
- gtk_container_foreach (GTK_CONTAINER (menu_chat),
- (GtkCallback) (gtk_widget_destroy), NULL);
- gtk_widget_set_sensitive (GTK_WIDGET (btntb_chat), FALSE);
-
- if (!person)
- {
- /* FIXME: set retval as appropriate instead */
- return TRUE;
- }
-
- live_contacts = soylent_person_get_live_contacts (person);
-
- /* FIXME: this needs to be sync'd for presence updates, and must only contain
- * online IM names */
- for (; live_contacts && (live_contact_cur = live_contacts->data);
- live_contacts = g_list_next (live_contacts))
- {
- GtkWidget *item = NULL;
-
- item = gtk_menu_item_new_with_label
- (empathy_contact_get_id (live_contact_cur));
- g_signal_connect
- (G_OBJECT (item), "activate",
- G_CALLBACK (soylent_browser_person_action_chat_menu_item_cb),
- browser);
-
- gtk_menu_shell_append (GTK_MENU_SHELL (menu_chat), item);
- gtk_widget_show (GTK_WIDGET (item));
- gtk_widget_set_sensitive (GTK_WIDGET (btntb_chat), TRUE);
- }
-
retval = TRUE;
return retval;
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Sat Mar 15 04:37:51 2008
@@ -434,7 +434,58 @@
return retval;
}
-/* Get a GList* of the currently-selected people. Kinda hacky. */
+/* Get a GList* of SoylentPerson* of the currently-selected people. Kinnda
+ * hacky. */
+GList*
+soylent_browser_get_selected_people (SoylentBrowser *browser)
+{
+ GList *retval = NULL;
+ GList *selected_people_e_uids = NULL;
+ GList *l = NULL;
+ guint i = -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), retval);
+ */
+
+ selected_people_e_uids = soylent_browser_get_selected_people_e_uid (browser);
+
+ /* TODO: use gtk_icon_view_selected_foreach () */
+
+ for (i = 0, l = selected_people_e_uids; l != NULL; l = g_list_next (l))
+ {
+ gchar *e_uid = NULL;
+
+ e_uid = (gchar*) l->data;
+ if (e_uid)
+ {
+ SoylentPerson *person = NULL;
+
+ person = g_hash_table_lookup (browser->people, e_uid);
+ if (person)
+ {
+ retval = g_list_prepend (retval, person);
+ }
+ else
+ {
+ g_warning ("invalid UID: '%s'\n", e_uid);
+ }
+
+ g_free (e_uid);
+ }
+ else
+ {
+ g_warning ("list of selected people contains NULL UID\n");
+ }
+ }
+
+ g_list_free (selected_people_e_uids);
+
+ return retval;
+}
+
+/* Get a GList* of EContact* of the currently-selected people. Kinda hacky. */
GList*
soylent_browser_get_selected_people_e_contact (SoylentBrowser *browser)
{
Modified: trunk/src/soylent-browser.h
==============================================================================
--- trunk/src/soylent-browser.h (original)
+++ trunk/src/soylent-browser.h Sat Mar 15 04:37:51 2008
@@ -119,6 +119,7 @@
SoylentPerson* soylent_browser_get_person_from_e_contact
(SoylentBrowser *browser,
EContact *e_contact);
+GList* soylent_browser_get_selected_people (SoylentBrowser *browser);
GList* soylent_browser_get_selected_people_e_contact (SoylentBrowser *browser);
GList* soylent_browser_get_selected_people_e_uid (SoylentBrowser *browser);
SoylentPerson* soylent_browser_get_selected_person (SoylentBrowser *browser);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]