[gtk-css-engine] [style] Introduce 'gtk-trough' pseudo widget.



commit 652a5139c05b387c28e398e811fa3b55aff39aa3
Author: Robert Staudinger <robsta gnome org>
Date:   Tue Jun 23 11:54:50 2009 +0200

    [style] Introduce 'gtk-trough' pseudo widget.

 src/gce-maps.c                    |   64 +++++++++++++++++++++----------------
 src/gce-style.c                   |   11 ++++++
 themes/moblesse/gtk-2.0/gtkrc.css |   18 ++++++-----
 3 files changed, 57 insertions(+), 36 deletions(-)
---
diff --git a/src/gce-maps.c b/src/gce-maps.c
index 0f615c7..977b057 100644
--- a/src/gce-maps.c
+++ b/src/gce-maps.c
@@ -84,6 +84,8 @@ get_stepper (GtkWidget		*widget,
 	return NULL;
 }
 
+static char const *_trough_detail[] = { "trough", NULL };
+
 static char const *_gtk_icon_view__focus__details[] = { "iconview-drop-indicator", NULL };
 
 static char const *_gtk_tree_view__focus__details[] = { "treeview-drop-indicator", 
@@ -92,35 +94,41 @@ static char const *_gtk_tree_view__focus__details[] = { "treeview-drop-indicator
 							"tree-view-drop-indicator-middle", NULL };
 
 static const struct {
+	char const		 *role;
 	char const		 *type_name;
 	char const		 *primitive;
-	char const		 *role;
 	int			  shadow;
-	match_rectangle_f	  match_rectangle;
 	char const		**details;
+	match_rectangle_f	  match_rectangle;
 } _widgets[] = {
 /* TODO: add a new column that matches against parent widgets and use it for combo's dropdown button, treeview's header button etc.  */
-  { "GtkCalendar",		"shadow",	"gtk-header", 		GTK_SHADOW_OUT, NULL,		NULL },
-  { "GtkCellRendererToggle",	"check",	"gtk-check-mark",	-1,		NULL,		NULL },
-  { "GtkCellRendererToggle",	"option",	"gtk-radio-knob",	-1,		NULL,		NULL },
-  { "GtkCheckButton",		"check",	"gtk-check-mark",	-1,		NULL,		NULL },
-  { "GtkCheckMenuItem",		"check",	"gtk-check-mark",	-1,		NULL,		NULL },
-  { "GtkCheckMenuItem",		"option",	"gtk-radio-knob",	-1,		NULL,		NULL },
-  { "GtkExpander",		"expander",	"gtk-expander",		-1,		NULL,		NULL },
-  { "GtkHScale",		"slider",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkHScrollbar",		"box",		NULL,			-1,		get_stepper,	NULL },
-  { "GtkHScrollbar",		"slider",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkHandleBox",		"handle",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkIconView",		"focus",	"gtk-drop-indicator",	-1,		NULL, 		_gtk_icon_view__focus__details },
-  { "GtkNotebook",		"extension",	"gtk-tab",		-1,		NULL,		NULL },
-  { "GtkPaned",			"handle",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkRadioButton",		"option",	"gtk-radio-knob",	-1,		NULL,		NULL },
-  { "GtkStatusbar",		"resize-grip",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkTreeView",		"expander",	"gtk-expander",		-1,		NULL,		NULL },
-  { "GtkTreeView",		"focus",	"gtk-drop-indicator",	-1,		NULL,		_gtk_tree_view__focus__details },
-  { "GtkVScale",		"slider",	"gtk-handle",		-1,		NULL,		NULL },
-  { "GtkVScrollbar",		"box",		NULL,			-1,		get_stepper,	NULL },
-  { "GtkVScrollbar",		"slider",	"gtk-handle",		-1,		NULL,		NULL }
+  { "gtk-header",	"GtkCalendar",			"shadow",	GTK_SHADOW_OUT, NULL,		NULL },
+  { "gtk-check-mark",	"GtkCellRendererToggle",	"check",	-1,		NULL,		NULL },
+  { "gtk-radio-knob",	"GtkCellRendererToggle",	"option",	-1,		NULL,		NULL },
+  { "gtk-check-mark",	"GtkCheckButton",		"check",	-1,		NULL,		NULL },
+  { "gtk-check-mark",	"GtkCheckMenuItem",		"check",	-1,		NULL,		NULL },
+  { "gtk-radio-knob",	"GtkCheckMenuItem",		"option",	-1,		NULL,		NULL },
+  { "gtk-expander",	"GtkExpander",			"expander",	-1,		NULL,		NULL },
+  { "gtk-trough",	"GtkHScale",			"box",		-1,		_trough_detail,	NULL },
+  { "gtk-handle",	"GtkHScale",			"slider",	-1,		NULL,		NULL },
+  { "gtk-trough",	"GtkHScrollbar",		"box",		-1,		_trough_detail,	NULL },
+  { NULL,		"GtkHScrollbar",		"box",		-1,		NULL,		get_stepper },
+  { "gtk-handle",	"GtkHScrollbar",		"slider",	-1,		NULL,		NULL },
+  { "gtk-handle",	"GtkHandleBox",			"handle",	-1,		NULL,		NULL },
+  { "gtk-drop-indicator","GtkIconView",			"focus",	-1,		_gtk_icon_view__focus__details, NULL },
+  { "gtk-tab",		"GtkNotebook",			"extension",	-1,		NULL,		NULL },
+  { "gtk-handle",	"GtkPaned",			"handle",	-1,		NULL,		NULL },
+  { "gtk-trough",	"GtkProgressBar",		"box",		-1,		_trough_detail,	NULL },
+  { "gtk-trough",	"GtkProgressBar",		"flat-box",	-1,		_trough_detail,	NULL },
+  { "gtk-radio-knob",	"GtkRadioButton",		"option",	-1,		NULL,		NULL },
+  { "gtk-handle",	"GtkStatusbar",			"resize-grip",	-1,		NULL,		NULL },
+  { "gtk-expander",	"GtkTreeView",			"expander",	-1,		NULL,		NULL },
+  { "gtk-drop-indicator","GtkTreeView",			"focus",	-1,		_gtk_tree_view__focus__details, NULL },
+  { "gtk-trough",	"GtkVScale",			"box",		-1,		_trough_detail,	NULL },
+  { "gtk-handle",	"GtkVScale",			"slider",	-1,		NULL,		NULL },
+  { "gtk-trough",	"GtkVScrollbar",		"box",		-1,		_trough_detail,	NULL },
+  { NULL,		"GtkVScrollbar",		"box",		-1,		NULL,		get_stepper },
+  { "gtk-handle",	"GtkVScrollbar",		"slider",	-1,		NULL,		NULL }
 };
 
 char const *
@@ -153,17 +161,17 @@ gce_maps_match_role (GtkWidget		*widget,
 					if (_widgets[i].shadow == shadow)
 						return _widgets[i].role;
 					return NULL;
-				} else if (_widgets[i].match_rectangle) {
-					/* Match by function. */
-					GdkRectangle rect = { .x = x, .y = y, .width = width, .height = height };
-					return _widgets[i].match_rectangle (widget, &rect);
 				} else if (_widgets[i].details) {
 					/* Match by detail string. */
 					for (unsigned int j = 0; _widgets[i].details[j] != NULL; j++) {
-						if (0 == g_strcmp0 (primitive,  _widgets[i].details[j]))
+						if (0 == g_strcmp0 (detail,  _widgets[i].details[j]))
 							return _widgets[i].role;
 					}
 					return NULL;
+				} else if (_widgets[i].match_rectangle) {
+					/* Match by function. */
+					GdkRectangle rect = { .x = x, .y = y, .width = width, .height = height };
+					return _widgets[i].match_rectangle (widget, &rect);
 				} else {
 					/* No further match required. */
 					return _widgets[i].role;
diff --git a/src/gce-style.c b/src/gce-style.c
index 2336958..82f18ee 100644
--- a/src/gce-style.c
+++ b/src/gce-style.c
@@ -276,9 +276,20 @@ draw_box (GtkStyle		*self,
 	char const	*role;
 	GceNode		*node = NULL;
 
+if (GTK_IS_VSCROLLBAR (widget) &&
+    0 == g_strcmp0 ("trough", detail))
+	g_debug ("trough?");
+
 	role = gce_maps_match_role (widget, "box", shadow, detail, x, y, width, height);
 	detail = gce_maps_get_detail (detail);
 
+if (role)
+	g_debug ("%s() widget='%s' role='%s' detail='%s'",
+		 __FUNCTION__,
+		 G_OBJECT_TYPE_NAME (widget),
+		 role,
+		 detail);
+
 	if (widget)
 		node = gce_node_cache_fetch_node (widget, 
 			detail,
diff --git a/themes/moblesse/gtk-2.0/gtkrc.css b/themes/moblesse/gtk-2.0/gtkrc.css
index 3ffd430..c15ed98 100644
--- a/themes/moblesse/gtk-2.0/gtkrc.css
+++ b/themes/moblesse/gtk-2.0/gtkrc.css
@@ -25,10 +25,6 @@
 	color: gtk-mix(0.5, text_color, grey) ! important;
 }
 
-*.trough {
-	background: gtk-mix(0.5, bg_color, grey);
-}
-
 /*
  * Pseudo-widgets that are implemented by the CSS engine.
  */
@@ -75,6 +71,10 @@ gtk-tab {
 	border: 1px solid;
 }
 
+gtk-trough {
+	background: gtk-mix(0.5, bg_color, grey);
+}
+
 /*
  * Regular gtk widgets.
  */
@@ -94,6 +94,8 @@ GtkCalendar {
 	border: 1px solid;
 }
 
+/* FIXME: the calendar seems to invalidate a bigger area for the
+ * arrow than what is redrawn. */
 GtkCalendar > arrow {
 	background: gtk-mix(0.5, selected_bg_color, grey);
 }
@@ -126,17 +128,17 @@ GtkProgressBar > box.bar {
 	background: gtk-color(selected_bg_color);
 }
 
-GtkSpinButton > arrow[orientation=up] {
+GtkSpinButton > arrow {
 	background-position: center;
 	background-repeat: no-repeat;
 	background-size: 100%;
+}
+
+GtkSpinButton > arrow[orientation=up] {
 	background-image: url(arrow-up-small.png);
 }
 
 GtkSpinButton > arrow[orientation=down] {
-	background-position: center;
-	background-repeat: no-repeat;
-	background-size: 100%;
 	background-image: url(arrow-down-small.png);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]