Commit 1f2cfb56 authored by Cosimo Cecchi's avatar Cosimo Cecchi

all: add an 'only-child' pseudo-class selector

Add an :only-child pseudo-class selector, which selects single children
of a parent container.

https://bugzilla.gnome.org/show_bug.cgi?id=660833
parent 3a6996ea
......@@ -1987,6 +1987,7 @@ parse_selector_pseudo_class (GtkCssScanner *scanner,
} pseudo_classes[] = {
{ "first-child", GTK_REGION_FIRST, 0 },
{ "last-child", GTK_REGION_LAST, 0 },
{ "only-child", GTK_REGION_ONLY, 0 },
{ "sorted", GTK_REGION_SORTED, 0 },
{ "active", 0, GTK_STATE_FLAG_ACTIVE },
{ "prelight", 0, GTK_STATE_FLAG_PRELIGHT },
......
......@@ -130,6 +130,7 @@ _gtk_css_selector_print (const GtkCssSelector *selector,
"nth-child(odd)",
"first-child",
"last-child",
"only-child",
"sorted"
};
guint i;
......@@ -201,6 +202,8 @@ compute_region_flags_for_index (const GtkWidgetPath *path,
flags |= GTK_REGION_FIRST;
if (sibling_id + 1 == n_siblings)
flags |= GTK_REGION_LAST;
if (n_siblings == 1)
flags |= GTK_REGION_ONLY;
return flags;
}
......
......@@ -862,6 +862,7 @@ typedef enum
* @GTK_REGION_ODD: Region has an odd number within a set.
* @GTK_REGION_FIRST: Region is the first one within a set.
* @GTK_REGION_LAST: Region is the last one within a set.
* @GTK_REGION_ONLY: Region is the only one within a set.
* @GTK_REGION_SORTED: Region is part of a sorted area.
*
* Describes a region within a widget.
......@@ -871,6 +872,7 @@ typedef enum {
GTK_REGION_ODD = 1 << 1,
GTK_REGION_FIRST = 1 << 2,
GTK_REGION_LAST = 1 << 3,
GTK_REGION_ONLY = 1 << 4,
GTK_REGION_SORTED = 1 << 5
} GtkRegionFlags;
......
......@@ -357,6 +357,7 @@ gtk_widget_path_to_string (const GtkWidgetPath *path)
"odd",
"first",
"last",
"only",
"sorted"
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment