Compare commits

...

16 Commits

Author SHA1 Message Date
Benjamin Otte
07392c4d96 css: Rename GTK_CSS_CHANGE_SOURCE to GTK_CSS_CHANGE_STYLE_SHEET
Because that's what it's for after the introduction of
GTK_CSS_CHANGE_ROOT: Tracking changes to the style sheet(s).
2020-02-18 15:26:09 +01:00
Benjamin Otte
8a7119c2ec stylecontext: Make stylesheet APIs take StyleSheet objects
It's the only type of GtkStyleProvider we have left.

Also, drop the priority argument, use the StyleSheet's priority instead.
2020-02-18 15:26:09 +01:00
Benjamin Otte
b5e21cd2a6 cssstylesheet: Add a priority property
This one is going to replace properties used when adding style
providers.
2020-02-18 15:26:09 +01:00
Benjamin Otte
af62ce371d cssstylesheet: Move struct into .c file
... and remove the private struct.
2020-02-18 15:26:09 +01:00
Benjamin Otte
04b21191c2 css: Rename GtkCssPprovider to GtkCssStyleSheet
Reasons:
- less confusing for people new to GTK
- same name as used in HTML/JS
- I want to add more API from HTML/JS
2020-02-18 15:26:08 +01:00
Benjamin Otte
f81fce05c8 css: Track the scale factor via the root
As a side effect, we don't need to track the scale factor in
GtkStyleContext anymore, so remove that code, too.
2020-02-18 15:25:52 +01:00
Benjamin Otte
cdbc80ed6a css: Get the GtkSettings from the root
... instead of providing it via the style provider.

As a side effect, GtkSettings no longer needs to implement
GtkStyleProvider.
2020-02-18 15:25:52 +01:00
Benjamin Otte
bd6dad80d5 cssnode: Don't invalidate the parent changes unless necessary
If old_parent == new_parent, GTK_CSS_CHANGE_ANY_PARENT doesn't need to
be emitted.
2020-02-18 15:25:52 +01:00
Benjamin Otte
00df57d29b css: Introduce GTK_CSS_CHANGE_ROOT
This is meant for any change triggered by the root, such as default
values, icontheme or scale factor.

So far it is only triggered by reparenting a CSS node and it's
managed the same way as GTK_CSS_CHANGE_SOURCE.
2020-02-18 15:25:52 +01:00
Benjamin Otte
e16b84d6c8 cssnode: Have GtkRoots be a root widget
Nodes are declared as roots on creation when they are owned by a
GtkRoot. All other nodes aren't roots.

When getting the root for a node, we walk the parents until we find a
root node and then return its widget.

This also means that nodes of unrooted widgets will not report a root
widget.
2020-02-18 15:25:52 +01:00
Benjamin Otte
3b23cfa8fb cssvalue: Pass a "root" widget to compute()
This widget is meant to be the GtkRoot that manages the display and
settings that provide default and viewport-relevant values for the CSS
engine (like scale factor, icon theme or all the stuff we might ever
expose for @media).

For now, this is just the plumbing. We always pass %NULL.
2020-02-18 15:25:52 +01:00
Benjamin Otte
252234f55f testgtk: Use global css provider 2020-02-18 15:25:50 +01:00
Benjamin Otte
927c2919c4 tests: Use per-screen CSS providers 2020-02-18 15:25:28 +01:00
Benjamin Otte
45d83f7123 gtk-demo: Modernize accordion demo 2020-02-18 15:25:28 +01:00
Benjamin Otte
6aa48240ce fontbutton: Use attributes for custom font
Don't try to use CSS.
2020-02-18 14:39:53 +01:00
Benjamin Otte
8179aaa5ac widget: Changing the scale does no longer require a redraw
It doesn't require one generally anyway, because only the root can
change scale and when that happens the root will queue a redraw.

But even if the root doesn't queue a redraw, render nodes (the only
thing discarded by queue_draw()) are scale-independant.
2020-02-18 14:39:53 +01:00
131 changed files with 1514 additions and 1775 deletions

View File

@@ -52,7 +52,7 @@ constraint_editor_application_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
G_APPLICATION_CLASS (constraint_editor_application_parent_class)->startup (app);
@@ -62,11 +62,9 @@ constraint_editor_application_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "app.quit", quit_accels);
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/gtk4/constraint-editor/constraint-editor.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_resource (stylesheet, "/org/gtk/gtk4/constraint-editor/constraint-editor.css");
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
}
static void

View File

