X-Git-Url: https://git.0d.be/?p=empathy.git;a=blobdiff_plain;f=libempathy-gtk%2Fempathy-contact-list-view.c;h=dd3dc54a6d5d5d682189711a42c6cd85e490c2fe;hp=6935ead505ce4ad74439e2c736acfd05070e568d;hb=f014e7c05ae05ec40926e8fdc4e7cd69bcf3359a;hpb=008e6bf5763d296800a24c13696d8ded00c37d35 diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 6935ead5..dd3dc54a 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -53,9 +53,6 @@ #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include -/* Flashing delay for icons (milliseconds). */ -#define FLASH_TIMEOUT 500 - /* Active users are those which have recently changed state * (e.g. online, offline or from normal to a busy state). */ @@ -66,6 +63,7 @@ typedef struct { GtkTreeRowReference *drag_row; EmpathyContactListFeatureFlags list_features; EmpathyContactFeatureFlags contact_features; + GtkWidget *tooltip_widget; } EmpathyContactListViewPriv; typedef struct { @@ -116,6 +114,58 @@ static guint signals[LAST_SIGNAL]; G_DEFINE_TYPE (EmpathyContactListView, empathy_contact_list_view, GTK_TYPE_TREE_VIEW); +static gboolean +contact_list_view_query_tooltip_cb (EmpathyContactListView *view, + gint x, + gint y, + gboolean keyboard_mode, + GtkTooltip *tooltip, + gpointer user_data) +{ + EmpathyContactListViewPriv *priv = GET_PRIV (view); + EmpathyContact *contact; + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + + /* FIXME: We need GTK version >= 2.12.10. See GNOME bug #504087 */ + if (gtk_check_version (2, 12, 10)) { + return FALSE; + } + + if (!gtk_tree_view_get_tooltip_context (GTK_TREE_VIEW (view), &x, &y, + keyboard_mode, + &model, &path, &iter)) { + return FALSE; + } + + gtk_tree_view_set_tooltip_row (GTK_TREE_VIEW (view), tooltip, path); + gtk_tree_path_free (path); + + gtk_tree_model_get (model, &iter, + EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, + -1); + if (!contact) { + return FALSE; + } + + if (!priv->tooltip_widget) { + priv->tooltip_widget = empathy_contact_widget_new (contact, + EMPATHY_CONTACT_WIDGET_EDIT_NONE); + g_object_add_weak_pointer (G_OBJECT (priv->tooltip_widget), + (gpointer) &priv->tooltip_widget); + } else { + empathy_contact_widget_set_contact (priv->tooltip_widget, + contact); + } + + gtk_tooltip_set_custom (tooltip, priv->tooltip_widget); + + g_object_unref (contact); + + return TRUE; +} + static void contact_list_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, @@ -466,21 +516,22 @@ contact_list_view_row_activated_cb (EmpathyContactListView *view, GtkTreeModel *model; GtkTreeIter iter; - if (!(priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT)) { - return; - } - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (view)); - + model = GTK_TREE_MODEL (priv->store); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, EMPATHY_CONTACT_LIST_STORE_COL_CONTACT, &contact, -1); - if (contact) { + if (!contact) { + return; + } + + /* There is no event for the contact, default action is starting a chat */ + if (priv->contact_features & EMPATHY_CONTACT_FEATURE_CHAT) { empathy_dispatcher_chat_with_contact (contact); - g_object_unref (contact); } + + g_object_unref (contact); } static void @@ -873,6 +924,7 @@ contact_list_view_set_list_features (EmpathyContactListView *view, EmpathyContactListFeatureFlags features) { EmpathyContactListViewPriv *priv = GET_PRIV (view); + gboolean has_tooltip; g_return_if_fail (EMPATHY_IS_CONTACT_LIST_VIEW (view)); @@ -897,9 +949,13 @@ contact_list_view_set_list_features (EmpathyContactListView *view, G_N_ELEMENTS (drag_types_dest), GDK_ACTION_MOVE | GDK_ACTION_COPY); } else { - /* FIXME: URI could still be droped depending on FT feature */ + /* FIXME: URI could still be droped depending on FT feature */ gtk_drag_dest_unset (GTK_WIDGET (view)); } + + /* Update has-tooltip */ + has_tooltip = (features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_TOOLTIP) != 0; + gtk_widget_set_has_tooltip (GTK_WIDGET (view), has_tooltip); } static void @@ -1041,26 +1097,24 @@ empathy_contact_list_view_init (EmpathyContactListView *view) NULL, NULL); /* Connect to tree view signals rather than override. */ - g_signal_connect (view, - "button-press-event", + g_signal_connect (view, "button-press-event", G_CALLBACK (contact_list_view_button_press_event_cb), NULL); - g_signal_connect (view, - "key-press-event", + g_signal_connect (view, "key-press-event", G_CALLBACK (contact_list_view_key_press_event_cb), NULL); - g_signal_connect (view, - "row-activated", + g_signal_connect (view, "row-activated", G_CALLBACK (contact_list_view_row_activated_cb), NULL); - g_signal_connect (view, - "row-expanded", + g_signal_connect (view, "row-expanded", G_CALLBACK (contact_list_view_row_expand_or_collapse_cb), GINT_TO_POINTER (TRUE)); - g_signal_connect (view, - "row-collapsed", + g_signal_connect (view, "row-collapsed", G_CALLBACK (contact_list_view_row_expand_or_collapse_cb), GINT_TO_POINTER (FALSE)); + g_signal_connect (view, "query-tooltip", + G_CALLBACK (contact_list_view_query_tooltip_cb), + NULL); } EmpathyContactListView * @@ -1144,8 +1198,8 @@ contact_list_view_remove_dialog_show (GtkWindow *parent, dialog = gtk_dialog_new_with_buttons (window_title, parent, GTK_DIALOG_MODAL, + GTK_STOCK_CANCEL, GTK_RESPONSE_NO, GTK_STOCK_DELETE, GTK_RESPONSE_YES, - GTK_STOCK_CANCEL, GTK_RESPONSE_NO, NULL); gtk_dialog_set_has_separator (GTK_DIALOG(dialog), FALSE); @@ -1293,10 +1347,9 @@ empathy_contact_list_view_get_contact_menu (EmpathyContactListView *view) menu = empathy_contact_menu_new (contact, priv->contact_features); - if (!menu && - !(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) { + if (!(priv->list_features & EMPATHY_CONTACT_LIST_FEATURE_CONTACT_REMOVE)) { g_object_unref (contact); - return NULL; + return menu; } if (menu) {