summaryrefslogtreecommitdiff
path: root/tests/testgtk.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2020-02-08 03:59:55 +0100
committerMatthias Clasen <mclasen@redhat.com>2022-10-09 10:13:44 -0400
commit0db5c7f421d117021e78741400840c0cf497c0c5 (patch)
treea4efca93f21ad3754470a89e8974be55fb05054f /tests/testgtk.c
parented83272f35e77c0aeeb863c07a671e228e02c773 (diff)
downloadgtk+-0db5c7f421d117021e78741400840c0cf497c0c5.tar.gz
testgtk: Use global css provider
Diffstat (limited to 'tests/testgtk.c')
-rw-r--r--tests/testgtk.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 6de750e9b3..e7cebbc100 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -193,26 +193,30 @@ create_alpha_window (GtkWidget *widget)
if (!window)
{
+ static GtkCssProvider *provider = NULL;
GtkWidget *content_area;
GtkWidget *vbox;
GtkWidget *label;
GdkDisplay *display;
- GtkCssProvider *provider;
window = gtk_dialog_new_with_buttons ("Alpha Window",
GTK_WINDOW (gtk_widget_get_root (widget)), 0,
"_Close", 0,
NULL);
- provider = gtk_css_provider_new ();
- gtk_css_provider_load_from_data (provider,
- "dialog {\n"
- " background: radial-gradient(ellipse at center, #FFBF00, #FFBF0000);\n"
- "}\n",
- -1);
- gtk_style_context_add_provider (gtk_widget_get_style_context (window),
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
- g_object_unref (provider);
+ gtk_widget_add_css_class (window, "alpha");
+ if (provider == NULL)
+ {
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ "dialog.alpha {\n"
+ " background: radial-gradient(ellipse at center, #FFBF00, #FFBF0000);\n"
+ "}\n",
+ -1);
+ gtk_style_context_add_provider_for_display (gtk_widget_get_display (window),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+ }
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));