diff options
author | Arnaud Bonatti <arnaud.bonatti@gmail.com> | 2020-04-18 13:18:06 +0200 |
---|---|---|
committer | Arnaud Bonatti <arnaud.bonatti@gmail.com> | 2020-04-18 13:18:06 +0200 |
commit | 95b26ac974f4169aa391d1a68a37c71b44d325b4 (patch) | |
tree | 53e1c8de48c16f955e85486b5b6f2286c00c994b | |
parent | 6a4f788976c015927e6dcfea826d98694e9f8bd1 (diff) | |
download | gtk+-arnaudb/css-invalidation-failure.tar.gz |
Demo CSS cache invalidation failure.arnaudb/css-invalidation-failure
-rw-r--r-- | demos/widget-factory/data/themes/theme1/flag.svg | 90 | ||||
-rw-r--r-- | demos/widget-factory/data/themes/theme2/flag.svg | 25 | ||||
-rw-r--r-- | demos/widget-factory/widget-factory.c | 40 | ||||
-rw-r--r-- | demos/widget-factory/widget-factory.css | 6 | ||||
-rw-r--r-- | demos/widget-factory/widget-factory.gresource.xml | 6 | ||||
-rw-r--r-- | demos/widget-factory/widget-factory.ui | 20 |
6 files changed, 187 insertions, 0 deletions
diff --git a/demos/widget-factory/data/themes/theme1/flag.svg b/demos/widget-factory/data/themes/theme1/flag.svg new file mode 100644 index 0000000000..ceb16a307b --- /dev/null +++ b/demos/widget-factory/data/themes/theme1/flag.svg @@ -0,0 +1,90 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + version="1.1" + width="64" + height="64" + id="svg9373" + inkscape:version="0.48.4 r9939" + sodipodi:docname="flag.svg"> + <metadata + id="metadata9418"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs9416" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1600" + inkscape:window-height="834" + id="namedview9414" + showgrid="false" + inkscape:snap-nodes="false" + inkscape:snap-bbox="true" + inkscape:zoom="1" + inkscape:cx="37.101481" + inkscape:cy="14.748665" + inkscape:window-x="0" + inkscape:window-y="27" + inkscape:window-maximized="1" + inkscape:current-layer="svg9373"> + <inkscape:grid + type="xygrid" + id="grid9641" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <linearGradient + id="paint" + gradientUnits="userSpaceOnUse" + x1="14.5" + y1="99" + x2="119.5" + y2="99"> + <stop + offset="0" + style="stop-color:#DA1800" + id="stop9404" /> + <stop + offset="0.33" + style="stop-color:#B42D2D" + id="stop9406" /> + <stop + offset="0.66" + style="stop-color:#FA1818" + id="stop9408" /> + <stop + offset="1" + style="stop-color:#B42D2D" + id="stop9410" /> + </linearGradient> + <path + style="fill:#2e3436;fill-opacity:1;stroke-width:1;stroke-miterlimit:4" + d="M 8.086319,0.175024 17.084785,0 l 0,3.104056 L 58.104384,20.741065 17.040446,38.378074 16.99727,64 8,64 z" + id="path9621" + inkscape:connector-curvature="0" + sodipodi:nodetypes="cccccccc" /> +</svg> diff --git a/demos/widget-factory/data/themes/theme2/flag.svg b/demos/widget-factory/data/themes/theme2/flag.svg new file mode 100644 index 0000000000..5d706a0191 --- /dev/null +++ b/demos/widget-factory/data/themes/theme2/flag.svg @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="161" height="161"> + <rect x="102.67" y="19" fill="#777777" stroke="#000000" stroke-width="3" width="36.67" height="8"/> + <rect x="98.67" y="60" fill="#777777" stroke="#000000" stroke-width="3" width="42.31" height="8"/> + <rect x="94.67" y="99" fill="#777777" stroke="#000000" stroke-width="3" width="50.9" height="8"/> + <polygon fill="#404040" points="151.64,126.87 144.6,126.87 132.03,27.19 139.07,27.19"/> + <polygon fill="#777777" points="148.1,127.17 144.6,126.87 132.03,27.19 135.53,27.48"/> + <polygon fill="none" stroke="#000000" stroke-width="3" points="151.64,126.87 144.6,126.87 132.03,27.19 139.07,27.19"/> + <polygon fill="#404040" points="90.86,126.87 97.9,126.87 110.47,27.19 103.43,27.19"/> + <polygon fill="#777777" points="90.86,126.87 94.9,126.87 107.47,27.19 103.43,27.19"/> + <polygon fill="none" stroke="#000000" stroke-width="3" points="90.86,126.87 97.9,126.87 110.47,27.19 103.43,27.19"/> + <path fill="#404040" stroke="#404040" d="M154.18,121.94h-5.24c0,0,0.98,24.81-4.89,24.81c-5.87,0-44.99,0-50.86,0c-4.33,0-4.93-13.47-4.95-20.56c-0.02,8.28,0.51,25.81,5.38,25.81c6.38,0,48.87,0,55.24,0C155.25,152,154.18,121.94,154.18,121.94z"/> + <path fill="#777777" stroke="#777777" d="M93.2,146.75c5.87,0,44.99,0,50.86,0c5.87,0,4.89-24.81,4.89-24.81H88.32h-0.01c0,0-0.07,1.72-0.06,4.25C88.27,133.27,88.88,146.75,93.2,146.75z"/> + <path fill="none" stroke="#000000" stroke-width="3.5" d="M93.63,152c6.38,0,48.87,0,55.24,0c6.37,0,5.31-30.06,5.31-30.06H88.32C88.32,121.94,87.25,152,93.63,152z"/> + <rect x="118.5" y="23" fill="#777777" stroke="#000000" stroke-width="2" width="7" height="80"/> + <path fill="#FFFFFF" d="M91.57,137.06c-1.31-13.13-1.31-13.43,24.89-11.81C91.57,127.16,93.48,125.55,91.57,137.06z"/> + <linearGradient id="paint" gradientUnits="userSpaceOnUse" x1="14.5" y1="99" x2="119.5" y2="99"> + <stop offset="0" style="stop-color:#DA1800"/> + <stop offset="0.33" style="stop-color:#B42D2D"/> + <stop offset="0.66" style="stop-color:#FA1818"/> + <stop offset="1" style="stop-color:#B42D2D"/> + </linearGradient> + <path fill="url(#paint)" stroke="#000000" stroke-width="6" d="M67.35,13.97c-13.99,13.43-51.85,0-51.85,0V60.6v47.93c0,0,37.86,13.43,51.85,0c14-13.43,53.15,0,53.15,0V60.6V13.97C120.5,13.97,81.35,0.54,67.35,13.97z"/> +</svg> diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 8752760c88..38220f3d64 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -1689,6 +1689,43 @@ set_up_context_popover (GtkWidget *widget, } static void +cache_invalidation_test_first_init () +{ + GdkDisplay *display; + GtkIconTheme *icon_theme; + + display = gdk_display_get_default (); + icon_theme = gtk_icon_theme_get_for_display (display); + + gtk_icon_theme_add_resource_path (icon_theme, "/org/gtk/WidgetFactory4/theme1"); +} + +static void +on_cache_invalidation_test_toggled (GtkToggleButton *button, + gpointer user_data) +{ + GdkDisplay *display; + GtkIconTheme *icon_theme; + char ***icon_resource_path; + guint length; + char **theme_path; + + display = gdk_display_get_default (); + icon_theme = gtk_icon_theme_get_for_display (display); + icon_resource_path = gtk_icon_theme_get_resource_path (icon_theme); + length = g_strv_length (icon_resource_path); + theme_path = icon_resource_path [length - 1]; + + if (g_strcmp0 (theme_path, "/org/gtk/WidgetFactory4/theme2") == 0) + theme_path = "/org/gtk/WidgetFactory4/theme1"; + else + theme_path = "/org/gtk/WidgetFactory4/theme2"; + + icon_resource_path[length - 1] = theme_path; + gtk_icon_theme_set_resource_path (icon_theme, icon_resource_path); +} + +static void activate (GApplication *app) { GtkBuilder *builder; @@ -1752,9 +1789,12 @@ activate (GApplication *app) GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); g_object_unref (provider); + cache_invalidation_test_first_init (); + builder = gtk_builder_new (); scope = gtk_builder_cscope_new (); gtk_builder_cscope_add_callback_symbols (GTK_BUILDER_CSCOPE (scope), + "on_cache_invalidation_test_toggled", (GCallback)on_cache_invalidation_test_toggled, "on_entry_icon_release", (GCallback)on_entry_icon_release, "on_scale_button_value_changed", (GCallback)on_scale_button_value_changed, "on_record_button_toggled", (GCallback)on_record_button_toggled, diff --git a/demos/widget-factory/widget-factory.css b/demos/widget-factory/widget-factory.css index 1674f189ac..80ef6437b4 100644 --- a/demos/widget-factory/widget-factory.css +++ b/demos/widget-factory/widget-factory.css @@ -24,3 +24,9 @@ .border-ridge { border-width: 2px; } + +.cache-invalidation-test { + background-repeat:no-repeat; + background-image:-gtk-icontheme('flag'); + background-position:center center; +} diff --git a/demos/widget-factory/widget-factory.gresource.xml b/demos/widget-factory/widget-factory.gresource.xml index 39d665da06..64f4de2609 100644 --- a/demos/widget-factory/widget-factory.gresource.xml +++ b/demos/widget-factory/widget-factory.gresource.xml @@ -6,6 +6,12 @@ <gresource prefix="/org/gtk/WidgetFactory4"> <file>widget-factory.css</file> </gresource> + <gresource prefix="/org/gtk/WidgetFactory4/theme1"> + <file alias="flag.svg">data/themes/theme1/flag.svg</file> + </gresource> + <gresource prefix="/org/gtk/WidgetFactory4/theme2"> + <file alias="flag.svg">data/themes/theme2/flag.svg</file> + </gresource> <gresource prefix="/org/gtk/WidgetFactory4/gtk"> <file preprocess="xml-stripblanks">help-overlay.ui</file> </gresource> diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index 9060c816ce..4551e0810e 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -879,6 +879,26 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property> <property name="halign">center</property> </object> </child> + <child> + <object class="GtkBox"> + <child> + <object class="GtkToggleButton" id="cache_invalidation_test"> + <property name="label">Test</property> + <property name="halign">fill</property> + <property name="hexpand">True</property> + <signal name="toggled" handler="on_cache_invalidation_test_toggled" swapped="no"/> + </object> + </child> + <child> + <object class="GtkButton"> + <property name="halign">end</property> + <style> + <class name="cache-invalidation-test"/> + </style> + </object> + </child> + </object> + </child> </object> </child> <child> |