[gtk+] all: add an 'only-child' pseudo-class selector
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] all: add an 'only-child' pseudo-class selector
- Date: Tue, 4 Oct 2011 15:48:41 +0000 (UTC)
commit 1f2cfb5619f0d7b1838e54c58738bae766d74c0b
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Oct 3 17:09:09 2011 -0400
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
gtk/gtkcssprovider.c | 1 +
gtk/gtkcssselector.c | 3 +++
gtk/gtkenums.h | 2 ++
gtk/gtkwidgetpath.c | 1 +
4 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c
index a905f1a..bd01915 100644
--- a/gtk/gtkcssprovider.c
+++ b/gtk/gtkcssprovider.c
@@ -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 },
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c
index d300d41..2abe092 100644
--- a/gtk/gtkcssselector.c
+++ b/gtk/gtkcssselector.c
@@ -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;
}
diff --git a/gtk/gtkenums.h b/gtk/gtkenums.h
index a2428ab..dbc0e90 100644
--- a/gtk/gtkenums.h
+++ b/gtk/gtkenums.h
@@ -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;
diff --git a/gtk/gtkwidgetpath.c b/gtk/gtkwidgetpath.c
index d0be6de..a694f7b 100644
--- a/gtk/gtkwidgetpath.c
+++ b/gtk/gtkwidgetpath.c
@@ -357,6 +357,7 @@ gtk_widget_path_to_string (const GtkWidgetPath *path)
"odd",
"first",
"last",
+ "only",
"sorted"
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]