From 88d88591d2cd539f75a70f5e4fc8f4331be78bec Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 4 Jun 2015 19:46:20 +0200 Subject: [PATCH] texthandle: Allow setting individual states, and separately to handles Now each handle gets its individual current state, and we can accumulate more than one state on these. https://bugzilla.gnome.org/show_bug.cgi?id=750396 --- gtk/gtktexthandle.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c index eeaa7e74e7..7faea0cead 100644 --- a/gtk/gtktexthandle.c +++ b/gtk/gtktexthandle.c @@ -168,21 +168,30 @@ gtk_text_handle_widget_draw (GtkWidget *widget, static void gtk_text_handle_set_state (GtkTextHandle *handle, + gint pos, GtkStateFlags state) { - GtkTextHandlePrivate *priv; - gint i; + GtkTextHandlePrivate *priv = handle->priv; - priv = handle->priv; + if (!priv->windows[pos].widget) + return; - for (i = 0; i <= GTK_TEXT_HANDLE_POSITION_SELECTION_START; i++) - { - if (!priv->windows[i].widget) - continue; + gtk_widget_set_state_flags (priv->windows[pos].widget, state, FALSE); + gtk_widget_queue_draw (priv->windows[pos].widget); +} - gtk_widget_set_state_flags (priv->windows[i].widget, state, TRUE); - gtk_widget_queue_draw (priv->windows[i].widget); - } +static void +gtk_text_handle_unset_state (GtkTextHandle *handle, + gint pos, + GtkStateFlags state) +{ + GtkTextHandlePrivate *priv = handle->priv; + + if (!priv->windows[pos].widget) + return; + + gtk_widget_unset_state_flags (priv->windows[pos].widget, state); + gtk_widget_queue_draw (priv->windows[pos].widget); } static gboolean @@ -204,13 +213,13 @@ gtk_text_handle_widget_event (GtkWidget *widget, priv->windows[pos].dx = event->button.x; priv->windows[pos].dy = event->button.y; priv->windows[pos].dragged = TRUE; - gtk_text_handle_set_state (handle, GTK_STATE_FLAG_ACTIVE); + gtk_text_handle_set_state (handle, pos, GTK_STATE_FLAG_ACTIVE); } else if (event->type == GDK_BUTTON_RELEASE) { g_signal_emit (handle, signals[DRAG_FINISHED], 0, pos); priv->windows[pos].dragged = FALSE; - gtk_text_handle_set_state (handle, GTK_STATE_FLAG_NORMAL); + gtk_text_handle_unset_state (handle, pos, GTK_STATE_FLAG_ACTIVE); } else if (event->type == GDK_MOTION_NOTIFY && event->motion.state & GDK_BUTTON1_MASK &&