Reduce use of GtkStyleContext

Remove some unnecessary uses of GtkStyleContext where
we can directly go to the GtkCssStyle, and and drop
unnnecessary includes.
This commit is contained in:
Matthias Clasen 2021-01-27 23:07:55 -05:00
parent 2d0d579735
commit 10d5705b70
35 changed files with 26 additions and 62 deletions

View File

@ -67,7 +67,6 @@
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"

View File

@ -20,7 +20,7 @@
#include "config.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkbuiltiniconprivate.h"
#include "gtkwidgetprivate.h"
@ -80,10 +80,11 @@ gtk_builtin_icon_measure (GtkWidget *widget,
int *minimum_baseline,
int *natural_baseline)
{
GtkCssValue *icon_size;
GtkCssStyle *style;
icon_size = _gtk_style_context_peek_property (gtk_widget_get_style_context (widget), GTK_CSS_PROPERTY_ICON_SIZE);
*minimum = *natural = _gtk_css_number_value_get (icon_size, 100);
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
*minimum = *natural = _gtk_css_number_value_get (style->icon->icon_size, 100);
}
static void

View File

@ -103,7 +103,6 @@
#include "gtkprivate.h"
#include "gtkrendericonprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkgestureclick.h"
#include "gtkgesturedrag.h"

View File

@ -35,7 +35,7 @@
#include "gtklabel.h"
#include "gtkprivate.h"
#include "gtkshortcuttrigger.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkmodelbuttonprivate.h"

View File

@ -34,7 +34,6 @@
#include "gtkpopovermenu.h"
#include "gtkprivate.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkeventcontrollerkey.h"
#include "gtknative.h"

View File

@ -20,7 +20,7 @@
#include "gtkcssinheritvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstyleprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE

View File

@ -30,7 +30,6 @@
#include "gtkcssshorthandpropertyprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstyleprovider.h"
#include "gtkstylecontextprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkmarshalers.h"

View File

@ -25,7 +25,6 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtksnapshotprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkpango.h"
#include "gsk/gskcairoblurprivate.h"

View File

@ -54,7 +54,6 @@
#include "gtkprogressbar.h"
#include "gtksettings.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtktextprivate.h"
#include "gtktexthandleprivate.h"
#include "gtktextutil.h"

View File

@ -127,7 +127,6 @@
#include "gtkmarshalers.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include <string.h>

View File

@ -66,7 +66,6 @@
#include "gtkshow.h"
#include "gtkmain.h"
#include "gtkscrollable.h"
#include "gtkstylecontextprivate.h"
#include "gtkpopover.h"
#include "gtkrevealer.h"
#include "gtkspinner.h"

View File

@ -45,7 +45,6 @@
#include "gtkscrolledwindow.h"
#include "gtksearchentry.h"
#include "gtkspinbutton.h"
#include "gtkstylecontextprivate.h"
#include "gtktextview.h"
#include "gtkwidgetprivate.h"
#include "gtksettings.h"

View File

