]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-view.c
Updated Basque language
[empathy.git] / libempathy-gtk / empathy-contact-list-view.c
index 5df6c8d2a18b5c4b6eeb4f0b952902171744d4ba..dcbbb18bf57ffccf276ed544ef5c21e8b24ed02e 100644 (file)
@@ -15,8 +15,8 @@
  *
  * You should have received a copy of the GNU General Public
  * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA  02110-1301  USA
  *
  * Authors: Mikael Hallendal <micke@imendio.com>
  *          Martyn Russell <martyn@imendio.com>
 #include <glib/gi18n-lib.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 
-#include <libmissioncontrol/mc-account.h>
+#include <telepathy-glib/util.h>
 
+#include <libempathy/empathy-account-manager.h>
 #include <libempathy/empathy-call-factory.h>
-#include <libempathy/empathy-contact-factory.h>
+#include <libempathy/empathy-tp-contact-factory.h>
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-contact-groups.h>
 #include <libempathy/empathy-dispatcher.h>
@@ -120,11 +120,11 @@ contact_list_view_tooltip_destroy_cb (GtkWidget              *widget,
                                      EmpathyContactListView *view)
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
-       
+
        if (priv->tooltip_widget) {
                DEBUG ("Tooltip destroyed");
+               g_object_unref (priv->tooltip_widget);
                priv->tooltip_widget = NULL;
-               g_object_unref (widget);
        }
 }
 
@@ -141,19 +141,14 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
        GtkTreeModel               *model;
        GtkTreeIter                 iter;
        GtkTreePath                *path;
-       static gboolean             running = FALSE;
+       static gint                 running = 0;
        gboolean                    ret = FALSE;
 
        /* Avoid an infinite loop. See GNOME bug #574377 */
