[gtk+] entry: Use the drag-started signal
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] entry: Use the drag-started signal
- Date: Mon, 8 Jun 2015 10:59:14 +0000 (UTC)
commit bd65c14813630fcc2a28d1ffd012325625628002
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 7 20:14:43 2015 -0400
entry: Use the drag-started signal
Use the drag-started signal to differentiate between drags that
move a handle and taps on a handle. Show the touch selection popup
for the latter, but not the former.
gtk/gtkentry.c | 29 +++++++++++++++++++++++------
1 files changed, 23 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 1d7bc84..de4ec31 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -620,6 +620,9 @@ static void gtk_entry_update_cached_style_values(GtkEntry *entry);
static gboolean get_middle_click_paste (GtkEntry *entry);
/* GtkTextHandle handlers */
+static void gtk_entry_handle_drag_started (GtkTextHandle *handle,
+ GtkTextHandlePosition pos,
+ GtkEntry *entry);
static void gtk_entry_handle_dragged (GtkTextHandle *handle,
GtkTextHandlePosition pos,
gint x,
@@ -2785,6 +2788,8 @@ gtk_entry_ensure_text_handles (GtkEntry *entry)
return;
priv->text_handle = _gtk_text_handle_new (GTK_WIDGET (entry));
+ g_signal_connect (priv->text_handle, "drag-started",
+ G_CALLBACK (gtk_entry_handle_drag_started), entry);
g_signal_connect (priv->text_handle, "handle-dragged",
G_CALLBACK (gtk_entry_handle_dragged), entry);
g_signal_connect (priv->text_handle, "drag-finished",
@@ -6698,9 +6703,15 @@ gtk_entry_handle_dragged (GtkTextHandle *handle,
selection_bound_pos != priv->selection_bound)
{
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
- gtk_entry_set_positions (entry, cursor_pos, cursor_pos);
+ {
+ entry->priv->cursor_handle_dragged = TRUE;
+ gtk_entry_set_positions (entry, cursor_pos, cursor_pos);
+ }
else
- gtk_entry_set_positions (entry, cursor_pos, selection_bound_pos);
+ {
+ entry->priv->selection_handle_dragged = TRUE;
+ gtk_entry_set_positions (entry, cursor_pos, selection_bound_pos);
+ }
gtk_entry_update_handles (entry, mode);
}
@@ -6708,16 +6719,22 @@ gtk_entry_handle_dragged (GtkTextHandle *handle,
gtk_entry_show_magnifier (entry, x, y);
}
+static void
+gtk_entry_handle_drag_started (GtkTextHandle *handle,
+ GtkTextHandlePosition pos,
+ GtkEntry *entry)
+{
+ entry->priv->cursor_handle_dragged = FALSE;
+ entry->priv->selection_handle_dragged = FALSE;
+}
static void
gtk_entry_handle_drag_finished (GtkTextHandle *handle,
GtkTextHandlePosition pos,
GtkEntry *entry)
{
- if (entry->priv->selection_bubble &&
- gtk_widget_get_visible (entry->priv->selection_bubble))
- gtk_entry_selection_bubble_popup_unset (entry);
- else
+ if (!entry->priv->cursor_handle_dragged &&
+ !entry->priv->selection_handle_dragged)
gtk_entry_selection_bubble_popup_set (entry);
if (entry->priv->magnifier_popover)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]