]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-contact-list-view.c
Move contact menu code to its own module.
[empathy.git] / libempathy-gtk / empathy-contact-list-view.c
index 70a2b0c0aaf033fee0d44227ddb52cf888725a8b..1bc1a657e21dbdc1bcdb2cd8c26b6ad477ef0823 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * Copyright (C) 2005-2007 Imendio AB
- * Copyright (C) 2007 Collabora Ltd.
+ * Copyright (C) 2007-2008 Collabora Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -31,8 +31,6 @@
 #include <gtk/gtk.h>
 #include <glade/glade.h>
 
-#include <libtelepathy/tp-helpers.h>
-
 #include <libmissioncontrol/mc-account.h>
 #include <libmissioncontrol/mission-control.h>
 
 #include <libempathy/empathy-contact-list.h>
 #include <libempathy/empathy-log-manager.h>
 #include <libempathy/empathy-tp-group.h>
+#include <libempathy/empathy-contact-groups.h>
 #include <libempathy/empathy-debug.h>
 #include <libempathy/empathy-utils.h>
-#include <libempathy/empathy-marshal.h>
 
 #include "empathy-contact-list-view.h"
 #include "empathy-contact-list-store.h"
+#include "empathy-contact-menu.h"
 #include "empathy-images.h"
-#include "empathy-contact-groups.h"
 #include "empathy-cell-renderer-expander.h"
 #include "empathy-cell-renderer-text.h"
 #include "empathy-cell-renderer-activatable.h"
 #include "empathy-ui-utils.h"
 #include "empathy-contact-dialogs.h"
-//#include "empathy-chat-invite.h"
-//#include "empathy-ft-window.h"
 #include "empathy-log-window.h"
+#include "empathy-gtk-enum-types.h"
+#include "empathy-gtk-marshal.h"
 
 #define DEBUG_DOMAIN "ContactListView"
 
 
 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONTACT_LIST_VIEW, EmpathyContactListViewPriv))
 
