summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-12-03 07:55:57 -0500
committerMatthias Clasen <mclasen@redhat.com>2015-12-03 07:55:57 -0500
commit36d5d29af6e866f1a6dd43ef9b6e50381ca48a10 (patch)
treea4cc418dc369884634c4ce95a5cdeaf7b9601f8f /tests
parent234c4974745e00e1049e34e4bcad77c0bfa3e5a9 (diff)
downloadgtk+-36d5d29af6e866f1a6dd43ef9b6e50381ca48a10.tar.gz
Simplify foreign drawing example a bit
Diffstat (limited to 'tests')
-rw-r--r--tests/foreigndrawing.c30
1 files changed, 9 insertions, 21 deletions
diff --git a/tests/foreigndrawing.c b/tests/foreigndrawing.c
index 3b9d9bdfba..c4efc5025e 100644
--- a/tests/foreigndrawing.c
+++ b/tests/foreigndrawing.c
@@ -66,24 +66,16 @@ draw_horizontal_scrollbar (GtkWidget *widget,
GtkStyleContext *trough_context;
GtkStyleContext *slider_context;
- PathElt scrollbar_path[1] = {
- { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", NULL },
- };
-
- PathElt trough_path[2] = {
- { GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", NULL },
- { G_TYPE_NONE, "trough", NULL, NULL }
- };
-
- PathElt slider_path[3] = {
+ /* This information is taken from the GtkScrollbar docs, see "CSS nodes" */
+ PathElt path[3] = {
{ GTK_TYPE_SCROLLBAR, "scrollbar", "horizontal", NULL },
{ G_TYPE_NONE, "trough", NULL, NULL },
{ G_TYPE_NONE, "slider", NULL, NULL }
};
- scrollbar_context = get_style (scrollbar_path, G_N_ELEMENTS (scrollbar_path));
- trough_context = get_style (trough_path, G_N_ELEMENTS (trough_path));
- slider_context = get_style (slider_path, G_N_ELEMENTS (slider_path));
+ 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);
@@ -115,22 +107,18 @@ draw_text (GtkWidget *widget,
GtkStyleContext *context;
PangoLayout *layout;
- PathElt label_path[1] = {
- { GTK_TYPE_LABEL, "label", "view", NULL },
- };
-
- PathElt selection_path[2] = {
+ /* This information is taken from the GtkLabel docs, see "CSS nodes" */
+ PathElt path[2] = {
{ GTK_TYPE_LABEL, "label", "view", NULL },
{ G_TYPE_NONE, "selection", NULL, NULL }
};
- label_context = get_style (label_path, G_N_ELEMENTS (label_path));
- selection_context = get_style (selection_path, G_N_ELEMENTS (selection_path));
+ label_context = get_style (path, 1);
+ selection_context = get_style (path, 2);
gtk_style_context_set_parent (selection_context, label_context);
gtk_style_context_set_state (label_context, state);
-
if (state & GTK_STATE_FLAG_SELECTED)
context = selection_context;
else