*/
#include "config.h"
-
-#include <string.h>
-
-#include <glib.h>
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-
-#include <folks/folks.h>
-#include <folks/folks-telepathy.h>
-#include <telepathy-glib/util.h>
-
-#include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-enum-types.h>
-
#include "empathy-individual-store-channel.h"
+#include <tp-account-widgets/tpaw-pixbuf-utils.h>
+
+#include "empathy-utils.h"
#include "empathy-ui-utils.h"
-#include "empathy-gtk-enum-types.h"
+#include "empathy-images.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
-#include <libempathy/empathy-debug.h>
+#include "empathy-debug.h"
struct _EmpathyIndividualStoreChannelPriv
{
if (g_hash_table_lookup (self->priv->individuals, contact) != NULL)
continue;
- individual = empathy_create_individual_from_tp_contact (contact);
+ individual = empathy_ensure_individual_from_tp_contact (contact);
if (individual == NULL)
return;
}
static void
-channel_prepare_cb (GObject *source,
- GAsyncResult *result,
- gpointer user_data)
+individual_store_channel_contact_chat_state_changed (TpTextChannel *channel,
+ TpContact *tp_contact,
+ TpChannelChatState state,
+ EmpathyIndividualStoreChannel *self)
{
- EmpathyIndividualStoreChannel *self = user_data;
- TpChannel *channel = (TpChannel *) source;
- GError *error = NULL;
- GPtrArray *members;
+ FolksIndividual *individual;
+ EmpathyContact *contact = NULL;
+ GList *iters, *l;
+ GdkPixbuf *pixbuf;
- if (!tp_proxy_prepare_finish (source, result, &error))
+ contact = empathy_contact_dup_from_tp_contact (tp_contact);
+ if (empathy_contact_is_user (contact))
{
- DEBUG ("Failed to prepare %s: %s", tp_proxy_get_object_path (source),
- error->message);
+ /* We don't care about our own chat composing states */
+ goto finally;
+ }
- g_error_free (error);
+ DEBUG ("Contact %s entered chat state %d",
+ tp_contact_get_identifier (tp_contact), state);
+
+ individual = g_hash_table_lookup (self->priv->individuals, tp_contact);
+ if (individual == NULL)
+ {
+ g_warning ("individual is NULL");
+ goto finally;
}
- /* Add initial members */
- members = tp_channel_group_dup_members_contacts (channel);
- if (members != NULL)
+ iters = empathy_individual_store_find_contact (
+ EMPATHY_INDIVIDUAL_STORE (self), individual);
+
+ if (state == TP_CHANNEL_CHAT_STATE_COMPOSING)
{
- add_members (self, members);
- g_ptr_array_unref (members);
+ gchar *icon_filename =
+ tpaw_filename_from_icon_name (EMPATHY_IMAGE_TYPING,
+ GTK_ICON_SIZE_MENU);
+
+ pixbuf = gdk_pixbuf_new_from_file (icon_filename, NULL);
+ g_free (icon_filename);
+ }
+ else
+ {
+ pixbuf = empathy_individual_store_get_individual_status_icon (
+ EMPATHY_INDIVIDUAL_STORE (self), individual);
+
+ /* Take a ref as the 'if' blocks creates a new pixbuf */
+ g_object_ref (pixbuf);
}
- tp_g_signal_connect_object (channel, "group-contacts-changed",
- G_CALLBACK (group_contacts_changed_cb), self, 0);
+ for (l = iters; l != NULL; l = l->next)
+ {
+ gtk_tree_store_set (GTK_TREE_STORE (self), l->data,
+ EMPATHY_INDIVIDUAL_STORE_COL_ICON_STATUS, pixbuf,
+ -1);
+ }
+ /* Store takes it's own ref */
+ g_object_unref (pixbuf);
+
+ empathy_individual_store_free_iters (iters);
+
+ finally:
+ g_object_unref (contact);
}
static void
EmpathyIndividualStoreChannel *self,
TpChannel *channel)
{
- GQuark features[] = { TP_CHANNEL_FEATURE_CONTACTS, 0 };
+ GPtrArray *members;
g_assert (self->priv->channel == NULL); /* construct only */
self->priv->channel = g_object_ref (channel);
- tp_proxy_prepare_async (channel, features, channel_prepare_cb, self);
+ /* Add initial members */
+ members = tp_channel_group_dup_members_contacts (channel);
+ if (members != NULL)
+ {
+ add_members (self, members);
+ g_ptr_array_unref (members);
+ }
+
+ tp_g_signal_connect_object (channel, "group-contacts-changed",
+ G_CALLBACK (group_contacts_changed_cb), self, 0);
+
+ tp_g_signal_connect_object (channel, "contact-chat-state-changed",
+ G_CALLBACK (individual_store_channel_contact_chat_state_changed),
+ self, 0);
}
static void