-struct _EmpathyContactListViewPriv {
-       EmpathyContactListStore *store;
-       GtkUIManager            *ui;
-       GtkTreeRowReference     *drag_row;
-       gboolean                 interactive;
-};
+typedef struct {
+       EmpathyContactListStore    *store;
+       GtkTreeRowReference        *drag_row;
+       EmpathyContactListFeatures  features;
+} EmpathyContactListViewPriv;
 
 typedef struct {
        EmpathyContactListView *view;
@@ -139,13 +136,11 @@ static void        contact_list_view_pixbuf_cell_data_func     (GtkTreeViewColum
                                                                GtkTreeModel               *model,
                                                                GtkTreeIter                *iter,
                                                                EmpathyContactListView     *view);
-#ifdef HAVE_VOIP
 static void        contact_list_view_voip_cell_data_func       (GtkTreeViewColumn          *tree_column,
                                                                GtkCellRenderer            *cell,
                                                                GtkTreeModel               *model,
                                                                GtkTreeIter                *iter,
                                                                EmpathyContactListView     *view);
-#endif
 static void        contact_list_view_avatar_cell_data_func     (GtkTreeViewColumn          *tree_column,
                                                                GtkCellRenderer            *cell,
                                                                GtkTreeModel               *model,
@@ -161,10 +156,6 @@ static void        contact_list_view_expander_cell_data_func   (GtkTreeViewColum
                                                                GtkTreeModel               *model,
                                                                GtkTreeIter                *iter,
                                                                EmpathyContactListView      *view);
-static GtkWidget * contact_list_view_get_contact_menu          (EmpathyContactListView      *view,
-                                                               gboolean                    can_send_file,
-                                                               gboolean                    can_show_log,
-                                                               gboolean                    can_voip);
 static gboolean    contact_list_view_button_press_event_cb     (EmpathyContactListView      *view,
                                                                GdkEventButton             *event,
                                                                gpointer                    user_data);
@@ -172,100 +163,24 @@ static void        contact_list_view_row_activated_cb          (EmpathyContactLi
                                                                GtkTreePath                *path,
                                                                GtkTreeViewColumn          *col,
                                                                gpointer                    user_data);
-#ifdef HAVE_VOIP
 static void        contact_list_view_voip_activated_cb         (EmpathyCellRendererActivatable *cell,
                                                                const gchar                *path_string,
                                                                EmpathyContactListView     *view);
-#endif
 static void        contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView      *view,
                                                                GtkTreeIter                *iter,
                                                                GtkTreePath                *path,
                                                                gpointer                    user_data);
-static void        contact_list_view_action_cb                 (GtkAction                  *action,
-                                                               EmpathyContactListView      *view);
-static void        contact_list_view_action_activated          (EmpathyContactListView      *view,
-                                                               EmpathyContact              *contact);
 static void        contact_list_view_voip_activated            (EmpathyContactListView      *view,
                                                                EmpathyContact              *contact);
+static gboolean           contact_list_view_remove_dialog_show         (GtkWindow                  *parent,
+                                                               const gchar                 *window_title, 
+                                                               const gchar                 *text);
 
 enum {
        PROP_0,
-       PROP_INTERACTIVE
-};
-
-static const GtkActionEntry entries[] = {
-       { "ContactMenu", NULL,
-         N_("_Contact"), NULL, NULL,
-         NULL
-       },
-       { "GroupMenu", NULL,
-         N_("_Group"),NULL, NULL,
-         NULL
-       },
-       { "Chat", EMPATHY_IMAGE_MESSAGE,
-         N_("_Chat"), NULL, N_("Chat with contact"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Information", EMPATHY_IMAGE_CONTACT_INFORMATION,
-         N_("Infor_mation"), "<control>I", N_("View contact information"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Rename", NULL,
-         N_("Re_name"), NULL, N_("Rename"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Edit", GTK_STOCK_EDIT,
-         N_("_Edit"), NULL, N_("Edit the groups and name for this contact"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Remove", GTK_STOCK_REMOVE,
-         N_("_Remove"), NULL, N_("Remove contact"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Invite", EMPATHY_IMAGE_GROUP_MESSAGE,
-         N_("_Invite to Chat Room"), NULL, N_("Invite to a currently open chat room"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "SendFile", NULL,
-         N_("_Send File..."), NULL, N_("Send a file"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-       { "Log", GTK_STOCK_JUSTIFY_LEFT,
-         N_("_View Previous Conversations"), NULL, N_("View previous conversations with this contact"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-#ifdef HAVE_VOIP
-       { "Call", EMPATHY_IMAGE_VOIP,
-         N_("_Call"), NULL, N_("Start a voice or video conversation with this contact"),
-         G_CALLBACK (contact_list_view_action_cb)
-       },
-#endif
+       PROP_FEATURES
 };
 
-static guint n_entries = G_N_ELEMENTS (entries);
-
-static const gchar *ui_info =
-       "<ui>"
-       "  <popup name='Contact'>"
-       "    <menuitem action='Chat'/>"
-#ifdef HAVE_VOIP
-       "    <menuitem action='Call'/>"
-#endif
-       "    <menuitem action='Log'/>"
-       "    <menuitem action='SendFile'/>"
-       "    <separator/>"
-       "    <menuitem action='Invite'/>"
-       "    <separator/>"
-       "    <menuitem action='Edit'/>"
-       "    <menuitem action='Remove'/>"
-       "    <separator/>"
-       "    <menuitem action='Information'/>"
-       "  </popup>"
-       "  <popup name='Group'>"
-       "    <menuitem action='Rename'/>"
-       "  </popup>"
-       "</ui>";
-
 enum DndDragType {
        DND_DRAG_TYPE_CONTACT_ID,
        DND_DRAG_TYPE_URL,
@@ -322,17 +237,18 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass)
                              G_SIGNAL_RUN_LAST,
                              0,
                              NULL, NULL,
-                             empathy_marshal_VOID__OBJECT_STRING_STRING,
+                             _empathy_gtk_marshal_VOID__OBJECT_STRING_STRING,
                              G_TYPE_NONE,
                              3, EMPATHY_TYPE_CONTACT, G_TYPE_STRING, G_TYPE_STRING);
 
        g_object_class_install_property (object_class,
-                                        PROP_INTERACTIVE,
-                                        g_param_spec_boolean ("interactive",
-                                                              "View is interactive",
-                                                              "Is the view interactive",
-                                                              FALSE,
-                                                              G_PARAM_READWRITE));
+                                        PROP_FEATURES,
+                                        g_param_spec_flags ("features",
+                                                            "Features of the view",
+                                                            "Falgs for all enabled features",
+                                                             EMPATHY_TYPE_CONTACT_LIST_FEATURES,
+                                                             0,
+                                                             G_PARAM_READWRITE));
 
        g_type_class_add_private (object_class, sizeof (EmpathyContactListViewPriv));
 }
@@ -340,30 +256,9 @@ empathy_contact_list_view_class_init (EmpathyContactListViewClass *klass)
 static void
 empathy_contact_list_view_init (EmpathyContactListView *view)
 {
-       EmpathyContactListViewPriv *priv;
-       GtkActionGroup            *action_group;
-       GError                    *error = NULL;
-
-       priv = GET_PRIV (view);
-
        /* Get saved group states. */
        empathy_contact_groups_get_all ();
 
-       /* Set up UI Manager */
-       priv->ui = gtk_ui_manager_new ();
-
-       action_group = gtk_action_group_new ("Actions");
-       gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       gtk_action_group_add_actions (action_group, entries, n_entries, view);
-       gtk_ui_manager_insert_action_group (priv->ui, action_group, 0);
-
-       if (!gtk_ui_manager_add_ui_from_string (priv->ui, ui_info, -1, &error)) {
-               g_warning ("Could not build contact menus from string:'%s'", error->message);
-               g_error_free (error);
-       }
-
-       g_object_unref (action_group);
-
        gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (view), 
                                              empathy_contact_list_store_row_separator_func,
                                              NULL, NULL);
@@ -394,9 +289,6 @@ contact_list_view_finalize (GObject *object)
 
        priv = GET_PRIV (object);
 
-       if (priv->ui) {
-               g_object_unref (priv->ui);
-       }
        if (priv->store) {
                g_object_unref (priv->store);
        }
@@ -415,8 +307,8 @@ contact_list_view_get_property (GObject    *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
-       case PROP_INTERACTIVE:
-               g_value_set_boolean (value, priv->interactive);
+       case PROP_FEATURES:
+               g_value_set_flags (value, priv->features);
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -436,8 +328,8 @@ contact_list_view_set_property (GObject      *object,
        priv = GET_PRIV (object);
 
        switch (param_id) {
-       case PROP_INTERACTIVE:
-               empathy_contact_list_view_set_interactive (view, g_value_get_boolean (value));
+       case PROP_FEATURES:
+               empathy_contact_list_view_set_features (view, g_value_get_flags (value));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -446,40 +338,69 @@ contact_list_view_set_property (GObject      *object,
 }
 
 EmpathyContactListView *
-empathy_contact_list_view_new (EmpathyContactListStore *store)
+empathy_contact_list_view_new (EmpathyContactListStore    *store,
+                              EmpathyContactListFeatures  features)
 {
-       EmpathyContactListViewPriv *priv;
        EmpathyContactListView     *view;
+       EmpathyContactListViewPriv *priv;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_STORE (store), NULL);
        
-       view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW, NULL);
-       priv = GET_PRIV (view);
+       view = g_object_new (EMPATHY_TYPE_CONTACT_LIST_VIEW,
+                           "features", features,
+                           NULL);
 
+       priv = GET_PRIV (view);
        priv->store = g_object_ref (store);
-       contact_list_view_setup (view);
+       contact_list_view_setup (EMPATHY_CONTACT_LIST_VIEW (view));
 
        return view;
 }
 
 void
-empathy_contact_list_view_set_interactive (EmpathyContactListView  *view,
-                                          gboolean                 interactive)
+empathy_contact_list_view_set_features (EmpathyContactListView     *view,
+                                       EmpathyContactListFeatures  features)
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
 
        g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view));
 
-       priv->interactive = interactive;
-       g_object_notify (G_OBJECT (view), "interactive");
+       priv->features = features;
+
+       /* Update DnD source/dest */
+       if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DRAG) {
+               gtk_drag_source_set (GTK_WIDGET (view),
+                                    GDK_BUTTON1_MASK,
+                                    drag_types_source,
+                                    G_N_ELEMENTS (drag_types_source),
+                                    GDK_ACTION_MOVE | GDK_ACTION_COPY);
+       } else {
+               gtk_drag_source_unset (GTK_WIDGET (view));
+
+       }
+
+       if (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_DROP) {
+               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_COPY);
+       } else {
+               /* FIXME: URI could still be  droped depending on FT feature */
+               gtk_drag_dest_unset (GTK_WIDGET (view));
+       }
+
+       g_object_notify (G_OBJECT (view), "features");
 }
 
-gboolean
-empathy_contact_list_view_get_interactive (EmpathyContactListView  *view)
+EmpathyContactListFeatures
+empathy_contact_list_view_get_features (EmpathyContactListView  *view)
 {
        EmpathyContactListViewPriv *priv = GET_PRIV (view);
 
        g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), FALSE);
 
-       return priv->interactive;
+       return priv->features;
 }
 
 EmpathyContact *
@@ -500,7 +421,9 @@ empathy_contact_list_view_get_selected (EmpathyContactListView *view)
                return NULL;
        }
 
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        return contact;
 }