-       if (running) {
+       if (running > 0) {
                return FALSE;
        }
-       running = TRUE;
-
-       /* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */
-       if (gtk_check_version (2, 12, 10)) {
-               goto OUT;
-       }
+       running++;
 
        if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y,
                                                keyboard_mode,
@@ -173,11 +168,13 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
 
        if (!priv->tooltip_widget) {
                priv->tooltip_widget = empathy_contact_widget_new (contact,
-                       EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP);
+                       EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP |
+                       EMPATHY_CONTACT_WIDGET_SHOW_LOCATION);
                g_object_ref (priv->tooltip_widget);
                g_signal_connect (priv->tooltip_widget, "destroy",
                                  G_CALLBACK (contact_list_view_tooltip_destroy_cb),
                                  view);
+               gtk_widget_show (priv->tooltip_widget);
        } else {
                empathy_contact_widget_set_contact (priv->tooltip_widget,
                                                    contact);
@@ -188,13 +185,57 @@ contact_list_view_query_tooltip_cb (EmpathyContactListView *view,
 
        g_object_unref (contact);
 OUT:
-       running = FALSE;
+       running--;
 
        return ret;
 }
 
+typedef struct {
+       gchar *new_group;
+       gchar *old_group;
+       GdkDragAction action;
+} DndGetContactData;
+
+static void
+contact_list_view_dnd_get_contact_free (DndGetContactData *data)
+{
+       g_free (data->new_group);
+       g_free (data->old_group);
+       g_slice_free (DndGetContactData, data);
+}
+
+static void
+contact_list_view_drag_got_contact (EmpathyTpContactFactory *factory,
+                                   EmpathyContact          *contact,
+                                   const GError            *error,
+                                   gpointer                 user_data,
+                                   GObject                 *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       DndGetContactData          *data = user_data;
+       EmpathyContactList         *list;
+
+       if (error != NULL) {
+               DEBUG ("Error: %s", error->message);
+               return;
+       }
+
+       DEBUG ("contact %s (%d) dragged from '%s' to '%s'",
+               empathy_contact_get_id (contact),
+               empathy_contact_get_handle (contact),
+               data->old_group, data->new_group);
+
+       list = empathy_contact_list_store_get_list_iface (priv->store);
+       if (data->new_group) {
+               empathy_contact_list_add_to_group (list, contact, data->new_group);
+       }
+       if (data->old_group && data->action == GDK_ACTION_MOVE) {
+               empathy_contact_list_remove_from_group (list, contact, data->old_group);
+       }
+}
+
 static void
-contact_list_view_drag_data_received (GtkWidget         *widget,
+contact_list_view_drag_data_received (GtkWidget         *view,
                                      GdkDragContext    *context,
                                      gint               x,
                                      gint               y,
@@ -203,88 +244,100 @@ contact_list_view_drag_data_received (GtkWidget         *widget,
                                      guint              time)
 {
        EmpathyContactListViewPriv *priv;
-       EmpathyContactList         *list;
-       EmpathyContactFactory      *factory;
-       McAccount                  *account;
+       EmpathyAccountManager      *account_manager;
+       EmpathyTpContactFactory    *factory = NULL;
+       EmpathyAccount             *account;
        GtkTreeModel               *model;
-       GtkTreePath                *path;
        GtkTreeViewDropPosition     position;
-       EmpathyContact             *contact = NULL;
+       GtkTreePath                *path;
        const gchar                *id;
-       gchar                     **strv;
+       gchar                     **strv = NULL;
+       const gchar                *account_id;
+       const gchar                *contact_id;
        gchar                      *new_group = NULL;
        gchar                      *old_group = NULL;
+       DndGetContactData          *data;
        gboolean                    is_row;
+       gboolean                    success = TRUE;
 
-       priv = GET_PRIV (widget);
-
-       id = (const gchar*) selection->data;
-       DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'",
-               context->action == GDK_ACTION_MOVE ? "move" : "",
-               context->action == GDK_ACTION_COPY ? "copy" : "",
-               id);
+       priv = GET_PRIV (view);
+       model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
-       strv = g_strsplit (id, "/", 2);
-       factory = empathy_contact_factory_dup_singleton ();
-       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_strfreev (strv);
+       /* Get destination group information. */
+       is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (view),
+                                                   x,
+                                                   y,
+                                                   &path,
+                                                   &position);
 
-       if (!contact) {
-               DEBUG ("No contact found associated with drag & drop");
-               return;
+       if (is_row) {
+               new_group = empathy_contact_list_store_get_parent_group (model,
+                       path, NULL);
+               gtk_tree_path_free (path);
        }
 
-       empathy_contact_run_until_ready (contact,
-                                        EMPATHY_CONTACT_READY_HANDLE,
-                                        NULL);
-
-       model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget));
-
        /* Get source group information. */
        if (priv->drag_row) {
                path = gtk_tree_row_reference_get_path (priv->drag_row);
                if (path) {
-                       old_group = empathy_contact_list_store_get_parent_group (model, path, NULL);
+                       old_group = empathy_contact_list_store_get_parent_group (
+                               model, path, NULL);
                        gtk_tree_path_free (path);
                }
        }
 
-       /* Get destination group information. */
-       is_row = gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
-                                                   x,
-                                                   y,
-                                                   &path,
-                                                   &position);
-
-       if (is_row) {
-               new_group = empathy_contact_list_store_get_parent_group (model, path, NULL);
-               gtk_tree_path_free (path);
+       if (!tp_strdiff (old_group, new_group)) {
+               g_free (new_group);
+               g_free (old_group);
+               goto OUT;
        }
 
-       DEBUG ("contact %s (%d) dragged from '%s' to '%s'",
-               empathy_contact_get_id (contact),
-               empathy_contact_get_handle (contact),
-               old_group, new_group);
+       id = (const gchar*) gtk_selection_data_get_data (selection);
+       DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'",
+               context->action == GDK_ACTION_MOVE ? "move" : "",
+               context->action == GDK_ACTION_COPY ? "copy" : "",
+               id);
 
