[gtk+/wip/baedert/visible-widgets] POC: Entry: Use buttons for icons



commit 28779f926e9ec0cb0d001fd794b3eb7dac11dd87
Author: Timm Bäder <mail baedert org>
Date:   Sat Jan 14 08:51:32 2017 +0100

    POC: Entry: Use buttons for icons

 gtk/gtkentry.c |  433 ++++++++------------------------------------------------
 1 files changed, 62 insertions(+), 371 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index ab698ff..c64c831 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -279,7 +279,6 @@ struct _GtkEntryPrivate
 
 struct _EntryIconInfo
 {
-  GdkWindow *window;
   gchar *tooltip;
   guint insensitive    : 1;
   guint nonactivatable : 1;
@@ -287,6 +286,8 @@ struct _EntryIconInfo
   guint in_drag        : 1;
   guint pressed        : 1;
 
+  GtkWidget *widget;
+  GtkWidget *image;
   GdkDragAction actions;
   GtkTargetList *target_list;
   GtkCssGadget *gadget;
@@ -419,10 +420,6 @@ static void   gtk_entry_snapshot             (GtkWidget        *widget,
                                               GtkSnapshot      *snapshot);
 static gboolean gtk_entry_event              (GtkWidget        *widget,
                                               GdkEvent         *event);
-static gint   gtk_entry_enter_notify         (GtkWidget        *widget,
-                                              GdkEventCrossing *event);
-static gint   gtk_entry_leave_notify         (GtkWidget        *widget,
-                                              GdkEventCrossing *event);
 static gint   gtk_entry_key_press            (GtkWidget        *widget,
                                              GdkEventKey      *event);
 static gint   gtk_entry_key_release          (GtkWidget        *widget,
@@ -747,8 +744,6 @@ gtk_entry_class_init (GtkEntryClass *class)
   widget_class->measure = gtk_entry_measure_;
   widget_class->size_allocate = gtk_entry_size_allocate;
   widget_class->snapshot = gtk_entry_snapshot;
-  widget_class->enter_notify_event = gtk_entry_enter_notify;
-  widget_class->leave_notify_event = gtk_entry_leave_notify;
   widget_class->event = gtk_entry_event;
   widget_class->key_press_event = gtk_entry_key_press;
   widget_class->key_release_event = gtk_entry_key_release;
@@ -2577,11 +2572,9 @@ get_icon_width (GtkEntry             *entry,
   if (!icon_info)
     return 0;
 
-  gtk_css_gadget_get_preferred_size (icon_info->gadget,
-                                     GTK_ORIENTATION_HORIZONTAL,
-                                     -1,
-                                     &width, NULL,
-                                     NULL, NULL);
+  gtk_widget_measure (icon_info->widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                      &width, NULL,
+                      NULL, NULL);
 
   return width;
 }
@@ -2699,6 +2692,7 @@ gtk_entry_finalize (GObject *object)
         gtk_target_list_unref (icon_info->target_list);
 
       g_clear_object (&icon_info->gadget);
+      gtk_widget_unparent (icon_info->widget);
 
       g_slice_free (EntryIconInfo, icon_info);
     }
@@ -2821,77 +2815,13 @@ _gtk_entry_get_display_text (GtkEntry *entry,
 }
 
 static void
-update_cursors (GtkWidget *widget)
-{
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = NULL;
-  GdkDisplay *display;
-  GdkCursor *cursor;
-  gint i;
-
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if ((icon_info = priv->icons[i]) != NULL)
-        {
-          if (!_gtk_icon_helper_get_is_empty (GTK_ICON_HELPER (icon_info->gadget)) && 
-              icon_info->window != NULL)
-            gdk_window_show_unraised (icon_info->window);
-
-          /* The icon windows are not children of the visible entry window,
-           * thus we can't just inherit the xterm cursor. Slight complication 
-           * here is that for the entry, insensitive => arrow cursor, but for 
-           * an icon in a sensitive entry, insensitive => xterm cursor.
-           */
-          if (gtk_widget_is_sensitive (widget) &&
-              (icon_info->insensitive || 
-               (icon_info->nonactivatable && icon_info->target_list == NULL)))
-            {
-              display = gtk_widget_get_display (widget);
-              cursor = gdk_cursor_new_from_name (display, "text");
-              gdk_window_set_cursor (icon_info->window, cursor);
-              g_clear_object (&cursor);
-            }
-          else
-            {
-              gdk_window_set_cursor (icon_info->window, NULL);
-            }
-        }
-    }
-}
-
-static void
-realize_icon_info (GtkWidget            *widget, 
-                   GtkEntryIconPosition  icon_pos)
-{
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = priv->icons[icon_pos];
-
-  g_return_if_fail (icon_info != NULL);
-
-  icon_info->window = gdk_window_new_input (gtk_widget_get_window (widget),
-                                            gtk_widget_get_events (widget)
-                                            | GDK_BUTTON_PRESS_MASK
-                                            | GDK_BUTTON_RELEASE_MASK
-                                            | GDK_BUTTON1_MOTION_MASK
-                                            | GDK_BUTTON3_MOTION_MASK
-                                            | GDK_POINTER_MOTION_MASK
-                                            | GDK_ENTER_NOTIFY_MASK
-                                            | GDK_LEAVE_NOTIFY_MASK,
-                                            &(GdkRectangle) { 0, 0, 1, 1});
-  gtk_widget_register_window (widget, icon_info->window);
-
-  gtk_widget_queue_resize (widget);
-}
-
-static void
 update_icon_style (GtkWidget            *widget,
                    GtkEntryIconPosition  icon_pos)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
   EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GtkStyleContext *context;
   const gchar *sides[2] = { GTK_STYLE_CLASS_LEFT, GTK_STYLE_CLASS_RIGHT };
 
   if (icon_info == NULL)