@@ -525,8 +448,8 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
        }
 
        gtk_tree_model_get (model, &iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        if (!is_group) {
@@ -537,48 +460,6 @@ empathy_contact_list_view_get_selected_group (EmpathyContactListView *view)
        return name;
 }
 
-GtkWidget *
-empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
-{
-       EmpathyContactListViewPriv *priv;
-       GtkWidget                 *widget;
-
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
-
-       priv = GET_PRIV (view);
-
-       widget = gtk_ui_manager_get_widget (priv->ui, "/Group");
-
-       return widget;
-}
-
-GtkWidget *
-empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
-                                           EmpathyContact         *contact)
-{
-       EmpathyLogManager *log_manager;
-       gboolean           can_show_log;
-       gboolean           can_send_file;
-       gboolean           can_voip;
-
-       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
-       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
-
-       log_manager = empathy_log_manager_new ();
-       can_show_log = empathy_log_manager_exists (log_manager,
-                                                  empathy_contact_get_account (contact),
-                                                  empathy_contact_get_id (contact),
-                                                  FALSE);
-       g_object_unref (log_manager);
-       can_send_file = FALSE;
-       can_voip = empathy_contact_can_voip (contact);
-
-       return contact_list_view_get_contact_menu (view,
-                                                  can_send_file,
-                                                  can_show_log,
-                                                  can_voip);
-}
-
 static void
 contact_list_view_setup (EmpathyContactListView *view)
 {
@@ -631,13 +512,12 @@ contact_list_view_setup (EmpathyContactListView *view)
                view, NULL);
 
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "name", COL_NAME);
+                                           "name", EMPATHY_CONTACT_LIST_STORE_COL_NAME);
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "status", COL_STATUS);
+                                           "status", EMPATHY_CONTACT_LIST_STORE_COL_STATUS);
        gtk_tree_view_column_add_attribute (col, cell,
-                                           "is_group", COL_IS_GROUP);
+                                           "is_group", EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP);
 