-       list = empathy_contact_list_store_get_list_iface (priv->store);
-       if (new_group) {
-               empathy_contact_list_add_to_group (list, contact, new_group);
+       strv = g_strsplit (id, "/", 2);
+       account_id = strv[0];
+       contact_id = strv[1];
+  account_manager = empathy_account_manager_dup_singleton ();
+       account = empathy_account_manager_get_account (account_manager, account_id);
+       if (account) {
+               TpConnection *connection;
+
+               connection = empathy_account_get_connection (account);
+               if (connection) {
+                       factory = empathy_tp_contact_factory_dup_singleton (connection);
+               }
        }
-       if (old_group && context->action == GDK_ACTION_MOVE) {  
-               empathy_contact_list_remove_from_group (list, contact, old_group);
+       g_object_unref (account_manager);
+
+       if (!factory) {
+               DEBUG ("Failed to get factory for account '%s'", account_id);
+               success = FALSE;
+               g_free (new_group);
+               g_free (old_group);
+               goto OUT;
        }
 
-       g_free (old_group);
-       g_free (new_group);
+       data = g_slice_new0 (DndGetContactData);
+       data->new_group = new_group;
+       data->old_group = old_group;
+       data->action = context->action;
+
+       /* FIXME: We should probably wait for the cb before calling
+        * gtk_drag_finish */
+       empathy_tp_contact_factory_get_from_id (factory, contact_id,
+               contact_list_view_drag_got_contact,
+               data, (GDestroyNotify) contact_list_view_dnd_get_contact_free,
+               G_OBJECT (view));
+
+       g_object_unref (factory);
 
-       gtk_drag_finish (context, TRUE, FALSE, GDK_CURRENT_TIME);
+OUT:
+       g_strfreev (strv);
+       gtk_drag_finish (context, success, FALSE, GDK_CURRENT_TIME);
 }
 
 static gboolean
@@ -311,6 +364,7 @@ contact_list_view_drag_motion (GtkWidget      *widget,
        gboolean               is_row;
        gboolean               is_different = FALSE;
        gboolean               cleanup = TRUE;
+       int                    action = 0;
 
        is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
                                                x,
@@ -329,6 +383,13 @@ contact_list_view_drag_motion (GtkWidget      *widget,
                cleanup &= FALSE;
        }
 
+       if (context->actions == GDK_ACTION_COPY) {
+               action = context->suggested_action;
+       } else if (context->actions & GDK_ACTION_MOVE) {
+               action = GDK_ACTION_MOVE;
+       }
+       gdk_drag_status (context, action, time);
+
        if (!is_different && !cleanup) {
                return TRUE;
        }
@@ -395,7 +456,7 @@ contact_list_view_drag_data_get (GtkWidget        *widget,
        GtkTreeIter                 iter;
        GtkTreeModel               *model;
        EmpathyContact             *contact;
-       McAccount                  *account;
+       EmpathyAccount             *account;
        const gchar                *contact_id;
        const gchar                *account_id;
        gchar                      *str;
@@ -419,13 +480,13 @@ contact_list_view_drag_data_get (GtkWidget        *widget,
 
        gtk_tree_path_free (src_path);
 
-       contact = empathy_contact_list_view_get_selected (EMPATHY_CONTACT_LIST_VIEW (widget));
+       contact = empathy_contact_list_view_dup_selected (EMPATHY_CONTACT_LIST_VIEW (widget));
        if (!contact) {
                return;
        }
 
        account = empathy_contact_get_account (contact);
-       account_id = mc_account_get_unique_name (account);
+       account_id = empathy_account_get_unique_name (account);
        contact_id = empathy_contact_get_id (contact);
        g_object_unref (contact);
        str = g_strconcat (account_id, "/", contact_id, NULL);
@@ -433,7 +494,7 @@ contact_list_view_drag_data_get (GtkWidget        *widget,
        switch (info) {
        case DND_DRAG_TYPE_CONTACT_ID:
                gtk_selection_data_set (selection, drag_atoms_source[info], 8,
-                                       (guchar*)str, strlen (str) + 1);
+                                       (guchar *) str, strlen (str) + 1);
                break;
        }
 
@@ -560,9 +621,10 @@ contact_list_view_row_activated (GtkTreeView       *view,
 }
 
 static void
-contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
-                                    const gchar                    *path_string,
-                                    EmpathyContactListView         *view)
+contact_list_start_voip_call (EmpathyCellRendererActivatable *cell,
+    const gchar                    *path_string,
+    EmpathyContactListView         *view,
+    gboolean with_video)
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
        GtkTreeModel               *model;
@@ -584,14 +646,31 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
 
        if (contact) {
                EmpathyCallFactory *factory;
-
                factory = empathy_call_factory_get ();
-               empathy_call_factory_new_call (factory, contact);
-
+               empathy_call_factory_new_call_with_streams (factory, contact,
+                       TRUE, with_video);
                g_object_unref (contact);
        }
 }
 
+static void
+contact_list_view_video_call_activated_cb (
+    EmpathyCellRendererActivatable *cell,
+    const gchar                    *path_string,
+    EmpathyContactListView         *view)
+{
+  contact_list_start_voip_call (cell, path_string, view, TRUE);
+}
+
+
+static void
+contact_list_view_audio_call_activated_cb (EmpathyCellRendererActivatable *cell,
+                                    const gchar                    *path_string,
+                                    EmpathyContactListView         *view)
+{
+  contact_list_start_voip_call (cell, path_string, view, FALSE);
+}
+
 static void
 contact_list_view_cell_set_background (EmpathyContactListView *view,
                                       GtkCellRenderer       *cell,
@@ -653,7 +732,8 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn     *tree_column,
 }
 
 static void
-contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
+contact_list_view_audio_call_cell_data_func (
+                                      GtkTreeViewColumn      *tree_column,
                                       GtkCellRenderer        *cell,
                                       GtkTreeModel           *model,
                                       GtkTreeIter            *iter,
@@ -666,7 +746,7 @@ contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
        gtk_tree_model_get (model, iter,
                            EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
                            EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
-                           EMPATHY_CONTACT_LIST_STORE_COL_CAN_VOIP, &can_voip,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CAN_AUDIO_CALL, &can_voip,
                            -1);
 
        g_object_set (cell,
@@ -677,6 +757,33 @@ contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
 
+static void
+contact_list_view_video_call_cell_data_func (
+                                      GtkTreeViewColumn      *tree_column,
+                                      GtkCellRenderer        *cell,
+                                      GtkTreeModel           *model,
+                                      GtkTreeIter            *iter,
+                                      EmpathyContactListView *view)
+{
+       gboolean is_group;
+       gboolean is_active;
+       gboolean can_voip;
+
+       gtk_tree_model_get (model, iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CAN_VIDEO_CALL, &can_voip,
+                           -1);
+
+       g_object_set (cell,
+                     "visible", !is_group && can_voip,
+                     "icon-name", EMPATHY_IMAGE_VIDEO_CALL,
+                     NULL);
+
+       contact_list_view_cell_set_background (view, cell, is_group, is_active);
+}
+
+
 static void
 contact_list_view_avatar_cell_data_func (GtkTreeViewColumn     *tree_column,
                                         GtkCellRenderer       *cell,
@@ -718,16 +825,20 @@ contact_list_view_text_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean is_group;
        gboolean is_active;
        gboolean show_status;
+       gchar *name;
 
        gtk_tree_model_get (model, iter,
                            EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
                            EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
                            EMPATHY_CONTACT_LIST_STORE_COL_STATUS_VISIBLE, &show_status,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        g_object_set (cell,
                      "show-status", show_status,
+                     "text", name,
                      NULL);
+       g_free (name);
 
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
@@ -752,7 +863,7 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn     *column,
                gboolean     row_expanded;
 
                path = gtk_tree_model_get_path (model, iter);
-               row_expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (column->tree_view), path);
+               row_expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view (column)), path);
                gtk_tree_path_free (path);
 
                g_object_set (cell,
@@ -893,12 +1004,12 @@ contact_list_view_setup (EmpathyContactListView *view)
        gtk_tree_view_column_add_attribute (col, cell,
                                            "is_group", EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP);
 
-       /* Voip Capability Icon */
+       /* Audio Call Icon */
        cell = empathy_cell_renderer_activatable_new ();
        gtk_tree_view_column_pack_start (col, cell, FALSE);
        gtk_tree_view_column_set_cell_data_func (
                col, cell,
-               (GtkTreeCellDataFunc) contact_list_view_voip_cell_data_func,
+               (GtkTreeCellDataFunc) contact_list_view_audio_call_cell_data_func,
                view, NULL);
 
        g_object_set (cell,
@@ -906,7 +1017,23 @@ contact_list_view_setup (EmpathyContactListView *view)
                      NULL);
 
        g_signal_connect (cell, "path-activated",
-                         G_CALLBACK (contact_list_view_voip_activated_cb),
+                         G_CALLBACK (contact_list_view_audio_call_activated_cb),
+                         view);
+
+       /* Video Call Icon */
+       cell = empathy_cell_renderer_activatable_new ();
+       gtk_tree_view_column_pack_start (col, cell, FALSE);
+       gtk_tree_view_column_set_cell_data_func (
+               col, cell,
+               (GtkTreeCellDataFunc) contact_list_view_video_call_cell_data_func,
+               view, NULL);
+
+       g_object_set (cell,
+                     "visible", FALSE,
+                     NULL);
+
+       g_signal_connect (cell, "path-activated",
+                         G_CALLBACK (contact_list_view_video_call_activated_cb),
                          view);
 
        /* Avatar */
@@ -1126,7 +1253,7 @@ empathy_contact_list_view_init (EmpathyContactListView *view)
        /* Get saved group states. */
        empathy_contact_groups_get_all ();
 
-       gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (view), 
+       gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (view),
                                              empathy_contact_list_store_row_separator_func,
                                              NULL, NULL);
 
@@ -1154,7 +1281,7 @@ empathy_contact_list_view_new (EmpathyContactListStore        *store,
                               EmpathyContactFeatureFlags      contact_features)
 {
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL);
-       
+
        return g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
                             "store", store,
                             "contact-features", contact_features,
@@ -1163,7 +1290,7 @@ empathy_contact_list_view_new (EmpathyContactListStore        *store,
 }
 
 EmpathyContact *
-empathy_contact_list_view_get_selected (EmpathyContactListView *view)
+empathy_contact_list_view_dup_selected (EmpathyContactListView *view)
 {
        EmpathyContactListViewPriv *priv;
        GtkTreeSelection          *selection;
@@ -1187,6 +1314,31 @@ empathy_contact_list_view_get_selected (EmpathyContactListView *view)
        return contact;
 }
 
+EmpathyContactListFlags
+empathy_contact_list_view_get_flags (EmpathyContactListView *view)
+{
+       EmpathyContactListViewPriv *priv;
+       GtkTreeSelection          *selection;
+       GtkTreeIter                iter;
+       GtkTreeModel              *model;
+       EmpathyContactListFlags    flags;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), 0);
+
+       priv = GET_PRIV (view);
+
+       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (view));
+       if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+               return 0;
+       }
+
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_FLAGS, &flags,
+                           -1);
+
+       return flags;
+}
+
 gchar *
 empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
 {
@@ -1220,13 +1372,13 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
 }
 
 static gboolean
