[gtk+] tests: Make testiconview-keynav set its custom style using CSS.
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] tests: Make testiconview-keynav set its custom style using CSS.
- Date: Wed, 15 Dec 2010 13:52:52 +0000 (UTC)
commit cae6021d3a67d3ba90a9f3e1dc5f94ca9206625d
Author: Benjamin Otte <otte redhat com>
Date: Wed Dec 15 14:29:04 2010 +0100
tests: Make testiconview-keynav set its custom style using CSS.
tests/testiconview-keynav.c | 36 ++++++++++++++++++++----------------
1 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c
index 07e9479..002c003 100644
--- a/tests/testiconview-keynav.c
+++ b/tests/testiconview-keynav.c
@@ -209,20 +209,28 @@ focus_in (GtkWidget *view,
return FALSE;
}
+#define CSS \
+ "GtkWindow {\n" \
+ " background-color: @base_color;\n" \
+ "}\n"
+
static void
-header_style_set (GtkWidget *widget,
- GtkStyle *old_style)
+set_styles (void)
{
- GtkStyle *style;
+ GtkCssProvider *provider;
+ GdkScreen *screen;
+
+ provider = gtk_css_provider_new ();
+
+ if (!gtk_css_provider_load_from_data (provider, CSS, -1, NULL))
+ {
+ g_assert_not_reached ();
+ }
- style = gtk_widget_get_style (widget);
+ screen = gdk_display_get_default_screen (gdk_display_get_default ());
- g_signal_handlers_block_by_func (widget, header_style_set, NULL);
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL,
- &style->base[GTK_STATE_NORMAL]);
- gtk_widget_modify_fg (widget, GTK_STATE_NORMAL,
- &style->text[GTK_STATE_NORMAL]);
- g_signal_handlers_unblock_by_func (widget, header_style_set, NULL);
+ gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
int
@@ -234,6 +242,8 @@ main (int argc, char *argv[])
gtk_init (&argc, &argv);
+ set_styles ();
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
@@ -263,12 +273,6 @@ main (int argc, char *argv[])
G_CALLBACK (focus_in), NULL);
g_signal_connect (views.view2, "focus-out-event",
G_CALLBACK (focus_out), NULL);
- g_signal_connect (views.header1, "style-set",
- G_CALLBACK (header_style_set), NULL);
- g_signal_connect (views.header2, "style-set",
- G_CALLBACK (header_style_set), NULL);
- g_signal_connect (window, "style-set",
- G_CALLBACK (header_style_set), NULL);
gtk_container_add (GTK_CONTAINER (vbox), views.header1);
gtk_container_add (GTK_CONTAINER (vbox), views.view1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]