-#ifdef HAVE_VOIP
        /* Voip Capability Icon */
        cell = empathy_cell_renderer_activatable_new ();
        gtk_tree_view_column_pack_start (col, cell, FALSE);
@@ -653,7 +533,6 @@ contact_list_view_setup (EmpathyContactListView *view)
        g_signal_connect (cell, "path-activated",
                          G_CALLBACK (contact_list_view_voip_activated_cb),
                          view);
-#endif
 
        /* Avatar */
        cell = gtk_cell_renderer_pixbuf_new ();
@@ -692,21 +571,6 @@ contact_list_view_setup (EmpathyContactListView *view)
                drag_atoms_source[i] = gdk_atom_intern (drag_types_source[i].target,
                                                        FALSE);
        }
-
-       /* Note: We support the COPY action too, but need to make the
-        * MOVE action the default.
-        */
-       gtk_drag_source_set (GTK_WIDGET (view),
-                            GDK_BUTTON1_MASK,
-                            drag_types_source,
-                            G_N_ELEMENTS (drag_types_source),
-                            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_COPY);
 }
 
 static void
@@ -715,12 +579,13 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel          *model,
                                            GtkTreeIter           *iter,
                                            EmpathyContactListView *view)
 {
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
        gboolean  is_group = FALSE;
        gchar    *name = NULL;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        if (!is_group || G_STR_EMPTY (name)) {
@@ -728,7 +593,8 @@ contact_list_view_row_has_child_toggled_cb (GtkTreeModel          *model,
                return;
        }
 
-       if (empathy_contact_group_get_expanded (name)) {
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE) ||
+           empathy_contact_group_get_expanded (name)) {
                g_signal_handlers_block_by_func (view,
                                                 contact_list_view_row_expand_or_collapse_cb,
                                                 GINT_TO_POINTER (TRUE));
@@ -797,6 +663,10 @@ contact_list_view_drag_data_received (GtkWidget         *widget,
                return;
        }
 
+       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. */
@@ -891,8 +761,7 @@ contact_list_view_drag_motion (GtkWidget      *widget,
                dm->view = EMPATHY_CONTACT_LIST_VIEW (widget);
                dm->path = gtk_tree_path_copy (path);
 
-               dm->timeout_id = g_timeout_add (
-                       1500,
+               dm->timeout_id = g_timeout_add_seconds (1,
                        (GSourceFunc) contact_list_view_drag_motion_cb,
                        dm);
        }
@@ -953,7 +822,6 @@ contact_list_view_drag_data_get (GtkWidget        *widget,
        const gchar                *contact_id;
        const gchar                *account_id;
        gchar                      *str;
-       
 
        priv = GET_PRIV (widget);
 
@@ -1033,27 +901,21 @@ contact_list_view_cell_set_background (EmpathyContactListView *view,
 
        style = gtk_widget_get_style (GTK_WIDGET (view));
 
-       if (!is_group) {
-               if (is_active) {
-                       color = style->bg[GTK_STATE_SELECTED];
-
-                       /* Here we take the current theme colour and add it to
-                        * the colour for white and average the two. This
-                        * gives a colour which is inline with the theme but
-                        * slightly whiter.
-                        */
-                       color.red = (color.red + (style->white).red) / 2;
-                       color.green = (color.green + (style->white).green) / 2;
-                       color.blue = (color.blue + (style->white).blue) / 2;
-
-                       g_object_set (cell,
-                                     "cell-background-gdk", &color,
-                                     NULL);
-               } else {
-                       g_object_set (cell,
-                                     "cell-background-gdk", NULL,
-                                     NULL);
-               }
+       if (!is_group && is_active) {
+               color = style->bg[GTK_STATE_SELECTED];
+
+               /* Here we take the current theme colour and add it to
+                * the colour for white and average the two. This
+                * gives a colour which is inline with the theme but
+                * slightly whiter.
+                */
+               color.red = (color.red + (style->white).red) / 2;
+               color.green = (color.green + (style->white).green) / 2;
+               color.blue = (color.blue + (style->white).blue) / 2;
+
+               g_object_set (cell,
+                             "cell-background-gdk", &color,
+                             NULL);
        } else {
                g_object_set (cell,
                              "cell-background-gdk", NULL,
@@ -1073,9 +935,9 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean  is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
-                           COL_ICON_STATUS, &icon_name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_ICON_STATUS, &icon_name,
                            -1);
 
        g_object_set (cell,
@@ -1088,7 +950,6 @@ contact_list_view_pixbuf_cell_data_func (GtkTreeViewColumn     *tree_column,
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
 
-#ifdef HAVE_VOIP
 static void
 contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
                                       GtkCellRenderer        *cell,
@@ -1101,9 +962,9 @@ contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
        gboolean can_voip;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
-                           COL_CAN_VOIP, &can_voip,
+                           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,
                            -1);
 
        g_object_set (cell,
@@ -1113,7 +974,6 @@ contact_list_view_voip_cell_data_func (GtkTreeViewColumn      *tree_column,
 
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
-#endif
 
 static void
 contact_list_view_avatar_cell_data_func (GtkTreeViewColumn     *tree_column,
@@ -1128,10 +988,10 @@ contact_list_view_avatar_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean   is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_PIXBUF_AVATAR, &pixbuf,
-                           COL_PIXBUF_AVATAR_VISIBLE, &show_avatar,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR, &pixbuf,
+                           EMPATHY_CONTACT_LIST_STORE_COL_PIXBUF_AVATAR_VISIBLE, &show_avatar,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
                            -1);
 
        g_object_set (cell,
@@ -1158,9 +1018,9 @@ contact_list_view_text_cell_data_func (GtkTreeViewColumn     *tree_column,
        gboolean show_status;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
-                           COL_STATUS_VISIBLE, &show_status,
+                           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,
                            -1);
 
        g_object_set (cell,
@@ -1181,8 +1041,8 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn     *column,
        gboolean is_active;
 
        gtk_tree_model_get (model, iter,
-                           COL_IS_GROUP, &is_group,
-                           COL_IS_ACTIVE, &is_active,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_GROUP, &is_group,
+                           EMPATHY_CONTACT_LIST_STORE_COL_IS_ACTIVE, &is_active,
                            -1);
 
        if (gtk_tree_model_iter_has_child (model, iter)) {
@@ -1204,33 +1064,224 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn     *column,
        contact_list_view_cell_set_background (view, cell, is_group, is_active);
 }
 
-static GtkWidget *
-contact_list_view_get_contact_menu (EmpathyContactListView *view,
-                                   gboolean               can_send_file,
-                                   gboolean               can_show_log,
-                                   gboolean               can_voip)
+static gboolean
+contact_list_view_remove_dialog_show (GtkWindow   *parent, 
+                                     const gchar *window_title, 
+                                     const gchar *text)
 {
-       EmpathyContactListViewPriv *priv;
-       GtkAction                 *action;
-       GtkWidget                 *widget;
+       GtkWidget *dialog, *label, *image, *hbox;
+       gboolean res;
+       
+       dialog = gtk_dialog_new_with_buttons (window_title, parent,
+                                             GTK_DIALOG_MODAL,
+                                             GTK_STOCK_DELETE, GTK_RESPONSE_YES,
+                                             GTK_STOCK_CANCEL, GTK_RESPONSE_NO,
+                                             NULL);
+       gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE);
+        
+       label = gtk_label_new (text);
+       image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+        
+       hbox = gtk_hbox_new (FALSE, 5);
+       gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+       gtk_box_pack_start_defaults (GTK_BOX (hbox), image);
+       gtk_box_pack_start_defaults (GTK_BOX (hbox), label);     
+       gtk_box_pack_start_defaults (GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox);
+
+       gtk_widget_show (image);
+       gtk_widget_show (label);
+       gtk_widget_show (hbox);
+       gtk_widget_show (dialog);
+        
+       res = gtk_dialog_run (GTK_DIALOG (dialog));
+       gtk_widget_destroy (dialog);
+
+       return (res == GTK_RESPONSE_YES);
+}
 
-       priv = GET_PRIV (view);
+static void
+contact_list_view_group_remove_activate_cb (GtkMenuItem            *menuitem,
+                                           EmpathyContactListView *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       gchar                      *group;
+
+       group = empathy_contact_list_view_get_selected_group (view);
+       if (group) {
+               gchar     *text;
+               GtkWindow *parent;
+
+               text = g_strdup_printf (_("Do you really want to remove the group '%s' ?"), group);
+               parent = empathy_get_toplevel_window (GTK_WIDGET (view));
+               if (contact_list_view_remove_dialog_show (parent, _("Removing group"), text)) {
+                       EmpathyContactList *list;
+
+                       list = empathy_contact_list_store_get_list_iface (priv->store);
+                       empathy_contact_list_remove_group (list, group);
+               }
+
+               g_free (text);
+       }
+
+       g_free (group);
+}
+
+GtkWidget *
+empathy_contact_list_view_get_group_menu (EmpathyContactListView *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkWidget                  *menu;
+       GtkWidget                  *item;
+       GtkWidget                  *image;
+
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
+
+       if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME |
+                               EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE))) {
+               return NULL;
+       }
+
+       menu = gtk_menu_new ();
+
+       /* FIXME: Not implemented yet
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_RENAME) {
+               item = gtk_menu_item_new_with_mnemonic (_("Re_name"));
+               gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+               gtk_widget_show (item);
+               g_signal_connect (item, "activate",
+                                 G_CALLBACK (contact_list_view_group_rename_activate_cb),
+                                 view);
+       }*/
+
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_REMOVE) {
+               item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
+               image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
+                                                     GTK_ICON_SIZE_MENU);
+               gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+               gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+               gtk_widget_show (item);
+               g_signal_connect (item, "activate",
+                                 G_CALLBACK (contact_list_view_group_remove_activate_cb),
+                                 view);
+       }
+
+       return menu;
+}
+
+static void
+contact_list_view_remove_activate_cb (GtkMenuItem            *menuitem,
+                                     EmpathyContactListView *view)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       EmpathyContact             *contact;
+               
+       contact = empathy_contact_list_view_get_selected (view);
+
+       if (contact) {
+               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));                                            
+               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."));
+               }
+
+               g_free (text);
+               g_object_unref (contact);
+       }
+}
+
+GtkWidget *
+empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view,
+                                           EmpathyContact         *contact)
+{
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkWidget                  *menu;
+       GtkMenuShell               *shell;
+       GtkWidget                  *item;
+       GtkWidget                  *image;
 
-       /* Sort out sensitive items */
-       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Log");
-       gtk_action_set_sensitive (action, can_show_log);
+       g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
+       g_return_val_if_fail (EMPATHY_IS_CONTACT (contact), NULL);
 
-#ifdef HAVE_VOIP
-       action = gtk_ui_manager_get_action (priv->ui, "/Contact/Call");
-       gtk_action_set_sensitive (action, can_voip);
-#endif
+       if (!(priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_FT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INVITE |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO |
+                               EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE))) {
+               return NULL;
+       }
 
-       action = gtk_ui_manager_get_action (priv->ui, "/Contact/SendFile");
-       gtk_action_set_visible (action, can_send_file);
+       menu = gtk_menu_new ();
+       shell = GTK_MENU_SHELL (menu);
 
-       widget = gtk_ui_manager_get_widget (priv->ui, "/Contact");
+       /* Main items */
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT) {
+               item = empathy_contact_chat_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL) {
+               item = empathy_contact_call_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_LOG) {
+               item = empathy_contact_log_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
 
-       return widget;
+       /* Separator */
+       if (priv->features & (EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT |
+                             EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO)) {
+               item = gtk_separator_menu_item_new ();
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+
+       /* More items */
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_EDIT) {
+               item = empathy_contact_edit_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_INFO) {
+               item = empathy_contact_info_menu_item_new (contact);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+
+       /* Separator */
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+               item = gtk_separator_menu_item_new ();
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+       }
+
+       /* Custom items */
+       if (priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE) {
+               item = gtk_image_menu_item_new_with_mnemonic (_("_Remove"));
+               image = gtk_image_new_from_icon_name (GTK_STOCK_REMOVE,
+                                                     GTK_ICON_SIZE_MENU);
+               gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
+               gtk_menu_shell_append (shell, item);
+               gtk_widget_show (item);
+               g_signal_connect (item, "activate",
+                                 G_CALLBACK (contact_list_view_remove_activate_cb),
+                                 view);
+       }
+
+       return menu;
 }
 
 static gboolean