@@ -2900,31 +2830,9 @@ update_icon_style (GtkWidget            *widget,
   if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
     icon_pos = 1 - icon_pos;
 
-  gtk_css_gadget_add_class (icon_info->gadget, sides[icon_pos]);
-  gtk_css_gadget_remove_class (icon_info->gadget, sides[1 - icon_pos]);
-}
-
-static void
-update_icon_state (GtkWidget            *widget,
-                   GtkEntryIconPosition  icon_pos)
-{
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = priv->icons[icon_pos];
-  GtkStateFlags state;
-
-  if (icon_info == NULL)
-    return;
-
-  state = gtk_widget_get_state_flags (widget);
-  state &= ~(GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_DROP_ACTIVE);
-
-  if ((state & GTK_STATE_FLAG_INSENSITIVE) || icon_info->insensitive)
-    state |= GTK_STATE_FLAG_INSENSITIVE;
-  else if (icon_info->prelight)
-    state |= GTK_STATE_FLAG_PRELIGHT;
-
-  gtk_css_gadget_set_state (icon_info->gadget, state);
+  context = gtk_widget_get_style_context (icon_info->widget);
+  gtk_style_context_add_class (context, sides[icon_pos]);
+  gtk_style_context_remove_class (context, sides[1 - icon_pos]);
 }
 
 static void
@@ -2978,6 +2886,32 @@ update_node_ordering (GtkEntry *entry)
     }
 }
 
+static void
+icon_info_clicked_cb (GtkButton *button,
+                      gpointer   user_data)
+{
+  GtkEntry *entry = GTK_ENTRY (gtk_widget_get_parent (GTK_WIDGET (button)));
+  GtkWidget *widget = GTK_WIDGET (entry);
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = user_data;
+
+  /* O_o */
+  if (icon_info == priv->icons[GTK_ENTRY_ICON_PRIMARY])
+    {
+      g_signal_emit (widget, signals[ICON_PRESS], 0, GTK_ENTRY_ICON_PRIMARY, NULL);
+      g_signal_emit (widget, signals[ICON_RELEASE], 0, GTK_ENTRY_ICON_PRIMARY, NULL);
+    }
+  else if (icon_info == priv->icons[GTK_ENTRY_ICON_SECONDARY])
+    {
+      g_signal_emit (widget, signals[ICON_PRESS], 0, GTK_ENTRY_ICON_SECONDARY, NULL);
+      g_signal_emit (widget, signals[ICON_RELEASE], 0, GTK_ENTRY_ICON_SECONDARY, NULL);
+    }
+  else
+    {
+      g_assert_not_reached ();
+    }
+}
+
 static EntryIconInfo*
 construct_icon_info (GtkWidget            *widget,
                      GtkEntryIconPosition  icon_pos)
