[gtk+/wip/cssnode3: 99/101] entry: Use the :active state for pressed icons
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 99/101] entry: Use the :active state for pressed icons
- Date: Wed, 11 Mar 2015 00:27:55 +0000 (UTC)
commit 5096b1e39b63cdc4e750928670cca1fa045b6c13
Author: Benjamin Otte <otte redhat com>
Date: Tue Mar 10 17:48:44 2015 +0100
entry: Use the :active state for pressed icons
gtk/gtkentry.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index d7f1690..18a6822 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -242,7 +242,6 @@ struct _EntryIconInfo
guint nonactivatable : 1;
guint prelight : 1;
guint in_drag : 1;
- guint pressed : 1;
GdkDragAction actions;
GtkTargetList *target_list;
@@ -3206,19 +3205,20 @@ update_state_for_icon_infos (GtkWidget *widget)
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = entry->priv;
GtkStateFlags state;
+#define NOT_INHERITED (GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE)
cssnode = gtk_widget_get_css_node (widget);
state = gtk_widget_get_state_flags (widget);
if (priv->icons[GTK_ENTRY_ICON_PRIMARY])
gtk_css_node_set_state (priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node,
- (state & ~GTK_STATE_FLAG_PRELIGHT)
- | (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node) &
GTK_STATE_FLAG_PRELIGHT)
+ (state & ~NOT_INHERITED)
+ | (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_PRIMARY]->css_node) &
NOT_INHERITED)
| (priv->icons[GTK_ENTRY_ICON_PRIMARY]->insensitive ? GTK_STATE_FLAG_INSENSITIVE
: 0));
if (priv->icons[GTK_ENTRY_ICON_SECONDARY])
gtk_css_node_set_state (priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node,
- (state & ~GTK_STATE_FLAG_PRELIGHT)
- | (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node) &
GTK_STATE_FLAG_PRELIGHT)
+ (state & ~NOT_INHERITED)
+ | (gtk_css_node_get_state (priv->icons[GTK_ENTRY_ICON_SECONDARY]->css_node) &
NOT_INHERITED)
| (priv->icons[GTK_ENTRY_ICON_SECONDARY]->insensitive ?
GTK_STATE_FLAG_INSENSITIVE : 0));
if (state & GTK_STATE_FLAG_DIR_RTL)
@@ -3246,6 +3246,8 @@ update_state_for_icon_infos (GtkWidget *widget)
gtk_css_node_remove_class (last_node, GTK_STYLE_CLASS_LEFT);
gtk_css_node_add_class (last_node, GTK_STYLE_CLASS_RIGHT);
}
+
+#undef NOT_INHERITED
}
static void
@@ -4116,7 +4118,7 @@ gtk_entry_leave_notify (GtkWidget *widget,
{
/* a grab means that we may never see the button release */
if (event->mode == GDK_CROSSING_GRAB || event->mode == GDK_CROSSING_GTK_GRAB)
- icon_info->pressed = FALSE;
+ gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
if (should_prelight (entry, i))
gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT);
@@ -4362,7 +4364,7 @@ gtk_entry_event (GtkWidget *widget,
priv->start_x = x;
priv->start_y = y;
- icon_info->pressed = TRUE;
+ gtk_css_node_add_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
icon_info->device = device;
if (!icon_info->nonactivatable)
@@ -4375,7 +4377,7 @@ gtk_entry_event (GtkWidget *widget,
break;
/* Fall through */
case GDK_MOTION_NOTIFY:
- if (icon_info->pressed &&
+ if ((gtk_css_node_get_state (icon_info->css_node) & GTK_STATE_FLAG_ACTIVE) &&
icon_info->target_list != NULL &&
gtk_drag_check_threshold (widget,
priv->start_x,
@@ -4401,7 +4403,7 @@ gtk_entry_event (GtkWidget *widget,
icon_info->current_sequence = NULL;
/* Fall through */
case GDK_BUTTON_RELEASE:
- icon_info->pressed = FALSE;
+ gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_ACTIVE);
icon_info->device = NULL;
if (!icon_info->nonactivatable)
@@ -9021,8 +9023,7 @@ gtk_entry_set_icon_sensitive (GtkEntry *entry,
{
icon_info->insensitive = !sensitive;
- icon_info->pressed = FALSE;
- gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT);
+ gtk_css_node_remove_state (icon_info->css_node, GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_ACTIVE);
if (gtk_widget_get_realized (GTK_WIDGET (entry)))
update_cursors (GTK_WIDGET (entry));
@@ -9540,7 +9541,7 @@ check_undo_icon_grab (GtkEntry *entry,
!gtk_widget_device_is_shadowed (GTK_WIDGET (entry), info->device))
return;
- info->pressed = FALSE;
+ gtk_css_node_remove_state (info->css_node, GTK_STATE_FLAG_ACTIVE);
info->current_sequence = NULL;
info->device = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]