gtk-css-engine r174 - in trunk: . conf src



Author: robsta
Date: Tue Oct 28 19:23:01 2008
New Revision: 174
URL: http://svn.gnome.org/viewvc/gtk-css-engine?rev=174&view=rev

Log:
* conf/user-agent.css: inherit trough for scales and scroll-bars.

* src/gce-maps.c (get_stepper), (gce_maps_match_role):
* src/gce-maps.h:
Role matching function, not used yet.



Modified:
   trunk/ChangeLog
   trunk/conf/user-agent.css
   trunk/src/gce-maps.c
   trunk/src/gce-maps.h

Modified: trunk/conf/user-agent.css
==============================================================================
--- trunk/conf/user-agent.css	(original)
+++ trunk/conf/user-agent.css	Tue Oct 28 19:23:01 2008
@@ -100,7 +100,15 @@
 	border-top-right-radius: inherit;
 }
 
-GtkHScrollbar > box.trough {
+GtkHScale > box {
+	background: inherit;
+	border-top: inherit;
+	border-bottom: inherit;
+}
+
+/* The steppers would fit this rule as well, but they are overridden by a 
+ * custom match. */
+GtkHScrollbar > box {
 	background: inherit;
 	border-top: inherit;
 	border-bottom: inherit;
@@ -237,7 +245,15 @@
 	border-radius: inherit;
 }
 
-GtkVScrollbar > box.trough {
+GtkVScale > box {
+	background: inherit;
+	border-top: inherit;
+	border-bottom: inherit;
+}
+
+/* The steppers would fit this rule as well, but they are overridden by a 
+ * custom match. */
+GtkVScrollbar > box {
 	background: inherit;
 	border-left: inherit;
 	border-right: inherit;

Modified: trunk/src/gce-maps.c
==============================================================================
--- trunk/src/gce-maps.c	(original)
+++ trunk/src/gce-maps.c	Tue Oct 28 19:23:01 2008
@@ -1,6 +1,10 @@
 /* The CSS Theme Engine for Gtk+.
  * Copyright (C) 2008 Robert Staudinger
  *
+ * get_stepper() is from the Clearlooks theme engine,
+ * Copyright (C) 2005 Richard Stellingwerff
+ * Copyright (C) 2007 Benjamin Berg
+ *
  * This  library is free  software; you can  redistribute it and/or
  * modify it  under  the terms  of the  GNU Lesser  General  Public
  * License  as published  by the Free  Software  Foundation; either
@@ -20,6 +24,155 @@
 #include <string.h>
 #include "gce-maps.h"
 
+typedef char const * (*match_rectangle_f) (GtkWidget *, GdkRectangle *);
+
+static char const *
+get_stepper (GtkWidget		*widget,
+	     GdkRectangle	*stepper)
+{
+	GdkRectangle tmp;
+	GdkRectangle check_rectangle;
+	GtkOrientation orientation;
+
+	if (!GTK_IS_RANGE (widget))
+		return NULL;
+
+	check_rectangle.x      = widget->allocation.x;
+	check_rectangle.y      = widget->allocation.y;
+	check_rectangle.width  = stepper->width;
+	check_rectangle.height = stepper->height;
+	
+	orientation = GTK_RANGE (widget)->orientation;
+	
+	if (widget->allocation.x == -1 && widget->allocation.y == -1)
+		return NULL;
+		
+	if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+		return "gtk-stepper-up";
+
+	/* Haven't found a match */
+	if (orientation == GTK_ORIENTATION_HORIZONTAL)
+		check_rectangle.x = widget->allocation.x + stepper->width;
+	else
+		check_rectangle.y = widget->allocation.y + stepper->height;
+	
+	if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+		return "gtk-secondary-stepper-down";
+
+	/* Haven't found a match */
+	if (orientation == GTK_ORIENTATION_HORIZONTAL)
+		check_rectangle.x = widget->allocation.x + widget->allocation.width - (stepper->width * 2);
+	else
+		check_rectangle.y = widget->allocation.y + widget->allocation.height - (stepper->height * 2);
+	
+	if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+		return "gtk-secondary-stepper-up";
+
+	/* Haven't found a match */
+	if (orientation == GTK_ORIENTATION_HORIZONTAL)
+		check_rectangle.x = widget->allocation.x + widget->allocation.width - stepper->width;
+	else
+		check_rectangle.y = widget->allocation.y + widget->allocation.height - stepper->height;
+	
+	if (gdk_rectangle_intersect (stepper, &check_rectangle, &tmp))
+		return "gtk-stepper-down";
+	
+	/* Haven't found a match */
+	return NULL;
+}
+
+static char const *_gtk_icon_view__focus__details[] = { "iconview-drop-indicator", NULL };
+
+static char const *_gtk_tree_view__focus__details[] = { "treeview-drop-indicator", 
+							"treeview-drop-indicator-left",
+							"treeview-drop-indicator-right",
+							"tree-view-drop-indicator-middle", NULL };
+
+static const struct {
+	char const		 *type;
+	char const		 *primitive;
+	char const		 *role;
+	int			  shadow;
+	match_rectangle_f	  match_rectangle;
+	char const		**details;
+} _widgets[] = {
+  { "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 }
+};
+
+char const *
+gce_maps_match_role (GtkWidget		*widget,
+		     char const		*primitive,
+		     GtkShadowType	 shadow_type,
+		     char const		*detail,
+		     gint		 x,
+		     gint		 y,
+		     gint		 width,
+		     gint		 height)
+{
+	char const	*type;
+	int		 shadow;
+	gboolean	 had_match;
+
+	g_return_val_if_fail (widget, NULL);
+
+	type = G_OBJECT_CLASS_NAME (widget);
+	shadow = shadow_type;
+
+	had_match = FALSE;
+	for (unsigned int i = 0; i < G_N_ELEMENTS (_widgets); i++) {
+		if (0 == g_strcmp0 (type, _widgets[i].type)) {
+			had_match = TRUE;
+			if (0 == g_strcmp0 (primitive, _widgets[i].primitive)) {
+				if (_widgets[i].shadow > -1) {
+					/* Match by shadow. */
+					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]))
+							return _widgets[i].role;
+					}
+					return NULL;
+				} else {
+					/* No further match. */
+					return _widgets[i].role;
+				}
+			}
+			continue;
+		} else if (had_match) {
+			break;
+		}
+	}
+
+	return NULL;
+}
+
 /**
  * Map between detail strings in gtk and css format.
  */

Modified: trunk/src/gce-maps.h
==============================================================================
--- trunk/src/gce-maps.h	(original)
+++ trunk/src/gce-maps.h	Tue Oct 28 19:23:01 2008
@@ -25,6 +25,16 @@
 
 G_BEGIN_DECLS
 
+char const *
+gce_maps_match_role (GtkWidget		*widget,
+		     char const		*primitive,
+		     GtkShadowType	 shadow_type,
+		     char const		*detail,
+		     gint		 x,
+		     gint		 y,
+		     gint		 width,
+		     gint		 height);
+
 char const *		gce_maps_match_detail		(char const *gce_detail);
 char const *		gce_maps_get_detail		(char const *gtk_detail);
 



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