-contact_list_view_remove_dialog_show (GtkWindow   *parent, 
-                                     const gchar *message, 
+contact_list_view_remove_dialog_show (GtkWindow   *parent,
+                                     const gchar *message,
                                      const gchar *secondary_text)
 {
        GtkWidget *dialog;
        gboolean res;
-       
+
        dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
                                         GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
                                         "%s", message);
@@ -1236,9 +1388,9 @@ contact_list_view_remove_dialog_show (GtkWindow   *parent,
                                NULL);
        gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                                  "%s", secondary_text);
-        
+
        gtk_widget_show (dialog);
-        
+
        res = gtk_dialog_run (GTK_DIALOG (dialog));
        gtk_widget_destroy (dialog);
 
@@ -1328,22 +1480,21 @@ contact_list_view_remove_activate_cb (GtkMenuItem            *menuitem,
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
        EmpathyContact             *contact;
-               
-       contact = empathy_contact_list_view_get_selected (view);
+
+       contact = empathy_contact_list_view_dup_selected (view);
 
        if (contact) {
-               gchar     *text; 
+               gchar     *text;
                GtkWindow *parent;
 
                parent = empathy_get_toplevel_window (GTK_WIDGET (view));
                text = g_strdup_printf (_("Do you really want to remove the contact '%s'?"),
-                                       empathy_contact_get_name (contact));                                            
+                                       empathy_contact_get_name (contact));
                if (contact_list_view_remove_dialog_show (parent, _("Removing contact"), text)) {
                        EmpathyContactList *list;
 
                        list = empathy_contact_list_store_get_list_iface (priv->store);
-                       empathy_contact_list_remove (list, contact, 
-                               _("Sorry, I don't want you in my contact list anymore."));
+                       empathy_contact_list_remove (list, contact, "");
                }
 
                g_free (text);
@@ -1359,32 +1510,31 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view)
        GtkWidget                  *menu;
        GtkWidget                  *item;
        GtkWidget                  *image;
+       EmpathyContactListFlags     flags;
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
 
-       contact = empathy_contact_list_view_get_selected (view);
+       contact = empathy_contact_list_view_dup_selected (view);
        if (!contact) {
                return NULL;
        }
+       flags = empathy_contact_list_view_get_flags (view);
 
        menu = empathy_contact_menu_new (contact, priv->contact_features);
 
-       if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) {
-               g_object_unref (contact);
-               return menu;
-       }
-
-       if (menu) {
-               /* Separator */
-               item = gtk_separator_menu_item_new ();
-               gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-               gtk_widget_show (item);
-       } else {
-               menu = gtk_menu_new ();
-       }
-
        /* Remove contact */
-       if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+       if (priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE &&
+           flags & EMPATHY_CONTACT_LIST_CAN_REMOVE) {
+               /* create the menu if required, or just add a separator */
+               if (!menu) {
+                       menu = gtk_menu_new ();
+               } else {
+                       item = gtk_separator_menu_item_new ();
+                       gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+                       gtk_widget_show (item);
+               }
+
+               /* Remove */
                item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
                image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
                                                      GTK_ICON_SIZE_MENU);