@@ -2997,13 +2931,17 @@ construct_icon_info (GtkWidget            *widget,
   _gtk_icon_helper_set_force_scale_pixbuf (GTK_ICON_HELPER (icon_info->gadget), TRUE);
   gtk_css_node_set_parent (gtk_css_gadget_get_node (icon_info->gadget), widget_node);
 
-  update_icon_state (widget, icon_pos);
+  icon_info->widget = gtk_button_new ();
+  g_signal_connect (icon_info->widget, "clicked", G_CALLBACK (icon_info_clicked_cb), icon_info);
+  gtk_widget_set_focus_on_click (icon_info->widget, FALSE);
+  icon_info->image = gtk_image_new ();
+  gtk_container_add (GTK_CONTAINER (icon_info->widget), icon_info->image);
+  gtk_style_context_add_class (gtk_widget_get_style_context (icon_info->widget), "image-button");
+  gtk_widget_set_parent (icon_info->widget, widget);
+
   update_icon_style (widget, icon_pos);
   update_node_ordering (entry);
 
-  if (gtk_widget_get_realized (widget))
-    realize_icon_info (widget, icon_pos);
-
   return icon_info;
 }
 
@@ -3012,24 +2950,10 @@ gtk_entry_map (GtkWidget *widget)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = NULL;
-  gint i;
 
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->map (widget);
 
   gdk_window_show (priv->text_area);
-
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if ((icon_info = priv->icons[i]) != NULL)
-        {
-          if (!_gtk_icon_helper_get_is_empty (GTK_ICON_HELPER (icon_info->gadget)) &&
-              icon_info->window != NULL)
-            gdk_window_show (icon_info->window);
-        }
-    }
-
-  update_cursors (widget);
 }
 
 static void
@@ -3037,23 +2961,11 @@ gtk_entry_unmap (GtkWidget *widget)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = NULL;
-  gint i;
 
   if (priv->text_handle)
     _gtk_text_handle_set_mode (priv->text_handle,
                                GTK_TEXT_HANDLE_MODE_NONE);
 
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if ((icon_info = priv->icons[i]) != NULL)
-        {
-          if (!_gtk_icon_helper_get_is_empty (GTK_ICON_HELPER (icon_info->gadget)) && 
-              icon_info->window != NULL)
-            gdk_window_hide (icon_info->window);
-        }
-    }
-
   gdk_window_hide (priv->text_area);
 
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->unmap (widget);
@@ -3075,8 +2987,6 @@ gtk_entry_realize (GtkWidget *widget)
 {
   GtkEntry *entry;
   GtkEntryPrivate *priv;
-  EntryIconInfo *icon_info;
-  int i;
   GtkAllocation text_allocation;
 
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->realize (widget);
@@ -3112,19 +3022,6 @@ gtk_entry_realize (GtkWidget *widget)
 
   gtk_entry_adjust_scroll (entry);
   gtk_entry_update_primary_selection (entry);
-
-  /* If the icon positions are already setup, create their windows.
-   * Otherwise if they don't exist yet, then construct_icon_info()
-   * will create the windows once the widget is already realized.
-   */
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if ((icon_info = priv->icons[i]) != NULL)
-        {
-          if (icon_info->window == NULL)
-            realize_icon_info (widget, i);
-        }
-    }
 }
 
 static void
