[gtk/wip/otte/css: 296/307] testgtk: Use global css provider
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/css: 296/307] testgtk: Use global css provider
- Date: Tue, 18 Feb 2020 20:04:47 +0000 (UTC)
commit 252234f55f6f35c36759498865ffabd1aa7eba50
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 8 03:59:55 2020 +0100
testgtk: Use global css provider
tests/testgtk.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 3d4c32bf1c..937ef6d00b 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -187,26 +187,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));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]