[gtk/matthiasc/for-master: 3/4] GtkPaned: Pay attention to style changes



commit 2ee04ee8eda7ca61196f86b0bc973f0ce4af5b07
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 24 20:54:01 2020 -0500

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

 gtk/gtkpaned.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index ef5a8830a9..f1689302ca 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -230,6 +230,7 @@ static void     gtk_paned_size_allocate         (GtkWidget           *widget,
 static void     gtk_paned_unrealize             (GtkWidget        *widget);
 static gboolean gtk_paned_focus                 (GtkWidget        *widget,
                                                 GtkDirectionType  direction);
+static void     gtk_paned_style_updated         (GtkWidget        *widget);
 static void     gtk_paned_add                   (GtkContainer     *container,
                                                 GtkWidget        *widget);
 static void     gtk_paned_remove                (GtkContainer     *container,
@@ -354,6 +355,7 @@ gtk_paned_class_init (GtkPanedClass *class)
   widget_class->size_allocate = gtk_paned_size_allocate;
   widget_class->unrealize = gtk_paned_unrealize;
   widget_class->focus = gtk_paned_focus;
+  widget_class->style_updated = gtk_paned_style_updated;
 
   container_class->add = gtk_paned_add;
   container_class->remove = gtk_paned_remove;
@@ -1462,6 +1464,29 @@ gtk_paned_focus (GtkWidget        *widget,
   return retval;
 }
 
+static void
+gtk_paned_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_paned_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);
+    }
+}
+
 /**
  * gtk_paned_new:
  * @orientation: the paned’s orientation.


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