@@ -3133,8 +3030,6 @@ gtk_entry_unrealize (GtkWidget *widget)
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = entry->priv;
   GtkClipboard *clipboard;
-  EntryIconInfo *icon_info;
-  gint i;
 
   gtk_entry_reset_layout (entry);
   
@@ -3158,19 +3053,6 @@ gtk_entry_unrealize (GtkWidget *widget)
     }
 
   GTK_WIDGET_CLASS (gtk_entry_parent_class)->unrealize (widget);
-
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if ((icon_info = priv->icons[i]) != NULL)
-        {
-          if (icon_info->window != NULL)
-            {
-              gtk_widget_unregister_window (widget, icon_info->window);
-              gdk_window_destroy (icon_info->window);
-              icon_info->window = NULL;
-            }
-        }
-    }
 }
 
 static void
@@ -3279,11 +3161,9 @@ gtk_entry_measure (GtkCssGadget   *gadget,
           if (!icon_info)
             continue;
 
-          gtk_css_gadget_get_preferred_size (icon_info->gadget,
-                                             GTK_ORIENTATION_VERTICAL,
-                                             -1,
-                                             NULL, &h,
-                                             NULL, NULL);
+          gtk_widget_measure (icon_info->widget, GTK_ORIENTATION_VERTICAL, -1,
+                              NULL, &h,
+                              NULL, NULL);
           icon_height = MAX (icon_height, h);
         }
 
@@ -3317,47 +3197,12 @@ gtk_entry_measure (GtkCssGadget   *gadget,
 }
 
 static void
-place_windows (GtkEntry *entry)
-{
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info;
-  GtkAllocation content_allocation;
-
-  icon_info = priv->icons[GTK_ENTRY_ICON_PRIMARY];
-  if (icon_info)
-    {
-      GtkAllocation primary;
-
-      gtk_css_gadget_get_border_allocation (icon_info->gadget, &primary, NULL);
-      gdk_window_move_resize (icon_info->window,
-                              primary.x, primary.y,
-                              primary.width, primary.height);
-    }
-
-  icon_info = priv->icons[GTK_ENTRY_ICON_SECONDARY];
-  if (icon_info)
-    {
-      GtkAllocation secondary;
-
-      gtk_css_gadget_get_border_allocation (icon_info->gadget, &secondary, NULL);
-      gdk_window_move_resize (icon_info->window,
-                              secondary.x, secondary.y,
-                              secondary.width, secondary.height);
-    }
-
-  gtk_entry_get_text_allocation (entry, &content_allocation);
-  gdk_window_move_resize (priv->text_area,
-                          content_allocation.x, content_allocation.y,
-                          content_allocation.width, content_allocation.height);
-}
-
-static void
 gtk_entry_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
 {
   GdkRectangle clip;
 
-  gtk_widget_set_allocation (widget, allocation);
+  GTK_WIDGET_CLASS (gtk_entry_parent_class)->size_allocate (widget, allocation);
 
   gtk_css_gadget_allocate (GTK_ENTRY (widget)->priv->gadget,
                            allocation,
@@ -3398,21 +3243,18 @@ gtk_entry_allocate (GtkCssGadget        *gadget,
       EntryIconInfo *icon_info = priv->icons[i];
       GtkAllocation icon_alloc;
       GdkRectangle clip;
-      gint dummy, width, height;
+      gint width, height;
 
       if (!icon_info)
         continue;
 
-      gtk_css_gadget_get_preferred_size (icon_info->gadget,
-                                         GTK_ORIENTATION_HORIZONTAL,
-                                         -1,
-                                         &dummy, &width,
-                                         NULL, NULL);
-      gtk_css_gadget_get_preferred_size (icon_info->gadget,
-                                         GTK_ORIENTATION_VERTICAL,
-                                         -1,
-                                         &dummy, &height,
-                                         NULL, NULL);
+      gtk_widget_measure (icon_info->widget, GTK_ORIENTATION_HORIZONTAL, -1,
+                          NULL, &width,
+                          NULL, NULL);
+
+      gtk_widget_measure (icon_info->widget, GTK_ORIENTATION_VERTICAL, -1,
+                          NULL, &height,
+                          NULL, NULL);
 
       if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && i == GTK_ENTRY_ICON_PRIMARY) ||
           (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && i == GTK_ENTRY_ICON_SECONDARY))
@@ -3424,15 +3266,13 @@ gtk_entry_allocate (GtkCssGadget        *gadget,
           icon_alloc.x = allocation->x + priv->text_x;
           priv->text_x += width;
         }
+
       icon_alloc.y = allocation->y + (allocation->height - height) / 2;
       icon_alloc.width = width;
       icon_alloc.height = height;
       priv->text_width -= width;
 
-      gtk_css_gadget_allocate (icon_info->gadget,
-                               &icon_alloc,
-                               baseline,
-                               &clip);
+      gtk_widget_size_allocate (icon_info->widget, &icon_alloc);
 
       gdk_rectangle_union (out_clip, &clip, out_clip);
     }