@@ -1249,7 +1300,7 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
 
        priv = GET_PRIV (view);
 
-       if (!priv->interactive || event->button != 3) {
+       if (event->button != 3) {
                return FALSE;
        }
 
@@ -1272,7 +1323,9 @@ contact_list_view_button_press_event_cb (EmpathyContactListView *view,
        gtk_tree_model_get_iter (model, &iter, path);
        gtk_tree_path_free (path);
 
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        if (contact) {
                menu = empathy_contact_list_view_get_contact_menu (view, contact);
@@ -1305,22 +1358,23 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view,
        GtkTreeModel               *model;
        GtkTreeIter                 iter;
 
-       if (!priv->interactive) {
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CHAT)) {
                return;
        }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
        gtk_tree_model_get_iter (model, &iter, path);
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        if (contact) {
-               contact_list_view_action_activated (view, contact);
+               empathy_chat_with_contact (contact);
                g_object_unref (contact);
        }
 }
 
-#ifdef HAVE_VOIP
 static void
 contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
                                     const gchar                    *path_string,
@@ -1331,7 +1385,7 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
        GtkTreeIter                 iter;
        EmpathyContact             *contact;
 
-       if (!priv->interactive) {
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_CALL)) {
                return;
        }
 
@@ -1340,15 +1394,15 @@ contact_list_view_voip_activated_cb (EmpathyCellRendererActivatable *cell,
                return;
        }
 
