[gtk/matthiasc/for-master: 2/4] GtkIcon: Pay attention to style changes



commit 6e358e2a491e53287e9ffa3467135260b95ebb04
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 24 20:53:16 2020 -0500

    GtkIcon: Pay attention to style changes
    
    Make GtkIcon redraw and resize when style changes
    require it.

 gtk/gtkicon.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
---
diff --git a/gtk/gtkicon.c b/gtk/gtkicon.c
index 8661a69943..3c33ba5bcf 100644
--- a/gtk/gtkicon.c
+++ b/gtk/gtkicon.c
@@ -54,6 +54,29 @@ gtk_icon_snapshot (GtkWidget   *widget,
     gtk_css_style_snapshot_icon (style, snapshot, width, height);
 }
 
+static void
+gtk_icon_style_updated (GtkWidget *widget)
+{
+  GtkStyleContext *context;
+  GtkCssStyleChange *change = NULL;
+
+  context = gtk_widget_get_style_context (widget);
+  change = gtk_style_context_get_change (context);
+
+  GTK_WIDGET_CLASS (gtk_icon_parent_class)->style_updated (widget);
+
+  if (change == NULL ||
+      gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
+    {
+      gtk_widget_queue_resize (widget);
+    }
+  else if (gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_TEXTURE) ||
+           gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_REDRAW))
+    {
+      gtk_widget_queue_draw (widget);
+    }
+}
+
 static void
 gtk_icon_measure (GtkWidget      *widget,
                   GtkOrientation  orientation,
@@ -76,6 +99,7 @@ gtk_icon_class_init (GtkIconClass *klass)
 
   wclass->snapshot = gtk_icon_snapshot;
   wclass->measure = gtk_icon_measure;
+  wclass->style_updated = gtk_icon_style_updated;
 }
 
 static void


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