@@ -3480,7 +3320,6 @@ gtk_entry_allocate (GtkCssGadget        *gadget,
     {
       GtkEntryCompletion *completion;
 
-      place_windows (entry);
       gtk_entry_recompute (entry);
 
       completion = gtk_entry_get_completion (entry);
@@ -3489,25 +3328,6 @@ gtk_entry_allocate (GtkCssGadget        *gadget,
     }
 }
 
-static gboolean
-should_prelight (GtkEntry             *entry,
-                 GtkEntryIconPosition  icon_pos)
-{
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = priv->icons[icon_pos];
-
-  if (!icon_info)
-    return FALSE;
-
-  if (icon_info->nonactivatable && icon_info->target_list == NULL)
-    return FALSE;
-
-  if (icon_info->pressed)
-    return FALSE;
-
-  return TRUE;
-}
-
 static void
 gtk_entry_snapshot (GtkWidget   *widget,
                     GtkSnapshot *snapshot)
@@ -3626,7 +3446,7 @@ gtk_entry_render (GtkCssGadget *gadget,
       EntryIconInfo *icon_info = priv->icons[i];
 
       if (icon_info != NULL)
-        gtk_css_gadget_snapshot (icon_info->gadget, snapshot);
+        gtk_widget_snapshot_child (widget, icon_info->widget, snapshot);
     }
 
   gtk_entry_draw_undershoot (entry, snapshot);
@@ -3634,66 +3454,6 @@ gtk_entry_render (GtkCssGadget *gadget,
   return FALSE;
 }
 
-static gint
-gtk_entry_enter_notify (GtkWidget        *widget,
-                        GdkEventCrossing *event)
-{
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = entry->priv;
-  gint i;
-
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      EntryIconInfo *icon_info = priv->icons[i];
-
-      if (icon_info != NULL && event->window == icon_info->window)
-        {
-          if (should_prelight (entry, i))
-            {
-              icon_info->prelight = TRUE;
-              update_icon_state (widget, i);
-              gtk_widget_queue_draw (widget);
-            }
-
-          break;
-        }
-    }
-
-    return GDK_EVENT_PROPAGATE;
-}
-
-static gint
-gtk_entry_leave_notify (GtkWidget        *widget,
-                        GdkEventCrossing *event)
-{
-  GtkEntry *entry = GTK_ENTRY (widget);
-  GtkEntryPrivate *priv = entry->priv;
-  gint i;
-
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      EntryIconInfo *icon_info = priv->icons[i];
-
-      if (icon_info != NULL && event->window == icon_info->window)
-        {
-          /* 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;
-
-          if (should_prelight (entry, i))
-            {
-              icon_info->prelight = FALSE;
-              update_icon_state (widget, i);
-              gtk_widget_queue_draw (widget);
-            }
-
-          break;
-        }
-    }
-
-  return GDK_EVENT_PROPAGATE;
-}
-
 static void
 gtk_entry_get_pixel_ranges (GtkEntry  *entry,
                            gint     **ranges,
@@ -3870,7 +3630,6 @@ gtk_entry_event (GtkWidget *widget,
   GdkEventSequence *sequence;
   GdkDevice *device;
   gdouble x, y;
-  gint i;
 
   if (event->type == GDK_MOTION_NOTIFY &&
       priv->mouse_cursor_obscured &&
@@ -3885,16 +3644,6 @@ gtk_entry_event (GtkWidget *widget,
       return GDK_EVENT_PROPAGATE;
     }
 
-  for (i = 0; i < MAX_ICONS; i++)
-    {
-      if (priv->icons[i] &&
-          priv->icons[i]->window == event->any.window)
-        {
-          icon_info = priv->icons[i];
-          break;
-        }
-    }
-
   if (!icon_info)
     return GDK_EVENT_PROPAGATE;
 
@@ -3916,22 +3665,10 @@ gtk_entry_event (GtkWidget *widget,
     case GDK_BUTTON_PRESS:
     case GDK_2BUTTON_PRESS:
     case GDK_3BUTTON_PRESS:
-      if (should_prelight (GTK_ENTRY (widget), i))
-        {
-          icon_info->prelight = FALSE;
-          update_icon_state (widget, i);
-          gtk_widget_queue_draw (widget);
-        }
-
       priv->start_x = x;
       priv->start_y = y;
       icon_info->pressed = TRUE;
       icon_info->device = device;
-
-      if (!icon_info->nonactivatable) {
-        g_signal_emit (widget, signals[ICON_PRESS], 0, i, event);
-      }
-
       break;
     case GDK_TOUCH_UPDATE:
       if (icon_info->device != device ||
@@ -3967,20 +3704,6 @@ gtk_entry_event (GtkWidget *widget,
     case GDK_BUTTON_RELEASE:
       icon_info->pressed = FALSE;
       icon_info->device = NULL;
-
-      if (should_prelight (GTK_ENTRY (widget), i) &&
-          x >= 0 && y >= 0 &&
-          x < gdk_window_get_width (icon_info->window) &&
-          y < gdk_window_get_height (icon_info->window))
-        {
-          icon_info->prelight = TRUE;
-          update_icon_state (widget, i);
-          gtk_widget_queue_draw (widget);
-        }
-
-      if (!icon_info->nonactivatable)
-        g_signal_emit (widget, signals[ICON_RELEASE], 0, i, event);
-
       break;
     default:
       return GDK_EVENT_PROPAGATE;
@@ -4684,8 +4407,6 @@ gtk_entry_state_flags_changed (GtkWidget     *widget,
         g_object_unref (cursor);
 
       priv->mouse_cursor_obscured = FALSE;
-
-      update_cursors (widget);
     }
 
   if (!gtk_widget_is_sensitive (widget))
@@ -4695,8 +4416,6 @@ gtk_entry_state_flags_changed (GtkWidget     *widget,
     }
 
   update_node_state (entry);
-  update_icon_state (widget, GTK_ENTRY_ICON_PRIMARY);
-  update_icon_state (widget, GTK_ENTRY_ICON_SECONDARY);
 
   gtk_entry_update_cached_style_values (entry);
 }
@@ -6992,12 +6711,6 @@ gtk_entry_clear (GtkEntry             *entry,
 
   g_object_freeze_notify (G_OBJECT (entry));
 
-  /* Explicitly check, as the pointer may become invalidated
-   * during destruction.
-   */
-  if (GDK_IS_WINDOW (icon_info->window))
-    gdk_window_hide (icon_info->window);
-
   storage_type = _gtk_icon_helper_get_storage_type (icon_helper);
 
   switch (storage_type)
@@ -7936,9 +7649,7 @@ gtk_entry_set_icon_from_pixbuf (GtkEntry             *entry,
 
   if (pixbuf)
     {
-      _gtk_icon_helper_set_pixbuf (GTK_ICON_HELPER (icon_info->gadget), pixbuf);
-      _gtk_icon_helper_set_icon_size (GTK_ICON_HELPER (icon_info->gadget),
-                                      GTK_ICON_SIZE_MENU);
+      gtk_image_set_from_pixbuf (GTK_IMAGE (icon_info->image), pixbuf);
 
       if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
         {
@@ -7951,17 +7662,11 @@ gtk_entry_set_icon_from_pixbuf (GtkEntry             *entry,
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_SECONDARY]);
         }
 
-      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
-          gdk_window_show_unraised (icon_info->window);
-
       g_object_unref (pixbuf);
     }
   else
     gtk_entry_clear (entry, icon_pos);
 
-  if (gtk_widget_get_visible (GTK_WIDGET (entry)))
-    gtk_widget_queue_resize (GTK_WIDGET (entry));
-
   g_object_thaw_notify (G_OBJECT (entry));
 }
 
@@ -8002,7 +7707,7 @@ gtk_entry_set_icon_from_icon_name (GtkEntry             *entry,
 
   if (icon_name != NULL)
     {
-      _gtk_icon_helper_set_icon_name (GTK_ICON_HELPER (icon_info->gadget), icon_name, GTK_ICON_SIZE_MENU);
+      gtk_image_set_from_icon_name (GTK_IMAGE (icon_info->image), icon_name, GTK_ICON_SIZE_MENU);
 
       if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
         {
@@ -8014,9 +7719,6 @@ gtk_entry_set_icon_from_icon_name (GtkEntry             *entry,
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_ICON_NAME_SECONDARY]);
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_SECONDARY]);
         }
