diff options
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-chat-window.c | 35 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-dialogs.c | 12 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.c | 373 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-store.h | 5 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 346 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.h | 25 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-widget.c | 114 | ||||
-rw-r--r-- | libempathy-gtk/empathy-group-chat.c | 49 | ||||
-rw-r--r-- | libempathy-gtk/empathy-images.h | 2 | ||||
-rw-r--r-- | libempathy-gtk/empathy-main-window.c | 1 | ||||
-rw-r--r-- | libempathy-gtk/empathy-private-chat.c | 40 | ||||
-rw-r--r-- | libempathy-gtk/empathy-status-icon.c | 49 | ||||
-rw-r--r-- | libempathy-gtk/empathy-ui-utils.c | 10 |
13 files changed, 386 insertions, 675 deletions
diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index 7d48abf8a..c1df38b15 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -34,7 +34,7 @@ #include <glade/glade.h> #include <glib/gi18n.h> -#include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-factory.h> #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-log-manager.h> #include <libempathy/empathy-chatroom-manager.h> @@ -823,17 +823,20 @@ chat_window_update_menu (EmpathyChatWindow *window) window); } else { EmpathyPrivateChat *chat; - EmpathySubscription subscription; EmpathyContact *contact; + EmpathyPresence *presence; chat = EMPATHY_PRIVATE_CHAT (priv->current_chat); /* Show / Hide widgets */ gtk_widget_hide (priv->menu_room); + /* presence==NULL means this contact refuses to send us his + * presence. By adding the contact we ask the contact to accept + * to send his presence. */ contact = empathy_private_chat_get_contact (chat); - subscription = empathy_contact_get_subscription (contact); - if (!(subscription & EMPATHY_SUBSCRIPTION_FROM)) { + presence = empathy_contact_get_presence (contact); + if (!presence) { gtk_widget_show (priv->menu_conv_add_contact); } else { gtk_widget_hide (priv->menu_conv_add_contact); @@ -1583,12 +1586,13 @@ chat_window_drag_data_received (GtkWidget *widget, { /* FIXME: DnD of contact do not seems to work... */ if (info == DND_DRAG_TYPE_CONTACT_ID) { - EmpathyContactManager *manager; - EmpathyContact *contact; - EmpathyChat *chat; - EmpathyChatWindow *old_window; + EmpathyContactFactory *factory; + EmpathyContact *contact = NULL; + EmpathyChat *chat; + EmpathyChatWindow *old_window; McAccount *account; const gchar *id = NULL; + gchar **strv; if (selection) { id = (const gchar*) selection->data; @@ -1596,9 +1600,18 @@ chat_window_drag_data_received (GtkWidget *widget, empathy_debug (DEBUG_DOMAIN, "DND contact from roster with id:'%s'", id); - manager = empathy_contact_manager_new (); - contact = empathy_contact_list_find (EMPATHY_CONTACT_LIST (manager), id); - g_object_unref (manager); + strv = g_strsplit (id, "/", 2); + factory = empathy_contact_factory_new (); + account = mc_account_lookup (strv[0]); + if (account) { + contact = empathy_contact_factory_get_from_id (factory, + account, + strv[1]); + g_object_unref (account); + } + g_object_unref (factory); + g_object_unref (account); + g_strfreev (strv); if (!contact) { empathy_debug (DEBUG_DOMAIN, "DND contact from roster not found"); diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 437e255fa..553f85bcc 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -42,7 +42,7 @@ static GtkWidget *new_contact_dialog = NULL; static gint -contact_dialogs_find (GtkDialog *dialog, +contact_dialogs_find (GtkDialog *dialog, EmpathyContact *contact) { GtkWidget *contact_widget; @@ -64,18 +64,18 @@ subscription_dialog_response_cb (GtkDialog *dialog, GtkWidget *contact_widget) { EmpathyContactManager *manager; - EmpathyContact *contact; + EmpathyContact *contact; manager = empathy_contact_manager_new (); contact = empathy_contact_widget_get_contact (contact_widget); if (response == GTK_RESPONSE_YES) { - empathy_contact_list_process_pending (EMPATHY_CONTACT_LIST (manager), - contact, TRUE); + empathy_contact_list_add (EMPATHY_CONTACT_LIST (manager), + contact, ""); } else if (response == GTK_RESPONSE_NO) { - empathy_contact_list_process_pending (EMPATHY_CONTACT_LIST (manager), - contact, FALSE); + empathy_contact_list_remove (EMPATHY_CONTACT_LIST (manager), + contact, ""); } subscription_dialogs = g_list_remove (subscription_dialogs, dialog); diff --git a/libempathy-gtk/empathy-contact-list-store.c b/libempathy-gtk/empathy-contact-list-store.c index ac2fa62cd..9cf03bfe8 100644 --- a/libempathy-gtk/empathy-contact-list-store.c +++ b/libempathy-gtk/empathy-contact-list-store.c @@ -57,10 +57,10 @@ struct _EmpathyContactListStorePriv { gboolean show_avatars; gboolean is_compact; gboolean show_active; - EmpathyContactListStoreSort sort_criterium; + EmpathyContactListStoreSort sort_criterium; guint inhibit_active; - EmpathyContactGroupsFunc get_contact_groups; + EmpathyContactGroupsFunc get_contact_groups; gpointer get_contact_groups_data; }; @@ -84,71 +84,74 @@ typedef struct { static void empathy_contact_list_store_class_init (EmpathyContactListStoreClass *klass); static void empathy_contact_list_store_init (EmpathyContactListStore *list); -static void contact_list_store_finalize (GObject *object); -static void contact_list_store_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void contact_list_store_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void contact_list_store_setup (EmpathyContactListStore *store); -static gboolean contact_list_store_inibit_active_cb (EmpathyContactListStore *store); -static void contact_list_store_contact_added_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContactListStore *store); -static void contact_list_store_add_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_contact_removed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContactListStore *store); -static void contact_list_store_remove_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_contact_update (EmpathyContactListStore *store, - EmpathyContact *contact); -static void contact_list_store_contact_groups_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyContactListStore *store); -static void contact_list_store_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyContactListStore *store); -static void contact_list_store_contact_set_active (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean active, - gboolean set_changed); -static ShowActiveData * contact_list_store_contact_active_new (EmpathyContactListStore *store, - EmpathyContact *contact, - gboolean remove); -static void contact_list_store_contact_active_free (ShowActiveData *data); -static gboolean contact_list_store_contact_active_cb (ShowActiveData *data); -static gboolean contact_list_store_get_group_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindGroup *fg); -static void contact_list_store_get_group (EmpathyContactListStore *store, - const gchar *name, - GtkTreeIter *iter_group_to_set, - GtkTreeIter *iter_separator_to_set, - gboolean *created); -static gint contact_list_store_state_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data); -static gint contact_list_store_name_sort_func (GtkTreeModel *model, - GtkTreeIter *iter_a, - GtkTreeIter *iter_b, - gpointer user_data); -static gboolean contact_list_store_find_contact_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - FindContact *fc); -static GList * contact_list_store_find_contact (EmpathyContactListStore *store, - EmpathyContact *contact); -static gboolean contact_list_store_update_list_mode_foreach (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - EmpathyContactListStore *store); +static void contact_list_store_finalize (GObject *object); +static void contact_list_store_get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec); +static void contact_list_store_set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec); +static void contact_list_store_setup (EmpathyContactListStore *store); +static gboolean contact_list_store_inibit_active_cb (EmpathyContactListStore *store); +static void contact_list_store_members_changed_cb (EmpathyContactList *list_iface, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, + EmpathyContactListStore *store); +static void contact_list_store_groups_changed_cb (EmpathyContactList *list_iface, + EmpathyContact *contact, + gchar *group, + gboolean is_member, + EmpathyContactListStore *store); +static void contact_list_store_add_contact (EmpathyContactListStore *store, + EmpathyContact *contact); +static void contact_list_store_remove_contact (EmpathyContactListStore *store, + EmpathyContact *contact); +static void contact_list_store_contact_update (EmpathyContactListStore *store, + EmpathyContact *contact); +static void contact_list_store_contact_updated_cb (EmpathyContact *contact, + GParamSpec *param, + EmpathyContactListStore *store); +static void contact_list_store_contact_set_active (EmpathyContactListStore *store, + EmpathyContact *contact, + gboolean active, + gboolean set_changed); +static ShowActiveData * contact_list_store_contact_active_new (EmpathyContactListStore *store, + EmpathyContact *contact, + gboolean remove); +static void contact_list_store_contact_active_free (ShowActiveData *data); +static gboolean contact_list_store_contact_active_cb (ShowActiveData *data); +static gboolean contact_list_store_get_group_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + FindGroup *fg); +static void contact_list_store_get_group (EmpathyContactListStore *store, + const gchar *name, + GtkTreeIter *iter_group_to_set, + GtkTreeIter *iter_separator_to_set, + gboolean *created); +static gint contact_list_store_state_sort_func (GtkTreeModel *model, + GtkTreeIter *iter_a, + GtkTreeIter *iter_b, + gpointer user_data); +static gint contact_list_store_name_sort_func (GtkTreeModel *model, + GtkTreeIter *iter_a, + GtkTreeIter *iter_b, + gpointer user_data); +static gboolean contact_list_store_find_contact_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + FindContact *fc); +static GList * contact_list_store_find_contact (EmpathyContactListStore *store, + EmpathyContact *contact); +static gboolean contact_list_store_update_list_mode_foreach (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + EmpathyContactListStore *store); enum { PROP_0, @@ -317,24 +320,23 @@ empathy_contact_list_store_new (EmpathyContactList *list_iface) /* Signal connection. */ g_signal_connect (priv->list, - "contact-added", - G_CALLBACK (contact_list_store_contact_added_cb), + "members-changed", + G_CALLBACK (contact_list_store_members_changed_cb), store); g_signal_connect (priv->list, - "contact-removed", - G_CALLBACK (contact_list_store_contact_removed_cb), + "groups-changed", + G_CALLBACK (contact_list_store_groups_changed_cb), store); /* Add contacts already created. */ contacts = empathy_contact_list_get_members (priv->list); for (l = contacts; l; l = l->next) { - EmpathyContact *contact; + contact_list_store_members_changed_cb (priv->list, l->data, + NULL, 0, NULL, + TRUE, + store); - contact = l->data; - - contact_list_store_contact_added_cb (priv->list, contact, store); - - g_object_unref (contact); + g_object_unref (l->data); } g_list_free (contacts); @@ -385,13 +387,9 @@ empathy_contact_list_store_set_show_offline (EmpathyContactListStore *store, contacts = empathy_contact_list_get_members (priv->list); for (l = contacts; l; l = l->next) { - EmpathyContact *contact; - - contact = EMPATHY_CONTACT (l->data); - - contact_list_store_contact_update (store, contact); + contact_list_store_contact_update (store, l->data); - g_object_unref (contact); + g_object_unref (l->data); } g_list_free (contacts); @@ -611,80 +609,6 @@ empathy_contact_list_store_search_equal_func (GtkTreeModel *model, return ret; } -void -empathy_contact_list_store_set_contact_groups_func (EmpathyContactListStore *store, - EmpathyContactGroupsFunc func, - gpointer user_data) -{ - EmpathyContactListStorePriv *priv; - GList *contacts, *l; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - - priv = GET_PRIV (store); - - if (func) { - priv->get_contact_groups = func; - priv->get_contact_groups_data = user_data; - } else { - priv->get_contact_groups = NULL; - priv->get_contact_groups_data = NULL; - } - - /* If we set a custom function to get contacts groups we have to - * disconnect our default notify::groups signal and wait for the user - * to call himself empathy_contact_list_store_update_contact_groups () - * when needed. If func is NULL we come back to default. - */ - contacts = empathy_contact_list_get_members (priv->list); - for (l = contacts; l; l = l->next) { - EmpathyContact *contact; - - contact = l->data; - - if (func) { - g_signal_handlers_disconnect_by_func (contact, - G_CALLBACK (contact_list_store_contact_groups_updated_cb), - store); - } else { - g_signal_connect (contact, "notify::groups", - G_CALLBACK (contact_list_store_contact_groups_updated_cb), - store); - } - - empathy_contact_list_store_update_contact_groups (store, contact); - - g_object_unref (contact); - } - g_list_free (contacts); -} - -void -empathy_contact_list_store_update_contact_groups (EmpathyContactListStore *store, - EmpathyContact *contact) -{ - EmpathyContactListStorePriv *priv; - gboolean show_active; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store)); - g_return_if_fail (EMPATHY_IS_CONTACT (contact)); - - priv = GET_PRIV (store); - - empathy_debug (DEBUG_DOMAIN, "Contact:'%s' updating groups", - empathy_contact_get_name (contact)); - - /* We do this to make sure the groups are correct, if not, we - * would have to check the groups already set up for each - * contact and then see what has been updated. - */ - show_active = priv->show_active; - priv->show_active = FALSE; - contact_list_store_remove_contact (store, contact); - contact_list_store_add_contact (store, contact); - priv->show_active = show_active; -} - static void contact_list_store_setup (EmpathyContactListStore *store) { @@ -733,37 +657,73 @@ contact_list_store_inibit_active_cb (EmpathyContactListStore *store) } static void -contact_list_store_contact_added_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContactListStore *store) +contact_list_store_members_changed_cb (EmpathyContactList *list_iface, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, + EmpathyContactListStore *store) { EmpathyContactListStorePriv *priv; priv = GET_PRIV (store); empathy_debug (DEBUG_DOMAIN, - "Contact:'%s' added", - empathy_contact_get_name (contact)); - - if (!priv->get_contact_groups) { - g_signal_connect (contact, "notify::groups", - G_CALLBACK (contact_list_store_contact_groups_updated_cb), + "Contact %s (%d) %s", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), + is_member ? "added" : "removed"); + + if (is_member) { + g_signal_connect (contact, "notify::presence", + G_CALLBACK (contact_list_store_contact_updated_cb), + store); + g_signal_connect (contact, "notify::name", + G_CALLBACK (contact_list_store_contact_updated_cb), store); + g_signal_connect (contact, "notify::avatar", + G_CALLBACK (contact_list_store_contact_updated_cb), + store); + g_signal_connect (contact, "notify::type", + G_CALLBACK (contact_list_store_contact_updated_cb), + store); + + contact_list_store_add_contact (store, contact); + } else { + g_signal_handlers_disconnect_by_func (contact, + G_CALLBACK (contact_list_store_contact_updated_cb), + store); + + contact_list_store_remove_contact (store, contact); } - g_signal_connect (contact, "notify::presence", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::name", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::avatar", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - g_signal_connect (contact, "notify::type", - G_CALLBACK (contact_list_store_contact_updated_cb), - store); +} +static void +contact_list_store_groups_changed_cb (EmpathyContactList *list_iface, + EmpathyContact *contact, + gchar *group, + gboolean is_member, + EmpathyContactListStore *store) +{ + EmpathyContactListStorePriv *priv; + gboolean show_active; + + priv = GET_PRIV (store); + + empathy_debug (DEBUG_DOMAIN, "Updating groups for contact %s (%d)", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact)); + + /* We do this to make sure the groups are correct, if not, we + * would have to check the groups already set up for each + * contact and then see what has been updated. + */ + show_active = priv->show_active; + priv->show_active = FALSE; + contact_list_store_remove_contact (store, contact); contact_list_store_add_contact (store, contact); + priv->show_active = show_active; } static void @@ -780,14 +740,9 @@ contact_list_store_add_contact (EmpathyContactListStore *store, return; } - /* If no groups just add it at the top level. */ - if (priv->get_contact_groups) { - groups = priv->get_contact_groups (contact, - priv->get_contact_groups_data); - } else { - groups = empathy_contact_get_groups (contact); - } + groups = empathy_contact_list_get_groups (priv->list, contact); + /* If no groups just add it at the top level. */ if (!groups) { gtk_tree_store_append (GTK_TREE_STORE (store), &iter, NULL); gtk_tree_store_set (GTK_TREE_STORE (store), &iter, @@ -800,15 +755,9 @@ contact_list_store_add_contact (EmpathyContactListStore *store, /* Else add to each group. */ for (l = groups; l; l = l->next) { - GtkTreeIter iter_group; - const gchar *name; - - name = l->data; - if (!name) { - continue; - } + GtkTreeIter iter_group; - contact_list_store_get_group (store, name, &iter_group, NULL, NULL); + contact_list_store_get_group (store, l->data, &iter_group, NULL, NULL); gtk_tree_store_insert_after (GTK_TREE_STORE (store), &iter, &iter_group, NULL); @@ -818,28 +767,12 @@ contact_list_store_add_contact (EmpathyContactListStore *store, COL_IS_GROUP, FALSE, COL_IS_SEPARATOR, FALSE, -1); + g_free (l->data); } + g_list_free (groups); contact_list_store_contact_update (store, contact); -} - -static void -contact_list_store_contact_removed_cb (EmpathyContactList *list_iface, - EmpathyContact *contact, - EmpathyContactListStore *store) -{ - empathy_debug (DEBUG_DOMAIN, "Contact:'%s' removed", - empathy_contact_get_name (contact)); - - /* Disconnect signals */ - g_signal_handlers_disconnect_by_func (contact, - G_CALLBACK (contact_list_store_contact_groups_updated_cb), - store); - g_signal_handlers_disconnect_by_func (contact, - G_CALLBACK (contact_list_store_contact_updated_cb), - store); - contact_list_store_remove_contact (store, contact); } static void @@ -1029,16 +962,8 @@ contact_list_store_contact_update (EmpathyContactListStore *store, } static void -contact_list_store_contact_groups_updated_cb (EmpathyContact *contact, - GParamSpec *param, - EmpathyContactListStore *store) -{ - empathy_contact_list_store_update_contact_groups (store, contact); -} - -static void contact_list_store_contact_updated_cb (EmpathyContact *contact, - GParamSpec *param, + GParamSpec *param, EmpathyContactListStore *store) { empathy_debug (DEBUG_DOMAIN, @@ -1180,10 +1105,10 @@ contact_list_store_get_group (EmpathyContactListStore *store, gboolean *created) { EmpathyContactListStorePriv *priv; - GtkTreeModel *model; - GtkTreeIter iter_group; - GtkTreeIter iter_separator; - FindGroup fg; + GtkTreeModel *model; + GtkTreeIter iter_group; + GtkTreeIter iter_separator; + FindGroup fg; priv = GET_PRIV (store); diff --git a/libempathy-gtk/empathy-contact-list-store.h b/libempathy-gtk/empathy-contact-list-store.h index d7c9635f5..d096daafd 100644 --- a/libempathy-gtk/empathy-contact-list-store.h +++ b/libempathy-gtk/empathy-contact-list-store.h @@ -106,11 +106,6 @@ gboolean empathy_contact_list_store_search_equal_func (GtkTre const gchar *key, GtkTreeIter *iter, gpointer search_data); -void empathy_contact_list_store_set_contact_groups_func (EmpathyContactListStore*store, - EmpathyContactGroupsFunc func, - gpointer user_data); -void empathy_contact_list_store_update_contact_groups (EmpathyContactListStore *store, - EmpathyContact *contact); G_END_DECLS diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 2a5cf3406..5b3f0de08 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -34,7 +34,7 @@ #include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mission-control.h> -#include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-factory.h> #include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-log-manager.h> #include <libempathy/empathy-debug.h> @@ -66,13 +66,8 @@ struct _EmpathyContactListViewPriv { EmpathyContactListStore *store; - GtkUIManager *ui; - GtkTreeRowReference *drag_row; - GtkTreeModel *filter; - gchar *filter_text; - - EmpathyContactListViewDragReceivedFunc drag_received; - gpointer drag_received_data; + GtkUIManager *ui; + GtkTreeRowReference *drag_row; }; typedef struct { @@ -103,11 +98,6 @@ static void contact_list_view_row_has_child_toggled_cb (GtkTreeModel GtkTreePath *path, GtkTreeIter *iter, EmpathyContactListView *view); -static void contact_list_view_contact_received (EmpathyContactListView *view, - EmpathyContact *contact, - GdkDragAction action, - const gchar *old_group, - const gchar *new_group); static void contact_list_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, @@ -173,14 +163,6 @@ static void contact_list_view_row_expand_or_collapse_cb (EmpathyContactLi GtkTreeIter *iter, GtkTreePath *path, gpointer user_data); -static gboolean contact_list_view_filter_show_contact (EmpathyContact *contact, - const gchar *filter); -static gboolean contact_list_view_filter_show_group (EmpathyContactListView *view, - const gchar *group, - const gchar *filter); -static gboolean contact_list_view_filter_func (GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view); static void contact_list_view_action_cb (GtkAction *action, EmpathyContactListView *view); static void contact_list_view_action_activated (EmpathyContactListView *view, @@ -188,7 +170,6 @@ static void contact_list_view_action_activated (EmpathyContactLi enum { PROP_0, - PROP_FILTER, }; static const GtkActionEntry entries[] = { @@ -315,14 +296,6 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass) G_TYPE_NONE, 3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING); - g_object_class_install_property (object_class, - PROP_FILTER, - g_param_spec_string ("filter", - "Filter", - "The text to use to filter the contact list", - NULL, - G_PARAM_READWRITE)); - g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv)); } @@ -389,10 +362,6 @@ contact_list_view_finalize (GObject *object) if (priv->store) { g_object_unref (priv->store); } - if (priv->filter) { - g_object_unref (priv->filter); - } - g_free (priv->filter_text); G_OBJECT_CLASS (empathy_contact_list_view_parent_class)->finalize (object); } @@ -408,9 +377,6 @@ contact_list_view_get_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { - case PROP_FILTER: - g_value_set_string (value, priv->filter_text); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -428,10 +394,6 @@ contact_list_view_set_property (GObject *object, priv = GET_PRIV (object); switch (param_id) { - case PROP_FILTER: - empathy_contact_list_view_set_filter (EMPATHY_CONTACT_LIST_VIEW (object), - g_value_get_string (value)); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -547,47 +509,6 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, can_show_log); } -void -empathy_contact_list_view_set_filter (EmpathyContactListView *view, - const gchar *filter) -{ - EmpathyContactListViewPriv *priv; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); - - priv = GET_PRIV (view); - - g_free (priv->filter_text); - if (filter) { - priv->filter_text = g_utf8_casefold (filter, -1); - } else { - priv->filter_text = NULL; - } - - empathy_debug (DEBUG_DOMAIN, "Refiltering with filter:'%s' (case folded)", filter); - gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter)); -} - -void -empathy_contact_list_view_set_drag_received_func (EmpathyContactListView *view, - EmpathyContactListViewDragReceivedFunc func, - gpointer user_data) -{ - EmpathyContactListViewPriv *priv; - - g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); - - priv = GET_PRIV (view); - - if (func) { - priv->drag_received = func; - priv->drag_received_data = user_data; - } else { - priv->drag_received = NULL; - priv->drag_received_data = NULL; - } -} - static void contact_list_view_setup (EmpathyContactListView *view) { @@ -598,21 +519,11 @@ contact_list_view_setup (EmpathyContactListView *view) priv = GET_PRIV (view); - /* Create filter */ - priv->filter = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), NULL); - - gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (priv->filter), - (GtkTreeModelFilterVisibleFunc) - contact_list_view_filter_func, - view, NULL); - gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (view), - empathy_contact_list_store_search_equal_func, - view, NULL); - g_signal_connect (priv->filter, "row-has-child-toggled", + g_signal_connect (priv->store, "row-has-child-toggled", G_CALLBACK (contact_list_view_row_has_child_toggled_cb), view); - gtk_tree_view_set_model (GTK_TREE_VIEW (view), priv->filter); - + gtk_tree_view_set_model (GTK_TREE_VIEW (view), + GTK_TREE_MODEL (priv->store)); /* Setup view */ g_object_set (view, @@ -697,13 +608,13 @@ contact_list_view_setup (EmpathyContactListView *view) GDK_BUTTON1_MASK, drag_types_source, G_N_ELEMENTS (drag_types_source), - GDK_ACTION_MOVE); + GDK_ACTION_MOVE | GDK_ACTION_COPY); gtk_drag_dest_set (GTK_WIDGET (view), GTK_DEST_DEFAULT_ALL, drag_types_dest, G_N_ELEMENTS (drag_types_dest), - GDK_ACTION_MOVE | GDK_ACTION_LINK); + GDK_ACTION_MOVE | GDK_ACTION_COPY); } static void @@ -747,46 +658,6 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel *model, } static void -contact_list_view_contact_received (EmpathyContactListView *view, - EmpathyContact *contact, - GdkDragAction action, - const gchar *old_group, - const gchar *new_group) -{ - EmpathyContactListViewPriv *priv; - GList *groups, *l; - GList *new_groups_list = NULL; - - priv = GET_PRIV (view); - - groups = empathy_contact_get_groups (contact); - for (l = groups; l; l = l->next) { - gchar *str; - - str = l->data; - - if (action == GDK_ACTION_MOVE && - old_group != NULL && - strcmp (str, old_group) == 0) { - continue; - } - - if (new_group && strcmp (str, new_group) == 0) { - /* Otherwise we set it twice */ - continue; - } - - new_groups_list = g_list_prepend (new_groups_list, g_strdup (str)); - } - - if (new_group) { - new_groups_list = g_list_prepend (new_groups_list, g_strdup (new_group)); - } - - empathy_contact_set_groups (contact, new_groups_list); -} - -static void contact_list_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, @@ -796,15 +667,18 @@ contact_list_view_drag_data_received (GtkWidget *widget, guint time) { EmpathyContactListViewPriv *priv; - EmpathyContactList *list; - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeViewDropPosition position; - EmpathyContact *contact; - const gchar *id; - gchar *new_group = NULL; - gchar *old_group = NULL; - gboolean is_row; + EmpathyContactList *list; + EmpathyContactFactory *factory; + McAccount *account; + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeViewDropPosition position; + EmpathyContact *contact = NULL; + const gchar *id; + gchar **strv; + gchar *new_group = NULL; + gchar *old_group = NULL; + gboolean is_row; priv = GET_PRIV (widget); @@ -814,9 +688,18 @@ contact_list_view_drag_data_received (GtkWidget *widget, context->action == GDK_ACTION_COPY ? "copy" : "", id); - /* FIXME: This is ambigous, an id can come from multiple accounts */ - list = empathy_contact_list_store_get_list_iface (priv->store); - contact = empathy_contact_list_find (list, id); + strv = g_strsplit (id, "/", 2); + factory = empathy_contact_factory_new (); + account = mc_account_lookup (strv[0]); + if (account) { + contact = empathy_contact_factory_get_from_id (factory, + account, + strv[1]); + g_object_unref (account); + } + g_object_unref (factory); + g_object_unref (account); + g_strfreev (strv); if (!contact) { empathy_debug (DEBUG_DOMAIN, "No contact found associated with drag & drop"); @@ -847,22 +730,17 @@ contact_list_view_drag_data_received (GtkWidget *widget, } empathy_debug (DEBUG_DOMAIN, - "contact '%s' dragged from '%s' to '%s'", - empathy_contact_get_name (contact), + "contact %s (%d) dragged from '%s' to '%s'", + empathy_contact_get_id (contact), + empathy_contact_get_handle (contact), old_group, new_group); - if (priv->drag_received) { - priv->drag_received (contact, - context->action, - old_group, - new_group, - priv->drag_received_data); - } else { - contact_list_view_contact_received (EMPATHY_CONTACT_LIST_VIEW (widget), - contact, - context->action, - old_group, - new_group); + list = empathy_contact_list_store_get_list_iface (priv->store); + if (new_group) { + empathy_contact_list_add_to_group (list, contact, new_group); + } + if (old_group && context->action == GDK_ACTION_MOVE) { + empathy_contact_list_remove_from_group (list, contact, old_group); } g_free (old_group); @@ -976,11 +854,15 @@ contact_list_view_drag_data_get (GtkWidget *widget, guint time) { EmpathyContactListViewPriv *priv; - GtkTreePath *src_path; - GtkTreeIter iter; - GtkTreeModel *model; + GtkTreePath *src_path; + GtkTreeIter iter; + GtkTreeModel *model; EmpathyContact *contact; - const gchar *id; + McAccount *account; + const gchar *contact_id; + const gchar *account_id; + gchar *str; + priv = GET_PRIV (widget); @@ -1006,18 +888,20 @@ contact_list_view_drag_data_get (GtkWidget *widget, return; } - id = empathy_contact_get_id (contact); + account = empathy_contact_get_account (contact); + account_id = mc_account_get_unique_name (account); + contact_id = empathy_contact_get_id (contact); g_object_unref (contact); + str = g_strconcat (account_id, "/", contact_id, NULL); switch (info) { case DND_DRAG_TYPE_CONTACT_ID: gtk_selection_data_set (selection, drag_atoms_source[info], 8, - (guchar*)id, strlen (id) + 1); + (guchar*)str, strlen (str) + 1); break; - - default: - return; } + + g_free (str); } static void @@ -1329,124 +1213,6 @@ contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view, g_free (name); } -static gboolean -contact_list_view_filter_show_contact (EmpathyContact *contact, - const gchar *filter) -{ - gchar *str; - gboolean visible; - - /* Check contact id */ - str = g_utf8_casefold (empathy_contact_get_id (contact), -1); - visible = G_STR_EMPTY (str) || strstr (str, filter); - g_free (str); - - if (visible) { - return TRUE; - } - - /* Check contact name */ - str = g_utf8_casefold (empathy_contact_get_name (contact), -1); - visible = G_STR_EMPTY (str) || strstr (str, filter); - g_free (str); - - return visible; -} - -static gboolean -contact_list_view_filter_show_group (EmpathyContactListView *view, - const gchar *group, - const gchar *filter) -{ - EmpathyContactListViewPriv *priv; - EmpathyContactList *list; - GList *contacts, *l; - gchar *str; - gboolean show_group = FALSE; - - priv = GET_PRIV (view); - - str = g_utf8_casefold (group, -1); - if (!str) { - return FALSE; - } - - /* If the filter is the partially the group name, we show the - * whole group. - */ - if (strstr (str, filter)) { - g_free (str); - return TRUE; - } - - /* At this point, we need to check in advance if this - * group should be shown because a contact we want to - * show exists in it. - */ - list = empathy_contact_list_store_get_list_iface (priv->store); - contacts = empathy_contact_list_get_members (list); - for (l = contacts; l && !show_group; l = l->next) { - if (!empathy_contact_is_in_group (l->data, group)) { - g_object_unref (l->data); - continue; - } - - if (contact_list_view_filter_show_contact (l->data, filter)) { - show_group = TRUE; - } - g_object_unref (l->data); - } - g_list_free (contacts); - g_free (str); - - return show_group; -} - -static gboolean -contact_list_view_filter_func (GtkTreeModel *model, - GtkTreeIter *iter, - EmpathyContactListView *view) -{ - EmpathyContactListViewPriv *priv; - gboolean is_group; - gboolean is_separator; - gboolean visible = TRUE; - - priv = GET_PRIV (view); - - if (G_STR_EMPTY (priv->filter_text)) { - return TRUE; - } - - /* Check to see if iter matches any group names */ - gtk_tree_model_get (model, iter, - COL_IS_GROUP, &is_group, - COL_IS_SEPARATOR, &is_separator, - -1); - - if (is_group) { - gchar *name; - - gtk_tree_model_get (model, iter, COL_NAME, &name, -1); - visible &= contact_list_view_filter_show_group (view, - name, - priv->filter_text); - g_free (name); - } else if (is_separator) { - /* Do nothing here */ - } else { - EmpathyContact *contact; - - /* Check contact id */ - gtk_tree_model_get (model, iter, COL_CONTACT, &contact, -1); - visible &= contact_list_view_filter_show_contact (contact, - priv->filter_text); - g_object_unref (contact); - } - - return visible; -} - static void contact_list_view_action_cb (GtkAction *action, EmpathyContactListView *view) diff --git a/libempathy-gtk/empathy-contact-list-view.h b/libempathy-gtk/empathy-contact-list-view.h index 4d7cf1cb9..b9de24357 100644 --- a/libempathy-gtk/empathy-contact-list-view.h +++ b/libempathy-gtk/empathy-contact-list-view.h @@ -53,24 +53,13 @@ struct _EmpathyContactListViewClass { GtkTreeViewClass parent_class; }; -typedef void (*EmpathyContactListViewDragReceivedFunc) (EmpathyContact *contact, - GdkDragAction action, - const gchar *old_group, - const gchar *new_group, - gpointer user_data); - -GType empathy_contact_list_view_get_type (void) G_GNUC_CONST; -EmpathyContactListView *empathy_contact_list_view_new (EmpathyContactListStore *store); -EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); -gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); -GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, - EmpathyContact *contact); -GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); -void empathy_contact_list_view_set_filter (EmpathyContactListView *view, - const gchar *filter); -void empathy_contact_list_view_set_drag_received_func (EmpathyContactListView *view, - EmpathyContactListViewDragReceivedFunc func, - gpointer user_data); +GType empathy_contact_list_view_get_type (void) G_GNUC_CONST; +EmpathyContactListView *empathy_contact_list_view_new (EmpathyContactListStore *store); +EmpathyContact * empathy_contact_list_view_get_selected (EmpathyContactListView *view); +gchar * empathy_contact_list_view_get_selected_group (EmpathyContactListView *view); +GtkWidget * empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view, + EmpathyContact *contact); +GtkWidget * empathy_contact_list_view_get_group_menu (EmpathyContactListView *view); G_END_DECLS diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 5c8f6d3d8..b3081b130 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -31,7 +31,9 @@ #include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-contact-factory.h> #include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-list.h> #include <libempathy/empathy-utils.h> #include "empathy-contact-widget.h" @@ -42,44 +44,45 @@ #define ID_CHANGED_TIMEOUT 500 typedef struct { - EmpathyContact *contact; - gboolean is_user; - EmpathyContactWidgetType type; - GtkCellRenderer *renderer; - guint widget_id_timeout; + EmpathyContactFactory *factory; + EmpathyContactManager *manager; + EmpathyContact *contact; + gboolean is_user; + EmpathyContactWidgetType type; + GtkCellRenderer *renderer; + guint widget_id_timeout; - GtkWidget *vbox_contact_widget; + GtkWidget *vbox_contact_widget; /* Contact */ - GtkWidget *vbox_contact; - GtkWidget *widget_avatar; - GtkWidget *widget_account; - GtkWidget *widget_id; - GtkWidget *widget_alias; - GtkWidget *label_alias; - GtkWidget *entry_alias; - GtkWidget *hbox_presence; - GtkWidget *image_state; - GtkWidget *label_status; - GtkWidget *table_contact; - GtkWidget *hbox_contact; + GtkWidget *vbox_contact; + GtkWidget *widget_avatar; + GtkWidget *widget_account; + GtkWidget *widget_id; + GtkWidget *widget_alias; + GtkWidget *label_alias; + GtkWidget *entry_alias; + GtkWidget *hbox_presence; + GtkWidget *image_state; + GtkWidget *label_status; + GtkWidget *table_contact; + GtkWidget *hbox_contact; /* Groups */ - GtkWidget *vbox_groups; - GtkWidget *entry_group; - GtkWidget *button_group; - GtkWidget *treeview_groups; + GtkWidget *vbox_groups; + GtkWidget *entry_group; + GtkWidget *button_group; + GtkWidget *treeview_groups; /* Details */ - GtkWidget *vbox_details; - GtkWidget *table_details; - GtkWidget *hbox_details_requested; + GtkWidget *vbox_details; + GtkWidget *table_details; + GtkWidget *hbox_details_requested; /* Client */ - GtkWidget *vbox_client; - GtkWidget *table_client; - GtkWidget *hbow_client_requested; - + GtkWidget *vbox_client; + GtkWidget *table_client; + GtkWidget *hbow_client_requested; } EmpathyContactWidget; typedef struct { @@ -151,6 +154,7 @@ empathy_contact_widget_new (EmpathyContact *contact, information = g_slice_new0 (EmpathyContactWidget); information->type = type; + information->factory = empathy_contact_factory_new (); if (contact) { information->is_user = empathy_contact_is_user (contact); } else { @@ -231,6 +235,12 @@ contact_widget_destroy_cb (GtkWidget *widget, if (information->widget_id_timeout != 0) { g_source_remove (information->widget_id_timeout); } + if (information->factory) { + g_object_unref (information->factory); + } + if (information->manager) { + g_object_unref (information->manager); + } g_slice_free (EmpathyContactWidget, information); } @@ -467,17 +477,15 @@ contact_widget_update_contact (EmpathyContactWidget *information) id = gtk_entry_get_text (GTK_ENTRY (information->widget_id)); if (account && !G_STR_EMPTY (id)) { - EmpathyContactManager *manager; - EmpathyContact *contact; + EmpathyContact *contact; - manager = empathy_contact_manager_new (); - contact = empathy_contact_manager_create (manager, account, id); + contact = empathy_contact_factory_get_from_id (information->factory, + account, id); contact_widget_set_contact (information, contact); if (contact) { g_object_unref (contact); } - g_object_unref (manager); } return FALSE; @@ -508,7 +516,9 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable *editable, const gchar *name; name = gtk_entry_get_text (GTK_ENTRY (editable)); - empathy_contact_set_name (information->contact, name); + empathy_contact_factory_set_name (information->factory, + information->contact, + name); } return FALSE; @@ -559,6 +569,7 @@ static void contact_widget_groups_setup (EmpathyContactWidget *information) { if (information->type > CONTACT_WIDGET_TYPE_SHOW) { + information->manager = empathy_contact_manager_new (); contact_widget_model_setup (information); } } @@ -657,21 +668,19 @@ contact_widget_model_populate_columns (EmpathyContactWidget *information) static void contact_widget_groups_populate_data (EmpathyContactWidget *information) { - EmpathyContactManager *manager; - GtkTreeView *view; - GtkListStore *store; - GtkTreeIter iter; - GList *my_groups, *l; - GList *all_groups; + GtkTreeView *view; + GtkListStore *store; + GtkTreeIter iter; + GList *my_groups, *l; + GList *all_groups; view = GTK_TREE_VIEW (information->treeview_groups); store = GTK_LIST_STORE (gtk_tree_view_get_model (view)); gtk_list_store_clear (store); - manager = empathy_contact_manager_new (); - all_groups = empathy_contact_manager_get_groups (manager); - my_groups = empathy_contact_get_groups (information->contact); - g_object_unref (manager); + all_groups = empathy_contact_list_get_all_groups (EMPATHY_CONTACT_LIST (information->manager)); + my_groups = empathy_contact_list_get_groups (EMPATHY_CONTACT_LIST (information->manager), + information->contact); for (l = all_groups; l; l = l->next) { const gchar *group_str; @@ -691,7 +700,10 @@ contact_widget_groups_populate_data (EmpathyContactWidget *information) -1); } + g_list_foreach (all_groups, (GFunc) g_free, NULL); + g_list_foreach (my_groups, (GFunc) g_free, NULL); g_list_free (all_groups); + g_list_free (my_groups); } static void @@ -792,9 +804,13 @@ contact_widget_cell_toggled (GtkCellRendererToggle *cell, if (group) { if (enabled) { - empathy_contact_remove_group (information->contact, group); + empathy_contact_list_remove_from_group (EMPATHY_CONTACT_LIST (information->manager), + information->contact, + group); } else { - empathy_contact_add_group (information->contact, group); + empathy_contact_list_add_to_group (EMPATHY_CONTACT_LIST (information->manager), + information->contact, + group); } g_free (group); @@ -846,7 +862,9 @@ contact_widget_button_group_clicked_cb (GtkButton *button, COL_ENABLED, TRUE, -1); - empathy_contact_add_group (information->contact, group); + empathy_contact_list_add_to_group (EMPATHY_CONTACT_LIST (information->manager), + information->contact, + group); } static void diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c index ca046a3d7..48439302d 100644 --- a/libempathy-gtk/empathy-group-chat.c +++ b/libempathy-gtk/empathy-group-chat.c @@ -78,11 +78,12 @@ static void group_chat_finalize (GObject *obj static void group_chat_create_ui (EmpathyGroupChat *chat); static void group_chat_widget_destroy_cb (GtkWidget *widget, EmpathyGroupChat *chat); -static void group_chat_contact_added_cb (EmpathyTpChatroom *tp_chat, - EmpathyContact *contact, - EmpathyGroupChat *chat); -static void group_chat_contact_removed_cb (EmpathyTpChatroom *tp_chat, +static void group_chat_members_changed_cb (EmpathyTpChatroom *tp_chat, EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, EmpathyGroupChat *chat); static void group_chat_topic_entry_activate_cb (GtkWidget *entry, GtkDialog *dialog); @@ -348,33 +349,26 @@ group_chat_widget_destroy_cb (GtkWidget *widget, } static void -group_chat_contact_added_cb (EmpathyTpChatroom *tp_chat, - EmpathyContact *contact, - EmpathyGroupChat *chat) -{ - EmpathyGroupChatPriv *priv; - gchar *str; - - priv = GET_PRIV (chat); - - str = g_strdup_printf (_("%s has joined the room"), - empathy_contact_get_name (contact)); - empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, str); - g_free (str); -} - -static void -group_chat_contact_removed_cb (EmpathyTpChatroom *tp_chat, +group_chat_members_changed_cb (EmpathyTpChatroom *tp_chat, EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, EmpathyGroupChat *chat) { EmpathyGroupChatPriv *priv; - gchar *str; + gchar *str; priv = GET_PRIV (chat); - str = g_strdup_printf (_("%s has left the room"), - empathy_contact_get_name (contact)); + if (is_member) { + str = g_strdup_printf (_("%s has joined the room"), + empathy_contact_get_name (contact)); + } else { + str = g_strdup_printf (_("%s has left the room"), + empathy_contact_get_name (contact)); + } empathy_chat_view_append_event (EMPATHY_CHAT (chat)->view, str); g_free (str); } @@ -540,11 +534,8 @@ group_chat_set_tp_chat (EmpathyChat *chat, gtk_widget_show (GTK_WIDGET (priv->view)); /* Connect signals */ - g_signal_connect (priv->tp_chat, "contact-added", - G_CALLBACK (group_chat_contact_added_cb), - chat); - g_signal_connect (priv->tp_chat, "contact-removed", - G_CALLBACK (group_chat_contact_removed_cb), + g_signal_connect (priv->tp_chat, "members-changed", + G_CALLBACK (group_chat_members_changed_cb), chat); g_signal_connect (priv->tp_chat, "notify::subject", G_CALLBACK (group_chat_subject_notify_cb), diff --git a/libempathy-gtk/empathy-images.h b/libempathy-gtk/empathy-images.h index 227ebe599..ad6d43b28 100644 --- a/libempathy-gtk/empathy-images.h +++ b/libempathy-gtk/empathy-images.h @@ -31,7 +31,7 @@ G_BEGIN_DECLS #define EMPATHY_IMAGE_BUSY "empathy-busy" #define EMPATHY_IMAGE_AWAY "empathy-away" #define EMPATHY_IMAGE_EXT_AWAY "empathy-extended-away" -#define EMPATHY_IMAGE_PENDING "empathy-pending" +#define EMPATHY_IMAGE_UNKNOWN "empathy-pending" #define EMPATHY_IMAGE_MESSAGE "empathy-message" #define EMPATHY_IMAGE_NEW_MESSAGE "empathy-new-message" diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c index 13c578d89..4b89c4e67 100644 --- a/libempathy-gtk/empathy-main-window.c +++ b/libempathy-gtk/empathy-main-window.c @@ -288,7 +288,6 @@ empathy_main_window_show (void) empathy_status_presets_get_all (); list_iface = EMPATHY_CONTACT_LIST (empathy_contact_manager_new ()); - empathy_contact_list_setup (list_iface); window->list_store = empathy_contact_list_store_new (list_iface); window->list_view = empathy_contact_list_view_new (window->list_store); g_object_unref (list_iface); diff --git a/libempathy-gtk/empathy-private-chat.c b/libempathy-gtk/empathy-private-chat.c index 81f93c021..b187e98cd 100644 --- a/libempathy-gtk/empathy-private-chat.c +++ b/libempathy-gtk/empathy-private-chat.c @@ -36,7 +36,7 @@ #include <libempathy/empathy-debug.h> #include <libempathy/empathy-tp-chat.h> #include <libempathy/empathy-tp-contact-list.h> -#include <libempathy/empathy-contact-manager.h> +#include <libempathy/empathy-contact-factory.h> #include "empathy-private-chat.h" #include "empathy-chat-view.h" @@ -51,11 +51,12 @@ #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_PRIVATE_CHAT, EmpathyPrivateChatPriv)) struct _EmpathyPrivateChatPriv { - EmpathyContact *contact; - gchar *name; - gboolean is_online; - GtkWidget *widget; - GtkWidget *text_view_sw; + EmpathyContactFactory *factory; + EmpathyContact *contact; + gchar *name; + gboolean is_online; + GtkWidget *widget; + GtkWidget *text_view_sw; }; static void empathy_private_chat_class_init (EmpathyPrivateChatClass *klass); @@ -125,7 +126,9 @@ private_chat_finalize (GObject *object) if (priv->contact) { g_object_unref (priv->contact); } - + if (priv->factory) { + g_object_unref (priv->factory); + } g_free (priv->name); G_OBJECT_CLASS (empathy_private_chat_parent_class)->finalize (object); @@ -327,27 +330,30 @@ EmpathyPrivateChat * empathy_private_chat_new (McAccount *account, TpChan *tp_chan) { - EmpathyPrivateChat *chat; - EmpathyTpChat *tp_chat; - EmpathyContactManager *manager; - EmpathyTpContactList *list; - EmpathyContact *contact; + EmpathyPrivateChat *chat; + EmpathyPrivateChatPriv *priv; + EmpathyTpChat *tp_chat; + EmpathyContactFactory *factory; + EmpathyContact *contact; g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); g_return_val_if_fail (TELEPATHY_IS_CHAN (tp_chan), NULL); - manager = empathy_contact_manager_new (); - list = empathy_contact_manager_get_list (manager, account); - contact = empathy_tp_contact_list_get_from_handle (list, tp_chan->handle); + factory = empathy_contact_factory_new (); + contact = empathy_contact_factory_get_from_handle (factory, + account, + tp_chan->handle); chat = g_object_new (EMPATHY_TYPE_PRIVATE_CHAT, NULL); - tp_chat = empathy_tp_chat_new (account, tp_chan); + priv = GET_PRIV (chat); + priv->factory = factory; + tp_chat = empathy_tp_chat_new (account, tp_chan); private_chat_setup (chat, contact, tp_chat); g_object_unref (tp_chat); g_object_unref (contact); - g_object_unref (manager); + g_object_unref (factory); return chat; } diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 1ec1a21a5..1fdc00953 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -117,9 +117,12 @@ static void status_icon_quit_cb (GtkWidget *windo EmpathyStatusIcon *icon); static void status_icon_show_hide_window_cb (GtkWidget *widget, EmpathyStatusIcon *icon); -static void status_icon_local_pending_cb (EmpathyContactManager *manager, - EmpathyContact *contact, +static void status_icon_pendings_changed_cb (EmpathyContactManager *manager, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, gchar *message, + gboolean is_pending, EmpathyStatusIcon *icon); static void status_icon_event_subscribe_cb (StatusIconEvent *event); static void status_icon_event_flash_state_cb (StatusIconEvent *event); @@ -148,7 +151,7 @@ static void empathy_status_icon_init (EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv; - GList *pending, *l; + GList *pendings, *l; priv = GET_PRIV (icon); @@ -177,21 +180,25 @@ empathy_status_icon_init (EmpathyStatusIcon *icon) g_signal_connect (priv->icon, "popup-menu", G_CALLBACK (status_icon_popup_menu_cb), icon); - g_signal_connect (priv->manager, "local-pending", - G_CALLBACK (status_icon_local_pending_cb), + g_signal_connect (priv->manager, "pendings-changed", + G_CALLBACK (status_icon_pendings_changed_cb), icon); - pending = empathy_contact_list_get_local_pending (EMPATHY_CONTACT_LIST (priv->manager)); - for (l = pending; l; l = l->next) { - EmpathyContactListInfo *info; + pendings = empathy_contact_list_get_pendings (EMPATHY_CONTACT_LIST (priv->manager)); + for (l = pendings; l; l = l->next) { + EmpathyPendingInfo *info; info = l->data; - status_icon_local_pending_cb (priv->manager, - info->contact, - info->message, - icon); + status_icon_pendings_changed_cb (priv->manager, + info->member, + info->actor, + 0, + info->message, + TRUE, + icon); + empathy_pending_info_free (info); } - g_list_free (pending); + g_list_free (pendings); } static void @@ -533,10 +540,13 @@ status_icon_show_hide_window_cb (GtkWidget *widget, } static void -status_icon_local_pending_cb (EmpathyContactManager *manager, - EmpathyContact *contact, - gchar *message, - EmpathyStatusIcon *icon) +status_icon_pendings_changed_cb (EmpathyContactManager *manager, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_pending, + EmpathyStatusIcon *icon) { EmpathyStatusIconPriv *priv; StatusIconEvent *event; @@ -545,6 +555,11 @@ status_icon_local_pending_cb (EmpathyContactManager *manager, priv = GET_PRIV (icon); + if (!is_pending) { + /* FIXME: We should remove the event */ + return; + } + for (l = priv->events; l; l = l->next) { if (empathy_contact_equal (contact, ((StatusIconEvent*)l->data)->user_data)) { return; diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index fb491cc5e..aedacb08b 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -378,8 +378,7 @@ empathy_icon_name_for_presence (EmpathyPresence *presence) const gchar * empathy_icon_name_for_contact (EmpathyContact *contact) { - EmpathyPresence *presence; - EmpathySubscription subscription; + EmpathyPresence *presence; g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), EMPATHY_IMAGE_OFFLINE); @@ -389,12 +388,7 @@ empathy_icon_name_for_contact (EmpathyContact *contact) return empathy_icon_name_for_presence (presence); } - subscription = empathy_contact_get_subscription (contact); - if (!(subscription & EMPATHY_SUBSCRIPTION_FROM)) { - return EMPATHY_IMAGE_PENDING; - } - - return EMPATHY_IMAGE_OFFLINE; + return EMPATHY_IMAGE_UNKNOWN; } static void |