[gtk+/gestures] textview: Improve touch popover interaction



commit bec3243a08ed3f40076af6384f4621254b18afa7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 16 17:27:42 2014 +0200

    textview: Improve touch popover interaction
    
    Presses alternatively show and dismiss the popover, the popover is still
    always shown invariably after any dragging happens (either text selection,
    or dragging a text handle)

 gtk/gtktextview.c |   22 +++++++++++++++-------
 1 files changed, 15 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 57f635c..f11e927 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -4816,7 +4816,11 @@ gtk_text_view_handle_drag_finished (GtkTextHandle         *handle,
                                     GtkTextHandlePosition  pos,
                                     GtkTextView           *text_view)
 {
-  gtk_text_view_selection_bubble_popup_set (text_view);
+  if (text_view->priv->selection_bubble &&
+      gtk_widget_get_visible (text_view->priv->selection_bubble))
+    gtk_text_view_selection_bubble_popup_unset (text_view);
+  else
+    gtk_text_view_selection_bubble_popup_set (text_view);
 
   if (text_view->priv->magnifier_popover)
     gtk_widget_hide (text_view->priv->magnifier_popover);
@@ -5101,7 +5105,6 @@ gtk_text_view_multipress_gesture_pressed (GtkGestureMultiPress *gesture,
   gtk_gesture_set_sequence_state (GTK_GESTURE (gesture), sequence,
                                   GTK_EVENT_SEQUENCE_CLAIMED);
   gtk_text_view_reset_blink_time (text_view);
-  gtk_text_view_selection_bubble_popup_unset (text_view);
 
 #if 0
   /* debug hack */
@@ -7049,6 +7052,8 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
     gdk_threads_add_timeout (50, selection_scan_timeout, text_view);
   g_source_set_name_by_id (text_view->priv->scroll_timeout, "[gtk+] selection_scan_timeout");
 
+  gtk_text_view_selection_bubble_popup_unset (text_view);
+
   if (is_touchscreen)
     {
       _gtk_text_view_ensure_text_handles (text_view);
@@ -7089,18 +7094,21 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
   if (priv->magnifier_popover)
     gtk_widget_hide (priv->magnifier_popover);
 
-  /* Check whether the drag was cancelled rather than finished */
-  if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
-    return;
-
   event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
   device = gdk_event_get_source_device (event);
   is_touchscreen = test_touchscreen ||
     gdk_device_get_source (device) == GDK_SOURCE_TOUCHSCREEN;
 
-  if (is_touchscreen)
+  if (priv->selection_bubble &&
+      gtk_widget_get_visible (priv->selection_bubble))
+    gtk_text_view_selection_bubble_popup_unset (text_view);
+  else if (is_touchscreen)
     gtk_text_view_selection_bubble_popup_set (text_view);
 
+  /* Check whether the drag was cancelled rather than finished */
+  if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
+    return;
+
   if (clicked_in_selection &&
       !gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]