diff options
author | Benjamin Otte <otte@redhat.com> | 2015-12-03 14:40:32 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2015-12-03 14:43:56 +0100 |
commit | 52ba39ba73d55974b5a9f3eddc6bb90f0adc6ba0 (patch) | |
tree | 202fc41c3a2376c1444979cd91f33be684a5714a /tests | |
parent | ec5baa144d30b0affc0917cae022e02a42b82830 (diff) | |
download | gtk+-52ba39ba73d55974b5a9f3eddc6bb90f0adc6ba0.tar.gz |
tests: Rework some foreigndrawing code
Instead of specifying the full path everytime, just specify the parent
style context and then use its path.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/foreigndrawing.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/tests/foreigndrawing.c b/tests/foreigndrawing.c index c4efc5025e..2f0ade0243 100644 --- a/tests/foreigndrawing.c +++ b/tests/foreigndrawing.c @@ -26,27 +26,27 @@ typedef struct { } PathElt; static GtkStyleContext * -get_style (PathElt pelt[], gint n_elts) +get_style (PathElt *pelt, GtkStyleContext *parent) { GtkWidgetPath *path; - gint i; GtkStyleContext *context; - path = gtk_widget_path_new (); + if (parent) + path = gtk_widget_path_copy (gtk_style_context_get_path (parent)); + else + path = gtk_widget_path_new (); - for (i = 0; i < n_elts; i++) - { - gtk_widget_path_append_type (path, pelt[i].type); - if (pelt[i].name) - gtk_widget_path_iter_set_object_name (path, i, pelt[i].name); - if (pelt[i].class1) - gtk_widget_path_iter_add_class (path, i, pelt[i].class1); - if (pelt[i].class2) - gtk_widget_path_iter_add_class (path, i, pelt[i].class2); - } + gtk_widget_path_append_type (path, pelt->type); + if (pelt->name) + gtk_widget_path_iter_set_object_name (path, -1, pelt->name); + if (pelt->class1) + gtk_widget_path_iter_add_class (path, -1, pelt->class1); + if (pelt->class2) + gtk_widget_path_iter_add_class (path, -1, pelt->class2); context = gtk_style_context_new (); gtk_style_context_set_path (context, path); + gtk_style_context_set_parent (context, parent); gtk_widget_path_unref (path); return context; @@ -73,11 +73,9 @@ draw_horizontal_scrollbar (GtkWidget *widget, { G_TYPE_NONE, "slider", NULL, NULL } }; - scrollbar_context = get_style (path, 1); - trough_context = get_style (path, 2); - slider_context = get_style (path, 3); - gtk_style_context_set_parent (slider_context, trough_context); - gtk_style_context_set_parent (trough_context, scrollbar_context); + scrollbar_context = get_style (&path[0], NULL); + trough_context = get_style (&path[1], scrollbar_context); + slider_context = get_style (&path[2], trough_context); gtk_style_context_set_state (scrollbar_context, state); gtk_style_context_set_state (trough_context, state); @@ -113,9 +111,8 @@ draw_text (GtkWidget *widget, { G_TYPE_NONE, "selection", NULL, NULL } }; - label_context = get_style (path, 1); - selection_context = get_style (path, 2); - gtk_style_context_set_parent (selection_context, label_context); + label_context = get_style (&path[0], NULL); + selection_context = get_style (&path[1], label_context); gtk_style_context_set_state (label_context, state); |