diff options
author | Xavier Claessens <xclaesse@gmail.com> | 2011-07-26 16:19:39 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2011-07-26 16:19:39 +0800 |
commit | 5a56118ce05c8b0579e4a7397d9c57fdd3b01937 (patch) | |
tree | 916f696113bf01c529719c254a13116a50a25fb3 | |
parent | e10a0655a4eb8c36f232d533078bcf6b8e7fdbd0 (diff) | |
parent | d954376bde5deb4cadfc55e510b703d946ede93f (diff) | |
download | gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar.gz gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar.bz2 gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar.lz gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar.xz gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.tar.zst gsoc2013-empathy-5a56118ce05c8b0579e4a7397d9c57fdd3b01937.zip |
Merge remote-tracking branch 'danni/drag-n-drop-558942'
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 52 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contact-list-view.c | 6 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-view.c | 6 |
3 files changed, 52 insertions, 12 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 239be0b1f..5f441af19 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -149,6 +149,11 @@ struct _EmpathyChatPriv { * messages in tab will be properly shown */ gboolean retrieving_backlogs; gboolean sms_channel; + + /* we need to know whether populate-popup happened in response to + * the keyboard or the mouse. We can't ask GTK for the most recent + * event, because it will be a notify event. Instead we track it here */ + GdkEventType most_recent_event_type; }; typedef struct { @@ -1702,6 +1707,8 @@ chat_input_key_press_event_cb (GtkWidget *widget, priv = GET_PRIV (chat); + priv->most_recent_event_type = event->type; + /* Catch ctrl+up/down so we can traverse messages we sent */ if ((event->state & GDK_CONTROL_MASK) && (event->keyval == GDK_KEY_Up || @@ -2157,11 +2164,24 @@ chat_text_send_cb (GtkMenuItem *menuitem, chat_input_text_view_send (chat); } +static gboolean +chat_input_button_press_event_cb (GtkTextView *view, + GdkEventButton *event, + EmpathyChat *chat) +{ + EmpathyChatPriv *priv = GET_PRIV (chat); + + priv->most_recent_event_type = event->type; + + return FALSE; +} + static void chat_input_populate_popup_cb (GtkTextView *view, GtkMenu *menu, EmpathyChat *chat) { + EmpathyChatPriv *priv = GET_PRIV (chat); GtkTextBuffer *buffer; GtkTextTagTable *table; GtkTextTag *tag; @@ -2212,12 +2232,29 @@ chat_input_populate_popup_cb (GtkTextView *view, /* Add the spell check menu item. */ table = gtk_text_buffer_get_tag_table (buffer); tag = gtk_text_tag_table_lookup (table, "misspelled"); - gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); - gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), - GTK_TEXT_WINDOW_WIDGET, - x, y, - &x, &y); - gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &iter, x, y); + + switch (priv->most_recent_event_type) { + case GDK_BUTTON_PRESS: + /* get the location from the pointer */ + gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y); + gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (view), + GTK_TEXT_WINDOW_WIDGET, + x, y, + &x, &y); + gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), + &iter, x, y); + break; + + case GDK_KEY_PRESS: + /* get the location from the cursor */ + gtk_text_buffer_get_iter_at_mark (buffer, &iter, + gtk_text_buffer_get_insert (buffer)); + break; + + default: + break; + } + start = end = iter; if (gtk_text_iter_backward_to_tag_toggle (&start, tag) && gtk_text_iter_forward_to_tag_toggle (&end, tag)) { @@ -2891,6 +2928,9 @@ chat_create_ui (EmpathyChat *chat) g_signal_connect (chat->input_text_view, "realize", G_CALLBACK (chat_input_realize_cb), chat); + g_signal_connect (chat->input_text_view, "button-press-event", + G_CALLBACK (chat_input_button_press_event_cb), + chat); g_signal_connect (chat->input_text_view, "populate-popup", G_CALLBACK (chat_input_populate_popup_cb), chat); diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 2b0b51a36..4b2febd30 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -697,14 +697,14 @@ contact_list_view_drag_begin (GtkWidget *widget, priv = GET_PRIV (widget); - GTK_WIDGET_CLASS (empathy_contact_list_view_parent_class)->drag_begin (widget, - context); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) { return; } + GTK_WIDGET_CLASS (empathy_contact_list_view_parent_class)->drag_begin (widget, + context); + path = gtk_tree_model_get_path (model, &iter); priv->drag_row = gtk_tree_row_reference_new (model, path); gtk_tree_path_free (path); diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c index 0fb24430c..db63f0c0d 100644 --- a/libempathy-gtk/empathy-individual-view.c +++ b/libempathy-gtk/empathy-individual-view.c @@ -811,13 +811,13 @@ individual_view_drag_begin (GtkWidget *widget, priv = GET_PRIV (widget); - GTK_WIDGET_CLASS (empathy_individual_view_parent_class)->drag_begin (widget, - context); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget)); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return; + GTK_WIDGET_CLASS (empathy_individual_view_parent_class)->drag_begin (widget, + context); + path = gtk_tree_model_get_path (model, &iter); priv->drag_row = gtk_tree_row_reference_new (model, path); gtk_tree_path_free (path); |