#include <gtk/gtk.h>
#include <telepathy-glib/util.h>
-#include <libmissioncontrol/mc-account.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-call-factory.h>
EmpathyContactListView *view)
{
EmpathyContactListViewPriv *priv = GET_PRIV (view);
-
+
if (priv->tooltip_widget) {
DEBUG ("Tooltip destroyed");
g_object_unref (priv->tooltip_widget);
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),
if (data->new_group) {
empathy_contact_list_add_to_group (list, contact, data->new_group);
}
- if (data->old_group && data->action == GDK_ACTION_MOVE) {
+ if (data->old_group && data->action == GDK_ACTION_MOVE) {
empathy_contact_list_remove_from_group (list, contact, data->old_group);
}
}
EmpathyContactListViewPriv *priv;
EmpathyAccountManager *account_manager;
EmpathyTpContactFactory *factory = NULL;
- McAccount *account;
+ EmpathyAccount *account;
GtkTreeModel *model;
GtkTreeViewDropPosition position;
GtkTreePath *path;
goto OUT;
}
- id = (const gchar*) selection->data;
+ 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" : "",
strv = g_strsplit (id, "/", 2);
account_id = strv[0];
contact_id = strv[1];
- account = mc_account_lookup (account_id);
+ account_manager = empathy_account_manager_dup_singleton ();
+ account = empathy_account_manager_get_account (account_manager, account_id);
if (account) {
TpConnection *connection;
- /* FIXME: We assume we have already an account manager */
- account_manager = empathy_account_manager_dup_singleton ();
- connection = empathy_account_manager_get_connection (account_manager,
- account);
+ connection = empathy_account_get_connection (account);
if (connection) {
factory = empathy_tp_contact_factory_dup_singleton (connection);
}
- g_object_unref (account_manager);
}
+ g_object_unref (account_manager);
if (!factory) {
DEBUG ("Failed to get factory for account '%s'", account_id);
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,
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;
}
GtkTreeIter iter;
GtkTreeModel *model;
EmpathyContact *contact;
- McAccount *account;
+ EmpathyAccount *account;
const gchar *contact_id;
const gchar *account_id;
gchar *str;
}
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);
}
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;
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,
}
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,
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,
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,
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);
}
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,
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_audio_call_cell_data_func,
+ view, NULL);
+
+ g_object_set (cell,
+ "visible", FALSE,
+ NULL);
+
+ g_signal_connect (cell, "path-activated",
+ 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_voip_cell_data_func,
+ (GtkTreeCellDataFunc) contact_list_view_video_call_cell_data_func,
view, NULL);
g_object_set (cell,
NULL);
g_signal_connect (cell, "path-activated",
- G_CALLBACK (contact_list_view_voip_activated_cb),
+ G_CALLBACK (contact_list_view_video_call_activated_cb),
view);
/* Avatar */
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,
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)
{
{
GtkWidget *dialog;
gboolean res;
-
+
dialog = gtk_message_dialog_new (parent, GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
"%s", message);
{
EmpathyContactListViewPriv *priv = GET_PRIV (view);
EmpathyContact *contact;
-
+
contact = empathy_contact_list_view_dup_selected (view);
if (contact) {
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);
GtkWidget *menu;
GtkWidget *item;
GtkWidget *image;
+ EmpathyContactListFlags flags;
g_return_val_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view), NULL);
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);