-       gtk_tree_model_get (model, &iter, COL_CONTACT, &contact, -1);
+       gtk_tree_model_get (model, &iter,
+                           EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact,
+                           -1);
 
        if (contact) {
                contact_list_view_voip_activated (view, contact);
                g_object_unref (contact);
        }
 }
-#endif
-
 
 static void
 contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view,
@@ -1356,14 +1410,19 @@ contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view,
                                             GtkTreePath           *path,
                                             gpointer               user_data)
 {
-       GtkTreeModel *model;
-       gchar        *name;
-       gboolean      expanded;
+       EmpathyContactListViewPriv *priv = GET_PRIV (view);
+       GtkTreeModel               *model;
+       gchar                      *name;
+       gboolean                    expanded;
+
+       if (!(priv->features & EMPATHY_CONTACT_LIST_FEATURE_GROUPS_SAVE)) {
+               return;
+       }
 
        model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
 
        gtk_tree_model_get (model, iter,
-                           COL_NAME, &name,
+                           EMPATHY_CONTACT_LIST_STORE_COL_NAME, &name,
                            -1);
 
        expanded = GPOINTER_TO_INT (user_data);
@@ -1372,88 +1431,10 @@ contact_list_view_row_expand_or_collapse_cb (EmpathyContactListView *view,
        g_free (name);
 }
 
-static void
-contact_list_view_action_cb (GtkAction             *action,
-                            EmpathyContactListView *view)
-{
-       EmpathyContactListViewPriv *priv;
-       EmpathyContact             *contact;
-       const gchar               *name;
-       gchar                     *group;
-       GtkWindow                 *parent;
-
-       priv = GET_PRIV (view);
-
-       name = gtk_action_get_name (action);
-       if (!name) {
-               return;
-       }
-
-       empathy_debug (DEBUG_DOMAIN, "Action:'%s' activated", name);
-
-       contact = empathy_contact_list_view_get_selected (view);
-       group = empathy_contact_list_view_get_selected_group (view);
-       parent = empathy_get_toplevel_window (GTK_WIDGET (view));
-
-       if (contact && strcmp (name, "Chat") == 0) {
-               contact_list_view_action_activated (view, contact);
-       }
-       else if (contact && strcmp (name, "Call") == 0) {
-               contact_list_view_voip_activated (view, contact);
-       }
-       else if (contact && strcmp (name, "Information") == 0) {
-               empathy_contact_information_dialog_show (contact, parent, FALSE);
-       }
-       else if (contact && strcmp (name, "Edit") == 0) {
-               empathy_contact_information_dialog_show (contact, parent, TRUE);
-       }
-       else if (contact && strcmp (name, "Remove") == 0) {
-               /* FIXME: Ask for confirmation */
-               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."));
-       }
-       else if (contact && strcmp (name, "Invite") == 0) {
-       }
-       else if (contact && strcmp (name, "SendFile") == 0) {
-       }
-       else if (contact && strcmp (name, "Log") == 0) {
-               empathy_log_window_show (empathy_contact_get_account (contact),
-                                       empathy_contact_get_id (contact),
-                                       FALSE,
-                                       parent);
-       }
-       else if (group && strcmp (name, "Rename") == 0) {
-       }
-
-       g_free (group);
-       if (contact) {
-               g_object_unref (contact);
-       }
-}
-
-static void
-contact_list_view_action_activated (EmpathyContactListView *view,
-                                   EmpathyContact         *contact)
-{
-       MissionControl *mc;
-
-       mc = empathy_mission_control_new ();
-       mission_control_request_channel (mc,
-                                        empathy_contact_get_account (contact),
-                                        TP_IFACE_CHANNEL_TYPE_TEXT,
-                                        empathy_contact_get_handle (contact),
-                                        TP_HANDLE_TYPE_CONTACT,
-                                        NULL, NULL);
-       g_object_unref (mc);
-}
-
 static void
 contact_list_view_voip_activated (EmpathyContactListView *view,
                                  EmpathyContact         *contact)
 {
-       empathy_call_contact (contact);
+       empathy_call_with_contact (contact);
 }