-
-      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
-          gdk_window_show_unraised (icon_info->window);
     }
   else
     gtk_entry_clear (entry, icon_pos);
@@ -8062,7 +7764,7 @@ gtk_entry_set_icon_from_gicon (GtkEntry             *entry,
 
   if (icon)
     {
-      _gtk_icon_helper_set_gicon (GTK_ICON_HELPER (icon_info->gadget), icon, GTK_ICON_SIZE_MENU);
+      gtk_image_set_from_gicon (GTK_IMAGE (icon_info->image), icon, GTK_ICON_SIZE_MENU);
 
       if (icon_pos == GTK_ENTRY_ICON_PRIMARY)
         {
@@ -8074,9 +7776,6 @@ gtk_entry_set_icon_from_gicon (GtkEntry             *entry,
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_GICON_SECONDARY]);
           g_object_notify_by_pspec (G_OBJECT (entry), entry_props[PROP_STORAGE_TYPE_SECONDARY]);
         }
-
-      if (gtk_widget_get_mapped (GTK_WIDGET (entry)))
-          gdk_window_show_unraised (icon_info->window);
     }
   else
     gtk_entry_clear (entry, icon_pos);
@@ -8119,9 +7818,6 @@ gtk_entry_set_icon_activatable (GtkEntry             *entry,
     {
       icon_info->nonactivatable = !activatable;
 
-      if (gtk_widget_get_realized (GTK_WIDGET (entry)))
-        update_cursors (GTK_WIDGET (entry));
-
       g_object_notify_by_pspec (G_OBJECT (entry),
                                 entry_props[icon_pos == GTK_ENTRY_ICON_PRIMARY
                                             ? PROP_ACTIVATABLE_PRIMARY
@@ -8292,11 +7988,6 @@ gtk_entry_set_icon_sensitive (GtkEntry             *entry,
       icon_info->pressed = FALSE;
       icon_info->prelight = FALSE;
 
-      if (gtk_widget_get_realized (GTK_WIDGET (entry)))
-        update_cursors (GTK_WIDGET (entry));
-
-      update_icon_state (GTK_WIDGET (entry), icon_pos);
-
       g_object_notify_by_pspec (G_OBJECT (entry),
                                 entry_props[icon_pos == GTK_ENTRY_ICON_PRIMARY
                                             ? PROP_SENSITIVE_PRIMARY


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