forked from AuroraMiddleware/gtk
Merge branch 'wip/otte/css' into 'master'
Some CSS cleanup See merge request GNOME/gtk!1389
This commit is contained in:
commit
0ad791277a
@ -4801,7 +4801,6 @@ GTK_STYLE_CLASS_WARNING
|
||||
GTK_STYLE_CLASS_WIDE
|
||||
<SUBSECTION>
|
||||
GtkStyleContext
|
||||
gtk_style_context_new
|
||||
gtk_style_context_add_provider
|
||||
gtk_style_context_add_provider_for_display
|
||||
gtk_style_context_get_parent
|
||||
|
@ -3793,7 +3793,7 @@ gdk_surface_get_unscaled_size (GdkSurface *surface,
|
||||
* GTK will update this property automatically if
|
||||
* the @surface background is opaque, as we know where the opaque regions
|
||||
* are. If your surface background is not opaque, please update this
|
||||
* property in your #GtkWidget::style-updated handler.
|
||||
* property in your #GtkWidget:css-changed handler.
|
||||
*/
|
||||
void
|
||||
gdk_surface_set_opaque_region (GdkSurface *surface,
|
||||
|
@ -55,15 +55,10 @@ gtk_builtin_icon_snapshot (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_builtin_icon_style_updated (GtkWidget *widget)
|
||||
gtk_builtin_icon_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssStyleChange *change = NULL;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (context);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (change == NULL ||
|
||||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
|
||||
@ -99,7 +94,7 @@ gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
|
||||
|
||||
wclass->snapshot = gtk_builtin_icon_snapshot;
|
||||
wclass->measure = gtk_builtin_icon_measure;
|
||||
wclass->style_updated = gtk_builtin_icon_style_updated;
|
||||
wclass->css_changed = gtk_builtin_icon_css_changed;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -350,7 +350,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
|
||||
/* We validate the style contexts in a single loop before even trying
|
||||
* to handle resizes instead of doing validations inline.
|
||||
* This is mostly necessary for compatibility reasons with old code,
|
||||
* because both style_updated and size_allocate functions often change
|
||||
* because both css_changed and size_allocate functions often change
|
||||
* styles and so could cause infinite loops in this function.
|
||||
*
|
||||
* It's important to note that even an invalid style context returns
|
||||
|
@ -1359,17 +1359,14 @@ gtk_css_node_validate (GtkCssNode *cssnode)
|
||||
|
||||
gtk_css_node_validate_internal (cssnode, &filter, timestamp);
|
||||
|
||||
if (cssnode->parent == NULL)
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
if (gdk_profiler_is_running ())
|
||||
{
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "css validation", "");
|
||||
gdk_profiler_set_int_counter (invalidated_nodes_counter, after * 1000, invalidated_nodes);
|
||||
gdk_profiler_set_int_counter (created_styles_counter, after * 1000, created_styles);
|
||||
invalidated_nodes = 0;
|
||||
created_styles = 0;
|
||||
}
|
||||
gint64 after = g_get_monotonic_time ();
|
||||
gdk_profiler_add_mark (before * 1000, (after - before) * 1000, "css validation", "");
|
||||
gdk_profiler_set_int_counter (invalidated_nodes_counter, after * 1000, invalidated_nodes);
|
||||
gdk_profiler_set_int_counter (created_styles_counter, after * 1000, created_styles);
|
||||
invalidated_nodes = 0;
|
||||
created_styles = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ static void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
|
||||
GtkCssValue *specified,
|
||||
GtkCssSection *section);
|
||||
|
||||
static int core_props[] = {
|
||||
static const int core_props[] = {
|
||||
GTK_CSS_PROPERTY_COLOR,
|
||||
GTK_CSS_PROPERTY_DPI,
|
||||
GTK_CSS_PROPERTY_FONT_SIZE,
|
||||
@ -54,7 +54,7 @@ static int core_props[] = {
|
||||
GTK_CSS_PROPERTY_ICON_PALETTE
|
||||
};
|
||||
|
||||
static int background_props[] = {
|
||||
static const int background_props[] = {
|
||||
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
|
||||
GTK_CSS_PROPERTY_BOX_SHADOW,
|
||||
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
|
||||
@ -66,7 +66,7 @@ static int background_props[] = {
|
||||
GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE
|
||||
};
|
||||
|
||||
static int border_props[] = {
|
||||
static const int border_props[] = {
|
||||
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
|
||||
GTK_CSS_PROPERTY_BORDER_TOP_WIDTH,
|
||||
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
|
||||
@ -89,13 +89,13 @@ static int border_props[] = {
|
||||
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH
|
||||
};
|
||||
|
||||
static int icon_props[] = {
|
||||
static const int icon_props[] = {
|
||||
GTK_CSS_PROPERTY_ICON_SIZE,
|
||||
GTK_CSS_PROPERTY_ICON_SHADOW,
|
||||
GTK_CSS_PROPERTY_ICON_STYLE,
|
||||
};
|
||||
|
||||
static int outline_props[] = {
|
||||
static const int outline_props[] = {
|
||||
GTK_CSS_PROPERTY_OUTLINE_STYLE,
|
||||
GTK_CSS_PROPERTY_OUTLINE_WIDTH,
|
||||
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
|
||||
@ -106,7 +106,7 @@ static int outline_props[] = {
|
||||
GTK_CSS_PROPERTY_OUTLINE_COLOR,
|
||||
};
|
||||
|
||||
static int font_props[] = {
|
||||
static const int font_props[] = {
|
||||
GTK_CSS_PROPERTY_FONT_FAMILY,
|
||||
GTK_CSS_PROPERTY_FONT_STYLE,
|
||||
GTK_CSS_PROPERTY_FONT_WEIGHT,
|
||||
@ -118,7 +118,7 @@ static int font_props[] = {
|
||||
GTK_CSS_PROPERTY_FONT_FEATURE_SETTINGS,
|
||||
GTK_CSS_PROPERTY_FONT_VARIATION_SETTINGS,
|
||||
};
|
||||
static int font_variant_props[] = {
|
||||
static const int font_variant_props[] = {
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_LINE,
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR,
|
||||
GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE,
|
||||
@ -131,7 +131,7 @@ static int font_variant_props[] = {
|
||||
GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN,
|
||||
};
|
||||
|
||||
static int animation_props[] = {
|
||||
static const int animation_props[] = {
|
||||
GTK_CSS_PROPERTY_ANIMATION_NAME,
|
||||
GTK_CSS_PROPERTY_ANIMATION_DURATION,
|
||||
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
|
||||
@ -142,14 +142,14 @@ static int animation_props[] = {
|
||||
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
|
||||
};
|
||||
|
||||
static int transition_props[] = {
|
||||
static const int transition_props[] = {
|
||||
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
|
||||
GTK_CSS_PROPERTY_TRANSITION_DURATION,
|
||||
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
|
||||
GTK_CSS_PROPERTY_TRANSITION_DELAY,
|
||||
};
|
||||
|
||||
static int size_props[] = {
|
||||
static const int size_props[] = {
|
||||
GTK_CSS_PROPERTY_MARGIN_TOP,
|
||||
GTK_CSS_PROPERTY_MARGIN_LEFT,
|
||||
GTK_CSS_PROPERTY_MARGIN_BOTTOM,
|
||||
@ -163,7 +163,7 @@ static int size_props[] = {
|
||||
GTK_CSS_PROPERTY_MIN_HEIGHT,
|
||||
};
|
||||
|
||||
static int other_props[] = {
|
||||
static const int other_props[] = {
|
||||
GTK_CSS_PROPERTY_ICON_SOURCE,
|
||||
GTK_CSS_PROPERTY_ICON_TRANSFORM,
|
||||
GTK_CSS_PROPERTY_ICON_FILTER,
|
||||
|
@ -688,7 +688,7 @@ gtk_css_style_get_pango_font (GtkCssStyle *style)
|
||||
|
||||
/* Refcounted value structs */
|
||||
|
||||
static int values_size[] = {
|
||||
static const int values_size[] = {
|
||||
sizeof (GtkCssCoreValues),
|
||||
sizeof (GtkCssBackgroundValues),
|
||||
sizeof (GtkCssBorderValues),
|
||||
@ -771,5 +771,5 @@ gtk_css_values_new (GtkCssValuesType type)
|
||||
values->ref_count = 1;
|
||||
values->type = type;
|
||||
|
||||
return values;
|
||||
return values;
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkCssStyleChange GtkCssStyleChange;
|
||||
|
||||
struct _GtkCssStyleChange {
|
||||
GtkCssStyle *old_style;
|
||||
GtkCssStyle *new_style;
|
||||
|
@ -22,48 +22,6 @@
|
||||
#include "gtkcssnumbervalueprivate.h"
|
||||
#include "gtkstylecontextprivate.h"
|
||||
|
||||
cairo_operator_t
|
||||
_gtk_css_blend_mode_get_operator (GskBlendMode mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case GSK_BLEND_MODE_COLOR:
|
||||
return CAIRO_OPERATOR_HSL_COLOR;
|
||||
case GSK_BLEND_MODE_COLOR_BURN:
|
||||
return CAIRO_OPERATOR_COLOR_BURN;
|
||||
case GSK_BLEND_MODE_COLOR_DODGE:
|
||||
return CAIRO_OPERATOR_COLOR_DODGE;
|
||||
case GSK_BLEND_MODE_DARKEN:
|
||||
return CAIRO_OPERATOR_DARKEN;
|
||||
case GSK_BLEND_MODE_DIFFERENCE:
|
||||
return CAIRO_OPERATOR_DIFFERENCE;
|
||||
case GSK_BLEND_MODE_EXCLUSION:
|
||||
return CAIRO_OPERATOR_EXCLUSION;
|
||||
case GSK_BLEND_MODE_HARD_LIGHT:
|
||||
return CAIRO_OPERATOR_HARD_LIGHT;
|
||||
case GSK_BLEND_MODE_SOFT_LIGHT:
|
||||
return CAIRO_OPERATOR_SOFT_LIGHT;
|
||||
case GSK_BLEND_MODE_HUE:
|
||||
return CAIRO_OPERATOR_HSL_HUE;
|
||||
case GSK_BLEND_MODE_LIGHTEN:
|
||||
return CAIRO_OPERATOR_LIGHTEN;
|
||||
case GSK_BLEND_MODE_LUMINOSITY:
|
||||
return CAIRO_OPERATOR_HSL_LUMINOSITY;
|
||||
case GSK_BLEND_MODE_MULTIPLY:
|
||||
return CAIRO_OPERATOR_MULTIPLY;
|
||||
case GSK_BLEND_MODE_OVERLAY:
|
||||
return CAIRO_OPERATOR_OVERLAY;
|
||||
case GSK_BLEND_MODE_SATURATION:
|
||||
return CAIRO_OPERATOR_HSL_SATURATION;
|
||||
case GSK_BLEND_MODE_SCREEN:
|
||||
return CAIRO_OPERATOR_SCREEN;
|
||||
|
||||
case GSK_BLEND_MODE_DEFAULT:
|
||||
default:
|
||||
return CAIRO_OPERATOR_OVER;
|
||||
}
|
||||
}
|
||||
|
||||
GtkCssChange
|
||||
_gtk_css_change_for_sibling (GtkCssChange match)
|
||||
{
|
||||
|
@ -446,8 +446,6 @@ typedef enum /*< skip >*/ {
|
||||
GTK_CSS_FONT_VARIANT_EAST_ASIAN_RUBY = 1 << 9
|
||||
} GtkCssFontVariantEastAsian;
|
||||
|
||||
cairo_operator_t _gtk_css_blend_mode_get_operator (GskBlendMode mode);
|
||||
|
||||
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
|
||||
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);
|
||||
|
||||
|
@ -95,13 +95,7 @@ gtk_css_widget_node_validate (GtkCssNode *node)
|
||||
gtk_css_style_change_init (&change, widget_node->last_updated_style, style);
|
||||
if (gtk_css_style_change_has_change (&change))
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
|
||||
context = _gtk_widget_peek_style_context (widget_node->widget);
|
||||
if (context)
|
||||
gtk_style_context_validate (context, &change);
|
||||
else
|
||||
_gtk_widget_style_context_invalidated (widget_node->widget);
|
||||
gtk_widget_css_changed (widget_node->widget, &change);
|
||||
g_set_object (&widget_node->last_updated_style, style);
|
||||
}
|
||||
gtk_css_style_change_finish (&change);
|
||||
|
@ -278,9 +278,10 @@ static void gtk_file_chooser_button_root (GtkWidget *widget);
|
||||
static void gtk_file_chooser_button_map (GtkWidget *widget);
|
||||
static gboolean gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget,
|
||||
gboolean group_cycling);
|
||||
static void gtk_file_chooser_button_style_updated (GtkWidget *widget);
|
||||
static void gtk_file_chooser_button_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state);
|
||||
static void gtk_file_chooser_button_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_file_chooser_button_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state);
|
||||
|
||||
/* Utility Functions */
|
||||
static void set_info_for_file_at_iter (GtkFileChooserButton *fs,
|
||||
@ -371,7 +372,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
|
||||
widget_class->show = gtk_file_chooser_button_show;
|
||||
widget_class->hide = gtk_file_chooser_button_hide;
|
||||
widget_class->map = gtk_file_chooser_button_map;
|
||||
widget_class->style_updated = gtk_file_chooser_button_style_updated;
|
||||
widget_class->css_changed = gtk_file_chooser_button_css_changed;
|
||||
widget_class->root = gtk_file_chooser_button_root;
|
||||
widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
|
||||
widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
|
||||
@ -1456,12 +1457,10 @@ change_icon_theme (GtkFileChooserButton *button)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_button_style_updated (GtkWidget *widget)
|
||||
gtk_file_chooser_button_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
GtkCssStyleChange *change = gtk_style_context_get_change (context);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->css_changed (widget, change);
|
||||
|
||||
/* We need to update the icon surface, but only in case
|
||||
* the icon theme really changed. */
|
||||
|
@ -480,7 +480,8 @@ static void gtk_file_chooser_widget_map (GtkWidget *w
|
||||
static void gtk_file_chooser_widget_unmap (GtkWidget *widget);
|
||||
static void gtk_file_chooser_widget_root (GtkWidget *widget);
|
||||
static void gtk_file_chooser_widget_unroot (GtkWidget *widget);
|
||||
static void gtk_file_chooser_widget_style_updated (GtkWidget *widget);
|
||||
static void gtk_file_chooser_widget_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
|
||||
static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
|
||||
GFile *folder,
|
||||
@ -3647,7 +3648,8 @@ check_icon_theme (GtkFileChooserWidget *impl)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_widget_style_updated (GtkWidget *widget)
|
||||
gtk_file_chooser_widget_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkFileChooserWidget *impl;
|
||||
|
||||
@ -3655,9 +3657,9 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
|
||||
|
||||
impl = GTK_FILE_CHOOSER_WIDGET (widget);
|
||||
|
||||
profile_msg (" parent class style_udpated start", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->style_updated (widget);
|
||||
profile_msg (" parent class style_updated end", NULL);
|
||||
profile_msg (" parent class css_changed start", NULL);
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->css_changed (widget, change);
|
||||
profile_msg (" parent class css_changed end", NULL);
|
||||
|
||||
change_icon_theme (impl);
|
||||
|
||||
@ -7945,7 +7947,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
widget_class->unmap = gtk_file_chooser_widget_unmap;
|
||||
widget_class->root = gtk_file_chooser_widget_root;
|
||||
widget_class->unroot = gtk_file_chooser_widget_unroot;
|
||||
widget_class->style_updated = gtk_file_chooser_widget_style_updated;
|
||||
widget_class->css_changed = gtk_file_chooser_widget_css_changed;
|
||||
|
||||
/*
|
||||
* Signals
|
||||
|
@ -790,7 +790,6 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
|
||||
gtk_widget_class_bind_template_callback (widget_class, stop_search_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, cursor_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, gtk_font_chooser_widget_set_cell_size);
|
||||
gtk_widget_class_bind_template_callback (widget_class, rows_changed_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, size_change_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, output_cb);
|
||||
|
@ -2163,8 +2163,8 @@ choose_icon (GtkIconTheme *self,
|
||||
* they will be tried in order.
|
||||
*
|
||||
* Note that you probably want to listen for icon theme changes and
|
||||
* update the icon. This is usually done by connecting to the
|
||||
* GtkWidget::style-updated signal.
|
||||
* update the icon. This is usually done by overriding the
|
||||
* #GtkWidget:css-changed function.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): a #GtkIconPaintable object
|
||||
* containing the icon, or %NULL if the icon wasn’t found.
|
||||
|
@ -111,7 +111,8 @@ static void gtk_image_measure (GtkWidget *widget,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline);
|
||||
|
||||
static void gtk_image_style_updated (GtkWidget *widget);
|
||||
static void gtk_image_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_image_finalize (GObject *object);
|
||||
|
||||
static void gtk_image_set_property (GObject *object,
|
||||
@ -158,7 +159,7 @@ gtk_image_class_init (GtkImageClass *class)
|
||||
widget_class->snapshot = gtk_image_snapshot;
|
||||
widget_class->measure = gtk_image_measure;
|
||||
widget_class->unrealize = gtk_image_unrealize;
|
||||
widget_class->style_updated = gtk_image_style_updated;
|
||||
widget_class->css_changed = gtk_image_css_changed;
|
||||
|
||||
image_props[PROP_PAINTABLE] =
|
||||
g_param_spec_object ("paintable",
|
||||
@ -1283,16 +1284,15 @@ gtk_image_measure (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_image_style_updated (GtkWidget *widget)
|
||||
gtk_image_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkImage *image = GTK_IMAGE (widget);
|
||||
GtkImagePrivate *priv = gtk_image_get_instance_private (image);
|
||||
GtkStyleContext *context = gtk_widget_get_style_context (widget);
|
||||
GtkCssStyleChange *change = gtk_style_context_get_change (context);
|
||||
|
||||
gtk_icon_helper_invalidate_for_change (priv->icon_helper, change);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_image_parent_class)->css_changed (widget, change);
|
||||
|
||||
priv->baseline_align = 0.0;
|
||||
}
|
||||
|
@ -434,9 +434,10 @@ static void gtk_label_size_allocate (GtkWidget *widget,
|
||||
int baseline);
|
||||
static void gtk_label_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags prev_state);
|
||||
static void gtk_label_style_updated (GtkWidget *widget);
|
||||
static void gtk_label_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static void gtk_label_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_label_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
static gboolean gtk_label_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
|
||||
@ -641,7 +642,7 @@ gtk_label_class_init (GtkLabelClass *class)
|
||||
widget_class->destroy = gtk_label_destroy;
|
||||
widget_class->size_allocate = gtk_label_size_allocate;
|
||||
widget_class->state_flags_changed = gtk_label_state_flags_changed;
|
||||
widget_class->style_updated = gtk_label_style_updated;
|
||||
widget_class->css_changed = gtk_label_css_changed;
|
||||
widget_class->query_tooltip = gtk_label_query_tooltip;
|
||||
widget_class->snapshot = gtk_label_snapshot;
|
||||
widget_class->unrealize = gtk_label_unrealize;
|
||||
@ -3790,17 +3791,13 @@ gtk_label_state_flags_changed (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_label_style_updated (GtkWidget *widget)
|
||||
gtk_label_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkLabel *label = GTK_LABEL (widget);
|
||||
GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
|
||||
GtkStyleContext *context;
|
||||
GtkCssStyleChange *change;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (context);
|
||||
GTK_WIDGET_CLASS (gtk_label_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
|
||||
(priv->select_info && priv->select_info->links))
|
||||
|
@ -227,10 +227,11 @@ static void gtk_paned_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline);
|
||||
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_unrealize (GtkWidget *widget);
|
||||
static gboolean gtk_paned_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
static void gtk_paned_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_paned_add (GtkContainer *container,
|
||||
GtkWidget *widget);
|
||||
static void gtk_paned_remove (GtkContainer *container,
|
||||
@ -355,7 +356,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;
|
||||
widget_class->css_changed = gtk_paned_css_changed;
|
||||
|
||||
container_class->add = gtk_paned_add;
|
||||
container_class->remove = gtk_paned_remove;
|
||||
@ -1465,15 +1466,10 @@ gtk_paned_focus (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_paned_style_updated (GtkWidget *widget)
|
||||
gtk_paned_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
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);
|
||||
GTK_WIDGET_CLASS (gtk_paned_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (change == NULL ||
|
||||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
|
||||
|
114
gtk/gtkpathbar.c
114
gtk/gtkpathbar.c
@ -79,7 +79,6 @@ typedef struct
|
||||
GList *fake_root;
|
||||
GtkWidget *up_slider_button;
|
||||
GtkWidget *down_slider_button;
|
||||
guint settings_signal_id;
|
||||
gint16 slider_width;
|
||||
} GtkPathBarPrivate;
|
||||
|
||||
@ -149,10 +148,6 @@ static gboolean gtk_path_bar_slider_up_defocus (GtkWidget *widget,
|
||||
static gboolean gtk_path_bar_slider_down_defocus (GtkWidget *widget,
|
||||
GdkEventButton *event,
|
||||
GtkPathBar *path_bar);
|
||||
static void gtk_path_bar_style_updated (GtkWidget *widget);
|
||||
static void gtk_path_bar_root (GtkWidget *widget);
|
||||
static void gtk_path_bar_unroot (GtkWidget *widget);
|
||||
static void gtk_path_bar_check_icon_theme (GtkPathBar *path_bar);
|
||||
static void gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
|
||||
ButtonData *button_data,
|
||||
gboolean current_dir);
|
||||
@ -268,9 +263,6 @@ gtk_path_bar_class_init (GtkPathBarClass *path_bar_class)
|
||||
|
||||
widget_class->measure = gtk_path_bar_measure;
|
||||
widget_class->size_allocate = gtk_path_bar_size_allocate;
|
||||
widget_class->style_updated = gtk_path_bar_style_updated;
|
||||
widget_class->root = gtk_path_bar_root;
|
||||
widget_class->unroot = gtk_path_bar_unroot;
|
||||
|
||||
container_class->add = gtk_path_bar_add;
|
||||
container_class->forall = gtk_path_bar_forall;
|
||||
@ -329,32 +321,12 @@ gtk_path_bar_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (gtk_path_bar_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
/* Removes the settings signal handler. It's safe to call multiple times */
|
||||
static void
|
||||
remove_settings_signal (GtkPathBar *path_bar,
|
||||
GdkDisplay *display)
|
||||
{
|
||||
GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (path_bar);
|
||||
|
||||
if (priv->settings_signal_id)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
settings = gtk_settings_get_for_display (display);
|
||||
g_signal_handler_disconnect (settings,
|
||||
priv->settings_signal_id);
|
||||
priv->settings_signal_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_dispose (GObject *object)
|
||||
{
|
||||
GtkPathBar *path_bar = GTK_PATH_BAR (object);
|
||||
GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (path_bar);
|
||||
|
||||
remove_settings_signal (path_bar, gtk_widget_get_display (GTK_WIDGET (object)));
|
||||
|
||||
priv->get_info_cancellable = NULL;
|
||||
cancel_all_cancellables (path_bar);
|
||||
|
||||
@ -719,30 +691,6 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_style_updated (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->style_updated (widget);
|
||||
|
||||
gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_root (GtkWidget *widget)
|
||||
{
|
||||
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->root (widget);
|
||||
|
||||
gtk_path_bar_check_icon_theme (GTK_PATH_BAR (widget));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_unroot (GtkWidget *widget)
|
||||
{
|
||||
remove_settings_signal (GTK_PATH_BAR (widget), gtk_widget_get_display (widget));
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_path_bar_parent_class)->unroot (widget);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_path_bar_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
gdouble dx,
|
||||
@ -975,68 +923,6 @@ gtk_path_bar_slider_down_defocus (GtkWidget *widget,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Changes the icons wherever it is needed */
|
||||
static void
|
||||
reload_icons (GtkPathBar *path_bar)
|
||||
{
|
||||
GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (path_bar);
|
||||
GList *list;
|
||||
|
||||
g_clear_object (&priv->root_icon);
|
||||
g_clear_object (&priv->home_icon);
|
||||
g_clear_object (&priv->desktop_icon);
|
||||
|
||||
for (list = priv->button_list; list; list = list->next)
|
||||
{
|
||||
ButtonData *button_data;
|
||||
gboolean current_dir;
|
||||
|
||||
button_data = BUTTON_DATA (list->data);
|
||||
if (button_data->type != NORMAL_BUTTON)
|
||||
{
|
||||
current_dir = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button));
|
||||
gtk_path_bar_update_button_appearance (path_bar, button_data, current_dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
change_icon_theme (GtkPathBar *path_bar)
|
||||
{
|
||||
reload_icons (path_bar);
|
||||
}
|
||||
|
||||
/* Callback used when a GtkSettings value changes */
|
||||
static void
|
||||
settings_notify_cb (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GtkPathBar *path_bar)
|
||||
{
|
||||
const char *name;
|
||||
|
||||
name = g_param_spec_get_name (pspec);
|
||||
|
||||
if (strcmp (name, "gtk-icon-theme-name") == 0)
|
||||
change_icon_theme (path_bar);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_path_bar_check_icon_theme (GtkPathBar *path_bar)
|
||||
{
|
||||
GtkPathBarPrivate *priv = gtk_path_bar_get_instance_private (path_bar);
|
||||
|
||||
if (priv->settings_signal_id == 0)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
settings = gtk_widget_get_settings (GTK_WIDGET (path_bar));
|
||||
priv->settings_signal_id = g_signal_connect (settings, "notify",
|
||||
G_CALLBACK (settings_notify_cb), path_bar);
|
||||
}
|
||||
|
||||
change_icon_theme (path_bar);
|
||||
}
|
||||
|
||||
/* Public functions and their helpers */
|
||||
static void
|
||||
gtk_path_bar_clear_buttons (GtkPathBar *path_bar)
|
||||
|
@ -260,7 +260,7 @@ void
|
||||
gtk_css_style_snapshot_background (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCssBackgroundValues *background = boxes->style->background;
|
||||
const GtkCssBackgroundValues *background = boxes->style->background;
|
||||
GtkCssValue *background_image;
|
||||
const GdkRGBA *bg_color;
|
||||
const GtkCssValue *box_shadow;
|
||||
|
@ -651,12 +651,10 @@ void
|
||||
gtk_css_style_snapshot_border (GtkCssBoxes *boxes,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
GtkCssBorderValues *border;
|
||||
const GtkCssBorderValues *border = boxes->style->border;
|
||||
GtkBorderImage border_image;
|
||||
float border_width[4];
|
||||
|
||||
border = boxes->style->border;
|
||||
|
||||
if (border->base.type == GTK_CSS_BORDER_INITIAL_VALUES)
|
||||
return;
|
||||
|
||||
|
@ -121,15 +121,10 @@ gtk_spinner_snapshot (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_spinner_style_updated (GtkWidget *widget)
|
||||
gtk_spinner_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkCssStyleChange *change = NULL;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (context);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_spinner_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_spinner_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (change == NULL ||
|
||||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
|
||||
@ -215,7 +210,7 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
|
||||
widget_class = GTK_WIDGET_CLASS(klass);
|
||||
widget_class->snapshot = gtk_spinner_snapshot;
|
||||
widget_class->measure = gtk_spinner_measure;
|
||||
widget_class->style_updated = gtk_spinner_style_updated;
|
||||
widget_class->css_changed = gtk_spinner_css_changed;
|
||||
|
||||
/* GtkSpinner:active:
|
||||
*
|
||||
|
@ -68,11 +68,6 @@
|
||||
* RTL/LTR information set. The style context will also be updated
|
||||
* automatically if any of these settings change on the widget.
|
||||
*
|
||||
* If you are using the theming layer standalone, you will need to set a
|
||||
* widget path and a display yourself to the created style context through
|
||||
* gtk_style_context_set_path() and possibly gtk_style_context_set_display().
|
||||
* See the “Foreign drawing“ example in gtk4-demo.
|
||||
*
|
||||
* # Style Classes # {#gtkstylecontext-classes}
|
||||
*
|
||||
* Widgets can add style classes to their context, which can be used to associate
|
||||
@ -101,14 +96,6 @@
|
||||
*/
|
||||
|
||||
#define CURSOR_ASPECT_RATIO (0.04)
|
||||
typedef struct PropertyValue PropertyValue;
|
||||
|
||||
struct PropertyValue
|
||||
{
|
||||
GType widget_type;
|
||||
GParamSpec *pspec;
|
||||
GValue value;
|
||||
};
|
||||
|
||||
struct _GtkStyleContextPrivate
|
||||
{
|
||||
@ -116,30 +103,19 @@ struct _GtkStyleContextPrivate
|
||||
|
||||
guint cascade_changed_id;
|
||||
GtkStyleCascade *cascade;
|
||||
GtkStyleContext *parent;
|
||||
GtkCssNode *cssnode;
|
||||
GSList *saved_nodes;
|
||||
|
||||
GtkCssStyleChange *invalidating_context;
|
||||
};
|
||||
typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate;
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DISPLAY,
|
||||
PROP_PARENT,
|
||||
LAST_PROP
|
||||
};
|
||||
|
||||
enum {
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static GParamSpec *properties[LAST_PROP] = { NULL, };
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0 };
|
||||
|
||||
static void gtk_style_context_finalize (GObject *object);
|
||||
|
||||
static void gtk_style_context_impl_set_property (GObject *object,
|
||||
@ -155,19 +131,6 @@ static GtkCssNode * gtk_style_context_get_root (GtkStyleContext *context);
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_style_context_real_changed (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
if (GTK_IS_CSS_WIDGET_NODE (priv->cssnode))
|
||||
{
|
||||
GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode));
|
||||
if (widget != NULL)
|
||||
_gtk_widget_style_context_invalidated (widget);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_context_class_init (GtkStyleContextClass *klass)
|
||||
{
|
||||
@ -177,28 +140,6 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
|
||||
object_class->set_property = gtk_style_context_impl_set_property;
|
||||
object_class->get_property = gtk_style_context_impl_get_property;
|
||||
|
||||
klass->changed = gtk_style_context_real_changed;
|
||||
|
||||
/**
|
||||
* GtkStyleContext::changed:
|
||||
*
|
||||
* The ::changed signal is emitted when there is a change in the
|
||||
* #GtkStyleContext.
|
||||
*
|
||||
* For a #GtkStyleContext returned by gtk_widget_get_style_context(), the
|
||||
* #GtkWidget::style-updated signal/vfunc might be more convenient to use.
|
||||
*
|
||||
* This signal is useful when using the theming layer standalone.
|
||||
*/
|
||||
signals[CHANGED] =
|
||||
g_signal_new (I_("changed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GtkStyleContextClass, changed),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
properties[PROP_DISPLAY] =
|
||||
g_param_spec_object ("display",
|
||||
P_("Display"),
|
||||
@ -206,19 +147,6 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
|
||||
GDK_TYPE_DISPLAY,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
/**
|
||||
* GtkStyleContext:parent:
|
||||
*
|
||||
* Sets or gets the style context’s parent. See gtk_style_context_set_parent()
|
||||
* for details.
|
||||
*/
|
||||
properties[PROP_PARENT] =
|
||||
g_param_spec_object ("parent",
|
||||
P_("Parent"),
|
||||
P_("The parent style context"),
|
||||
GTK_TYPE_STYLE_CONTEXT,
|
||||
GTK_PARAM_READWRITE);
|
||||
|
||||
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
||||
}
|
||||
|
||||
@ -288,15 +216,6 @@ gtk_style_context_init (GtkStyleContext *context)
|
||||
_gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display), 1));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_context_clear_parent (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
if (priv->parent)
|
||||
g_object_unref (priv->parent);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_context_finalize (GObject *object)
|
||||
{
|
||||
@ -306,7 +225,6 @@ gtk_style_context_finalize (GObject *object)
|
||||
while (priv->saved_nodes)
|
||||
gtk_style_context_pop_style_node (context);
|
||||
|
||||
gtk_style_context_clear_parent (context);
|
||||
gtk_style_context_set_cascade (context, NULL);
|
||||
|
||||
if (priv->cssnode)
|
||||
@ -328,9 +246,6 @@ gtk_style_context_impl_set_property (GObject *object,
|
||||
case PROP_DISPLAY:
|
||||
gtk_style_context_set_display (context, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_PARENT:
|
||||
gtk_style_context_set_parent (context, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -351,9 +266,6 @@ gtk_style_context_impl_get_property (GObject *object,
|
||||
case PROP_DISPLAY:
|
||||
g_value_set_object (value, priv->display);
|
||||
break;
|
||||
case PROP_PARENT:
|
||||
g_value_set_object (value, priv->parent);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
@ -418,34 +330,6 @@ gtk_style_context_get_node (GtkStyleContext *context)
|
||||
return priv->cssnode;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_new:
|
||||
*
|
||||
* Creates a standalone #GtkStyleContext, this style context
|
||||
* won’t be attached to any widget, so you may want
|
||||
* to call gtk_style_context_set_path() yourself.
|
||||
*
|
||||
* This function is only useful when using the theming layer
|
||||
* separated from GTK+, if you are using #GtkStyleContext to
|
||||
* theme #GtkWidgets, use gtk_widget_get_style_context()
|
||||
* in order to get a style context ready to theme the widget.
|
||||
*
|
||||
* Returns: A newly created #GtkStyleContext.
|
||||
**/
|
||||
GtkStyleContext *
|
||||
gtk_style_context_new (void)
|
||||
{
|
||||
GtkStyleContext *context = g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL);
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
|
||||
/* Create default info store */
|
||||
priv->cssnode = gtk_css_node_new ();
|
||||
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
GtkStyleContext *
|
||||
gtk_style_context_new_for_node (GtkCssNode *node)
|
||||
{
|
||||
@ -744,70 +628,6 @@ gtk_style_context_get_scale (GtkStyleContext *context)
|
||||
return _gtk_style_cascade_get_scale (priv->cascade);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_set_parent:
|
||||
* @context: a #GtkStyleContext
|
||||
* @parent: (allow-none): the new parent or %NULL
|
||||
*
|
||||
* Sets the parent style context for @context. The parent style
|
||||
* context is used to implement
|
||||
* [inheritance](http://www.w3.org/TR/css3-cascade/#inheritance)
|
||||
* of properties.
|
||||
*
|
||||
* If you are using a #GtkStyleContext returned from
|
||||
* gtk_widget_get_style_context(), the parent will be set for you.
|
||||
**/
|
||||
void
|
||||
gtk_style_context_set_parent (GtkStyleContext *context,
|
||||
GtkStyleContext *parent)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (parent == NULL || GTK_IS_STYLE_CONTEXT (parent));
|
||||
|
||||
if (priv->parent == parent)
|
||||
return;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
GtkCssNode *root = gtk_style_context_get_root (context);
|
||||
g_object_ref (parent);
|
||||
|
||||
if (gtk_css_node_get_parent (root) == NULL)
|
||||
gtk_css_node_set_parent (root, gtk_style_context_get_root (parent));
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_node_set_parent (gtk_style_context_get_root (context), NULL);
|
||||
}
|
||||
|
||||
gtk_style_context_clear_parent (context);
|
||||
|
||||
priv->parent = parent;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_PARENT]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_get_parent:
|
||||
* @context: a #GtkStyleContext
|
||||
*
|
||||
* Gets the parent context set via gtk_style_context_set_parent().
|
||||
* See that function for details.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the parent context or %NULL
|
||||
**/
|
||||
GtkStyleContext *
|
||||
gtk_style_context_get_parent (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||
|
||||
return priv->parent;
|
||||
}
|
||||
|
||||
/*
|
||||
* gtk_style_context_save_to_node:
|
||||
* @context: a #GtkStyleContext
|
||||
@ -1143,30 +963,6 @@ gtk_style_context_lookup_color (GtkStyleContext *context,
|
||||
return gtk_style_context_resolve_color (context, value, color);
|
||||
}
|
||||
|
||||
static GtkCssStyleChange magic_number;
|
||||
|
||||
void
|
||||
gtk_style_context_validate (GtkStyleContext *context,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
|
||||
/* Avoid reentrancy */
|
||||
if (priv->invalidating_context)
|
||||
return;
|
||||
|
||||
if (change)
|
||||
priv->invalidating_context = change;
|
||||
else
|
||||
priv->invalidating_context = &magic_number;
|
||||
|
||||
g_signal_emit (context, signals[CHANGED], 0);
|
||||
|
||||
priv->invalidating_context = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_get_color:
|
||||
* @context: a #GtkStyleContext
|
||||
@ -1597,32 +1393,6 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_get_change:
|
||||
* @context: the context to query
|
||||
*
|
||||
* Queries the context for the changes for the currently executing
|
||||
* GtkStyleContext::invalidate signal. If no signal is currently
|
||||
* emitted or the signal has not been triggered by a CssNode
|
||||
* invalidation, this function returns %NULL.
|
||||
*
|
||||
* FIXME 4.0: Make this part of the signal.
|
||||
*
|
||||
* Returns: %NULL or the currently invalidating changes
|
||||
**/
|
||||
GtkCssStyleChange *
|
||||
gtk_style_context_get_change (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
|
||||
|
||||
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
|
||||
|
||||
if (priv->invalidating_context == &magic_number)
|
||||
return NULL;
|
||||
|
||||
return priv->invalidating_context;
|
||||
}
|
||||
|
||||
PangoAttrList *
|
||||
_gtk_style_context_get_pango_attributes (GtkStyleContext *context)
|
||||
{
|
||||
|
@ -849,9 +849,6 @@ struct _GtkStyleContextClass
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GType gtk_style_context_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkStyleContext * gtk_style_context_new (void);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_add_provider_for_display (GdkDisplay *display,
|
||||
GtkStyleProvider *provider,
|
||||
@ -886,9 +883,6 @@ void gtk_style_context_set_scale (GtkStyleContext *context,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gtk_style_context_get_scale (GtkStyleContext *context);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_style_context_set_parent (GtkStyleContext *context,
|
||||
GtkStyleContext *parent);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkStyleContext *gtk_style_context_get_parent (GtkStyleContext *context);
|
||||
|
||||
|
@ -44,14 +44,9 @@ void gtk_style_context_save_named (GtkStyleContext *c
|
||||
void gtk_style_context_save_to_node (GtkStyleContext *context,
|
||||
GtkCssNode *node);
|
||||
|
||||
GtkCssStyleChange *
|
||||
gtk_style_context_get_change (GtkStyleContext *context);
|
||||
|
||||
GtkCssStyle * gtk_style_context_lookup_style (GtkStyleContext *context);
|
||||
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
|
||||
guint property_id);
|
||||
void gtk_style_context_validate (GtkStyleContext *context,
|
||||
GtkCssStyleChange *change);
|
||||
gboolean _gtk_style_context_check_region_name (const gchar *str);
|
||||
|
||||
void _gtk_style_context_get_cursor_color (GtkStyleContext *context,
|
||||
|
@ -327,7 +327,8 @@ static void gtk_text_snapshot (GtkWidget *widget,
|
||||
static void gtk_text_focus_in (GtkWidget *widget);
|
||||
static void gtk_text_focus_out (GtkWidget *widget);
|
||||
static gboolean gtk_text_grab_focus (GtkWidget *widget);
|
||||
static void gtk_text_style_updated (GtkWidget *widget);
|
||||
static void gtk_text_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_text_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection previous_dir);
|
||||
static void gtk_text_state_flags_changed (GtkWidget *widget,
|
||||
@ -725,7 +726,7 @@ gtk_text_class_init (GtkTextClass *class)
|
||||
widget_class->size_allocate = gtk_text_size_allocate;
|
||||
widget_class->snapshot = gtk_text_snapshot;
|
||||
widget_class->grab_focus = gtk_text_grab_focus;
|
||||
widget_class->style_updated = gtk_text_style_updated;
|
||||
widget_class->css_changed = gtk_text_css_changed;
|
||||
widget_class->direction_changed = gtk_text_direction_changed;
|
||||
widget_class->state_flags_changed = gtk_text_state_flags_changed;
|
||||
widget_class->root = gtk_text_root;
|
||||
@ -3362,16 +3363,12 @@ gtk_text_update_cached_style_values (GtkText *self)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_style_updated (GtkWidget *widget)
|
||||
gtk_text_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkText *self = GTK_TEXT (widget);
|
||||
GtkStyleContext *context;
|
||||
GtkCssStyleChange *change = NULL;
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (context);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_text_parent_class)->css_changed (widget, change);
|
||||
|
||||
gtk_text_update_cached_style_values (self);
|
||||
|
||||
|
@ -200,7 +200,6 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
|
||||
if (!priv->windows[pos].widget)
|
||||
{
|
||||
GtkWidget *widget, *window;
|
||||
GtkStyleContext *context;
|
||||
GtkEventController *controller;
|
||||
|
||||
widget = gtk_gizmo_new (I_("cursor-handle"), NULL, NULL, snapshot_func, NULL);
|
||||
@ -220,16 +219,14 @@ _gtk_text_handle_ensure_widget (GtkTextHandle *handle,
|
||||
priv->toplevel = window = gtk_widget_get_ancestor (priv->parent, GTK_TYPE_WINDOW);
|
||||
_gtk_window_add_popover (GTK_WINDOW (window), widget, priv->parent, FALSE);
|
||||
|
||||
context = gtk_widget_get_style_context (widget);
|
||||
gtk_style_context_set_parent (context, gtk_widget_get_style_context (priv->parent));
|
||||
if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
|
||||
{
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_BOTTOM);
|
||||
gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_BOTTOM);
|
||||
if (priv->mode == GTK_TEXT_HANDLE_MODE_CURSOR)
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_INSERTION_CURSOR);
|
||||
gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_INSERTION_CURSOR);
|
||||
}
|
||||
else
|
||||
gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOP);
|
||||
gtk_widget_add_style_class (widget, GTK_STYLE_CLASS_TOP);
|
||||
}
|
||||
|
||||
return priv->windows[pos].widget;
|
||||
|
@ -373,10 +373,11 @@ static void gtk_text_view_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline);
|
||||
static void gtk_text_view_realize (GtkWidget *widget);
|
||||
static void gtk_text_view_unrealize (GtkWidget *widget);
|
||||
static void gtk_text_view_map (GtkWidget *widget);
|
||||
static void gtk_text_view_style_updated (GtkWidget *widget);
|
||||
static void gtk_text_view_realize (GtkWidget *widget);
|
||||
static void gtk_text_view_unrealize (GtkWidget *widget);
|
||||
static void gtk_text_view_map (GtkWidget *widget);
|
||||
static void gtk_text_view_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_text_view_direction_changed (GtkWidget *widget,
|
||||
GtkTextDirection previous_direction);
|
||||
static void gtk_text_view_state_flags_changed (GtkWidget *widget,
|
||||
@ -702,7 +703,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
||||
widget_class->realize = gtk_text_view_realize;
|
||||
widget_class->unrealize = gtk_text_view_unrealize;
|
||||
widget_class->map = gtk_text_view_map;
|
||||
widget_class->style_updated = gtk_text_view_style_updated;
|
||||
widget_class->css_changed = gtk_text_view_css_changed;
|
||||
widget_class->direction_changed = gtk_text_view_direction_changed;
|
||||
widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
|
||||
widget_class->measure = gtk_text_view_measure;
|
||||
@ -4640,21 +4641,17 @@ gtk_text_view_map (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_text_view_style_updated (GtkWidget *widget)
|
||||
gtk_text_view_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkTextView *text_view;
|
||||
GtkTextViewPrivate *priv;
|
||||
PangoContext *ltr_context, *rtl_context;
|
||||
GtkStyleContext *style_context;
|
||||
GtkCssStyleChange *change;
|
||||
|
||||
text_view = GTK_TEXT_VIEW (widget);
|
||||
priv = text_view->priv;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_text_view_parent_class)->style_updated (widget);
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (style_context);
|
||||
GTK_WIDGET_CLASS (gtk_text_view_parent_class)->css_changed (widget, change);
|
||||
|
||||
if ((change == NULL ||
|
||||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT |
|
||||
|
@ -205,7 +205,8 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline);
|
||||
static void gtk_toolbar_style_updated (GtkWidget *widget);
|
||||
static void gtk_toolbar_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static gboolean gtk_toolbar_focus (GtkWidget *widget,
|
||||
GtkDirectionType dir);
|
||||
static void gtk_toolbar_move_focus (GtkWidget *widget,
|
||||
@ -371,7 +372,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
|
||||
widget_class->snapshot = gtk_toolbar_snapshot;
|
||||
widget_class->measure = gtk_toolbar_measure;
|
||||
widget_class->size_allocate = gtk_toolbar_size_allocate;
|
||||
widget_class->style_updated = gtk_toolbar_style_updated;
|
||||
widget_class->css_changed = gtk_toolbar_css_changed;
|
||||
widget_class->focus = gtk_toolbar_focus;
|
||||
|
||||
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR);
|
||||
@ -1440,12 +1441,13 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_toolbar_style_updated (GtkWidget *widget)
|
||||
gtk_toolbar_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
|
||||
GtkToolbarPrivate *priv = toolbar->priv;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->css_changed (widget, change);
|
||||
|
||||
priv->max_homogeneous_pixels = -1;
|
||||
}
|
||||
|
@ -675,7 +675,8 @@ static void gtk_tree_view_key_controller_focus_out (GtkEventControllerKey
|
||||
static gint gtk_tree_view_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
static gboolean gtk_tree_view_grab_focus (GtkWidget *widget);
|
||||
static void gtk_tree_view_style_updated (GtkWidget *widget);
|
||||
static void gtk_tree_view_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
|
||||
/* container signals */
|
||||
static void gtk_tree_view_remove (GtkContainer *container,
|
||||
@ -1028,7 +1029,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
|
||||
widget_class->snapshot = gtk_tree_view_snapshot;
|
||||
widget_class->focus = gtk_tree_view_focus;
|
||||
widget_class->grab_focus = gtk_tree_view_grab_focus;
|
||||
widget_class->style_updated = gtk_tree_view_style_updated;
|
||||
widget_class->css_changed = gtk_tree_view_css_changed;
|
||||
|
||||
/* GtkContainer signals */
|
||||
container_class->remove = gtk_tree_view_remove;
|
||||
@ -7958,15 +7959,14 @@ gtk_tree_view_grab_focus (GtkWidget *widget)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_tree_view_style_updated (GtkWidget *widget)
|
||||
gtk_tree_view_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
|
||||
GList *list;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkStyleContext *style_context;
|
||||
GtkCssStyleChange *change;
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
{
|
||||
@ -7974,9 +7974,6 @@ gtk_tree_view_style_updated (GtkWidget *widget)
|
||||
gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->tree_lines_enabled);
|
||||
}
|
||||
|
||||
style_context = gtk_widget_get_style_context (widget);
|
||||
change = gtk_style_context_get_change (style_context);
|
||||
|
||||
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE))
|
||||
{
|
||||
for (list = tree_view->columns; list; list = list->next)
|
||||
|
@ -37,6 +37,7 @@ typedef struct _GtkAdjustment GtkAdjustment;
|
||||
typedef struct _GtkBuilder GtkBuilder;
|
||||
typedef struct _GtkBuilderScope GtkBuilderScope;
|
||||
typedef struct _GtkClipboard GtkClipboard;
|
||||
typedef struct _GtkCssStyleChange GtkCssStyleChange;
|
||||
typedef struct _GtkEventController GtkEventController;
|
||||
typedef struct _GtkGesture GtkGesture;
|
||||
typedef struct _GtkLayoutManager GtkLayoutManager;
|
||||
|
@ -614,7 +614,8 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
|
||||
gint y,
|
||||
gboolean keyboard_tip,
|
||||
GtkTooltip *tooltip);
|
||||
static void gtk_widget_real_style_updated (GtkWidget *widget);
|
||||
static void gtk_widget_real_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
|
||||
static gboolean gtk_widget_real_focus (GtkWidget *widget,
|
||||
GtkDirectionType direction);
|
||||
@ -908,7 +909,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
klass->keynav_failed = gtk_widget_real_keynav_failed;
|
||||
klass->can_activate_accel = gtk_widget_real_can_activate_accel;
|
||||
klass->query_tooltip = gtk_widget_real_query_tooltip;
|
||||
klass->style_updated = gtk_widget_real_style_updated;
|
||||
klass->css_changed = gtk_widget_real_css_changed;
|
||||
|
||||
/* Accessibility support */
|
||||
klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
|
||||
@ -1512,23 +1513,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
|
||||
G_TYPE_NONE, 1,
|
||||
GTK_TYPE_STATE_FLAGS);
|
||||
|
||||
/**
|
||||
* GtkWidget::style-updated:
|
||||
* @widget: the object on which the signal is emitted
|
||||
*
|
||||
* The ::style-updated signal is a convenience signal that is emitted when the
|
||||
* #GtkStyleContext::changed signal is emitted on the @widget's associated
|
||||
* #GtkStyleContext as returned by gtk_widget_get_style_context().
|
||||
*/
|
||||
widget_signals[STYLE_UPDATED] =
|
||||
g_signal_new (I_("style-updated"),
|
||||
G_TYPE_FROM_CLASS (gobject_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GtkWidgetClass, style_updated),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* GtkWidget::direction-changed:
|
||||
* @widget: the object on which the signal is emitted
|
||||
@ -2646,8 +2630,6 @@ gtk_widget_unparent (GtkWidget *widget)
|
||||
|
||||
/* Unset BACKDROP since we are no longer inside a toplevel window */
|
||||
gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_BACKDROP);
|
||||
if (priv->context)
|
||||
gtk_style_context_set_parent (priv->context, NULL);
|
||||
gtk_css_node_set_parent (priv->cssnode, NULL);
|
||||
|
||||
_gtk_widget_update_parent_muxer (widget);
|
||||
@ -5115,16 +5097,13 @@ gtk_widget_real_state_flags_changed (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_widget_real_style_updated (GtkWidget *widget)
|
||||
gtk_widget_real_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
|
||||
GtkCssStyleChange *change = NULL;
|
||||
|
||||
gtk_widget_update_alpha (widget);
|
||||
|
||||
if (priv->context)
|
||||
change = gtk_style_context_get_change (priv->context);
|
||||
|
||||
if (change)
|
||||
{
|
||||
const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
|
||||
@ -6148,10 +6127,6 @@ gtk_widget_reposition_after (GtkWidget *widget,
|
||||
previous_sibling ? previous_sibling->priv->cssnode : NULL);
|
||||
}
|
||||
|
||||
if (priv->context)
|
||||
gtk_style_context_set_parent (priv->context,
|
||||
_gtk_widget_get_style_context (parent));
|
||||
|
||||
_gtk_widget_update_parent_muxer (widget);
|
||||
|
||||
if (parent->priv->children_observer)
|
||||
@ -11223,9 +11198,10 @@ gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_widget_style_context_invalidated (GtkWidget *widget)
|
||||
gtk_widget_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
|
||||
GTK_WIDGET_GET_CLASS (widget)->css_changed (widget, change);
|
||||
}
|
||||
|
||||
GtkCssNode *
|
||||
@ -11273,10 +11249,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
||||
display = _gtk_widget_get_display (widget);
|
||||
if (display)
|
||||
gtk_style_context_set_display (priv->context, display);
|
||||
|
||||
if (priv->parent)
|
||||
gtk_style_context_set_parent (priv->context,
|
||||
_gtk_widget_get_style_context (priv->parent));
|
||||
}
|
||||
|
||||
return priv->context;
|
||||
|
@ -199,8 +199,10 @@ struct _GtkWidget
|
||||
* widget; or emitted when widget got focus in keyboard mode.
|
||||
* @compute_expand: Computes whether a container should give this
|
||||
* widget extra space when possible.
|
||||
* @style_updated: Signal emitted when the GtkStyleContext of a widget
|
||||
* is changed.
|
||||
* @css_changed: Signal emitted when the CSS used by widget was changed. Widgets
|
||||
* should then discard their caches that depend on CSS and queue resizes or
|
||||
* redraws accordingly. The default implementation will take care of this for
|
||||
* all the default CSS properties, so implementations must chain up.
|
||||
* @snapshot: Vfunc for gtk_widget_snapshot().
|
||||
* @contains: Vfunc for gtk_widget_contains().
|
||||
*/
|
||||
@ -279,7 +281,8 @@ struct _GtkWidgetClass
|
||||
gboolean *hexpand_p,
|
||||
gboolean *vexpand_p);
|
||||
|
||||
void (* style_updated) (GtkWidget *widget);
|
||||
void (* css_changed) (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
|
||||
void (* snapshot) (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot);
|
||||
|
@ -278,7 +278,8 @@ GtkStyleContext * _gtk_widget_peek_style_context (GtkWidget *widget);
|
||||
gboolean _gtk_widget_captured_event (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
|
||||
void _gtk_widget_style_context_invalidated (GtkWidget *widget);
|
||||
void gtk_widget_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
|
||||
void _gtk_widget_update_parent_muxer (GtkWidget *widget);
|
||||
GtkActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget,
|
||||
|
@ -500,9 +500,10 @@ static void gtk_window_activate_default_activate (GtkWidget *widget,
|
||||
const char *action_name,
|
||||
GVariant *parameter);
|
||||
|
||||
static void gtk_window_do_popup (GtkWindow *window,
|
||||
GdkEventButton *event);
|
||||
static void gtk_window_style_updated (GtkWidget *widget);
|
||||
static void gtk_window_do_popup (GtkWindow *window,
|
||||
GdkEventButton *event);
|
||||
static void gtk_window_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change);
|
||||
static void gtk_window_state_flags_changed (GtkWidget *widget,
|
||||
GtkStateFlags previous_state);
|
||||
static void _gtk_window_set_is_active (GtkWindow *window,
|
||||
@ -800,7 +801,7 @@ gtk_window_class_init (GtkWindowClass *klass)
|
||||
widget_class->move_focus = gtk_window_move_focus;
|
||||
widget_class->measure = gtk_window_measure;
|
||||
widget_class->state_flags_changed = gtk_window_state_flags_changed;
|
||||
widget_class->style_updated = gtk_window_style_updated;
|
||||
widget_class->css_changed = gtk_window_css_changed;
|
||||
widget_class->snapshot = gtk_window_snapshot;
|
||||
|
||||
container_class->add = gtk_window_add;
|
||||
@ -3242,7 +3243,6 @@ void
|
||||
gtk_window_set_attached_to (GtkWindow *window,
|
||||
GtkWidget *attach_widget)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
||||
@ -3261,11 +3261,11 @@ gtk_window_set_attached_to (GtkWindow *window,
|
||||
}
|
||||
|
||||
/* Update the style, as the widget path might change. */
|
||||
context = gtk_widget_get_style_context (GTK_WIDGET (window));
|
||||
if (priv->attach_widget)
|
||||
gtk_style_context_set_parent (context, gtk_widget_get_style_context (priv->attach_widget));
|
||||
gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (window)),
|
||||
gtk_widget_get_css_node (priv->attach_widget));
|
||||
else
|
||||
gtk_style_context_set_parent (context, NULL);
|
||||
gtk_css_node_set_parent (gtk_widget_get_css_node (GTK_WIDGET (window)), NULL);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (window), window_props[PROP_ATTACHED_TO]);
|
||||
}
|
||||
@ -6491,12 +6491,12 @@ gtk_window_state_flags_changed (GtkWidget *widget,
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_window_style_updated (GtkWidget *widget)
|
||||
gtk_window_css_changed (GtkWidget *widget,
|
||||
GtkCssStyleChange *change)
|
||||
{
|
||||
GtkCssStyleChange *change = gtk_style_context_get_change (gtk_widget_get_style_context (widget));
|
||||
GtkWindow *window = GTK_WINDOW (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_window_parent_class)->style_updated (widget);
|
||||
GTK_WIDGET_CLASS (gtk_window_parent_class)->css_changed (widget, change);
|
||||
|
||||
if (!_gtk_widget_get_alloc_needed (widget) &&
|
||||
(change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR)))
|
||||
|
@ -75,7 +75,6 @@
|
||||
<property name="fixed-height-mode">1</property>
|
||||
<signal name="cursor-changed" handler="cursor_changed_cb" swapped="no"/>
|
||||
<signal name="row-activated" handler="row_activated_cb" swapped="no"/>
|
||||
<signal name="style-updated" handler="gtk_font_chooser_widget_set_cell_size" object="GtkFontChooserWidget" after="yes" swapped="yes"/>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection" id="treeview-selection1">
|
||||
<property name="mode">browse</property>
|
||||
|
@ -406,6 +406,8 @@ test_data = [
|
||||
'radial.ref.css',
|
||||
'selector.css',
|
||||
'selector.ref.css',
|
||||
'selector-original.css',
|
||||
'selector-original.ref.css',
|
||||
'shadow.css',
|
||||
'shadow.ref.css',
|
||||
'shadow-ordering.css',
|
||||
|
39
testsuite/css/parser/selector-original.css
Normal file
39
testsuite/css/parser/selector-original.css
Normal file
@ -0,0 +1,39 @@
|
||||
* {}
|
||||
E {}
|
||||
E F {}
|
||||
E > F {}
|
||||
E + F {}
|
||||
E#id {}
|
||||
#id {}
|
||||
tab:first-child {}
|
||||
tab:last-child {}
|
||||
tab:first-child {}
|
||||
tab:last-child {}
|
||||
tab:nth-child(even) {}
|
||||
tab:nth-child(odd) {}
|
||||
.some-class {}
|
||||
.some-class.another-class {}
|
||||
.some-class .another-class {}
|
||||
E * {}
|
||||
E .class {}
|
||||
E > .foo {}
|
||||
E > #id {}
|
||||
E:active {}
|
||||
E:hover {}
|
||||
E:selected {}
|
||||
E:disabled {}
|
||||
E:indeterminate {}
|
||||
E:focus {}
|
||||
E:active:hover {}
|
||||
* > .notebook tab:first-child .label:focus {}
|
||||
E, F {}
|
||||
E, F /* comment here */ {}
|
||||
E,/* comment here */ F {}
|
||||
E1.e1_2 #T3_4 {}
|
||||
E:first-child {}
|
||||
E:last-child {}
|
||||
E:first-child {}
|
||||
E:last-child {}
|
||||
E:nth-child(even) {}
|
||||
E:nth-child(odd) {}
|
||||
E:focus tab {}
|
0
testsuite/css/parser/selector-original.ref.css
Normal file
0
testsuite/css/parser/selector-original.ref.css
Normal file
@ -54,7 +54,6 @@ tests = [
|
||||
['slicelistmodel'],
|
||||
['sortlistmodel'],
|
||||
['spinbutton'],
|
||||
['stylecontext'],
|
||||
['templates'],
|
||||
['textbuffer'],
|
||||
['textiter'],
|
||||
|
@ -1,132 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
typedef struct {
|
||||
GtkStyleContext *context;
|
||||
GtkCssProvider *blue_provider;
|
||||
GtkCssProvider *red_provider;
|
||||
GtkCssProvider *green_provider;
|
||||
} PrioritiesFixture;
|
||||
|
||||
static void
|
||||
test_parse_selectors (void)
|
||||
{
|
||||
GtkCssProvider *provider;
|
||||
gint i;
|
||||
const gchar *valid[] = {
|
||||
"* {}",
|
||||
"E {}",
|
||||
"E F {}",
|
||||
"E > F {}",
|
||||
"E + F {}",
|
||||
"E#id {}",
|
||||
"#id {}",
|
||||
"tab:first-child {}",
|
||||
"tab:last-child {}",
|
||||
"tab:first-child {}",
|
||||
"tab:last-child {}",
|
||||
"tab:nth-child(even) {}",
|
||||
"tab:nth-child(odd) {}",
|
||||
".some-class {}",
|
||||
".some-class.another-class {}",
|
||||
".some-class .another-class {}",
|
||||
"E * {}",
|
||||
"E .class {}",
|
||||
"E > .foo {}",
|
||||
"E > #id {}",
|
||||
"E:active {}",
|
||||
"E:hover {}",
|
||||
"E:selected {}",
|
||||
"E:disabled {}",
|
||||
"E:indeterminate {}",
|
||||
"E:focus {}",
|
||||
"E:active:hover {}",
|
||||
"* > .notebook tab:first-child .label:focus {}",
|
||||
"E, F {}",
|
||||
"E, F /* comment here */ {}",
|
||||
"E,/* comment here */ F {}",
|
||||
"E1.e1_2 #T3_4 {}",
|
||||
"E:first-child {}",
|
||||
"E:last-child {}",
|
||||
"E:first-child {}",
|
||||
"E:last-child {}",
|
||||
"E:nth-child(even) {}",
|
||||
"E:nth-child(odd) {}",
|
||||
"E:focus tab {}",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (i = 0; valid[i]; i++)
|
||||
{
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, valid[i], -1);
|
||||
|
||||
g_object_unref (provider);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_widget_path_parent (void)
|
||||
{
|
||||
GtkStyleContext *parent, *context;
|
||||
|
||||
parent = gtk_style_context_new ();
|
||||
context = gtk_style_context_new ();
|
||||
|
||||
gtk_style_context_set_parent (context, parent);
|
||||
|
||||
g_object_unref (parent);
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static void
|
||||
test_style_classes (void)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GList *classes;
|
||||
|
||||
context = gtk_style_context_new ();
|
||||
|
||||
classes = gtk_style_context_list_classes (context);
|
||||
g_assert_null (classes);
|
||||
|
||||
gtk_style_context_add_class (context, "A");
|
||||
|
||||
classes = gtk_style_context_list_classes (context);
|
||||
g_assert (classes);
|
||||
g_assert_null (classes->next);
|
||||
g_assert_cmpstr (classes->data, ==, "A");
|
||||
g_list_free (classes);
|
||||
|
||||
gtk_style_context_add_class (context, "B");
|
||||
|
||||
classes = gtk_style_context_list_classes (context);
|
||||
g_assert (classes);
|
||||
g_assert_cmpstr (classes->data, ==, "A");
|
||||
g_assert (classes->next);
|
||||
g_assert_cmpstr (classes->next->data, ==, "B");
|
||||
g_assert_null (classes->next->next);
|
||||
g_list_free (classes);
|
||||
|
||||
gtk_style_context_remove_class (context, "A");
|
||||
|
||||
classes = gtk_style_context_list_classes (context);
|
||||
g_assert (classes);
|
||||
g_assert_null (classes->next);
|
||||
g_assert_cmpstr (classes->data, ==, "B");
|
||||
g_list_free (classes);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gtk_init ();
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/style/parse/selectors", test_parse_selectors);
|
||||
g_test_add_func ("/style/widget-path-parent", test_widget_path_parent);
|
||||
g_test_add_func ("/style/classes", test_style_classes);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user