GtkPaned: Pay attention to style changes

Make GtkPaned redraw and resize when style change
require it.
This commit is contained in:
Matthias Clasen 2020-01-24 20:54:01 -05:00
parent 6e358e2a49
commit 2ee04ee8ed

View File

@ -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 paneds orientation.