@ -31,8 +31,6 @@
#include "gtkintl.h"
#include "gtkbuildable.h"
#include "gtkwidgetprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtklabel.h"
/**

View File

@ -29,7 +29,7 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtksizerequest.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"

View File

@ -26,7 +26,6 @@
#include "gtkcssenumvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsstransientnodeprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtkrendericonprivate.h"

View File

@ -26,7 +26,6 @@
#include "gtkimageprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkiconhelperprivate.h"
#include "gtkicontheme.h"
#include "gtkintl.h"

View File

@ -28,7 +28,6 @@
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkeventcontrollermotion.h"
#include "gtkeventcontrollerfocus.h"
#include "gtkgesturedrag.h"

View File

@ -124,13 +124,12 @@
#include "gtkbinlayout.h"
#include "gtkbuildable.h"
#include "gtkbuilderprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkgizmoprivate.h"
#include "gtkintl.h"
#include "gtklevelbar.h"
#include "gtkmarshalers.h"
#include "gtkorientable.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"

View File

@ -34,7 +34,6 @@
#include "gtkscrollable.h"
#include "gtksingleselection.h"
#include "gtksnapshot.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"

View File

@ -49,7 +49,6 @@
#include "gtkicontheme.h"
#include "gtkmain.h"
#include "gtksettings.h"
#include "gtkstylecontextprivate.h"
#include "gtkdialogprivate.h"
#include "gtkgestureclick.h"
#include "gtkmodelbuttonprivate.h"

View File

@ -31,7 +31,6 @@
#include "gtkboxlayout.h"
#include "gtkbuildable.h"
#include "gtkbutton.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkdroptarget.h"
#include "gtkdragicon.h"
#include "gtkdropcontrollermotion.h"

View File

@ -27,7 +27,6 @@
#include "gtkpaned.h"
#include "gtkcssboxesprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkeventcontrollermotion.h"
#include "gtkgesturepan.h"
#include "gtkgesturesingle.h"
@ -37,7 +36,7 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkrendericonprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkcssboxesprivate.h"

View File

@ -35,7 +35,7 @@
#include "gtkprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcsspositionvalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
/**

View File

@ -27,15 +27,12 @@
#include "gtkprogressbar.h"
#include "gtkboxlayout.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkgizmoprivate.h"
#include "gtkintl.h"
#include "gtklabel.h"
#include "gtkorientable.h"
#include "gtkprogresstrackerprivate.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
#include <string.h>

View File

@ -22,7 +22,6 @@
#include "gtkcsscornervalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsstypesprivate.h"
#include "gtkstylecontextprivate.h"
#include <string.h>

View File

@ -38,8 +38,6 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtkrangeprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"

View File

@ -36,7 +36,6 @@
#include "gtkbox.h"
#include "gtkbutton.h"
#include "gtkbuttonprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkeditable.h"
#include "gtkcelleditable.h"
#include "gtkimage.h"
@ -53,7 +52,6 @@
#include "gtkorientable.h"
#include "gtkprivate.h"
#include "gtksettings.h"
#include "gtkstylecontextprivate.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkboxlayout.h"

View File

@ -34,7 +34,7 @@
#include "gtkimage.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkrendericonprivate.h"

View File

@ -70,7 +70,6 @@
#include "gtkprivate.h"
#include "gtkprogresstrackerprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h"
typedef struct _GtkSwitchClass GtkSwitchClass;

View File

@ -26,8 +26,7 @@
#include "gtkwidgetprivate.h"
#include "gtkrendericonprivate.h"
#include "gtkcssboxesimplprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtknativeprivate.h"
#include "gtkintl.h"
@ -110,17 +109,15 @@ gtk_text_handle_native_get_surface_transform (GtkNative *native,
static void
gtk_text_handle_get_padding (GtkTextHandle *handle,
GtkBorder *border)
GtkBorder *padding)
{
GtkWidget *widget = GTK_WIDGET (handle);
GtkStyleContext *context;
GtkCssStyle *style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
context = gtk_widget_get_style_context (widget);
border->left = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_LEFT), 100);
border->right = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_RIGHT), 100);
border->top = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_TOP), 100);
border->bottom = _gtk_css_number_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_PADDING_BOTTOM), 100);
padding->left = _gtk_css_number_value_get (style->size->padding_left, 100);
padding->right = _gtk_css_number_value_get (style->size->padding_right, 100);
padding->top = _gtk_css_number_value_get (style->size->padding_top, 100);
padding->bottom = _gtk_css_number_value_get (style->size->padding_bottom, 100);
}
static void

View File

@ -34,7 +34,6 @@
#include "gtkintl.h"
#include "gtkwidgetprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkstylepropertyprivate.h"
#include "gtkcsscolorvalueprivate.h"
#define DRAG_ICON_MAX_WIDTH 250
@ -165,7 +164,6 @@ set_attributes_from_style (GtkWidget *widget,
GtkTextAttributes *values)
{
GtkCssStyle *style;
GtkStyleContext *context;
const GdkRGBA black = { 0, };
if (!values->appearance.bg_rgba)
@ -173,8 +171,7 @@ set_attributes_from_style (GtkWidget *widget,
if (!values->appearance.fg_rgba)
values->appearance.fg_rgba = gdk_rgba_copy (&black);
context = gtk_widget_get_style_context (widget);
style = gtk_style_context_lookup_style (context);
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
*values->appearance.bg_rgba = *gtk_css_color_value_get_rgba (style->background->background_color);
*values->appearance.fg_rgba = *gtk_css_color_value_get_rgba (style->core->color);

View File

@ -48,7 +48,7 @@
#include "gtktypebuiltins.h"
#include "gtktextviewchildprivate.h"
#include "gtktexthandleprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkpopover.h"
#include "gtkmagnifierprivate.h"
#include "gtkemojichooser.h"
@ -7491,7 +7491,7 @@ static void
gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
GtkTextAttributes *values)
{
GtkStyleContext *context;
GtkCssStyle *style;
const GdkRGBA black = { 0, };
const GdkRGBA *color;
@ -7500,17 +7500,17 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
if (!values->appearance.fg_rgba)
values->appearance.fg_rgba = gdk_rgba_copy (&black);
context = gtk_widget_get_style_context (GTK_WIDGET (text_view));
style = gtk_css_node_get_style (gtk_widget_get_css_node (GTK_WIDGET (text_view)));
color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
color = gtk_css_color_value_get_rgba (style->background->background_color);
*values->appearance.bg_rgba = *color;
color = gtk_css_color_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
color = gtk_css_color_value_get_rgba (style->core->color);
*values->appearance.fg_rgba = *color;
if (values->font)
pango_font_description_free (values->font);
values->font = gtk_css_style_get_pango_font (gtk_style_context_lookup_style (context));
values->font = gtk_css_style_get_pango_font (style);
}
static void

View File

@ -28,7 +28,6 @@
#include "gtkcellrenderer.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkdragsource.h"
#include "gtkdragicon.h"
#include "gtkdroptargetasync.h"

View File

@ -39,7 +39,6 @@
#include "gtkcsspositionvalueprivate.h"
#include "gtkcssfontvariationsvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcsswidgetnodeprivate.h"
#include "gtkdebug.h"
#include "gtkgesturedrag.h"

View File

@ -36,7 +36,6 @@
#include "gtkcsscornervalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssshadowvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkdroptargetasync.h"
#include "gtkeventcontrollerlegacy.h"
#include "gtkeventcontrollerkey.h"