@@ -7,11 +7,10 @@
#include <gtk/gtk.h>
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
destroy_provider (GtkWidget *window,
GtkCssStyleSheet *stylesheet)
{
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
gtk_style_context_remove_style_sheet_for_display (gtk_widget_get_display (window), stylesheet);
}
GtkWidget *
@@ -21,8 +20,8 @@ do_css_accordion (GtkWidget *do_widget)
if (!window)
{
GtkWidget *container, *child;
GtkStyleProvider *provider;
GtkWidget *container, *styled_box, *child;
GtkCssStyleSheet *stylesheet;
window = gtk_window_new ();
gtk_window_set_title (GTK_WINDOW (window), "CSS Accordion");
@@ -30,11 +29,14 @@ do_css_accordion (GtkWidget *do_widget)
gtk_window_set_default_size (GTK_WINDOW (window), 600, 300);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
styled_box = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (window), styled_box);
gtk_widget_add_css_class (styled_box, "accordion");
container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_halign (container, GTK_ALIGN_CENTER);
gtk_widget_set_valign (container, GTK_ALIGN_CENTER);
gtk_container_add (GTK_CONTAINER (window), container);
gtk_container_add (GTK_CONTAINER (styled_box), container);
child = gtk_button_new_with_label ("This");
gtk_container_add (GTK_CONTAINER (container), child);
@@ -54,10 +56,14 @@ do_css_accordion (GtkWidget *do_widget)
child = gtk_button_new_with_label (":-)");
gtk_container_add (GTK_CONTAINER (container), child);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
gtk_css_provider_load_from_resource (GTK_CSS_PROVIDER (provider), "/css_accordion/css_accordion.css");
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_resource (stylesheet, "/css_accordion/css_accordion.css");
apply_css (window, provider);
gtk_style_context_add_style_sheet_for_display (gtk_widget_get_display (window), stylesheet);
g_signal_connect (window, "destroy",
G_CALLBACK (destroy_provider), stylesheet);
g_object_unref (stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -1,13 +1,13 @@
@import url("resource://css_accordion/reset.css");
.accordion, .accordion * {
all: unset;
* {
transition-property: color, background-color, border-color, background-image, padding, border-width;
transition-duration: 1s;
font: 20px Cantarell;
}
window {
.accordion {
background: linear-gradient(153deg, #151515, #151515 5px, transparent 5px) 0 0,
linear-gradient(333deg, #151515, #151515 5px, transparent 5px) 10px 5px,
linear-gradient(153deg, #222, #222 5px, transparent 5px) 0 5px,
@@ -18,7 +18,7 @@ window {
background-size: 20px 20px;
}
button {
.accordion button {
color: black;
background-color: #bbb;
border-style: solid;
@@ -28,25 +28,25 @@ button {
padding: 12px 4px;
}
button:first-child {
.accordion button:first-child {
border-radius: 5px 0 0 5px;
}
button:last-child {
.accordion button:last-child {
border-radius: 0 5px 5px 0;
border-width: 2px;
}
button:hover {
.accordion button:hover {
padding: 12px 48px;
background-color: #4870bc;
}
button *:hover {
.accordion button *:hover {
color: white;
}
button:hover:active,
button:active {
.accordion button:hover:active,
.accordion button:active {
background-color: #993401;
}

View File

@@ -8,7 +8,7 @@
#include <gtk/gtk.h>
static void
show_parsing_error (GtkCssProvider *provider,
show_parsing_error (GtkCssStyleSheet *stylesheet,
GtkCssSection *section,
const GError *error,
GtkTextBuffer *buffer)
@@ -38,7 +38,7 @@ show_parsing_error (GtkCssProvider *provider,
static void
css_text_changed (GtkTextBuffer *buffer,
GtkCssProvider *provider)
GtkCssStyleSheet *stylesheet)
{
GtkTextIter start, end;
char *text;
@@ -48,16 +48,16 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_style_sheet_load_from_data (stylesheet, text, -1);
g_free (text);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
apply_css (GtkWidget *widget, GtkCssStyleSheet *stylesheet)
{
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
gtk_style_context_add_style_sheet (gtk_widget_get_style_context (widget), stylesheet);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, stylesheet);
}
GtkWidget *
@@ -68,7 +68,7 @@ do_css_basics (GtkWidget *do_widget)
if (!window)
{
GtkWidget *container, *child;
GtkStyleProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkTextBuffer *text;
GBytes *bytes;
@@ -89,25 +89,26 @@ do_css_basics (GtkWidget *do_widget)
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, G_MAXUINT);
container = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (window), container);
child = gtk_text_view_new_with_buffer (text);
gtk_container_add (GTK_CONTAINER (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);
G_CALLBACK (css_text_changed), stylesheet);
bytes = g_resources_lookup_data ("/css_basics/css_basics.css", 0, NULL);
gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
g_bytes_unref (bytes);
g_signal_connect (provider,
g_signal_connect (stylesheet,
"parsing-error",
G_CALLBACK (show_parsing_error),
gtk_text_view_get_buffer (GTK_TEXT_VIEW (child)));
apply_css (window, provider);
apply_css (window, stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -37,7 +37,7 @@ struct {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
static void
update_css_for_blend_mode (GtkCssProvider *provider,
update_css_for_blend_mode (GtkCssStyleSheet *stylesheet,
const gchar *blend_mode)
{
GBytes *bytes;
@@ -50,7 +50,7 @@ update_css_for_blend_mode (GtkCssProvider *provider,
blend_mode,
blend_mode);
gtk_css_provider_load_from_data (provider, css, -1);
gtk_css_style_sheet_load_from_data (stylesheet, css, -1);
g_bytes_unref (bytes);
g_free (css);
@@ -58,20 +58,20 @@ update_css_for_blend_mode (GtkCssProvider *provider,
#pragma GCC diagnostic pop
static void
row_activated (GtkListBox *listbox,
GtkListBoxRow *row,
GtkCssProvider *provider)
row_activated (GtkListBox *listbox,
GtkListBoxRow *row,
GtkCssStyleSheet *stylesheet)
{
const gchar *blend_mode;
blend_mode = blend_modes[gtk_list_box_row_get_index (row)].id;
update_css_for_blend_mode (provider, blend_mode);
update_css_for_blend_mode (stylesheet, blend_mode);
}
static void
setup_listbox (GtkBuilder *builder,
GtkStyleProvider *provider)
GtkCssStyleSheet *stylesheet)
{
GtkWidget *normal_row;
GtkWidget *listbox;
@@ -81,7 +81,7 @@ setup_listbox (GtkBuilder *builder,
listbox = gtk_list_box_new ();
gtk_container_add (GTK_CONTAINER (WID ("scrolledwindow")), listbox);
g_signal_connect (listbox, "row-activated", G_CALLBACK (row_activated), provider);
g_signal_connect (listbox, "row-activated", G_CALLBACK (row_activated), stylesheet);
/* Add a row for each blend mode available */
for (i = 0; blend_modes[i].name != NULL; i++)
@@ -118,7 +118,7 @@ do_css_blendmodes (GtkWidget *do_widget)
if (!window)
{
GtkStyleProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkBuilder *builder;
builder = gtk_builder_new_from_resource ("/css_blendmodes/blendmodes.ui");
@@ -127,14 +127,12 @@ do_css_blendmodes (GtkWidget *do_widget)
gtk_window_set_transient_for (GTK_WINDOW (window), GTK_WINDOW (do_widget));
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
/* Setup the CSS provider for window */
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
/* Setup the CSS stylesheet for window */
stylesheet = gtk_css_style_sheet_new ();
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
provider,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
setup_listbox (builder, provider);
setup_listbox (builder, stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -8,7 +8,7 @@
#include <gtk/gtk.h>
static void
show_parsing_error (GtkCssProvider *provider,
show_parsing_error (GtkCssStyleSheet *stylesheet,
GtkCssSection *section,
const GError *error,
GtkTextBuffer *buffer)
@@ -39,7 +39,7 @@ show_parsing_error (GtkCssProvider *provider,
static void
css_text_changed (GtkTextBuffer *buffer,
GtkCssProvider *provider)
GtkCssStyleSheet *stylesheet)
{
GtkTextIter start, end;
char *text;
@@ -49,7 +49,7 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_style_sheet_load_from_data (stylesheet, text, -1);
g_free (text);
}
@@ -67,11 +67,11 @@ drawing_area_draw (GtkDrawingArea *da,
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
apply_css (GtkWidget *widget, GtkCssStyleSheet *stylesheet)
{
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
gtk_style_context_add_style_sheet (gtk_widget_get_style_context (widget), stylesheet);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, stylesheet);
}
GtkWidget *
@@ -82,7 +82,7 @@ do_css_multiplebgs (GtkWidget *do_widget)
if (!window)
{
GtkWidget *paned, *container, *child;
GtkStyleProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkTextBuffer *text;
GBytes *bytes;
@@ -127,7 +127,8 @@ do_css_multiplebgs (GtkWidget *do_widget)
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, G_MAXUINT);
container = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (paned), container);
@@ -136,18 +137,18 @@ do_css_multiplebgs (GtkWidget *do_widget)
g_signal_connect (text,
"changed",
G_CALLBACK (css_text_changed),
provider);
stylesheet);
bytes = g_resources_lookup_data ("/css_multiplebgs/css_multiplebgs.css", 0, NULL);
gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
g_bytes_unref (bytes);
g_signal_connect (provider,
g_signal_connect (stylesheet,
"parsing-error",
G_CALLBACK (show_parsing_error),
gtk_text_view_get_buffer (GTK_TEXT_VIEW (child)));
apply_css (window, provider);
apply_css (window, stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -7,7 +7,7 @@
#include <gtk/gtk.h>
static void
show_parsing_error (GtkCssProvider *provider,
show_parsing_error (GtkCssStyleSheet *stylesheet,
GtkCssSection *section,
const GError *error,
GtkTextBuffer *buffer)
@@ -38,7 +38,7 @@ show_parsing_error (GtkCssProvider *provider,
static void
css_text_changed (GtkTextBuffer *buffer,
GtkCssProvider *provider)
GtkCssStyleSheet *stylesheet)
{
GtkTextIter start, end;
char *text;
@@ -48,16 +48,16 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_style_sheet_load_from_data (stylesheet, text, -1);
g_free (text);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
apply_css (GtkWidget *widget, GtkCssStyleSheet *stylesheet)
{
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
gtk_style_context_add_style_sheet (gtk_widget_get_style_context (widget), stylesheet);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, stylesheet);
}
GtkWidget *
@@ -68,7 +68,7 @@ do_css_pixbufs (GtkWidget *do_widget)
if (!window)
{
GtkWidget *paned, *container, *child;
GtkStyleProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkTextBuffer *text;
GBytes *bytes;
@@ -96,25 +96,26 @@ do_css_pixbufs (GtkWidget *do_widget)
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, G_MAXUINT);
container = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (paned), container);
child = gtk_text_view_new_with_buffer (text);
gtk_container_add (GTK_CONTAINER (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);
G_CALLBACK (css_text_changed), stylesheet);
bytes = g_resources_lookup_data ("/css_pixbufs/gtk.css", 0, NULL);
gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
g_bytes_unref (bytes);
g_signal_connect (provider,
g_signal_connect (stylesheet,
"parsing-error",
G_CALLBACK (show_parsing_error),
gtk_text_view_get_buffer (GTK_TEXT_VIEW (child)));
apply_css (window, provider);
apply_css (window, stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -6,7 +6,7 @@
#include <gtk/gtk.h>
static void
show_parsing_error (GtkCssProvider *provider,
show_parsing_error (GtkCssStyleSheet *stylesheet,
GtkCssSection *section,
const GError *error,
GtkTextBuffer *buffer)
@@ -36,7 +36,7 @@ show_parsing_error (GtkCssProvider *provider,
static void
css_text_changed (GtkTextBuffer *buffer,
GtkCssProvider *provider)
GtkCssStyleSheet *stylesheet)
{
GtkTextIter start, end;
char *text;
@@ -46,16 +46,16 @@ css_text_changed (GtkTextBuffer *buffer,
gtk_text_buffer_remove_all_tags (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
gtk_css_provider_load_from_data (provider, text, -1);
gtk_css_style_sheet_load_from_data (stylesheet, text, -1);
g_free (text);
}
static void
apply_css (GtkWidget *widget, GtkStyleProvider *provider)
apply_css (GtkWidget *widget, GtkCssStyleSheet *stylesheet)
{
gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
gtk_style_context_add_style_sheet (gtk_widget_get_style_context (widget), stylesheet);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, stylesheet);
}
GtkWidget *
@@ -87,7 +87,7 @@ do_css_shadows (GtkWidget *do_widget)
if (!window)
{
GtkWidget *paned, *container, *child;
GtkStyleProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkTextBuffer *text;
GBytes *bytes;
@@ -114,25 +114,26 @@ do_css_shadows (GtkWidget *do_widget)
"underline", PANGO_UNDERLINE_ERROR,
NULL);
provider = GTK_STYLE_PROVIDER (gtk_css_provider_new ());
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, G_MAXUINT);
container = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (paned), container);
child = gtk_text_view_new_with_buffer (text);
gtk_container_add (GTK_CONTAINER (container), child);
g_signal_connect (text, "changed",
G_CALLBACK (css_text_changed), provider);
G_CALLBACK (css_text_changed), stylesheet);
bytes = g_resources_lookup_data ("/css_shadows/gtk.css", 0, NULL);
gtk_text_buffer_set_text (text, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes));
g_bytes_unref (bytes);
g_signal_connect (provider,
g_signal_connect (stylesheet,
"parsing-error",
G_CALLBACK (show_parsing_error),
gtk_text_view_get_buffer (GTK_TEXT_VIEW (child)));
apply_css (window, provider);
apply_css (window, stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -14,7 +14,6 @@
</gresource>
<gresource prefix="/css_accordion">
<file>css_accordion.css</file>
<file>reset.css</file>
</gresource>
<gresource prefix="/css_basics">
<file>css_basics.css</file>

View File

@@ -263,7 +263,7 @@ static void
demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
{
GtkGesture *gesture;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
tag->box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_parent (tag->box, GTK_WIDGET (tag));
@@ -274,12 +274,11 @@ demo_tagged_entry_tag_init (DemoTaggedEntryTag *tag)
g_signal_connect (gesture, "released", G_CALLBACK (on_released), tag);
gtk_widget_add_controller (GTK_WIDGET (tag), GTK_EVENT_CONTROLLER (gesture));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/tagged_entry/tagstyle.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, 800);
gtk_css_style_sheet_load_from_resource (stylesheet, "/tagged_entry/tagstyle.css");
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
g_object_unref (stylesheet);
}
static void

View File

@@ -354,7 +354,7 @@ do_dnd (GtkWidget *do_widget)
{
GtkWidget *vbox, *fixed;
GtkGesture *multipress;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
@@ -378,11 +378,10 @@ do_dnd (GtkWidget *do_widget)
g_signal_connect (multipress, "released", G_CALLBACK (released_cb), NULL);
gtk_widget_add_controller (fixed, GTK_EVENT_CONTROLLER (multipress));
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/dnd/dnd.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, 800);
gtk_css_style_sheet_load_from_resource (stylesheet, "/dnd/dnd.css");
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
}
if (!gtk_widget_get_visible (window))

View File

@@ -271,15 +271,13 @@ GtkWidget *
do_fishbowl (GtkWidget *do_widget)
{
static GtkWidget *window = NULL;
static GtkCssProvider *provider = NULL;
static GtkCssStyleSheet *stylesheet = NULL;
if (provider == NULL)
if (stylesheet == NULL)
{
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_data (stylesheet, css, -1);
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
}
if (!window)

View File

@@ -103,7 +103,7 @@ create_faces (void)
}
static GtkWidget *demo_window = NULL;
static GtkCssProvider *provider = NULL;
static GtkCssStyleSheet *stylesheet = NULL;
static void
close_window (GtkWidget *widget)
@@ -112,9 +112,8 @@ close_window (GtkWidget *widget)
for (int i = 0; i < N_FACES; i++)
faces[i].face = NULL;
gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider));
provider = NULL;
gtk_style_context_remove_style_sheet_for_display (gdk_display_get_default (), stylesheet);
stylesheet = NULL;
demo_window = NULL;
}
@@ -142,12 +141,11 @@ create_demo_window (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (fixed), cube);
gtk_widget_set_overflow (fixed, GTK_OVERFLOW_VISIBLE);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/fixed/fixed.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, 800);
gtk_css_style_sheet_load_from_resource (stylesheet, "/fixed/fixed.css");
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
g_object_unref (stylesheet);
return window;
}

View File

@@ -68,7 +68,7 @@ node_editor_application_startup (GApplication *app)
{
const char *quit_accels[2] = { "<Ctrl>Q", NULL };
const char *open_accels[2] = { "<Ctrl>O", NULL };
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
G_APPLICATION_CLASS (node_editor_application_parent_class)->startup (app);
@@ -79,11 +79,9 @@ node_editor_application_startup (GApplication *app)
gtk_application_set_accels_for_action (GTK_APPLICATION (app), "win.open", open_accels);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_data (stylesheet, css, -1);
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
}
static void

View File

@@ -1653,7 +1653,7 @@ activate (GApplication *app)
GtkWidget *stack;
GtkWidget *dialog;
GtkAdjustment *adj;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
GMenuModel *model;
static GActionEntry win_entries[] = {
{ "dark", NULL, NULL, "false", change_theme_state },
@@ -1690,12 +1690,10 @@ activate (GApplication *app)
g_type_ensure (my_text_view_get_type ());
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/WidgetFactory4/widget-factory.css");
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_resource (stylesheet, "/org/gtk/WidgetFactory4/widget-factory.css");
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
g_object_unref (stylesheet);
builder = gtk_builder_new ();
scope = gtk_builder_cscope_new ();

View File

@@ -365,7 +365,7 @@
<xi:include href="css-overview.xml" />
<xi:include href="css-properties.xml" />
<xi:include href="xml/gtkstylecontext.xml" />
<xi:include href="xml/gtkcssprovider.xml" />
<xi:include href="xml/gtkcssstylesheet.xml" />
<xi:include href="xml/gtkstyleprovider.xml" />
<xi:include href="xml/gtkicontheme.xml" />
</part>

View File

@@ -4570,8 +4570,8 @@ GTK_STYLE_CLASS_WARNING
GTK_STYLE_CLASS_WIDE
<SUBSECTION>
GtkStyleContext
gtk_style_context_add_provider
gtk_style_context_add_provider_for_display
gtk_style_context_add_style_sheet
gtk_style_context_add_style_sheet_for_display
gtk_style_context_get_display
gtk_style_context_get_state
gtk_style_context_get_color
@@ -4579,8 +4579,8 @@ gtk_style_context_get_border
gtk_style_context_get_padding
gtk_style_context_get_margin
gtk_style_context_lookup_color
gtk_style_context_remove_provider
gtk_style_context_remove_provider_for_display
gtk_style_context_remove_style_sheet
gtk_style_context_remove_style_sheet_for_display
gtk_style_context_reset_widgets
gtk_style_context_restore
gtk_style_context_save
@@ -4591,8 +4591,6 @@ gtk_style_context_has_class
gtk_style_context_list_classes
gtk_style_context_set_display
gtk_style_context_set_state
gtk_style_context_set_scale
gtk_style_context_get_scale
GtkStyleContextPrintFlags
gtk_style_context_to_string
@@ -4633,16 +4631,18 @@ gtk_border_get_type
</SECTION>
<SECTION>
<FILE>gtkcssprovider</FILE>
<TITLE>GtkCssProvider</TITLE>
GtkCssProvider
gtk_css_provider_load_named
gtk_css_provider_load_from_data
gtk_css_provider_load_from_file
gtk_css_provider_load_from_path
gtk_css_provider_load_from_resource
gtk_css_provider_new
gtk_css_provider_to_string
<FILE>gtkcssstylesheet</FILE>
<TITLE>GtkCssStyleSheet</TITLE>
GtkCssStyleSheet
gtk_css_style_sheet_load_named
gtk_css_style_sheet_load_from_data
gtk_css_style_sheet_load_from_file
gtk_css_style_sheet_load_from_path
gtk_css_style_sheet_load_from_resource
gtk_css_style_sheet_new
gtk_css_style_sheet_set_priority
gtk_css_style_sheet_get_priority
gtk_css_style_sheet_to_string
GTK_CSS_PARSER_ERROR
GtkCssParserError
GtkCssParserWarning
@@ -4659,17 +4659,15 @@ gtk_css_section_get_parent
gtk_css_section_get_start_location
gtk_css_section_get_end_location
<SUBSECTION Standard>
GTK_TYPE_CSS_PROVIDER
GTK_CSS_PROVIDER
GTK_CSS_PROVIDER_CLASS
GTK_CSS_PROVIDER_GET_CLASS
GTK_IS_CSS_PROVIDER
GTK_IS_CSS_PROVIDER_CLASS
GTK_TYPE_CSS_STYLE_SHEET
GTK_CSS_STYLE_SHEET
GTK_CSS_STYLE_SHEET_CLASS
GTK_CSS_STYLE_SHEET_GET_CLASS
GTK_IS_CSS_STYLE_SHEET
GTK_IS_CSS_STYLE_SHEET_CLASS
<SUBSECTION Private>
GTK_TYPE_CSS_SECTION
GtkCssProviderPrivate
gtk_css_provider_get_type
gtk_css_provider_error_quark
gtk_css_style_sheet_get_type
gtk_css_section_get_type
</SECTION>

View File

@@ -74,7 +74,7 @@ private_headers = [
'gtkcssparserprivate.h',
'gtkcsspathnodeprivate.h',
'gtkcsspositionvalueprivate.h',
'gtkcssproviderprivate.h',
'gtkcssstylesheetprivate.h',
'gtkcssrepeatvalueprivate.h',
'gtkcssrgbavalueprivate.h',
'gtkcsssectionprivate.h',

View File

@@ -645,7 +645,7 @@ How do I change the color of a widget?
The background color of a widget is determined by the CSS style that applies
to it. To change that, you can set style classes on the widget, and provide
custom CSS to change the appearance. Such CSS can be loaded with
gtk_css_provider_load_from_file() and its variants. See gtk_style_context_add_provider().
gtk_css_provider_load_from_file() and its variants. See gtk_style_context_add_style_sheet().
</para></answer>
</qandaentry>
@@ -672,7 +672,7 @@ You can also change the font of a widget by putting
}
</programlisting>
in a CSS file, loading it with gtk_css_provider_load_from_file(), and
adding the provider with gtk_style_context_add_provider_for_display().
adding the provider with gtk_style_context_add_style_sheet_for_display().
To associate this style information with your widget, set a style class
on its #GtkStyleContext using gtk_style_context_add_class().
The advantage of this approach is that users can then override the font

View File

@@ -170,7 +170,7 @@ foreground color &mdash; use CSS to override their default values.
PangoFontDescription *font_desc;
GdkRGBA rgba;
GtkTextTag *tag;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkStyleContext *context;
view = gtk_text_view_new (<!-- -->);
@@ -180,16 +180,16 @@ foreground color &mdash; use CSS to override their default values.
gtk_text_buffer_set_text (buffer, "Hello, this is some text", -1);
/* Change default font and color throughout the widget */
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_data (stylesheet,
"textview {"
" font: 15 serif;"
" color: green;"
"}",
-1);
context = gtk_widget_get_style_context (view);
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (provider),
gtk_style_context_add_style_sheet (context,
GTK_STYLE_PROVIDER (stylesheet),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
/* Change left margin throughout the widget */

View File

@@ -203,7 +203,7 @@ plugin_action (GAction *action,
{
const char *action_name;
const char *css_to_load;
GtkCssProvider *css_provider;
GtkCssStyleSheet *stylesheet;
action_name = g_action_get_name (action);
if (strcmp (action_name, "red") == 0)
@@ -218,11 +218,10 @@ plugin_action (GAction *action,
g_message ("Color: %s", g_action_get_name (action));
css_provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (css_provider, css_to_load, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_data (stylesheet, css_to_load, -1);
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
g_object_unref (stylesheet);
}
static void

View File

@@ -60,7 +60,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserDialog, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkComboBox, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkComboBoxText, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCssProvider, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkCssStyleSheet, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkDrawingArea, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEditable, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkEntry, g_object_unref)

View File

@@ -86,7 +86,7 @@
#include <gtk/gtkconstraintlayout.h>
#include <gtk/gtkconstraint.h>
#include <gtk/gtkcontainer.h>
#include <gtk/gtkcssprovider.h>
#include <gtk/gtkcssstylesheet.h>
#include <gtk/gtkcustomlayout.h>
#include <gtk/gtkdebug.h>
#include <gtk/gtkdialog.h>

View File

@@ -765,6 +765,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animation_names;
@@ -813,7 +814,7 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
if (keyframes == NULL)
continue;
keyframes = _gtk_css_keyframes_compute (keyframes, provider, base_style, parent_style);
keyframes = gtk_css_keyframes_compute (keyframes, provider, root, base_style, parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
@@ -857,6 +858,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *previous_style)
{
GtkCssAnimatedStyle *result;
@@ -874,7 +876,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
if (previous_style != NULL)
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, previous_style);
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, root, previous_style);
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
if (animations == NULL)

View File

@@ -56,6 +56,7 @@ GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle
GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *previous_style);
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
GtkCssStyle *base,

View File

@@ -46,6 +46,7 @@ static GtkCssValue *
gtk_css_value_array_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -56,7 +57,7 @@ gtk_css_value_array_compute (GtkCssValue *value,
result = NULL;
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
i_value = gtk_css_value_compute (value->values[i], property_id, provider, root, style, parent_style);
if (result == NULL &&
i_value != value->values[i])

View File

@@ -44,6 +44,7 @@ static GtkCssValue *
gtk_css_value_bg_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -55,10 +56,10 @@ gtk_css_value_bg_size_compute (GtkCssValue *value,
x = y = NULL;
if (value->x)
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
x = gtk_css_value_compute (value->x, property_id, provider, root, style, parent_style);
if (value->y)
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
y = gtk_css_value_compute (value->y, property_id, provider, root, style, parent_style);
if (x == value->x && y == value->y)
{

View File

@@ -45,6 +45,7 @@ static GtkCssValue *
gtk_css_value_border_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -57,7 +58,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
{
if (value->values[i])
{
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
values[i] = gtk_css_value_compute (value->values[i], property_id, provider, root, style, parent_style);
changed |= (values[i] != value->values[i]);
}
else

View File

@@ -101,6 +101,7 @@ static GtkCssValue *
gtk_css_value_calc_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -112,7 +113,7 @@ gtk_css_value_calc_compute (GtkCssValue *value,
array = g_ptr_array_new ();
for (i = 0; i < value->n_terms; i++)
{
GtkCssValue *computed = _gtk_css_value_compute (value->terms[i], property_id, provider, style, parent_style);
GtkCssValue *computed = gtk_css_value_compute (value->terms[i], property_id, provider, root, style, parent_style);
changed |= computed != value->terms[i];
gtk_css_calc_array_add (array, computed);
}

View File

@@ -94,6 +94,7 @@ gtk_css_value_color_free (GtkCssValue *color)
static GtkCssValue *
gtk_css_value_color_get_fallback (guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -114,11 +115,12 @@ gtk_css_value_color_get_fallback (guint property_id,
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
case GTK_CSS_PROPERTY_CARET_COLOR:
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
root,
style,
parent_style);
case GTK_CSS_PROPERTY_ICON_PALETTE:
return _gtk_css_value_ref (style->core->color);
default:
@@ -133,6 +135,7 @@ static GtkCssValue *
gtk_css_value_color_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -151,10 +154,11 @@ gtk_css_value_color_compute (GtkCssValue *value,
else
current = NULL;
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
NULL);
resolved = gtk_css_color_value_resolve (value,
provider,
root,
current,
NULL);
}
else if (value->type == COLOR_TYPE_LITERAL)
{
@@ -164,14 +168,15 @@ gtk_css_value_color_compute (GtkCssValue *value,
{
GtkCssValue *current = style->core->color;
resolved = _gtk_css_color_value_resolve (value,
provider,
current,
NULL);
resolved = gtk_css_color_value_resolve (value,
provider,
root,
current,
NULL);
}
if (resolved == NULL)
return gtk_css_value_color_get_fallback (property_id, provider, style, parent_style);
return gtk_css_value_color_get_fallback (property_id, provider, root, style, parent_style);
return resolved;
}
@@ -346,10 +351,11 @@ apply_mix (const GdkRGBA *in1,
}
GtkCssValue *
_gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list)
gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssValue *current,
GSList *cycle_list)
{
GtkCssValue *value;
@@ -373,7 +379,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
if (named == NULL)
return NULL;
value = _gtk_css_color_value_resolve (named, provider, current, &cycle);
value = gtk_css_color_value_resolve (named, provider, root, current, &cycle);
if (value == NULL)
return NULL;
}
@@ -385,7 +391,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA shade;
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
val = gtk_css_color_value_resolve (color->sym_col.shade.color, provider, root, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
@@ -403,7 +409,7 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val;
GdkRGBA alpha;
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
val = gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, root, current, cycle_list);
if (val == NULL)
return NULL;
c = gtk_css_color_value_get_rgba (val);
@@ -421,12 +427,12 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue *val1, *val2;
GdkRGBA res;
val1 = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
val1 = gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, root, current, cycle_list);
if (val1 == NULL)
return NULL;
color1 = gtk_css_color_value_get_rgba (val1);
val2 = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
val2 = gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, root, current, cycle_list);
if (val2 == NULL)
return NULL;
color2 = gtk_css_color_value_get_rgba (val2);
@@ -450,10 +456,11 @@ _gtk_css_color_value_resolve (GtkCssValue *color,
if (initial->class == &GTK_CSS_VALUE_COLOR)
{
return _gtk_css_color_value_resolve (initial,
provider,
NULL,
cycle_list);
return gtk_css_color_value_resolve (initial,
provider,
root,
NULL,
cycle_list);
}
else
{

View File

@@ -40,8 +40,9 @@ GtkCssValue * _gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssValue *current,
GSList *cycle_list);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;

View File

@@ -40,13 +40,14 @@ static GtkCssValue *
gtk_css_value_corner_compute (GtkCssValue *corner,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style);
x = gtk_css_value_compute (corner->x, property_id, provider, root, style, parent_style);
y = gtk_css_value_compute (corner->y, property_id, provider, root, style, parent_style);
if (x == corner->x && y == corner->y)
{
_gtk_css_value_unref (x);

View File

@@ -37,17 +37,17 @@ gtk_css_value_dimension_free (GtkCssValue *value)
}
static double
get_base_font_size_px (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
get_base_font_size_px (guint property_id,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
if (parent_style)
return _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
return gtk_css_font_size_get_default_px (provider, style);
return gtk_css_font_size_get_default_px (root, style);
}
return _gtk_css_number_value_get (style->core->font_size, 100);
@@ -63,6 +63,7 @@ static GtkCssValue *
gtk_css_value_dimension_compute (GtkCssValue *number,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -75,7 +76,7 @@ gtk_css_value_dimension_compute (GtkCssValue *number,
/* percentages for font sizes are computed, other percentages aren't */
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
return gtk_css_dimension_value_new (number->value / 100.0 *
get_base_font_size_px (property_id, provider, style, parent_style),
get_base_font_size_px (property_id, root, style, parent_style),
GTK_CSS_PX);
G_GNUC_FALLTHROUGH;
case GTK_CSS_NUMBER:
@@ -100,16 +101,16 @@ gtk_css_value_dimension_compute (GtkCssValue *number,
GTK_CSS_PX);
case GTK_CSS_EM:
return gtk_css_dimension_value_new (number->value *
get_base_font_size_px (property_id, provider, style, parent_style),
get_base_font_size_px (property_id, root, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
return gtk_css_dimension_value_new (number->value * 0.5 *
get_base_font_size_px (property_id, provider, style, parent_style),
get_base_font_size_px (property_id, root, style, parent_style),
GTK_CSS_PX);
case GTK_CSS_REM:
return gtk_css_dimension_value_new (number->value *
gtk_css_font_size_get_default_px (provider, style),
gtk_css_font_size_get_default_px (root, style),
GTK_CSS_PX);
case GTK_CSS_RAD:
return gtk_css_dimension_value_new (number->value * 360.0 / (2 * G_PI),

View File

@@ -53,6 +53,7 @@ static GtkCssValue *
gtk_css_value_ease_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -19,10 +19,10 @@
#include "gtkcssenumvalueprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtksettingsprivate.h"
#include "gtkwidget.h"
#ifdef _MSC_VER
# include <intrin.h>
@@ -46,6 +46,7 @@ static GtkCssValue *
gtk_css_value_enum_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -211,16 +212,16 @@ get_dpi (GtkCssStyle *style)
#define DEFAULT_FONT_SIZE_PT 10
double
gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
GtkCssStyle *style)
gtk_css_font_size_get_default_px (GtkWidget *root,
GtkCssStyle *style)
{
GtkSettings *settings;
int font_size;
settings = gtk_style_provider_get_settings (provider);
if (settings == NULL)
if (root == NULL)
return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
settings = gtk_widget_get_settings (root);
font_size = gtk_settings_get_font_size (settings);
if (font_size == 0)
return DEFAULT_FONT_SIZE_PT * get_dpi (style) / 72.0;
@@ -234,6 +235,7 @@ static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -242,34 +244,34 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
switch (value->value)
{
case GTK_CSS_FONT_SIZE_XX_SMALL:
font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 5;
font_size = gtk_css_font_size_get_default_px (root, style) * 3. / 5;
break;
case GTK_CSS_FONT_SIZE_X_SMALL:
font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 4;
font_size = gtk_css_font_size_get_default_px (root, style) * 3. / 4;
break;
case GTK_CSS_FONT_SIZE_SMALL:
font_size = gtk_css_font_size_get_default_px (provider, style) * 8. / 9;
font_size = gtk_css_font_size_get_default_px (root, style) * 8. / 9;
break;
default:
g_assert_not_reached ();
/* fall thru */
case GTK_CSS_FONT_SIZE_MEDIUM:
font_size = gtk_css_font_size_get_default_px (provider, style);
font_size = gtk_css_font_size_get_default_px (root, style);
break;
case GTK_CSS_FONT_SIZE_LARGE:
font_size = gtk_css_font_size_get_default_px (provider, style) * 6. / 5;
font_size = gtk_css_font_size_get_default_px (root, style) * 6. / 5;
break;
case GTK_CSS_FONT_SIZE_X_LARGE:
font_size = gtk_css_font_size_get_default_px (provider, style) * 3. / 2;
font_size = gtk_css_font_size_get_default_px (root, style) * 3. / 2;
break;
case GTK_CSS_FONT_SIZE_XX_LARGE:
font_size = gtk_css_font_size_get_default_px (provider, style) * 2;
font_size = gtk_css_font_size_get_default_px (root, style) * 2;
break;
case GTK_CSS_FONT_SIZE_SMALLER:
if (parent_style)
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
font_size = gtk_css_font_size_get_default_px (provider, style);
font_size = gtk_css_font_size_get_default_px (root, style);
/* XXX: This is what WebKit does... */
font_size /= 1.2;
break;
@@ -277,7 +279,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
if (parent_style)
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
else
font_size = gtk_css_font_size_get_default_px (provider, style);
font_size = gtk_css_font_size_get_default_px (root, style);
/* XXX: This is what WebKit does... */
font_size *= 1.2;
break;
@@ -401,6 +403,7 @@ static GtkCssValue *
gtk_css_value_font_weight_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -38,7 +38,7 @@ GtkBorderStyle _gtk_css_border_style_value_get (const GtkCssValue *value)
GtkCssValue * _gtk_css_font_size_value_new (GtkCssFontSize size);
GtkCssValue * _gtk_css_font_size_value_try_parse (GtkCssParser *parser);
GtkCssFontSize _gtk_css_font_size_value_get (const GtkCssValue *value);
double gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
double gtk_css_font_size_get_default_px (GtkWidget *root,
GtkCssStyle *style);
GtkCssValue * _gtk_css_font_style_value_new (PangoStyle style);

View File

@@ -304,6 +304,7 @@ gtk_css_filter_compute (GtkCssFilter *dest,
GtkCssFilter *src,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -312,39 +313,39 @@ gtk_css_filter_compute (GtkCssFilter *dest,
switch (src->type)
{
case GTK_CSS_FILTER_BRIGHTNESS:
dest->brightness.value = _gtk_css_value_compute (src->brightness.value, property_id, provider, style, parent_style);
dest->brightness.value = gtk_css_value_compute (src->brightness.value, property_id, provider, root, style, parent_style);
return dest->brightness.value == src->brightness.value;
case GTK_CSS_FILTER_CONTRAST:
dest->contrast.value = _gtk_css_value_compute (src->contrast.value, property_id, provider, style, parent_style);
dest->contrast.value = gtk_css_value_compute (src->contrast.value, property_id, provider, root, style, parent_style);
return dest->contrast.value == src->contrast.value;
case GTK_CSS_FILTER_GRAYSCALE:
dest->grayscale.value = _gtk_css_value_compute (src->grayscale.value, property_id, provider, style, parent_style);
dest->grayscale.value = gtk_css_value_compute (src->grayscale.value, property_id, provider, root, style, parent_style);
return dest->grayscale.value == src->grayscale.value;
case GTK_CSS_FILTER_HUE_ROTATE:
dest->hue_rotate.value = _gtk_css_value_compute (src->hue_rotate.value, property_id, provider, style, parent_style);
dest->hue_rotate.value = gtk_css_value_compute (src->hue_rotate.value, property_id, provider, root, style, parent_style);
return dest->hue_rotate.value == src->hue_rotate.value;
case GTK_CSS_FILTER_INVERT:
dest->invert.value = _gtk_css_value_compute (src->invert.value, property_id, provider, style, parent_style);
dest->invert.value = gtk_css_value_compute (src->invert.value, property_id, provider, root, style, parent_style);
return dest->invert.value == src->invert.value;
case GTK_CSS_FILTER_OPACITY:
dest->opacity.value = _gtk_css_value_compute (src->opacity.value, property_id, provider, style, parent_style);
dest->opacity.value = gtk_css_value_compute (src->opacity.value, property_id, provider, root, style, parent_style);
return dest->opacity.value == src->opacity.value;
case GTK_CSS_FILTER_SATURATE:
dest->saturate.value = _gtk_css_value_compute (src->saturate.value, property_id, provider, style, parent_style);
dest->saturate.value = gtk_css_value_compute (src->saturate.value, property_id, provider, root, style, parent_style);
return dest->saturate.value == src->saturate.value;
case GTK_CSS_FILTER_SEPIA:
dest->sepia.value = _gtk_css_value_compute (src->sepia.value, property_id, provider, style, parent_style);
dest->sepia.value = gtk_css_value_compute (src->sepia.value, property_id, provider, root, style, parent_style);
return dest->sepia.value == src->sepia.value;
case GTK_CSS_FILTER_BLUR:
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style);
dest->blur.value = gtk_css_value_compute (src->blur.value, property_id, provider, root, style, parent_style);
return dest->blur.value == src->blur.value;
case GTK_CSS_FILTER_NONE:
@@ -359,6 +360,7 @@ static GtkCssValue *
gtk_css_value_filter_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -379,6 +381,7 @@ gtk_css_value_filter_compute (GtkCssValue *value,
&value->filters[i],
property_id,
provider,
root,
style,
parent_style);
}

View File

@@ -54,6 +54,7 @@ static GtkCssValue *
gtk_css_value_font_features_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -53,6 +53,7 @@ static GtkCssValue *
gtk_css_value_font_variations_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -20,9 +20,10 @@
#include "gtkcssiconthemevalueprivate.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
#include "gtksettingsprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkintl.h"
#include "gtkwidget.h"
/*
* The idea behind this value (and the '-gtk-icon-theme' CSS property) is
@@ -74,15 +75,22 @@ static GtkCssValue *
gtk_css_value_icon_theme_compute (GtkCssValue *icon_theme,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkIconTheme *icontheme;
GdkDisplay *display;
if (root)
display = gtk_widget_get_display (root);
else
display = gdk_display_get_default ();
if (icon_theme->icontheme)
icontheme = icon_theme->icontheme;
else
icontheme = gtk_icon_theme_get_for_display (_gtk_settings_get_display (gtk_style_provider_get_settings (provider)));
icontheme = gtk_icon_theme_get_for_display (display);
return gtk_css_icon_theme_value_new (icontheme);
}

View File

@@ -67,6 +67,7 @@ static GtkCssImage *
gtk_css_image_real_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -172,11 +173,12 @@ _gtk_css_image_get_aspect_ratio (GtkCssImage *image)
}
GtkCssImage *
_gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssImageClass *klass;
@@ -186,7 +188,7 @@ _gtk_css_image_compute (GtkCssImage *image,
klass = GTK_CSS_IMAGE_GET_CLASS (image);
return klass->compute (image, property_id, provider, style, parent_style);
return klass->compute (image, property_id, provider, root, style, parent_style);
}
GtkCssImage *

View File

@@ -382,6 +382,7 @@ static GtkCssImage *
gtk_css_image_cross_fade_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -398,7 +399,7 @@ gtk_css_image_cross_fade_compute (GtkCssImage *image,
gtk_css_image_cross_fade_add (result,
entry->has_progress,
entry->progress,
_gtk_css_image_compute (entry->image, property_id, provider, style, parent_style));
gtk_css_image_compute (entry->image, property_id, provider, root, style, parent_style));
}
return GTK_CSS_IMAGE (result);

View File

@@ -136,6 +136,7 @@ static GtkCssImage *
gtk_css_image_fallback_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -148,11 +149,12 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
GtkCssValue *computed_color = NULL;
if (fallback->color)
computed_color= _gtk_css_value_compute (fallback->color,
property_id,
provider,
style,
parent_style);
computed_color= gtk_css_value_compute (fallback->color,
property_id,
provider,
root,
style,
parent_style);
/* image($color) that didn't change */
if (computed_color && !fallback->images &&
@@ -164,11 +166,12 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
copy->images = g_new (GtkCssImage *, fallback->n_images);
for (i = 0; i < fallback->n_images; i++)
{
copy->images[i] = _gtk_css_image_compute (fallback->images[i],
property_id,
provider,
style,
parent_style);
copy->images[i] = gtk_css_image_compute (fallback->images[i],
property_id,
provider,
root,
style,
parent_style);
if (gtk_css_image_is_invalid (copy->images[i]))
continue;

View File

@@ -23,11 +23,11 @@
#include <math.h>
#include "gtkiconthemeprivate.h"
#include "gtkcssiconthemevalueprivate.h"
#include "gtksettingsprivate.h"
#include "gtksnapshot.h"
#include "gtkstyleproviderprivate.h"
#include "gtkiconthemeprivate.h"
#include "gtkwidget.h"
G_DEFINE_TYPE (GtkCssImageIconTheme, _gtk_css_image_icon_theme, GTK_TYPE_CSS_IMAGE)
@@ -141,6 +141,7 @@ static GtkCssImage *
gtk_css_image_icon_theme_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -150,7 +151,7 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
copy->name = g_strdup (icon_theme->name);
copy->icon_theme = gtk_css_icon_theme_value_get_icon_theme (style->core->icon_theme);
copy->scale = gtk_style_provider_get_scale (provider);
copy->scale = root ? gtk_widget_get_scale_factor (root) : 1;
gtk_icon_theme_lookup_symbolic_colors (style, &copy->color, &copy->success, &copy->warning, &copy->error);
return GTK_CSS_IMAGE (copy);

View File

@@ -26,7 +26,7 @@
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
G_DEFINE_TYPE (GtkCssImageLinear, _gtk_css_image_linear, GTK_TYPE_CSS_IMAGE)
@@ -491,6 +491,7 @@ static GtkCssImage *
gtk_css_image_linear_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -503,7 +504,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
copy->side = linear->side;
if (linear->angle)
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style);
copy->angle = gtk_css_value_compute (linear->angle, property_id, provider, root, style, parent_style);
copy->n_stops = linear->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageLinearColorStop) * copy->n_stops);
@@ -512,11 +513,11 @@ gtk_css_image_linear_compute (GtkCssImage *image,
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
GtkCssImageLinearColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
scopy->color = gtk_css_value_compute (stop->color, property_id, provider, root, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
scopy->offset = gtk_css_value_compute (stop->offset, property_id, provider, root, style, parent_style);
}
else
{

View File

@@ -99,6 +99,7 @@ static GtkCssImage *
gtk_css_image_paintable_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -60,6 +60,7 @@ struct _GtkCssImageClass
GtkCssImage *(* compute) (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style);
/* compare two images for equality */
@@ -101,9 +102,10 @@ int _gtk_css_image_get_width (GtkCssImage *
int _gtk_css_image_get_height (GtkCssImage *image) G_GNUC_PURE;
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
GtkCssImage * gtk_css_image_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style);
gboolean _gtk_css_image_equal (GtkCssImage *image1,

View File

@@ -27,7 +27,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcsspositionvalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
G_DEFINE_TYPE (GtkCssImageRadial, _gtk_css_image_radial, GTK_TYPE_CSS_IMAGE)
@@ -507,6 +507,7 @@ static GtkCssImage *
gtk_css_image_radial_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -519,13 +520,13 @@ gtk_css_image_radial_compute (GtkCssImage *image,
copy->circle = radial->circle;
copy->size = radial->size;
copy->position = _gtk_css_value_compute (radial->position, property_id, provider, style, parent_style);
copy->position = gtk_css_value_compute (radial->position, property_id, provider, root, style, parent_style);
if (radial->sizes[0])
copy->sizes[0] = _gtk_css_value_compute (radial->sizes[0], property_id, provider, style, parent_style);
copy->sizes[0] = gtk_css_value_compute (radial->sizes[0], property_id, provider, root, style, parent_style);
if (radial->sizes[1])
copy->sizes[1] = _gtk_css_value_compute (radial->sizes[1], property_id, provider, style, parent_style);
copy->sizes[1] = gtk_css_value_compute (radial->sizes[1], property_id, provider, root, style, parent_style);
copy->n_stops = radial->n_stops;
copy->color_stops = g_malloc (sizeof (GtkCssImageRadialColorStop) * copy->n_stops);
@@ -534,11 +535,11 @@ gtk_css_image_radial_compute (GtkCssImage *image,
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
GtkCssImageRadialColorStop *scopy = &copy->color_stops[i];
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
scopy->color = gtk_css_value_compute (stop->color, property_id, provider, root, style, parent_style);
if (stop->offset)
{
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
scopy->offset = gtk_css_value_compute (stop->offset, property_id, provider, root, style, parent_style);
}
else
{

View File

@@ -20,13 +20,14 @@
#include "config.h"
#include "gtkcssimagerecolorprivate.h"
#include "gtkcssimageprivate.h"
#include "gtkcsspalettevalueprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkiconthemeprivate.h"
#include "gdkpixbufutilsprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkwidget.h"
G_DEFINE_TYPE (GtkCssImageRecolor, _gtk_css_image_recolor, GTK_TYPE_CSS_IMAGE)
@@ -204,6 +205,7 @@ static GtkCssImage *
gtk_css_image_recolor_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -213,10 +215,13 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
int scale;
GError *error = NULL;
scale = gtk_style_provider_get_scale (provider);
if (root)
scale = gtk_widget_get_scale_factor (root);
else
scale = 1;
if (recolor->palette)
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style);
palette = gtk_css_value_compute (recolor->palette, property_id, provider, root, style, parent_style);
else
palette = _gtk_css_value_ref (style->core->icon_palette);

View File

@@ -21,7 +21,7 @@
#include "gtkcssimagescaledprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkwidget.h"
G_DEFINE_TYPE (GtkCssImageScaled, _gtk_css_image_scaled, GTK_TYPE_CSS_IMAGE)
@@ -100,6 +100,7 @@ static GtkCssImage *
gtk_css_image_scaled_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -109,8 +110,10 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
int i;
int best;
scale = gtk_style_provider_get_scale (provider);
scale = MAX(scale, 1);
if (root)
scale = gtk_widget_get_scale_factor (root);
else
scale = 1;
best = 0;
for (i = 0; i < scaled->n_images; i++)
@@ -133,11 +136,12 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
res->images = g_new (GtkCssImage *, 1);
res->scales = g_new (int, 1);
res->images[0] = _gtk_css_image_compute (scaled->images[best],
property_id,
provider,
style,
parent_style);
res->images[0] = gtk_css_image_compute (scaled->images[best],
property_id,
provider,
root,
style,
parent_style);
res->scales[0] = scaled->scales[best];
return GTK_CSS_IMAGE (res);

View File

@@ -125,6 +125,7 @@ static GtkCssImage *
gtk_css_image_url_compute (GtkCssImage *image,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_image_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -47,7 +48,7 @@ gtk_css_value_image_compute (GtkCssValue *value,
if (image == NULL)
return _gtk_css_value_ref (value);
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);
computed = gtk_css_image_compute (image, property_id, provider, root, style, parent_style);
if (computed == image)
{

View File

@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_inherit_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -46,11 +47,12 @@ gtk_css_value_inherit_compute (GtkCssValue *value,
}
else
{
return _gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (_gtk_css_initial_value_get (),
property_id,
provider,
root,
style,
parent_style);
}
}

View File

@@ -24,7 +24,7 @@
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkwidget.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
@@ -41,6 +41,7 @@ static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -49,7 +50,10 @@ gtk_css_value_initial_compute (GtkCssValue *value,
switch (property_id)
{
case GTK_CSS_PROPERTY_DPI:
settings = gtk_style_provider_get_settings (provider);
if (root)
settings = gtk_widget_get_settings (root);
else
settings = gtk_settings_get_for_display (gdk_display_get_default ());
if (settings)
{
int dpi_int;
@@ -62,7 +66,10 @@ gtk_css_value_initial_compute (GtkCssValue *value,
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = gtk_style_provider_get_settings (provider);
if (root)
settings = gtk_widget_get_settings (root);
else
settings = gtk_settings_get_for_display (gdk_display_get_default ());
if (settings && gtk_settings_get_font_family (settings) != NULL)
return _gtk_css_string_value_new (gtk_settings_get_font_family (settings));
break;
@@ -71,11 +78,12 @@ gtk_css_value_initial_compute (GtkCssValue *value,
break;
}
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
root,
style,
parent_style);
}
static gboolean
@@ -125,15 +133,18 @@ _gtk_css_initial_value_get (void)
{
return &initial;
}
GtkCssValue *
_gtk_css_initial_value_new_compute (guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_initial_value_new_compute (guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
return gtk_css_value_initial_compute (NULL,
property_id,
provider,
root,
style,
parent_style);
}

View File

@@ -26,8 +26,9 @@ G_BEGIN_DECLS
GtkCssValue * _gtk_css_initial_value_new (void);
GtkCssValue * _gtk_css_initial_value_get (void);
GtkCssValue * _gtk_css_initial_value_new_compute (guint property_id,
GtkCssValue * gtk_css_initial_value_new_compute (guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style);

View File

@@ -426,10 +426,11 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
}
GtkCssKeyframes *
_gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssKeyframes *resolved;
guint k, p;
@@ -453,11 +454,12 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
if (KEYFRAMES_VALUE (keyframes, k, p) == NULL)
continue;
KEYFRAMES_VALUE (resolved, k, p) = _gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
resolved->property_ids[p],
provider,
style,
parent_style);
KEYFRAMES_VALUE (resolved, k, p) = gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
resolved->property_ids[p],
provider,
root,
style,
parent_style);
}
}

View File

@@ -36,10 +36,11 @@ void _gtk_css_keyframes_unref (GtkCssKeyframes
void _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
GString *string);
GtkCssKeyframes * _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssKeyframes * gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes) G_GNUC_PURE;
guint _gtk_css_keyframes_get_property_id (GtkCssKeyframes *keyframes,

View File

@@ -89,7 +89,7 @@
* if we need to change things. */
#define GTK_CSS_RADICAL_CHANGE (GTK_CSS_CHANGE_ID | GTK_CSS_CHANGE_NAME | GTK_CSS_CHANGE_CLASS | \
GTK_CSS_CHANGE_PARENT_ID | GTK_CSS_CHANGE_PARENT_NAME | GTK_CSS_CHANGE_PARENT_CLASS | \
GTK_CSS_CHANGE_SOURCE | GTK_CSS_CHANGE_PARENT_STYLE)
GTK_CSS_CHANGE_STYLE_SHEET | GTK_CSS_CHANGE_ROOT | GTK_CSS_CHANGE_PARENT_STYLE)
/* When these change, we need to recompute the change flags for the new style
* since they may have changed.
@@ -437,6 +437,7 @@ gtk_css_node_real_update_style (GtkCssNode *cssnode,
parent ? gtk_css_node_get_style (parent) : NULL,
timestamp,
gtk_css_node_get_style_provider (cssnode),
gtk_css_node_get_root (cssnode),
should_create_transitions (change) ? style : NULL);
/* Clear the cache again, the static style we looked up above
@@ -716,6 +717,7 @@ gtk_css_node_reposition (GtkCssNode *node,
GtkCssNode *old_parent;
g_assert (! (new_parent == NULL && previous != NULL));
g_assert (!node->is_root);
old_parent = node->parent;
/* Take a reference here so the whole function has a reference */
@@ -752,7 +754,10 @@ gtk_css_node_reposition (GtkCssNode *node,
if (gtk_css_node_get_style_provider_or_null (node) == NULL)
gtk_css_node_invalidate_style_provider (node);
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_TIMESTAMP | GTK_CSS_CHANGE_ANIMATIONS);
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_PARENT
| GTK_CSS_CHANGE_ROOT
| GTK_CSS_CHANGE_TIMESTAMP
| GTK_CSS_CHANGE_ANIMATIONS);
if (new_parent)
{
@@ -796,8 +801,7 @@ gtk_css_node_reposition (GtkCssNode *node,
gtk_css_node_invalidate_style (node->next_sibling);
}
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_PARENT
| GTK_CSS_CHANGE_ANY_SIBLING
gtk_css_node_invalidate (node, GTK_CSS_CHANGE_ANY_SIBLING
| GTK_CSS_CHANGE_NTH_CHILD
| (node->previous_sibling ? 0 : GTK_CSS_CHANGE_FIRST_CHILD)
| (node->next_sibling ? 0 : GTK_CSS_CHANGE_LAST_CHILD));
@@ -1239,7 +1243,7 @@ gtk_css_node_invalidate_style_provider (GtkCssNode *cssnode)
{
GtkCssNode *child;
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_SOURCE);
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_STYLE_SHEET);
for (child = cssnode->first_child;
child;
@@ -1374,7 +1378,20 @@ gtk_css_node_get_style_provider (GtkCssNode *cssnode)
if (cssnode->parent)
return gtk_css_node_get_style_provider (cssnode->parent);
return GTK_STYLE_PROVIDER (_gtk_settings_get_style_cascade (gtk_settings_get_default (), 1));
return GTK_STYLE_PROVIDER (gtk_settings_get_style_cascade (gtk_settings_get_default ()));
}
GtkWidget *
gtk_css_node_get_root (GtkCssNode *self)
{
while (!self->is_root)
{
self = self->parent;
if (self == NULL)
return NULL;
}
return GTK_CSS_NODE_GET_CLASS (self)->get_root (self);
}
void

View File

@@ -53,6 +53,7 @@ struct _GtkCssNode
GtkCssChange pending_changes; /* changes that accumulated since the style was last computed */
guint is_root :1; /* node is the root of a CSS tree and never has parents */
guint visible :1; /* node will be skipped when validating or computing styles */
guint invalid :1; /* node or a child needs to be validated (even if just for animation) */
guint needs_propagation :1; /* children have state changes that need to be propagated to their siblings */
@@ -79,6 +80,8 @@ struct _GtkCssNodeClass
/* get style provider to use or NULL to use parent's */
GtkStyleProvider * (* get_style_provider) (GtkCssNode *cssnode);
/* get the root widget for this node - will only be called if cssnode->is_root == TRUE */
GtkWidget * (* get_root) (GtkCssNode *cssnode);
/* get frame clock or NULL (only relevant for root node) */
GdkFrameClock * (* get_frame_clock) (GtkCssNode *cssnode);
GtkCssStyle * (* update_style) (GtkCssNode *cssnode,
@@ -150,12 +153,13 @@ void gtk_css_node_invalidate (GtkCssNode *
GtkCssChange change);
void gtk_css_node_validate (GtkCssNode *cssnode);
GtkStyleProvider * gtk_css_node_get_style_provider (GtkCssNode *cssnode) G_GNUC_PURE;
GtkStyleProvider * gtk_css_node_get_style_provider (GtkCssNode *cssnode) G_GNUC_PURE;
GtkWidget * gtk_css_node_get_root (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_print (GtkCssNode *cssnode,
GtkStyleContextPrintFlags flags,
GString *string,
guint indent);
void gtk_css_node_print (GtkCssNode *cssnode,
GtkStyleContextPrintFlags flags,
GString *string,
guint indent);
G_END_DECLS

View File

@@ -108,6 +108,7 @@ static GtkCssValue *
gtk_css_value_palette_compute (GtkCssValue *specified,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -122,7 +123,7 @@ gtk_css_value_palette_compute (GtkCssValue *specified,
{
GtkCssValue *value = specified->color_values[i];
computed_color = _gtk_css_value_compute (value, property_id, provider, style, parent_style);
computed_color = gtk_css_value_compute (value, property_id, provider, root, style, parent_style);
result->color_names[i] = g_strdup (specified->color_names[i]);
result->color_values[i] = computed_color;

View File

@@ -18,7 +18,7 @@
#ifndef __GTK_CSS_PARSER_PRIVATE_H__
#define __GTK_CSS_PARSER_PRIVATE_H__
#include <gtk/gtkcssprovider.h>
#include <gtk/gtkcssstylesheet.h>
#include <gtk/css/gtkcss.h>
#include "gtk/css/gtkcsstokenizerprivate.h"

View File

@@ -40,13 +40,14 @@ static GtkCssValue *
gtk_css_value_position_compute (GtkCssValue *position,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
GtkCssValue *x, *y;
x = _gtk_css_value_compute (position->x, property_id, provider, style, parent_style);
y = _gtk_css_value_compute (position->y, property_id, provider, style, parent_style);
x = gtk_css_value_compute (position->x, property_id, provider, root, style, parent_style);
y = gtk_css_value_compute (position->y, property_id, provider, root, style, parent_style);
if (x == position->x && y == position->y)
{
_gtk_css_value_unref (x);

View File

@@ -1,71 +0,0 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_PROVIDER_H__
#define __GTK_CSS_PROVIDER_H__
#include <gio/gio.h>
#include <gtk/css/gtkcss.h>
G_BEGIN_DECLS
#define GTK_TYPE_CSS_PROVIDER (gtk_css_provider_get_type ())
#define GTK_CSS_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_CSS_PROVIDER, GtkCssProvider))
#define GTK_IS_CSS_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_CSS_PROVIDER))
typedef struct _GtkCssProvider GtkCssProvider;
typedef struct _GtkCssProviderClass GtkCssProviderClass;
typedef struct _GtkCssProviderPrivate GtkCssProviderPrivate;
struct _GtkCssProvider
{
GObject parent_instance;
};
GDK_AVAILABLE_IN_ALL
GType gtk_css_provider_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkCssProvider * gtk_css_provider_new (void);
GDK_AVAILABLE_IN_ALL
char * gtk_css_provider_to_string (GtkCssProvider *provider);
GDK_AVAILABLE_IN_ALL
void gtk_css_provider_load_from_data (GtkCssProvider *css_provider,
const gchar *data,
gssize length);
GDK_AVAILABLE_IN_ALL
void gtk_css_provider_load_from_file (GtkCssProvider *css_provider,
GFile *file);
GDK_AVAILABLE_IN_ALL
void gtk_css_provider_load_from_path (GtkCssProvider *css_provider,
const gchar *path);
GDK_AVAILABLE_IN_ALL
void gtk_css_provider_load_from_resource (GtkCssProvider *css_provider,
const gchar *resource_path);
GDK_AVAILABLE_IN_ALL
void gtk_css_provider_load_named (GtkCssProvider *provider,
const char *name,
const char *variant);
G_END_DECLS
#endif /* __GTK_CSS_PROVIDER_H__ */

View File

@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_repeat_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

View File

@@ -22,7 +22,7 @@
#include <stdlib.h>
#include <string.h>
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtkstylecontextprivate.h"
#include <errno.h>

View File

@@ -114,6 +114,7 @@ static GtkCssValue *
gtk_css_value_shadow_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -126,11 +127,11 @@ gtk_css_value_shadow_compute (GtkCssValue *value,
{
const ShadowValue *shadow = &value->shadows[i];
shadows[i].hoffset = _gtk_css_value_compute (shadow->hoffset, property_id, provider, style, parent_style);
shadows[i].voffset = _gtk_css_value_compute (shadow->voffset, property_id, provider, style, parent_style);
shadows[i].radius = _gtk_css_value_compute (shadow->radius, property_id, provider, style, parent_style);
shadows[i].spread = _gtk_css_value_compute (shadow->spread, property_id, provider, style, parent_style),
shadows[i].color = _gtk_css_value_compute (shadow->color, property_id, provider, style, parent_style);
shadows[i].hoffset = gtk_css_value_compute (shadow->hoffset, property_id, provider, root, style, parent_style);
shadows[i].voffset = gtk_css_value_compute (shadow->voffset, property_id, provider, root, style, parent_style);
shadows[i].radius = gtk_css_value_compute (shadow->radius, property_id, provider, root, style, parent_style);
shadows[i].spread = gtk_css_value_compute (shadow->spread, property_id, provider, root, style, parent_style),
shadows[i].color = gtk_css_value_compute (shadow->color, property_id, provider, root, style, parent_style);
shadows[i].inset = shadow->inset;
}

View File

@@ -41,6 +41,7 @@
static void gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
@@ -196,6 +197,7 @@ gtk_css_## NAME ## _values_compute_changes_and_affects (GtkCssStyle *style1, \
static inline void \
gtk_css_ ## NAME ## _values_new_compute (GtkCssStaticStyle *sstyle, \
GtkStyleProvider *provider, \
GtkWidget *root, \
GtkCssStyle *parent_style, \
GtkCssLookup *lookup) \
{ \
@@ -209,6 +211,7 @@ gtk_css_ ## NAME ## _values_new_compute (GtkCssStaticStyle *sstyle, \
guint id = NAME ## _props[i]; \
gtk_css_static_style_compute_value (sstyle, \
provider, \
root, \
parent_style, \
id, \
lookup->values[id].value, \
@@ -679,17 +682,11 @@ gtk_css_static_style_set_value (GtkCssStaticStyle *sstyle,
}
}
static GtkCssStyle *default_style;
static void
clear_default_style (gpointer data)
{
g_set_object (&default_style, NULL);
}
GtkCssStyle *
gtk_css_static_style_get_default (void)
{
static GtkCssStyle *default_style = NULL;
/* FIXME: This really depends on the screen, but we don't have
* a screen at hand when we call this function, and in practice,
* the default style is always replaced by something else
@@ -698,15 +695,14 @@ gtk_css_static_style_get_default (void)
if (default_style == NULL)
{
GtkCountingBloomFilter filter = GTK_COUNTING_BLOOM_FILTER_INIT;
GtkSettings *settings;
GtkCssStyleSheet *stylesheet;
settings = gtk_settings_get_default ();
default_style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER (settings),
stylesheet = gtk_css_style_sheet_new ();
default_style = gtk_css_static_style_new_compute (GTK_STYLE_PROVIDER (stylesheet),
&filter,
NULL,
0);
g_object_set_data_full (G_OBJECT (settings), I_("gtk-default-style"),
default_style, clear_default_style);
g_object_unref (stylesheet);
}
return default_style;
@@ -725,15 +721,15 @@ gtk_css_background_create_initial_values (void)
values = (GtkCssBackgroundValues *)gtk_css_values_new (GTK_CSS_BACKGROUND_INITIAL_VALUES);
values->background_color = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_COLOR, NULL, NULL, NULL);
values->box_shadow = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BOX_SHADOW, NULL, NULL, NULL);
values->background_clip = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_CLIP, NULL, NULL, NULL);
values->background_origin = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_ORIGIN, NULL, NULL, NULL);
values->background_size = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_SIZE, NULL, NULL, NULL);
values->background_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_POSITION, NULL, NULL, NULL);
values->background_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_REPEAT, NULL, NULL, NULL);
values->background_image = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_IMAGE, NULL, NULL, NULL);
values->background_blend_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE, NULL, NULL, NULL);
values->background_color = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_COLOR, NULL, NULL, NULL, NULL);
values->box_shadow = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BOX_SHADOW, NULL, NULL, NULL, NULL);
values->background_clip = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_CLIP, NULL, NULL, NULL, NULL);
values->background_origin = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_ORIGIN, NULL, NULL, NULL, NULL);
values->background_size = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_SIZE, NULL, NULL, NULL, NULL);
values->background_position = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_POSITION, NULL, NULL, NULL, NULL);
values->background_repeat = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_REPEAT, NULL, NULL, NULL, NULL);
values->background_image = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_IMAGE, NULL, NULL, NULL, NULL);
values->background_blend_mode = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BACKGROUND_BLEND_MODE, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -745,26 +741,26 @@ gtk_css_border_create_initial_values (void)
values = (GtkCssBorderValues *)gtk_css_values_new (GTK_CSS_BORDER_INITIAL_VALUES);
values->border_top_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, NULL, NULL, NULL);
values->border_top_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_WIDTH, NULL, NULL, NULL);
values->border_left_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE, NULL, NULL, NULL);
values->border_left_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH, NULL, NULL, NULL);
values->border_bottom_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE, NULL, NULL, NULL);
values->border_bottom_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH, NULL, NULL, NULL);
values->border_right_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE, NULL, NULL, NULL);
values->border_right_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH, NULL, NULL, NULL);
values->border_top_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, NULL, NULL, NULL);
values->border_top_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS, NULL, NULL, NULL);
values->border_bottom_left_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS, NULL, NULL, NULL);
values->border_bottom_right_radius = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS, NULL, NULL, NULL);
values->border_top_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_STYLE, NULL, NULL, NULL, NULL);
values->border_top_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_WIDTH, NULL, NULL, NULL, NULL);
values->border_left_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_STYLE, NULL, NULL, NULL, NULL);
values->border_left_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH, NULL, NULL, NULL, NULL);
values->border_bottom_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE, NULL, NULL, NULL, NULL);
values->border_bottom_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH, NULL, NULL, NULL, NULL);
values->border_right_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE, NULL, NULL, NULL, NULL);
values->border_right_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH, NULL, NULL, NULL, NULL);
values->border_top_left_radius = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS, NULL, NULL, NULL, NULL);
values->border_top_right_radius = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS, NULL, NULL, NULL, NULL);
values->border_bottom_left_radius = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS, NULL, NULL, NULL, NULL);
values->border_bottom_right_radius = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS, NULL, NULL, NULL, NULL);
values->border_top_color = NULL;
values->border_right_color = NULL;
values->border_bottom_color = NULL;
values->border_left_color = NULL;
values->border_image_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE, NULL, NULL, NULL);
values->border_image_repeat = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT, NULL, NULL, NULL);
values->border_image_slice = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE, NULL, NULL, NULL);
values->border_image_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH, NULL, NULL, NULL);
values->border_image_source = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE, NULL, NULL, NULL, NULL);
values->border_image_repeat = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT, NULL, NULL, NULL, NULL);
values->border_image_slice = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE, NULL, NULL, NULL, NULL);
values->border_image_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -776,9 +772,9 @@ gtk_css_outline_create_initial_values (void)
values = (GtkCssOutlineValues *)gtk_css_values_new (GTK_CSS_OUTLINE_INITIAL_VALUES);
values->outline_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, NULL, NULL, NULL);
values->outline_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, NULL, NULL, NULL);
values->outline_offset = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_OFFSET, NULL, NULL, NULL);
values->outline_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_STYLE, NULL, NULL, NULL, NULL);
values->outline_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_WIDTH, NULL, NULL, NULL, NULL);
values->outline_offset = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OUTLINE_OFFSET, NULL, NULL, NULL, NULL);
values->outline_color = NULL;
return (GtkCssValues *)values;
@@ -803,16 +799,16 @@ gtk_css_font_variant_create_initial_values (void)
values = (GtkCssFontVariantValues *)gtk_css_values_new (GTK_CSS_FONT_VARIANT_INITIAL_VALUES);
values->text_decoration_line = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, NULL, NULL, NULL);
values->text_decoration_line = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_LINE, NULL, NULL, NULL, NULL);
values->text_decoration_color = NULL;
values->text_decoration_style = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, NULL, NULL, NULL);
values->font_kerning = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_KERNING, NULL, NULL, NULL);
values->font_variant_ligatures = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES, NULL, NULL, NULL);
values->font_variant_position = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, NULL, NULL, NULL);
values->font_variant_caps = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_CAPS, NULL, NULL, NULL);
values->font_variant_numeric = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, NULL, NULL, NULL);
values->font_variant_alternates = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES, NULL, NULL, NULL);
values->font_variant_east_asian = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN, NULL, NULL, NULL);
values->text_decoration_style = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TEXT_DECORATION_STYLE, NULL, NULL, NULL, NULL);
values->font_kerning = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_KERNING, NULL, NULL, NULL, NULL);
values->font_variant_ligatures = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_LIGATURES, NULL, NULL, NULL, NULL);
values->font_variant_position = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_POSITION, NULL, NULL, NULL, NULL);
values->font_variant_caps = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_CAPS, NULL, NULL, NULL, NULL);
values->font_variant_numeric = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_NUMERIC, NULL, NULL, NULL, NULL);
values->font_variant_alternates = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_ALTERNATES, NULL, NULL, NULL, NULL);
values->font_variant_east_asian = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FONT_VARIANT_EAST_ASIAN, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -824,14 +820,14 @@ gtk_css_animation_create_initial_values (void)
values = (GtkCssAnimationValues *)gtk_css_values_new (GTK_CSS_ANIMATION_INITIAL_VALUES);
values->animation_name = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_NAME, NULL, NULL, NULL);
values->animation_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DURATION, NULL, NULL, NULL);
values->animation_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION, NULL, NULL, NULL);
values->animation_iteration_count = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT, NULL, NULL, NULL);
values->animation_direction = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DIRECTION, NULL, NULL, NULL);
values->animation_play_state = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE, NULL, NULL, NULL);
values->animation_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DELAY, NULL, NULL, NULL);
values->animation_fill_mode = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_FILL_MODE, NULL, NULL, NULL);
values->animation_name = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_NAME, NULL, NULL, NULL, NULL);
values->animation_duration = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DURATION, NULL, NULL, NULL, NULL);
values->animation_timing_function = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION, NULL, NULL, NULL, NULL);
values->animation_iteration_count = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT, NULL, NULL, NULL, NULL);
values->animation_direction = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DIRECTION, NULL, NULL, NULL, NULL);
values->animation_play_state = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE, NULL, NULL, NULL, NULL);
values->animation_delay = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_DELAY, NULL, NULL, NULL, NULL);
values->animation_fill_mode = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ANIMATION_FILL_MODE, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -843,10 +839,10 @@ gtk_css_transition_create_initial_values (void)
values = (GtkCssTransitionValues *)gtk_css_values_new (GTK_CSS_TRANSITION_INITIAL_VALUES);
values->transition_property = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_PROPERTY, NULL, NULL, NULL);
values->transition_duration = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DURATION, NULL, NULL, NULL);
values->transition_timing_function = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION, NULL, NULL, NULL);
values->transition_delay = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DELAY, NULL, NULL, NULL);
values->transition_property = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_PROPERTY, NULL, NULL, NULL, NULL);
values->transition_duration = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DURATION, NULL, NULL, NULL, NULL);
values->transition_timing_function = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION, NULL, NULL, NULL, NULL);
values->transition_delay = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSITION_DELAY, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -858,17 +854,17 @@ gtk_css_size_create_initial_values (void)
values = (GtkCssSizeValues *)gtk_css_values_new (GTK_CSS_SIZE_INITIAL_VALUES);
values->margin_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, NULL, NULL, NULL);
values->margin_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL);
values->margin_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, NULL, NULL, NULL);
values->margin_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_RIGHT, NULL, NULL, NULL);
values->padding_top = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_TOP, NULL, NULL, NULL);
values->padding_left = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, NULL, NULL, NULL);
values->padding_bottom = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, NULL, NULL, NULL);
values->padding_right = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_RIGHT, NULL, NULL, NULL);
values->border_spacing = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_SPACING, NULL, NULL, NULL);
values->min_width = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_WIDTH, NULL, NULL, NULL);
values->min_height = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_HEIGHT, NULL, NULL, NULL);
values->margin_top = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_TOP, NULL, NULL, NULL, NULL);
values->margin_left = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_LEFT, NULL, NULL, NULL, NULL);
values->margin_bottom = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_BOTTOM, NULL, NULL, NULL, NULL);
values->margin_right = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MARGIN_RIGHT, NULL, NULL, NULL, NULL);
values->padding_top = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_TOP, NULL, NULL, NULL, NULL);
values->padding_left = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_LEFT, NULL, NULL, NULL, NULL);
values->padding_bottom = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_BOTTOM, NULL, NULL, NULL, NULL);
values->padding_right = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_PADDING_RIGHT, NULL, NULL, NULL, NULL);
values->border_spacing = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_BORDER_SPACING, NULL, NULL, NULL, NULL);
values->min_width = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_WIDTH, NULL, NULL, NULL, NULL);
values->min_height = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_MIN_HEIGHT, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -880,12 +876,12 @@ gtk_css_other_create_initial_values (void)
values = (GtkCssOtherValues *)gtk_css_values_new (GTK_CSS_OTHER_INITIAL_VALUES);
values->icon_source = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_SOURCE, NULL, NULL, NULL);
values->icon_transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_TRANSFORM, NULL, NULL, NULL);
values->icon_filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_FILTER, NULL, NULL, NULL);
values->transform = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM, NULL, NULL, NULL);
values->opacity = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OPACITY, NULL, NULL, NULL);
values->filter = _gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FILTER, NULL, NULL, NULL);
values->icon_source = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_SOURCE, NULL, NULL, NULL, NULL);
values->icon_transform = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_TRANSFORM, NULL, NULL, NULL, NULL);
values->icon_filter = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_ICON_FILTER, NULL, NULL, NULL, NULL);
values->transform = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_TRANSFORM, NULL, NULL, NULL, NULL);
values->opacity = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_OPACITY, NULL, NULL, NULL, NULL);
values->filter = gtk_css_initial_value_new_compute (GTK_CSS_PROPERTY_FILTER, NULL, NULL, NULL, NULL);
return (GtkCssValues *)values;
}
@@ -893,6 +889,7 @@ gtk_css_other_create_initial_values (void)
static void
gtk_css_lookup_resolve (GtkCssLookup *lookup,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStaticStyle *sstyle,
GtkCssStyle *parent_style)
{
@@ -922,9 +919,9 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
}
else
{
gtk_css_core_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_icon_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_core_values_new_compute (sstyle, provider, root, parent_style, lookup);
gtk_css_icon_values_new_compute (sstyle, provider, root, parent_style, lookup);
gtk_css_font_values_new_compute (sstyle, provider, root, parent_style, lookup);
}
return;
@@ -933,57 +930,57 @@ gtk_css_lookup_resolve (GtkCssLookup *lookup,
if (parent_style && gtk_css_core_values_unset (lookup))
style->core = (GtkCssCoreValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->core);
else
gtk_css_core_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_core_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_background_values_unset (lookup))
style->background = (GtkCssBackgroundValues *)gtk_css_values_ref (gtk_css_background_initial_values);
else
gtk_css_background_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_background_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_border_values_unset (lookup))
style->border = (GtkCssBorderValues *)gtk_css_values_ref (gtk_css_border_initial_values);
else
gtk_css_border_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_border_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (parent_style && gtk_css_icon_values_unset (lookup))
style->icon = (GtkCssIconValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->icon);
else
gtk_css_icon_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_icon_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_outline_values_unset (lookup))
style->outline = (GtkCssOutlineValues *)gtk_css_values_ref (gtk_css_outline_initial_values);
else
gtk_css_outline_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_outline_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (parent_style && gtk_css_font_values_unset (lookup))
style->font = (GtkCssFontValues *)gtk_css_values_ref ((GtkCssValues *)parent_style->font);
else
gtk_css_font_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_font_variant_values_unset (lookup))
style->font_variant = (GtkCssFontVariantValues *)gtk_css_values_ref (gtk_css_font_variant_initial_values);
else
gtk_css_font_variant_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_font_variant_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_animation_values_unset (lookup))
style->animation = (GtkCssAnimationValues *)gtk_css_values_ref (gtk_css_animation_initial_values);
else
gtk_css_animation_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_animation_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_transition_values_unset (lookup))
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref (gtk_css_transition_initial_values);
else
gtk_css_transition_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_transition_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_size_values_unset (lookup))
style->size = (GtkCssSizeValues *)gtk_css_values_ref (gtk_css_size_initial_values);
else
gtk_css_size_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_size_values_new_compute (sstyle, provider, root, parent_style, lookup);
if (gtk_css_other_values_unset (lookup))
style->other = (GtkCssOtherValues *)gtk_css_values_ref (gtk_css_other_initial_values);
else
gtk_css_other_values_new_compute (sstyle, provider, parent_style, lookup);
gtk_css_other_values_new_compute (sstyle, provider, root, parent_style, lookup);
}
GtkCssStyle *
@@ -1016,6 +1013,7 @@ gtk_css_static_style_new_compute (GtkStyleProvider *provider,
gtk_css_lookup_resolve (&lookup,
provider,
node ? gtk_css_node_get_root (node) : NULL,
result,
parent ? gtk_css_node_get_style (parent) : NULL);
@@ -1033,6 +1031,7 @@ G_STATIC_ASSERT (GTK_CSS_PROPERTY_OUTLINE_STYLE == GTK_CSS_PROPERTY_OUTLINE_WIDT
static void
gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *parent_style,
guint id,
GtkCssValue *specified,
@@ -1076,7 +1075,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
*/
if (specified)
{
value = _gtk_css_value_compute (specified, id, provider, (GtkCssStyle *)style, parent_style);
value = gtk_css_value_compute (specified, id, provider, root, (GtkCssStyle *)style, parent_style);
}
else if (parent_style && _gtk_css_style_property_is_inherit (_gtk_css_style_property_lookup_by_id (id)))
{
@@ -1085,7 +1084,7 @@ gtk_css_static_style_compute_value (GtkCssStaticStyle *style,
}
else
{
value = _gtk_css_initial_value_new_compute (id, provider, (GtkCssStyle *)style, parent_style);
value = gtk_css_initial_value_new_compute (id, provider, root, (GtkCssStyle *)style, parent_style);
}
gtk_css_static_style_set_value (style, id, value, section);

View File

@@ -37,6 +37,7 @@ static GtkCssValue *
gtk_css_value_string_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{

File diff suppressed because it is too large Load Diff

72
gtk/gtkcssstylesheet.h Normal file
View File

@@ -0,0 +1,72 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
* 2020 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_STYLE_SHEET_H__
#define __GTK_CSS_STYLE_SHEET_H__
#include <gio/gio.h>
#include <gtk/css/gtkcss.h>
G_BEGIN_DECLS
#define GTK_TYPE_CSS_STYLE_SHEET (gtk_css_style_sheet_get_type ())
#define GTK_CSS_STYLE_SHEET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_CSS_STYLE_SHEET, GtkCssStyleSheet))
#define GTK_IS_CSS_STYLE_SHEET(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_CSS_STYLE_SHEET))
typedef struct _GtkCssStyleSheet GtkCssStyleSheet;
typedef struct _GtkCssStyleSheetClass GtkCssStyleSheetClass;
GDK_AVAILABLE_IN_ALL
GType gtk_css_style_sheet_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkCssStyleSheet * gtk_css_style_sheet_new (void);
GDK_AVAILABLE_IN_ALL
char * gtk_css_style_sheet_to_string (GtkCssStyleSheet *self);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_load_from_data (GtkCssStyleSheet *self,
const gchar *data,
gssize length);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_load_from_file (GtkCssStyleSheet *self,
GFile *file);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_load_from_path (GtkCssStyleSheet *self,
const gchar *path);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_load_from_resource (GtkCssStyleSheet *self,
const gchar *resource_path);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_load_named (GtkCssStyleSheet *self,
const char *name,
const char *variant);
GDK_AVAILABLE_IN_ALL
void gtk_css_style_sheet_set_priority (GtkCssStyleSheet *self,
guint priority);
GDK_AVAILABLE_IN_ALL
guint gtk_css_style_sheet_get_priority (GtkCssStyleSheet *self) G_GNUC_PURE;
G_END_DECLS
#endif /* __GTK_CSS_STYLE_SHEET_H__ */

View File

@@ -1,5 +1,6 @@
/* GTK - The GIMP Toolkit
* Copyright (C) 2011 Red Hat, Inc.
* 2020 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -15,19 +16,20 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GTK_CSS_PROVIDER_PRIVATE_H__
#define __GTK_CSS_PROVIDER_PRIVATE_H__
#ifndef __GTK_CSS_STYLE_SHEET_PRIVATE_H__
#define __GTK_CSS_STYLE_SHEET_PRIVATE_H__
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
G_BEGIN_DECLS
gchar *_gtk_get_theme_dir (void);
gchar * gtk_get_theme_dir (void);
const gchar *_gtk_css_provider_get_theme_dir (GtkCssProvider *provider);
void gtk_css_provider_set_keep_css_sections (void);
const gchar * gtk_css_style_sheet_get_theme_dir (GtkCssStyleSheet *self);
void gtk_css_style_sheet_set_keep_css_sections (void);
G_END_DECLS
#endif /* __GTK_CSS_PROVIDER_PRIVATE_H__ */
#endif /* __GTK_CSS_STYLE_SHEET_PRIVATE_H__ */

View File

@@ -277,6 +277,7 @@ gtk_css_transform_compute (GtkCssTransform *dest,
GtkCssTransform *src,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -287,41 +288,41 @@ gtk_css_transform_compute (GtkCssTransform *dest,
case GTK_CSS_TRANSFORM_MATRIX:
return TRUE;
case GTK_CSS_TRANSFORM_TRANSLATE:
dest->translate.x = _gtk_css_value_compute (src->translate.x, property_id, provider, style, parent_style);
dest->translate.y = _gtk_css_value_compute (src->translate.y, property_id, provider, style, parent_style);
dest->translate.z = _gtk_css_value_compute (src->translate.z, property_id, provider, style, parent_style);
dest->translate.x = gtk_css_value_compute (src->translate.x, property_id, provider, root, style, parent_style);
dest->translate.y = gtk_css_value_compute (src->translate.y, property_id, provider, root, style, parent_style);
dest->translate.z = gtk_css_value_compute (src->translate.z, property_id, provider, root, style, parent_style);
return dest->translate.x == src->translate.x
&& dest->translate.y == src->translate.y
&& dest->translate.z == src->translate.z;
case GTK_CSS_TRANSFORM_ROTATE:
dest->rotate.x = _gtk_css_value_compute (src->rotate.x, property_id, provider, style, parent_style);
dest->rotate.y = _gtk_css_value_compute (src->rotate.y, property_id, provider, style, parent_style);
dest->rotate.z = _gtk_css_value_compute (src->rotate.z, property_id, provider, style, parent_style);
dest->rotate.angle = _gtk_css_value_compute (src->rotate.angle, property_id, provider, style, parent_style);
dest->rotate.x = gtk_css_value_compute (src->rotate.x, property_id, provider, root, style, parent_style);
dest->rotate.y = gtk_css_value_compute (src->rotate.y, property_id, provider, root, style, parent_style);
dest->rotate.z = gtk_css_value_compute (src->rotate.z, property_id, provider, root, style, parent_style);
dest->rotate.angle = gtk_css_value_compute (src->rotate.angle, property_id, provider, root, style, parent_style);
return dest->rotate.x == src->rotate.x
&& dest->rotate.y == src->rotate.y
&& dest->rotate.z == src->rotate.z
&& dest->rotate.angle == src->rotate.angle;
case GTK_CSS_TRANSFORM_SCALE:
dest->scale.x = _gtk_css_value_compute (src->scale.x, property_id, provider, style, parent_style);
dest->scale.y = _gtk_css_value_compute (src->scale.y, property_id, provider, style, parent_style);
dest->scale.z = _gtk_css_value_compute (src->scale.z, property_id, provider, style, parent_style);
dest->scale.x = gtk_css_value_compute (src->scale.x, property_id, provider, root, style, parent_style);
dest->scale.y = gtk_css_value_compute (src->scale.y, property_id, provider, root, style, parent_style);
dest->scale.z = gtk_css_value_compute (src->scale.z, property_id, provider, root, style, parent_style);
return dest->scale.x == src->scale.x
&& dest->scale.y == src->scale.y
&& dest->scale.z == src->scale.z;
case GTK_CSS_TRANSFORM_SKEW:
dest->skew.x = _gtk_css_value_compute (src->skew.x, property_id, provider, style, parent_style);
dest->skew.y = _gtk_css_value_compute (src->skew.y, property_id, provider, style, parent_style);
dest->skew.x = gtk_css_value_compute (src->skew.x, property_id, provider, root, style, parent_style);
dest->skew.y = gtk_css_value_compute (src->skew.y, property_id, provider, root, style, parent_style);
return dest->skew.x == src->skew.x
&& dest->skew.y == src->skew.y;
case GTK_CSS_TRANSFORM_SKEW_X:
dest->skew_x.skew = _gtk_css_value_compute (src->skew_x.skew, property_id, provider, style, parent_style);
dest->skew_x.skew = gtk_css_value_compute (src->skew_x.skew, property_id, provider, root, style, parent_style);
return dest->skew_x.skew == src->skew_x.skew;
case GTK_CSS_TRANSFORM_SKEW_Y:
dest->skew_y.skew = _gtk_css_value_compute (src->skew_y.skew, property_id, provider, style, parent_style);
dest->skew_y.skew = gtk_css_value_compute (src->skew_y.skew, property_id, provider, root, style, parent_style);
return dest->skew_y.skew == src->skew_y.skew;
case GTK_CSS_TRANSFORM_PERSPECTIVE:
dest->perspective.depth = _gtk_css_value_compute (src->perspective.depth, property_id, provider, style, parent_style);
dest->perspective.depth = gtk_css_value_compute (src->perspective.depth, property_id, provider, root, style, parent_style);
return dest->perspective.depth == src->perspective.depth;
case GTK_CSS_TRANSFORM_NONE:
default:
@@ -334,6 +335,7 @@ static GtkCssValue *
gtk_css_value_transform_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -354,6 +356,7 @@ gtk_css_value_transform_compute (GtkCssValue *value,
&value->transforms[i],
property_id,
provider,
root,
style,
parent_style);
}

View File

@@ -38,7 +38,7 @@ _gtk_css_change_for_sibling (GtkCssChange match)
| GTK_CSS_CHANGE_SELECTED \
| GTK_CSS_CHANGE_BACKDROP)
#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE) \
#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_STYLE_SHEET|GTK_CSS_CHANGE_ROOT|GTK_CSS_CHANGE_PARENT_STYLE) \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD)
@@ -76,7 +76,7 @@ _gtk_css_change_for_child (GtkCssChange match)
| GTK_CSS_CHANGE_SIBLING_BACKDROP \
| GTK_CSS_CHANGE_SIBLING_SELECTED)
#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE))
#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_STYLE_SHEET|GTK_CSS_CHANGE_ROOT|GTK_CSS_CHANGE_PARENT_STYLE))
return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_PARENT_SHIFT);
@@ -144,7 +144,8 @@ gtk_css_change_print (GtkCssChange change,
{ GTK_CSS_CHANGE_PARENT_SIBLING_BACKDROP, "parent-sibling-backdrop" },
{ GTK_CSS_CHANGE_PARENT_SIBLING_SELECTED, "parent-sibling-selected" },
{ GTK_CSS_CHANGE_SOURCE, "source" },
{ GTK_CSS_CHANGE_STYLE_SHEET, "style-sheet" },
{ GTK_CSS_CHANGE_ROOT, "root" },
{ GTK_CSS_CHANGE_PARENT_STYLE, "parent-style" },
{ GTK_CSS_CHANGE_TIMESTAMP, "timestamp" },
{ GTK_CSS_CHANGE_ANIMATIONS, "animations" },

View File

@@ -89,10 +89,11 @@ typedef struct _GtkCssStaticStyle GtkCssStaticStyle;
#define GTK_CSS_CHANGE_PARENT_SIBLING_SELECTED (1ULL << 47)
/* add more */
#define GTK_CSS_CHANGE_SOURCE (1ULL << 48)
#define GTK_CSS_CHANGE_PARENT_STYLE (1ULL << 49)
#define GTK_CSS_CHANGE_TIMESTAMP (1ULL << 50)
#define GTK_CSS_CHANGE_ANIMATIONS (1ULL << 51)
#define GTK_CSS_CHANGE_STYLE_SHEET (1ULL << 48)
#define GTK_CSS_CHANGE_ROOT (1ULL << 49)
#define GTK_CSS_CHANGE_PARENT_STYLE (1ULL << 50)
#define GTK_CSS_CHANGE_TIMESTAMP (1ULL << 51)
#define GTK_CSS_CHANGE_ANIMATIONS (1ULL << 52)
#define GTK_CSS_CHANGE_RESERVED_BIT (1ULL << 62)
@@ -121,7 +122,8 @@ typedef guint64 GtkCssChange;
GTK_CSS_CHANGE_ANY_SIBLING | \
GTK_CSS_CHANGE_ANY_PARENT | \
GTK_CSS_CHANGE_ANY_PARENT_SIBLING | \
GTK_CSS_CHANGE_SOURCE | \
GTK_CSS_CHANGE_STYLE_SHEET | \
GTK_CSS_CHANGE_ROOT | \
GTK_CSS_CHANGE_PARENT_STYLE | \
GTK_CSS_CHANGE_TIMESTAMP | \
GTK_CSS_CHANGE_ANIMATIONS)

View File

@@ -38,6 +38,7 @@ static GtkCssValue *
gtk_css_value_unset_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
@@ -51,11 +52,12 @@ gtk_css_value_unset_compute (GtkCssValue *value,
else
unset_value = _gtk_css_initial_value_get ();
return _gtk_css_value_compute (unset_value,
property_id,
provider,
style,
parent_style);
return gtk_css_value_compute (unset_value,
property_id,
provider,
root,
style,
parent_style);
}
static gboolean

View File

@@ -193,10 +193,13 @@ gtk_css_value_unref (GtkCssValue *value)
}
/**
* _gtk_css_value_compute:
* gtk_css_value_compute:
* @value: the value to compute from
* @property_id: the ID of the property to compute
* @provider: Style provider for looking up extra information
* @root: (nullable): root widget of the CSS tree for looking up extra
* information or %NULL if the value is not looked up for a style of
* a rooted window.
* @style: Style to compute for
* @parent_style: parent style to use for inherited values
*
@@ -208,11 +211,12 @@ gtk_css_value_unref (GtkCssValue *value)
* Returns: the computed value
**/
GtkCssValue *
_gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style)
gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style)
{
if (gtk_css_value_is_computed (value))
return _gtk_css_value_ref (value);
@@ -221,7 +225,7 @@ _gtk_css_value_compute (GtkCssValue *value,
get_accounting_data (value->class->type_name)->computed++;
#endif
return value->class->compute (value, property_id, provider, style, parent_style);
return value->class->compute (value, property_id, provider, root, style, parent_style);
}
gboolean

View File

@@ -47,6 +47,7 @@ struct _GtkCssValueClass {
GtkCssValue * (* compute) (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style);
gboolean (* equal) (const GtkCssValue *value1,
@@ -73,11 +74,12 @@ GtkCssValue * gtk_css_value_ref (GtkCssValue
#define _gtk_css_value_unref gtk_css_value_unref
void gtk_css_value_unref (GtkCssValue *value);
GtkCssValue *_gtk_css_value_compute (GtkCssValue *value,
GtkCssValue * gtk_css_value_compute (GtkCssValue *value,
guint property_id,
GtkStyleProvider *provider,
GtkWidget *root,
GtkCssStyle *style,
GtkCssStyle *parent_style) G_GNUC_PURE;
GtkCssStyle *parent_style);
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2) G_GNUC_PURE;
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,

View File

@@ -115,11 +115,21 @@ gtk_css_widget_node_get_style_provider (GtkCssNode *node)
if (context)
return gtk_style_context_get_style_provider (context);
cascade = _gtk_settings_get_style_cascade (gtk_widget_get_settings (widget_node->widget),
gtk_widget_get_scale_factor (widget_node->widget));
cascade = gtk_settings_get_style_cascade (gtk_widget_get_settings (widget_node->widget));
return GTK_STYLE_PROVIDER (cascade);
}
static GtkWidget *
gtk_css_widget_node_get_root (GtkCssNode *node)
{
GtkCssWidgetNode *self = GTK_CSS_WIDGET_NODE (node);
g_assert (self->widget == NULL || GTK_IS_ROOT (self->widget));
return self->widget;
}
static GdkFrameClock *
gtk_css_widget_node_get_frame_clock (GtkCssNode *node)
{
@@ -145,6 +155,7 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
node_class->queue_validate = gtk_css_widget_node_queue_validate;
node_class->dequeue_validate = gtk_css_widget_node_dequeue_validate;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
node_class->get_root = gtk_css_widget_node_get_root;
node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
}
@@ -163,6 +174,8 @@ gtk_css_widget_node_new (GtkWidget *widget)
result = g_object_new (GTK_TYPE_CSS_WIDGET_NODE, NULL);
result->widget = widget;
if (GTK_IS_ROOT (widget))
GTK_CSS_NODE (result)->is_root = TRUE;
gtk_css_node_set_visible (GTK_CSS_NODE (result),
_gtk_widget_get_visible (widget));

View File

@@ -22,7 +22,7 @@
#include "gtkadjustmentprivate.h"
#include "gtkbox.h"
#include "gtkbutton.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtkentry.h"
#include "gtkflowbox.h"
#include "gtkstack.h"

View File

@@ -22,7 +22,7 @@
#include "gtktextprivate.h"
#include "gtkeditable.h"
#include "gtkbox.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtklistbox.h"
#include "gtklabel.h"
#include "gtkpopover.h"

View File

@@ -31,7 +31,6 @@
#include "gtkbinlayout.h"
#include "gtkbox.h"
#include "gtkcssprovider.h"
#include "gtkfontchooser.h"
#include "gtkfontchooserdialog.h"
#include "gtkfontchooserutils.h"
@@ -102,7 +101,6 @@ typedef struct
GtkFontFilterFunc font_filter;
gpointer font_filter_data;
GDestroyNotify font_filter_data_destroy;
GtkCssProvider *provider;
GtkFontChooserLevel level;
} GtkFontButtonPrivate;
@@ -610,8 +608,6 @@ gtk_font_button_finalize (GObject *object)
g_free (priv->preview_text);
g_clear_object (&priv->provider);
gtk_widget_unparent (priv->button);
G_OBJECT_CLASS (gtk_font_button_parent_class)->finalize (object);
@@ -1022,246 +1018,40 @@ dialog_destroy (GtkWidget *widget,
priv->font_dialog = NULL;
}
static void
add_css_variations (GString *s,
const char *variations)
{
const char *p;
const char *sep = "";
if (variations == NULL || variations[0] == '\0')
{
g_string_append (s, "normal");
return;
}
p = variations;
while (p && *p)
{
const char *start;
const char *end, *end2;
double value;
char name[5];
while (g_ascii_isspace (*p)) p++;
start = p;
end = strchr (p, ',');
if (end && (end - p < 6))
goto skip;
name[0] = p[0];
name[1] = p[1];
name[2] = p[2];
name[3] = p[3];
name[4] = '\0';
p += 4;
while (g_ascii_isspace (*p)) p++;
if (*p == '=') p++;
if (p - start < 5)
goto skip;
value = g_ascii_strtod (p, (char **) &end2);
while (end2 && g_ascii_isspace (*end2)) end2++;
if (end2 && (*end2 != ',' && *end2 != '\0'))
goto skip;
g_string_append_printf (s, "%s\"%s\" %g", sep, name, value);
sep = ", ";
skip:
p = end ? end + 1 : NULL;
}
}
static gchar *
pango_font_description_to_css (PangoFontDescription *desc,
const char *features,
const char *language)
{
GString *s;
PangoFontMask set;
s = g_string_new ("* { ");
set = pango_font_description_get_set_fields (desc);
if (set & PANGO_FONT_MASK_FAMILY)
{
g_string_append (s, "font-family: ");
g_string_append (s, pango_font_description_get_family (desc));
g_string_append (s, "; ");
}
if (set & PANGO_FONT_MASK_STYLE)
{
switch (pango_font_description_get_style (desc))
{
case PANGO_STYLE_NORMAL:
g_string_append (s, "font-style: normal; ");
break;
case PANGO_STYLE_OBLIQUE:
g_string_append (s, "font-style: oblique; ");
break;
case PANGO_STYLE_ITALIC:
g_string_append (s, "font-style: italic; ");
break;
default:
break;
}
}
if (set & PANGO_FONT_MASK_VARIANT)
{
switch (pango_font_description_get_variant (desc))
{
case PANGO_VARIANT_NORMAL:
g_string_append (s, "font-variant: normal; ");
break;
case PANGO_VARIANT_SMALL_CAPS:
g_string_append (s, "font-variant: small-caps; ");
break;
default:
break;
}
}
if (set & PANGO_FONT_MASK_WEIGHT)
{
switch (pango_font_description_get_weight (desc))
{
case PANGO_WEIGHT_THIN:
g_string_append (s, "font-weight: 100; ");
break;
case PANGO_WEIGHT_ULTRALIGHT:
g_string_append (s, "font-weight: 200; ");
break;
case PANGO_WEIGHT_LIGHT:
case PANGO_WEIGHT_SEMILIGHT:
g_string_append (s, "font-weight: 300; ");
break;
case PANGO_WEIGHT_BOOK:
case PANGO_WEIGHT_NORMAL:
g_string_append (s, "font-weight: 400; ");
break;
case PANGO_WEIGHT_MEDIUM:
g_string_append (s, "font-weight: 500; ");
break;
case PANGO_WEIGHT_SEMIBOLD:
g_string_append (s, "font-weight: 600; ");
break;
case PANGO_WEIGHT_BOLD:
g_string_append (s, "font-weight: 700; ");
break;
case PANGO_WEIGHT_ULTRABOLD:
g_string_append (s, "font-weight: 800; ");
break;
case PANGO_WEIGHT_HEAVY:
case PANGO_WEIGHT_ULTRAHEAVY:
g_string_append (s, "font-weight: 900; ");
break;
default:
break;
}
}
if (set & PANGO_FONT_MASK_STRETCH)
{
switch (pango_font_description_get_stretch (desc))
{
case PANGO_STRETCH_ULTRA_CONDENSED:
g_string_append (s, "font-stretch: ultra-condensed; ");
break;
case PANGO_STRETCH_EXTRA_CONDENSED:
g_string_append (s, "font-stretch: extra-condensed; ");
break;
case PANGO_STRETCH_CONDENSED:
g_string_append (s, "font-stretch: condensed; ");
break;
case PANGO_STRETCH_SEMI_CONDENSED:
g_string_append (s, "font-stretch: semi-condensed; ");
break;
case PANGO_STRETCH_NORMAL:
g_string_append (s, "font-stretch: normal; ");
break;
case PANGO_STRETCH_SEMI_EXPANDED:
g_string_append (s, "font-stretch: semi-expanded; ");
break;
case PANGO_STRETCH_EXPANDED:
g_string_append (s, "font-stretch: expanded; ");
break;
case PANGO_STRETCH_EXTRA_EXPANDED:
break;
case PANGO_STRETCH_ULTRA_EXPANDED:
g_string_append (s, "font-stretch: ultra-expanded; ");
break;
default:
break;
}
}
if (set & PANGO_FONT_MASK_SIZE)
{
g_string_append_printf (s, "font-size: %dpt; ", pango_font_description_get_size (desc) / PANGO_SCALE);
}
if (set & PANGO_FONT_MASK_VARIATIONS)
{
const char *variations;
g_string_append (s, "font-variation-settings: ");
variations = pango_font_description_get_variations (desc);
add_css_variations (s, variations);
g_string_append (s, "; ");
}
if (features)
{
g_string_append_printf (s, "font-feature-settings: %s;", features);
}
g_string_append (s, "}");
return g_string_free (s, FALSE);
}
static void
gtk_font_button_label_use_font (GtkFontButton *font_button)
{
GtkFontButtonPrivate *priv = gtk_font_button_get_instance_private (font_button);
GtkStyleContext *context;
context = gtk_widget_get_style_context (priv->font_label);
if (!priv->use_font)
{
if (priv->provider)
{
gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (priv->provider));
g_clear_object (&priv->provider);
}
gtk_label_set_attributes (GTK_LABEL (priv->font_label), NULL);
}
else
{
PangoFontDescription *desc;
gchar *data;
if (!priv->provider)
{
priv->provider = gtk_css_provider_new ();
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
PangoAttrList *attrs;
desc = pango_font_description_copy (priv->font_desc);
if (!priv->use_size)
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
data = pango_font_description_to_css (desc,
priv->font_features,
pango_language_to_string (priv->language));
gtk_css_provider_load_from_data (priv->provider, data, -1);
attrs = pango_attr_list_new ();
g_free (data);
/* Prevent font fallback */
pango_attr_list_insert (attrs, pango_attr_fallback_new (FALSE));
/* Force current font and features */
pango_attr_list_insert (attrs, pango_attr_font_desc_new (desc));
if (priv->font_features)
pango_attr_list_insert (attrs, pango_attr_font_features_new (priv->font_features));
if (priv->language)
pango_attr_list_insert (attrs, pango_attr_language_new (priv->language));
gtk_label_set_attributes (GTK_LABEL (priv->font_label), attrs);
pango_attr_list_unref (attrs);
pango_font_description_free (desc);
}
}

View File

@@ -20,16 +20,16 @@
#include "gtksettingsprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkcssstylesheetprivate.h"
#include "gtkhslaprivate.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkscrolledwindow.h"
#include "gtkstylecontext.h"
#include "gtkstyleproviderprivate.h"
#include "gtktypebuiltins.h"
#include "gtkversion.h"
#include "gtkwidget.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gdk/gdk-private.h"
@@ -123,8 +123,8 @@ struct _GtkSettingsPrivate
GData *queued_settings; /* of type GtkSettingsValue* */
GtkSettingsPropertyValue *property_values;
GdkDisplay *display;
GSList *style_cascades;
GtkCssProvider *theme_provider;
GtkStyleCascade *style_cascade;
GtkCssStyleSheet *theme_style_sheet;
gint font_size;
gboolean font_size_absolute;
gchar *font_family;
@@ -196,8 +196,6 @@ enum {
};
/* --- prototypes --- */
static void gtk_settings_provider_iface_init (GtkStyleProviderInterface *iface);
static void gtk_settings_finalize (GObject *object);
static void gtk_settings_get_property (GObject *object,
guint property_id,
@@ -226,9 +224,6 @@ static void settings_update_xsettings (GtkSettings *setting
static void gtk_settings_load_from_key_file (GtkSettings *settings,
const gchar *path,
GtkSettingsSource source);
static void settings_update_provider (GdkDisplay *display,
GtkCssProvider **old,
GtkCssProvider *new);
/* --- variables --- */
static GQuark quark_gtk_settings = 0;
@@ -238,10 +233,7 @@ static guint class_n_properties = 0;
static GPtrArray *display_settings;
G_DEFINE_TYPE_EXTENDED (GtkSettings, gtk_settings, G_TYPE_OBJECT, 0,
G_ADD_PRIVATE (GtkSettings)
G_IMPLEMENT_INTERFACE (GTK_TYPE_STYLE_PROVIDER,
gtk_settings_provider_iface_init));
G_DEFINE_TYPE_WITH_PRIVATE (GtkSettings, gtk_settings, G_TYPE_OBJECT);
/* --- functions --- */
static void
@@ -258,8 +250,9 @@ gtk_settings_init (GtkSettings *settings)
g_datalist_init (&priv->queued_settings);
object_list = g_slist_prepend (object_list, settings);
priv->style_cascades = g_slist_prepend (NULL, _gtk_style_cascade_new ());
priv->theme_provider = gtk_css_provider_new ();
priv->style_cascade = _gtk_style_cascade_new ();
priv->theme_style_sheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (priv->theme_style_sheet, GTK_STYLE_PROVIDER_PRIORITY_THEME);
/* build up property array for all yet existing properties and queue
* notification for them (at least notification for internal properties
@@ -967,18 +960,6 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_assert (result == PROP_OVERLAY_SCROLLING);
}
static GtkSettings *
gtk_settings_style_provider_get_settings (GtkStyleProvider *provider)
{
return GTK_SETTINGS (provider);
}
static void
gtk_settings_provider_iface_init (GtkStyleProviderInterface *iface)
{
iface->get_settings = gtk_settings_style_provider_get_settings;
}
static void
gtk_settings_finalize (GObject *object)
{
@@ -994,8 +975,8 @@ gtk_settings_finalize (GObject *object)
g_datalist_clear (&priv->queued_settings);
settings_update_provider (priv->display, &priv->theme_provider, NULL);
g_slist_free_full (priv->style_cascades, g_object_unref);
g_object_unref (priv->theme_style_sheet);
g_object_unref (priv->style_cascade);
if (priv->font_options)
cairo_font_options_destroy (priv->font_options);
@@ -1006,48 +987,26 @@ gtk_settings_finalize (GObject *object)
}
GtkStyleCascade *
_gtk_settings_get_style_cascade (GtkSettings *settings,
gint scale)
gtk_settings_get_style_cascade (GtkSettings *settings)
{
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
GtkStyleCascade *new_cascade;
GSList *list;
g_return_val_if_fail (GTK_IS_SETTINGS (settings), NULL);
for (list = priv->style_cascades; list; list = list->next)
{
if (_gtk_style_cascade_get_scale (list->data) == scale)
return list->data;
}
/* We are guaranteed to have the special cascade with scale == 1.
* It's created in gtk_settings_init()
*/
g_assert (scale != 1);
new_cascade = _gtk_style_cascade_new ();
_gtk_style_cascade_set_parent (new_cascade, _gtk_settings_get_style_cascade (settings, 1));
_gtk_style_cascade_set_scale (new_cascade, scale);
priv->style_cascades = g_slist_prepend (priv->style_cascades, new_cascade);
return new_cascade;
return priv->style_cascade;
}
static void
settings_init_style (GtkSettings *settings)
{
GtkSettingsPrivate *priv = gtk_settings_get_instance_private (settings);
static GtkCssProvider *css_provider = NULL;
GtkStyleCascade *cascade;
static GtkCssStyleSheet *css_style_sheet = NULL;
/* Add provider for user file */
if (G_UNLIKELY (!css_provider))
/* Add stylesheet for user file */
if (G_UNLIKELY (!css_style_sheet))
{
gchar *css_path;
css_provider = gtk_css_provider_new ();
css_style_sheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (css_style_sheet, GTK_STYLE_PROVIDER_PRIORITY_USER);
css_path = g_build_filename (g_get_user_config_dir (),
"gtk-4.0",
"gtk.css",
@@ -1055,23 +1014,15 @@ settings_init_style (GtkSettings *settings)
if (g_file_test (css_path,
G_FILE_TEST_IS_REGULAR))
gtk_css_provider_load_from_path (css_provider, css_path);
gtk_css_style_sheet_load_from_path (css_style_sheet, css_path);
g_free (css_path);
}
cascade = _gtk_settings_get_style_cascade (settings, 1);
_gtk_style_cascade_add_provider (cascade,
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
priv->style_cascade = _gtk_style_cascade_new ();
_gtk_style_cascade_add_provider (cascade,
GTK_STYLE_PROVIDER (settings),
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
_gtk_style_cascade_add_provider (cascade,
GTK_STYLE_PROVIDER (priv->theme_provider),
GTK_STYLE_PROVIDER_PRIORITY_SETTINGS);
gtk_style_cascade_add_style_sheet (priv->style_cascade, css_style_sheet);
gtk_style_cascade_add_style_sheet (priv->style_cascade, priv->theme_style_sheet),
settings_update_theme (settings);
}
@@ -1192,10 +1143,29 @@ gtk_settings_set_property (GObject *object,
priv->property_values[property_id - 1].source = GTK_SETTINGS_SOURCE_APPLICATION;
}
/* This function exists to avoid roots needing to connect to
* GtkSettings::notify to track CSS changes
*/
static void
settings_invalidate_style (GtkSettings *settings)
settings_invalidate_style (GtkSettings *settings,
GtkCssChange change)
{
gtk_style_provider_changed (GTK_STYLE_PROVIDER (settings));
GList *list, *toplevels;
GdkDisplay *display;
display = _gtk_settings_get_display (settings);
toplevels = gtk_window_list_toplevels ();
g_list_foreach (toplevels, (GFunc) g_object_ref, NULL);
for (list = toplevels; list; list = list->next)
{
if (gtk_widget_get_display (list->data) == display)
gtk_css_node_invalidate (gtk_widget_get_css_node (list->data), change);
g_object_unref (list->data);
}
g_list_free (toplevels);
}
static void
@@ -1255,8 +1225,7 @@ gtk_settings_notify (GObject *object,
break;
case PROP_FONT_NAME:
settings_update_font_values (settings);
settings_invalidate_style (settings);
gtk_style_context_reset_widgets (priv->display);
settings_invalidate_style (settings, GTK_CSS_CHANGE_ROOT);
break;
case PROP_THEME_NAME:
case PROP_APPLICATION_PREFER_DARK_THEME:
@@ -1267,6 +1236,7 @@ gtk_settings_notify (GObject *object,
* widgets with gtk_widget_style_set(), and also causes more
* recomputation than necessary.
*/
settings_invalidate_style (settings, GTK_CSS_CHANGE_ROOT);
gtk_style_context_reset_widgets (priv->display);
break;
case PROP_XFT_ANTIALIAS:
@@ -1630,31 +1600,6 @@ settings_update_fontconfig (GtkSettings *settings)
#endif /* GDK_WINDOWING_X11 || GDK_WINDOWING_WAYLAND */
}
static void
settings_update_provider (GdkDisplay *display,
GtkCssProvider **old,
GtkCssProvider *new)
{
if (display != NULL && *old != new)
{
if (*old)
{
gtk_style_context_remove_provider_for_display (display,
GTK_STYLE_PROVIDER (*old));
g_object_unref (*old);
*old = NULL;
}
if (new)
{
gtk_style_context_add_provider_for_display (display,
GTK_STYLE_PROVIDER (new),
GTK_STYLE_PROVIDER_PRIORITY_THEME);
*old = g_object_ref (new);
}
}
}
static void
get_theme_name (GtkSettings *settings,
gchar **theme_name,
@@ -1709,12 +1654,12 @@ settings_update_theme (GtkSettings *settings)
get_theme_name (settings, &theme_name, &theme_variant);
gtk_css_provider_load_named (priv->theme_provider,
theme_name,
theme_variant);
gtk_css_style_sheet_load_named (priv->theme_style_sheet,
theme_name,
theme_variant);
/* reload per-theme settings */
theme_dir = _gtk_css_provider_get_theme_dir (priv->theme_provider);
theme_dir = gtk_css_style_sheet_get_theme_dir (priv->theme_style_sheet);
if (theme_dir)
{
path = g_build_filename (theme_dir, "settings.ini", NULL);

View File

@@ -29,8 +29,7 @@ G_BEGIN_DECLS
const cairo_font_options_t *
gtk_settings_get_font_options (GtkSettings *settings);
GdkDisplay *_gtk_settings_get_display (GtkSettings *settings);
GtkStyleCascade *_gtk_settings_get_style_cascade (GtkSettings *settings,
gint scale);
GtkStyleCascade *gtk_settings_get_style_cascade (GtkSettings *settings);
typedef enum
{

View File

@@ -34,8 +34,7 @@ struct _GtkStyleCascadeIter {
struct _GtkStyleProviderData
{
GtkStyleProvider *provider;
guint priority;
GtkCssStyleSheet *stylesheet;
guint changed_signal_id;
};
@@ -54,10 +53,11 @@ gtk_style_cascade_iter_next (GtkStyleCascade *cascade,
if (iter->cascade_index[ix] <= 0)
continue;
data = &g_array_index (cas->providers,
data = &g_array_index (cas->stylesheets,
GtkStyleProviderData,
iter->cascade_index[ix] - 1);
if (highest_priority_data == NULL || data->priority > highest_priority_data->priority)
if (highest_priority_data == NULL ||
gtk_css_style_sheet_get_priority (data->stylesheet) > gtk_css_style_sheet_get_priority (highest_priority_data->stylesheet))
{
highest_priority_index = ix;
highest_priority_data = data;
@@ -67,7 +67,7 @@ gtk_style_cascade_iter_next (GtkStyleCascade *cascade,
if (highest_priority_data != NULL)
{
iter->cascade_index[highest_priority_index]--;
return highest_priority_data->provider;
return GTK_STYLE_PROVIDER (highest_priority_data->stylesheet);
}
return NULL;
}
@@ -85,7 +85,7 @@ gtk_style_cascade_iter_init (GtkStyleCascade *cascade,
iter->cascade_index = g_new (int, iter->n_cascades);
for (cas = cascade, ix = 0; ix < iter->n_cascades; cas = cas->parent, ix++)
iter->cascade_index[ix] = cas->providers->len;
iter->cascade_index[ix] = cas->stylesheets->len;
return gtk_style_cascade_iter_next (cascade, iter);
}
@@ -96,35 +96,11 @@ gtk_style_cascade_iter_clear (GtkStyleCascadeIter *iter)
g_free (iter->cascade_index);
}
static GtkSettings *
gtk_style_cascade_get_settings (GtkStyleProvider *provider)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkSettings *settings;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
settings = gtk_style_provider_get_settings (item);
if (settings)
{
gtk_style_cascade_iter_clear (&iter);
return settings;
}
}
gtk_style_cascade_iter_clear (&iter);
return NULL;
}
static GtkCssValue *
gtk_style_cascade_get_color (GtkStyleProvider *provider,
gtk_style_cascade_get_color (GtkStyleProvider *stylesheet,
const char *name)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (stylesheet);
GtkStyleCascadeIter iter;
GtkCssValue *color;
GtkStyleProvider *item;
@@ -145,19 +121,11 @@ gtk_style_cascade_get_color (GtkStyleProvider *provider,
return NULL;
}
static int
gtk_style_cascade_get_scale (GtkStyleProvider *provider)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
return cascade->scale;
}
static GtkCssKeyframes *
gtk_style_cascade_get_keyframes (GtkStyleProvider *provider,
gtk_style_cascade_get_keyframes (GtkStyleProvider *stylesheet,
const char *name)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (stylesheet);
GtkStyleCascadeIter iter;
GtkCssKeyframes *keyframes;
GtkStyleProvider *item;
@@ -179,13 +147,13 @@ gtk_style_cascade_get_keyframes (GtkStyleProvider *provider,
}
static void
gtk_style_cascade_lookup (GtkStyleProvider *provider,
gtk_style_cascade_lookup (GtkStyleProvider *stylesheet,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
GtkCssLookup *lookup,
GtkCssChange *change)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (stylesheet);
GtkStyleCascadeIter iter;
GtkStyleProvider *item;
GtkCssChange iter_change;
@@ -206,8 +174,6 @@ static void
gtk_style_cascade_provider_iface_init (GtkStyleProviderInterface *iface)
{
iface->get_color = gtk_style_cascade_get_color;
iface->get_settings = gtk_style_cascade_get_settings;
iface->get_scale = gtk_style_cascade_get_scale;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
}
@@ -222,7 +188,7 @@ gtk_style_cascade_dispose (GObject *object)
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (object);
_gtk_style_cascade_set_parent (cascade, NULL);
g_array_unref (cascade->providers);
g_array_unref (cascade->stylesheets);
G_OBJECT_CLASS (_gtk_style_cascade_parent_class)->dispose (object);
}
@@ -240,17 +206,15 @@ style_provider_data_clear (gpointer data_)
{
GtkStyleProviderData *data = data_;
g_signal_handler_disconnect (data->provider, data->changed_signal_id);
g_object_unref (data->provider);
g_signal_handler_disconnect (data->stylesheet, data->changed_signal_id);
g_object_unref (data->stylesheet);
}
static void
_gtk_style_cascade_init (GtkStyleCascade *cascade)
{
cascade->scale = 1;
cascade->providers = g_array_new (FALSE, FALSE, sizeof (GtkStyleProviderData));
g_array_set_clear_func (cascade->providers, style_provider_data_clear);
cascade->stylesheets = g_array_new (FALSE, FALSE, sizeof (GtkStyleProviderData));
g_array_set_clear_func (cascade->stylesheets, style_provider_data_clear);
}
GtkStyleCascade *
@@ -290,53 +254,52 @@ _gtk_style_cascade_set_parent (GtkStyleCascade *cascade,
}
void
_gtk_style_cascade_add_provider (GtkStyleCascade *cascade,
GtkStyleProvider *provider,
guint priority)
gtk_style_cascade_add_style_sheet (GtkStyleCascade *cascade,
GtkCssStyleSheet *stylesheet)
{
GtkStyleProviderData data;
guint i;
gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
gtk_internal_return_if_fail (GTK_STYLE_PROVIDER (cascade) != provider);
gtk_internal_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
data.provider = g_object_ref (provider);
data.priority = priority;
data.changed_signal_id = g_signal_connect_swapped (provider,
data.stylesheet = g_object_ref (stylesheet);
data.changed_signal_id = g_signal_connect_swapped (stylesheet,
"gtk-private-changed",
G_CALLBACK (gtk_style_provider_changed),
cascade);
/* ensure it gets removed first */
_gtk_style_cascade_remove_provider (cascade, provider);
gtk_style_cascade_remove_style_sheet (cascade, stylesheet);
for (i = 0; i < cascade->providers->len; i++)
for (i = 0; i < cascade->stylesheets->len; i++)
{
if (g_array_index (cascade->providers, GtkStyleProviderData, i).priority > priority)
GtkStyleProviderData *adata = &g_array_index (cascade->stylesheets, GtkStyleProviderData, i);
if (gtk_css_style_sheet_get_priority (adata->stylesheet) > gtk_css_style_sheet_get_priority (stylesheet))
break;
}
g_array_insert_val (cascade->providers, i, data);
g_array_insert_val (cascade->stylesheets, i, data);
gtk_style_provider_changed (GTK_STYLE_PROVIDER (cascade));
}
void
_gtk_style_cascade_remove_provider (GtkStyleCascade *cascade,
GtkStyleProvider *provider)
gtk_style_cascade_remove_style_sheet (GtkStyleCascade *cascade,
GtkCssStyleSheet *stylesheet)
{
guint i;
gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
gtk_internal_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
for (i = 0; i < cascade->providers->len; i++)
for (i = 0; i < cascade->stylesheets->len; i++)
{
GtkStyleProviderData *data = &g_array_index (cascade->providers, GtkStyleProviderData, i);
GtkStyleProviderData *data = &g_array_index (cascade->stylesheets, GtkStyleProviderData, i);
if (data->provider == provider)
if (data->stylesheet == stylesheet)
{
g_array_remove_index (cascade->providers, i);
g_array_remove_index (cascade->stylesheets, i);
gtk_style_provider_changed (GTK_STYLE_PROVIDER (cascade));
break;
@@ -344,24 +307,3 @@ _gtk_style_cascade_remove_provider (GtkStyleCascade *cascade,
}
}
void
_gtk_style_cascade_set_scale (GtkStyleCascade *cascade,
int scale)
{
gtk_internal_return_if_fail (GTK_IS_STYLE_CASCADE (cascade));
if (cascade->scale == scale)
return;
cascade->scale = scale;
gtk_style_provider_changed (GTK_STYLE_PROVIDER (cascade));
}
int
_gtk_style_cascade_get_scale (GtkStyleCascade *cascade)
{
gtk_internal_return_val_if_fail (GTK_IS_STYLE_CASCADE (cascade), 1);
return cascade->scale;
}

View File

@@ -38,8 +38,7 @@ struct _GtkStyleCascade
GObject object;
GtkStyleCascade *parent;
GArray *providers;
int scale;
GArray *stylesheets;
};
struct _GtkStyleCascadeClass
@@ -53,15 +52,10 @@ GtkStyleCascade * _gtk_style_cascade_new (void);
void _gtk_style_cascade_set_parent (GtkStyleCascade *cascade,
GtkStyleCascade *parent);
void _gtk_style_cascade_set_scale (GtkStyleCascade *cascade,
int scale);
int _gtk_style_cascade_get_scale (GtkStyleCascade *cascade);
void _gtk_style_cascade_add_provider (GtkStyleCascade *cascade,
GtkStyleProvider *provider,
guint priority);
void _gtk_style_cascade_remove_provider (GtkStyleCascade *cascade,
GtkStyleProvider *provider);
void gtk_style_cascade_add_style_sheet (GtkStyleCascade *cascade,
GtkCssStyleSheet *stylesheet);
void gtk_style_cascade_remove_style_sheet (GtkStyleCascade *cascade,
GtkCssStyleSheet *stylesheet);
G_END_DECLS

View File

@@ -59,8 +59,8 @@
* In order to construct the final style information, #GtkStyleContext
* queries information from all attached #GtkStyleProviders. Style providers
* can be either attached explicitly to the context through
* gtk_style_context_add_provider(), or to the display through
* gtk_style_context_add_provider_for_display(). The resulting style is a
* gtk_style_context_add_style_sheet(), or to the display through
* gtk_style_context_add_style_sheet_for_display(). The resulting style is a
* combination of all providers information in priority order.
*
* For GTK+ widgets, any #GtkStyleContext returned by
@@ -213,7 +213,7 @@ gtk_style_context_init (GtkStyleContext *context)
g_error ("Can't create a GtkStyleContext without a display connection");
gtk_style_context_set_cascade (context,
_gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display), 1));
gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display)));
}
static void
@@ -310,7 +310,7 @@ gtk_style_context_has_custom_cascade (GtkStyleContext *context)
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
GtkSettings *settings = gtk_settings_get_for_display (priv->display);
return priv->cascade != _gtk_settings_get_style_cascade (settings, _gtk_style_cascade_get_scale (priv->cascade));
return priv->cascade != gtk_settings_get_style_cascade (settings);
}
GtkCssStyle *
@@ -346,73 +346,66 @@ gtk_style_context_new_for_node (GtkCssNode *node)
}
/**
* gtk_style_context_add_provider:
* gtk_style_context_add_style_sheet:
* @context: a #GtkStyleContext
* @provider: a #GtkStyleProvider
* @priority: the priority of the style provider. The lower
* it is, the earlier it will be used in the style
* construction. Typically this will be in the range
* between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and
* %GTK_STYLE_PROVIDER_PRIORITY_USER
* @stylesheet: (transfer none): a #GtkCssStyleSheet
*
* Adds a style provider to @context, to be used in style construction.
* Note that a style provider added by this function only affects
* Adds a style sheet to @context, to be used in style construction.
* Note that a style sheet added by this function only affects
* the style of the widget to which @context belongs. If you want
* to affect the style of all widgets, use
* gtk_style_context_add_provider_for_display().
* gtk_style_context_add_style_sheet_for_display().
*
* Note: If both priorities are the same, a #GtkStyleProvider
* added through this function takes precedence over another added
* through gtk_style_context_add_provider_for_display().
* through gtk_style_context_add_style_sheet_for_display().
**/
void
gtk_style_context_add_provider (GtkStyleContext *context,
GtkStyleProvider *provider,
guint priority)
gtk_style_context_add_style_sheet (GtkStyleContext *context,
GtkCssStyleSheet *stylesheet)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
g_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
if (!gtk_style_context_has_custom_cascade (context))
{
GtkStyleCascade *new_cascade;
new_cascade = _gtk_style_cascade_new ();
_gtk_style_cascade_set_scale (new_cascade, _gtk_style_cascade_get_scale (priv->cascade));
_gtk_style_cascade_set_parent (new_cascade,
_gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display), 1));
_gtk_style_cascade_add_provider (new_cascade, provider, priority);
gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display)));
gtk_style_cascade_add_style_sheet (new_cascade, stylesheet);
gtk_style_context_set_cascade (context, new_cascade);
g_object_unref (new_cascade);
}
else
{
_gtk_style_cascade_add_provider (priv->cascade, provider, priority);
gtk_style_cascade_add_style_sheet (priv->cascade, stylesheet);
}
}
/**
* gtk_style_context_remove_provider:
* gtk_style_context_remove_style_sheet:
* @context: a #GtkStyleContext
* @provider: a #GtkStyleProvider
* @stylesheet: a #GtkCssStyleSheet
*
* Removes @provider from the style providers list in @context.
* Removes @stylesheet from the style providers list in @context.
**/
void
gtk_style_context_remove_provider (GtkStyleContext *context,
GtkStyleProvider *provider)
gtk_style_context_remove_style_sheet (GtkStyleContext *context,
GtkCssStyleSheet *stylesheet)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
g_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
if (!gtk_style_context_has_custom_cascade (context))
return;
_gtk_style_cascade_remove_provider (priv->cascade, provider);
gtk_style_cascade_remove_style_sheet (priv->cascade, stylesheet);
}
/**
@@ -446,14 +439,9 @@ gtk_style_context_reset_widgets (GdkDisplay *display)
}
/**
* gtk_style_context_add_provider_for_display:
* gtk_style_context_add_style_sheet_for_display:
* @display: a #GdkDisplay
* @provider: a #GtkStyleProvider
* @priority: the priority of the style provider. The lower
* it is, the earlier it will be used in the style
* construction. Typically this will be in the range
* between %GTK_STYLE_PROVIDER_PRIORITY_FALLBACK and
* %GTK_STYLE_PROVIDER_PRIORITY_USER
* @stylesheet: (transfer none): a #GtkCssStyleSheet
*
* Adds a global style provider to @display, which will be used
* in style construction for all #GtkStyleContexts under @display.
@@ -462,43 +450,40 @@ gtk_style_context_reset_widgets (GdkDisplay *display)
* available.
*
* Note: If both priorities are the same, A #GtkStyleProvider
* added through gtk_style_context_add_provider() takes precedence
* added through gtk_style_context_add_style_sheet() takes precedence
* over another added through this function.
**/
void
gtk_style_context_add_provider_for_display (GdkDisplay *display,
GtkStyleProvider *provider,
guint priority)
gtk_style_context_add_style_sheet_for_display (GdkDisplay *display,
GtkCssStyleSheet *stylesheet)
{
GtkStyleCascade *cascade;
g_return_if_fail (GDK_IS_DISPLAY (display));
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
g_return_if_fail (!GTK_IS_SETTINGS (provider) || _gtk_settings_get_display (GTK_SETTINGS (provider)) == display);
g_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
_gtk_style_cascade_add_provider (cascade, provider, priority);
cascade = gtk_settings_get_style_cascade (gtk_settings_get_for_display (display));
gtk_style_cascade_add_style_sheet (cascade, stylesheet);
}
/**
* gtk_style_context_remove_provider_for_display:
* gtk_style_context_remove_style_sheet_for_display:
* @display: a #GdkDisplay
* @provider: a #GtkStyleProvider
*
* Removes @provider from the global style providers list in @display.
**/
void
gtk_style_context_remove_provider_for_display (GdkDisplay *display,
GtkStyleProvider *provider)
gtk_style_context_remove_style_sheet_for_display (GdkDisplay *display,
GtkCssStyleSheet *stylesheet)
{
GtkStyleCascade *cascade;
g_return_if_fail (GDK_IS_DISPLAY (display));
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
g_return_if_fail (!GTK_IS_SETTINGS (provider));
g_return_if_fail (GTK_IS_CSS_STYLE_SHEET (stylesheet));
cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
_gtk_style_cascade_remove_provider (cascade, provider);
cascade = gtk_settings_get_style_cascade (gtk_settings_get_for_display (display));
gtk_style_cascade_remove_style_sheet (cascade, stylesheet);
}
/*
@@ -578,56 +563,6 @@ gtk_style_context_get_state (GtkStyleContext *context)
return gtk_css_node_get_state (priv->cssnode);
}
/**
* gtk_style_context_set_scale:
* @context: a #GtkStyleContext
* @scale: scale
*
* Sets the scale to use when getting image assets for the style.
**/
void
gtk_style_context_set_scale (GtkStyleContext *context,
gint scale)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
if (scale == _gtk_style_cascade_get_scale (priv->cascade))
return;
if (gtk_style_context_has_custom_cascade (context))
{
_gtk_style_cascade_set_scale (priv->cascade, scale);
}
else
{
GtkStyleCascade *new_cascade;
new_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (priv->display),
scale);
gtk_style_context_set_cascade (context, new_cascade);
}
}
/**
* gtk_style_context_get_scale:
* @context: a #GtkStyleContext
*
* Returns the scale used for assets.
*
* Returns: the scale
**/
gint
gtk_style_context_get_scale (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context);
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
return _gtk_style_cascade_get_scale (priv->cascade);
}
/*
* gtk_style_context_save_to_node:
* @context: a #GtkStyleContext
@@ -877,13 +812,12 @@ gtk_style_context_set_display (GtkStyleContext *context,
if (gtk_style_context_has_custom_cascade (context))
{
display_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display), 1);
display_cascade = gtk_settings_get_style_cascade (gtk_settings_get_for_display (display));
_gtk_style_cascade_set_parent (priv->cascade, display_cascade);
}
else
{
display_cascade = _gtk_settings_get_style_cascade (gtk_settings_get_for_display (display),
_gtk_style_cascade_get_scale (priv->cascade));
display_cascade = gtk_settings_get_style_cascade (gtk_settings_get_for_display (display));
gtk_style_context_set_cascade (context, display_cascade);
}
@@ -922,10 +856,11 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
g_return_val_if_fail (color != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
val = _gtk_css_color_value_resolve (color,
GTK_STYLE_PROVIDER (priv->cascade),
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
NULL);
val = gtk_css_color_value_resolve (color,
GTK_STYLE_PROVIDER (priv->cascade),
NULL,
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
NULL);
if (val == NULL)
return FALSE;

View File

@@ -25,7 +25,8 @@
#include <gtk/css/gtkcss.h>
#include <gtk/gtkborder.h>
#include <gtk/gtkstyleprovider.h>
#include <gtk/gtkcssstylesheet.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktypes.h>
G_BEGIN_DECLS
@@ -832,21 +833,18 @@ GDK_AVAILABLE_IN_ALL
GType gtk_style_context_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
void gtk_style_context_add_provider_for_display (GdkDisplay *display,
GtkStyleProvider *provider,
guint priority);
void gtk_style_context_add_style_sheet_for_display (GdkDisplay *display,
GtkCssStyleSheet *stylesheet);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_remove_provider_for_display (GdkDisplay *display,
GtkStyleProvider *provider);
void gtk_style_context_remove_style_sheet_for_display (GdkDisplay *display,
GtkCssStyleSheet *stylesheet);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_add_provider (GtkStyleContext *context,
GtkStyleProvider *provider,
guint priority);
void gtk_style_context_add_style_sheet (GtkStyleContext *context,
GtkCssStyleSheet *stylesheet);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_remove_provider (GtkStyleContext *context,
GtkStyleProvider *provider);
void gtk_style_context_remove_style_sheet (GtkStyleContext *context,
GtkCssStyleSheet *stylesheet);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_save (GtkStyleContext *context);
@@ -859,12 +857,6 @@ void gtk_style_context_set_state (GtkStyleContext *context,
GDK_AVAILABLE_IN_ALL
GtkStateFlags gtk_style_context_get_state (GtkStyleContext *context);
GDK_AVAILABLE_IN_ALL
void gtk_style_context_set_scale (GtkStyleContext *context,
gint scale);
GDK_AVAILABLE_IN_ALL
gint gtk_style_context_get_scale (GtkStyleContext *context);
GDK_AVAILABLE_IN_ALL
GList * gtk_style_context_list_classes (GtkStyleContext *context);

View File

@@ -19,7 +19,7 @@
#include "gtkstylepropertyprivate.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtkcssparserprivate.h"
#include "gtkcssshorthandpropertyprivate.h"
#include "gtkcssstylepropertyprivate.h"

View File

@@ -29,7 +29,7 @@
* @See_also: #GtkStyleContext, #GtkCssProvider
*
* GtkStyleProvider is an interface used to provide style information to a #GtkStyleContext.
* See gtk_style_context_add_provider() and gtk_style_context_add_provider_for_display().
* See gtk_style_context_add_style_sheet() and gtk_style_context_add_style_sheet_for_display().
*/
enum {
@@ -123,36 +123,6 @@ gtk_style_provider_changed (GtkStyleProvider *provider)
g_signal_emit (provider, signals[CHANGED], 0);
}
GtkSettings *
gtk_style_provider_get_settings (GtkStyleProvider *provider)
{
GtkStyleProviderInterface *iface;
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
iface = GTK_STYLE_PROVIDER_GET_INTERFACE (provider);
if (!iface->get_settings)
return NULL;
return iface->get_settings (provider);
}
int
gtk_style_provider_get_scale (GtkStyleProvider *provider)
{
GtkStyleProviderInterface *iface;
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), 1);
iface = GTK_STYLE_PROVIDER_GET_INTERFACE (provider);
if (!iface->get_scale)
return 1;
return iface->get_scale (provider);
}
void
gtk_style_provider_emit_error (GtkStyleProvider *provider,
GtkCssSection *section,

View File

@@ -38,10 +38,8 @@ struct _GtkStyleProviderInterface
GtkCssValue * (* get_color) (GtkStyleProvider *provider,
const char *name);
GtkSettings * (* get_settings) (GtkStyleProvider *provider);
GtkCssKeyframes * (* get_keyframes) (GtkStyleProvider *provider,
const char *name);
int (* get_scale) (GtkStyleProvider *provider);
void (* lookup) (GtkStyleProvider *provider,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,
@@ -54,12 +52,10 @@ struct _GtkStyleProviderInterface
void (* changed) (GtkStyleProvider *provider);
};
GtkSettings * gtk_style_provider_get_settings (GtkStyleProvider *provider);
GtkCssValue * gtk_style_provider_get_color (GtkStyleProvider *provider,
const char *name);
GtkCssKeyframes * gtk_style_provider_get_keyframes (GtkStyleProvider *provider,
const char *name);
int gtk_style_provider_get_scale (GtkStyleProvider *provider);
void gtk_style_provider_lookup (GtkStyleProvider *provider,
const GtkCountingBloomFilter *filter,
GtkCssNode *node,

View File

@@ -3556,9 +3556,7 @@ gtk_widget_realize (GtkWidget *widget)
gtk_widget_update_alpha (widget);
if (priv->context)
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
else
if (!priv->context)
gtk_widget_get_style_context (widget);
gtk_widget_pop_verify_invariants (widget);
@@ -6847,17 +6845,10 @@ gtk_widget_get_child_visible (GtkWidget *widget)
void
_gtk_widget_scale_changed (GtkWidget *widget)
{
GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
g_return_if_fail (GTK_IS_WIDGET (widget));
if (priv->context)
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_SCALE_FACTOR]);
gtk_widget_queue_draw (widget);
gtk_widget_forall (widget, (GtkCallback)_gtk_widget_scale_changed, NULL);
}
@@ -11240,8 +11231,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
priv->context = gtk_style_context_new_for_node (priv->cssnode);
gtk_style_context_set_scale (priv->context, gtk_widget_get_scale_factor (widget));
display = _gtk_widget_get_display (widget);
if (display)
gtk_style_context_set_display (priv->context, display);

View File

@@ -5216,7 +5216,10 @@ check_scale_changed (GtkWindow *window)
old_scale = priv->scale;
priv->scale = gtk_widget_get_scale_factor (widget);
if (old_scale != priv->scale)
_gtk_widget_scale_changed (widget);
{
gtk_css_node_invalidate (gtk_widget_get_css_node (widget), GTK_CSS_CHANGE_ROOT);
_gtk_widget_scale_changed (widget);
}
}
static void

View File

@@ -26,7 +26,7 @@
#include "window.h"
#include "css-editor.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtkstyleprovider.h"
#include "gtkstylecontext.h"
#include "gtktextview.h"
@@ -44,7 +44,7 @@ struct _GtkInspectorCssEditorPrivate
GtkWidget *view;
GtkTextBuffer *text;
GdkDisplay *display;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
GtkToggleButton *disable_button;
guint timeout;
GList *errors;
@@ -163,12 +163,9 @@ disable_toggled (GtkToggleButton *button,
return;
if (gtk_toggle_button_get_active (button))
gtk_style_context_remove_provider_for_display (ce->priv->display,
GTK_STYLE_PROVIDER (ce->priv->provider));
gtk_style_context_remove_style_sheet_for_display (ce->priv->display, ce->priv->stylesheet);
else
gtk_style_context_add_provider_for_display (ce->priv->display,
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_style_context_add_style_sheet_for_display (ce->priv->display, ce->priv->stylesheet);
}
static gchar *
@@ -259,7 +256,7 @@ update_style (GtkInspectorCssEditor *ce)
ce->priv->errors = NULL;
text = get_current_text (ce->priv->text);
gtk_css_provider_load_from_data (ce->priv->provider, text, -1);
gtk_css_style_sheet_load_from_data (ce->priv->stylesheet, text, -1);
g_free (text);
}
@@ -290,7 +287,7 @@ text_changed (GtkTextBuffer *buffer,
}
static void
show_parsing_error (GtkCssProvider *provider,
show_parsing_error (GtkCssStyleSheet *stylesheet,
GtkCssSection *section,
const GError *error,
GtkInspectorCssEditor *ce)
@@ -330,8 +327,9 @@ show_parsing_error (GtkCssProvider *provider,
static void
create_provider (GtkInspectorCssEditor *ce)
{
ce->priv->provider = gtk_css_provider_new ();
g_signal_connect (ce->priv->provider, "parsing-error",
ce->priv->stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (ce->priv->stylesheet, GTK_STYLE_PROVIDER_PRIORITY_USER);
g_signal_connect (ce->priv->stylesheet, "parsing-error",
G_CALLBACK (show_parsing_error), ce);
}
@@ -339,25 +337,23 @@ create_provider (GtkInspectorCssEditor *ce)
static void
destroy_provider (GtkInspectorCssEditor *ce)
{
g_signal_handlers_disconnect_by_func (ce->priv->provider, show_parsing_error, ce);
g_clear_object (&ce->priv->provider);
g_signal_handlers_disconnect_by_func (ce->priv->stylesheet, show_parsing_error, ce);
g_clear_object (&ce->priv->stylesheet);
}
static void
add_provider (GtkInspectorCssEditor *ce,
GdkDisplay *display)
{
gtk_style_context_add_provider_for_display (display,
GTK_STYLE_PROVIDER (ce->priv->provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_style_context_add_style_sheet_for_display (display, ce->priv->stylesheet);
}
static void
remove_provider (GtkInspectorCssEditor *ce,
GdkDisplay *display)
{
gtk_style_context_remove_provider_for_display (display,
GTK_STYLE_PROVIDER (ce->priv->provider));
gtk_style_context_remove_style_sheet_for_display (display,
ce->priv->stylesheet);
}
static void

View File

@@ -31,7 +31,7 @@
#include "gtklabel.h"
#include "gtkpopover.h"
#include "gtk/gtkwidgetprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkcssstylesheetprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkcssstyleprivate.h"
#include "gtkcssvalueprivate.h"

View File

@@ -46,7 +46,7 @@
#include "window.h"
#include "gtkmagnifierprivate.h"
#include "gtkcssproviderprivate.h"
#include "gtkcssstylesheetprivate.h"
#include "gtkmodulesprivate.h"
@@ -98,7 +98,7 @@ gtk_inspector_init (void)
g_io_module_scope_free (scope);
}
gtk_css_provider_set_keep_css_sections ();
gtk_css_style_sheet_set_keep_css_sections ();
}
// vim: set et sw=2 ts=2:

View File

@@ -30,7 +30,7 @@
#include "gtkadjustment.h"
#include "gtkbox.h"
#include "gtkcomboboxtext.h"
#include "gtkcssproviderprivate.h"
#include "gtkcssstylesheetprivate.h"
#include "gtkdebug.h"
#include "gtkprivate.h"
#include "gtksettings.h"
@@ -532,7 +532,7 @@ init_theme (GtkInspectorVisual *vis)
}
g_strfreev (builtin_themes);
path = _gtk_get_theme_dir ();
path = gtk_get_theme_dir ();
fill_gtk (path, t);
g_free (path);

View File

@@ -58,7 +58,7 @@
#include "gtkwindowgroup.h"
#include "gtkrevealer.h"
#include "gtklayoutmanager.h"
#include "gtkcssprovider.h"
#include "gtkcssstylesheet.h"
#include "gtkstylecontext.h"
@@ -317,19 +317,18 @@ static void
gtk_inspector_window_realize (GtkWidget *widget)
{
GskRenderer *renderer;
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
GTK_WIDGET_CLASS (gtk_inspector_window_parent_class)->realize (widget);
renderer = gtk_native_get_renderer (GTK_NATIVE (widget));
gsk_renderer_set_debug_flags (renderer, 0);
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_resource (provider, "/org/gtk/libgtk/inspector/inspector.css");
gtk_style_context_add_provider_for_display (gtk_widget_get_display (widget),
GTK_STYLE_PROVIDER (provider),
800);
g_object_unref (provider);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_set_priority (stylesheet, 800);
gtk_css_style_sheet_load_from_resource (stylesheet, "/org/gtk/libgtk/inspector/inspector.css");
gtk_style_context_add_style_sheet_for_display (gtk_widget_get_display (widget), stylesheet);
g_object_unref (stylesheet);
}
static void

View File

@@ -205,7 +205,7 @@ gtk_public_sources = files([
'gtkconstraintlayout.c',
'gtkconstraint.c',
'gtkcontainer.c',
'gtkcssprovider.c',
'gtkcssstylesheet.c',
'gtkdialog.c',
'gtkdragdest.c',
'gtkdragicon.c',
@@ -452,7 +452,7 @@ gtk_public_headers = files([
'gtkconstraintlayout.h',
'gtkconstraint.h',
'gtkcontainer.h',
'gtkcssprovider.h',
'gtkcssstylesheet.h',
'gtkcustomlayout.h',
'gtkdebug.h',
'gtkdialog.h',

View File

@@ -60,14 +60,12 @@ preview_file (const char *filename,
if (cssfile)
{
GtkCssProvider *provider;
GtkCssStyleSheet *stylesheet;
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, cssfile);
stylesheet = gtk_css_style_sheet_new ();
gtk_css_style_sheet_load_from_path (stylesheet, cssfile);
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_style_context_add_style_sheet_for_display (gdk_display_get_default (), stylesheet);
}
builder = gtk_builder_new ();

View File

@@ -115,7 +115,7 @@ gtk/gtkconstraint.c
gtk/gtkcontainer.c
gtk/gtkcssiconthemevalue.c
gtk/gtkcssnode.c
gtk/gtkcssprovider.c
gtk/gtkcssstylesheet.c
gtk/gtkcssshorthandproperty.c
gtk/gtkcssstaticstyle.c
gtk/gtkcssstyleproperty.c

Some files were not shown because too many files have changed in this diff Show More