Commit ece9d2fd authored by Benjamin Otte's avatar Benjamin Otte

gtk: Make widget only invalidate widget positions

Instead of resetting them completely
parent e7a984b3
......@@ -85,6 +85,7 @@
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtkboxaccessible.h"
......@@ -937,11 +938,17 @@ gtk_box_get_path_for_child (GtkContainer *container,
return path;
}
static void
gtk_box_invalidate_order_foreach (GtkWidget *widget)
{
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
static void
gtk_box_invalidate_order (GtkBox *box)
{
gtk_container_foreach (GTK_CONTAINER (box),
(GtkCallback) gtk_widget_reset_style,
(GtkCallback) gtk_box_invalidate_order_foreach,
NULL);
}
......
......@@ -41,6 +41,7 @@
#include "gtktreeselection.h"
#include "gtkseparator.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
......@@ -1381,11 +1382,17 @@ gtk_combo_box_button_state_flags_changed (GtkWidget *widget,
gtk_widget_queue_draw (widget);
}
static void
gtk_combo_box_invalidate_order_foreach (GtkWidget *widget)
{
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
static void
gtk_combo_box_invalidate_order (GtkComboBox *combo_box)
{
gtk_container_forall (GTK_CONTAINER (combo_box),
(GtkCallback) gtk_widget_reset_style,
(GtkCallback) gtk_combo_box_invalidate_order_foreach,
NULL);
}
......
......@@ -42,6 +42,7 @@
#include "gtkbuildable.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
#include "a11y/gtknotebookaccessible.h"
......@@ -6536,7 +6537,7 @@ gtk_notebook_update_tab_states (GtkNotebook *notebook)
GTK_STYLE_REGION_TAB,
&current_flags)
|| current_flags != _gtk_notebook_get_tab_flags (notebook, page))
gtk_widget_reset_style (page->tab_label);
_gtk_widget_invalidate_style_context (page->tab_label, GTK_CSS_CHANGE_PARENT_STATE);
}
}
}
......
......@@ -183,7 +183,6 @@ gtk_overlay_child_update_style_classes (GtkOverlay *overlay,
gboolean is_left, is_right, is_top, is_bottom;
gboolean has_left, has_right, has_top, has_bottom;
GtkStyleContext *context;
gint changed;
context = gtk_widget_get_style_context (child);
has_left = gtk_style_context_has_class (context, GTK_STYLE_CLASS_LEFT);
......@@ -192,7 +191,6 @@ gtk_overlay_child_update_style_classes (GtkOverlay *overlay,
has_bottom = gtk_style_context_has_class (context, GTK_STYLE_CLASS_BOTTOM);
is_left = is_right = is_top = is_bottom = FALSE;
changed = 4;
gtk_overlay_get_main_widget_allocation (overlay, &main_allocation);
gtk_widget_get_allocation (GTK_WIDGET (overlay), &overlay_allocation);
......@@ -221,32 +219,21 @@ gtk_overlay_child_update_style_classes (GtkOverlay *overlay,
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_LEFT);
else if (!has_left && is_left)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LEFT);
else
changed--;
if (has_right && !is_right)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_RIGHT);
else if (!has_right && is_right)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_RIGHT);
else
changed--;
if (has_top && !is_top)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TOP);
else if (!has_top && is_top)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
else
changed--;
if (has_bottom && !is_bottom)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_BOTTOM);
else if (!has_bottom && is_bottom)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
else
changed--;
if (changed > 0)
gtk_widget_reset_style (child);
}
static void
......
......@@ -35,6 +35,7 @@
#include "gtksettings.h"
#include "gtktogglebutton.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
enum {
......@@ -494,15 +495,18 @@ child_ordering_changed (GtkPathBar *path_bar)
GList *l;
if (path_bar->up_slider_button)
gtk_widget_reset_style (path_bar->up_slider_button);
_gtk_widget_invalidate_style_context (path_bar->up_slider_button,
GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
if (path_bar->down_slider_button)
gtk_widget_reset_style (path_bar->down_slider_button);
_gtk_widget_invalidate_style_context (path_bar->down_slider_button,
GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
for (l = path_bar->button_list; l; l = l->next)
{
ButtonData *data = l->data;
gtk_widget_reset_style (data->button);
_gtk_widget_invalidate_style_context (data->button,
GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
}
......
......@@ -55,6 +55,7 @@
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetpath.h"
#include "gtkwidgetprivate.h"
/**
......@@ -3964,11 +3965,17 @@ gtk_toolbar_get_path_for_child (GtkContainer *container,
return path;
}
static void
gtk_toolbar_invalidate_order_foreach (GtkWidget *widget)
{
_gtk_widget_invalidate_style_context (widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
static void
gtk_toolbar_invalidate_order (GtkToolbar *toolbar)
{
gtk_container_forall (GTK_CONTAINER (toolbar),
(GtkCallback) gtk_widget_reset_style,
(GtkCallback) gtk_toolbar_invalidate_order_foreach,
NULL);
}
......
......@@ -11946,7 +11946,7 @@ _gtk_tree_view_reset_header_styles (GtkTreeView *tree_view)
if (!header_widget)
header_widget = gtk_tree_view_column_get_button (column);
gtk_widget_reset_style (header_widget);
_gtk_widget_invalidate_style_context (header_widget, GTK_CSS_CHANGE_POSITION | GTK_CSS_CHANGE_SIBLING_POSITION);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment