[gnome-themes-standard] toolbars: theme active items for primary toolbars like in new mockups



commit f597129dab2fd01391603cd8d8eb39bd6e58dee7
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Mar 14 16:03:15 2011 -0400

    toolbars: theme active items for primary toolbars like in new mockups

 src/adwaita_engine.c           |   92 +++++++++++++++++++++++++++++++++++++++-
 themes/Adwaita/gtk-3.0/gtk.css |   36 ++++++++++-----
 2 files changed, 114 insertions(+), 14 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index f490eef..f9c1c8d 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include <gmodule.h>
 #include <math.h>
+#include <cairo-gobject.h>
 
 #define ADWAITA_NAMESPACE "adwaita"
 
@@ -89,6 +90,32 @@ _cairo_round_rectangle (cairo_t *cr,
 	cairo_arc (cr, x+radius,   y+radius,   radius, G_PI, G_PI * 1.5);
 }
 
+/* Set the appropriate matrix for
+ * patterns coming from the style context
+ */
+static void
+style_pattern_set_matrix (cairo_pattern_t *pattern,
+                          gdouble          width,
+                          gdouble          height)
+{
+  cairo_matrix_t matrix;
+  gint w, h;
+
+  if (cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SURFACE)
+    {
+      cairo_surface_t *surface;
+
+      cairo_pattern_get_surface (pattern, &surface);
+      w = cairo_image_surface_get_width (surface);
+      h = cairo_image_surface_get_height (surface);
+    }
+  else
+    w = h = 1;
+
+  cairo_matrix_init_scale (&matrix, (gdouble) w / width, (gdouble) h / height);
+  cairo_pattern_set_matrix (pattern, &matrix);
+}
+
 static void
 adwaita_engine_render_arrow (GtkThemingEngine *engine,
 			     cairo_t	      *cr,
@@ -801,6 +828,63 @@ render_menubar_active_frame (GtkThemingEngine *engine,
 }
 
 static void
+render_frame_default (GtkThemingEngine *engine,
+		      cairo_t *cr,
+		      gdouble x,
+		      gdouble y,
+		      gdouble width,
+		      gdouble height)
+{
+	cairo_pattern_t *pattern = NULL;
+	GtkStateFlags state;
+	GtkBorder *border;
+	gint line_width, border_radius;
+	GtkBorderStyle border_style;
+
+	state = gtk_theming_engine_get_state (engine);
+
+	gtk_theming_engine_get (engine, state,
+				"-adwaita-border-gradient", &pattern,
+				"border-style", &border_style,
+				NULL);
+
+	if (pattern == NULL || border_style == GTK_BORDER_STYLE_NONE) {
+		GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame
+			(engine, cr,
+			 x, y, width, height);
+
+		return;
+	}
+
+	cairo_save (cr);
+
+	gtk_theming_engine_get (engine, state,
+				"border-radius", &border_radius,
+				"border-width", &border,
+				NULL);
+
+	line_width = MIN (MIN (border->top, border->bottom),
+			  MIN (border->left, border->right));
+	style_pattern_set_matrix (pattern, width, height);
+
+	cairo_set_line_width (cr, line_width);
+	_cairo_round_rectangle (cr,
+				x + line_width / 2.0,
+				y + line_width / 2.0,
+				width - line_width,
+				height - line_width,
+				border_radius);
+	cairo_set_source (cr, pattern);
+
+	cairo_stroke (cr);
+
+	cairo_restore (cr);
+
+	cairo_pattern_destroy (pattern);
+	gtk_border_free (border);
+}
+
+static void
 adwaita_engine_render_frame (GtkThemingEngine *engine,
 			     cairo_t          *cr,
 			     gdouble           x,
@@ -895,8 +979,7 @@ adwaita_engine_render_frame (GtkThemingEngine *engine,
 			gtk_border_free (border_width);
 		}
 
-		GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_frame (engine, cr, x, y,
-										      width, height);
+		render_frame_default (engine, cr, x, y, width, height);
 	}
 
 out:
@@ -1619,6 +1702,11 @@ adwaita_engine_class_init (AdwaitaEngineClass *klass)
 								  "Notebook border color",
 								  "Notebook border color",
 								  GDK_TYPE_RGBA, 0));
+	gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
+					      g_param_spec_boxed ("border-gradient",
+								  "Border gradient",
+								  "Border gradient",
+								  CAIRO_GOBJECT_TYPE_PATTERN, 0));
 }
 
 static void
diff --git a/themes/Adwaita/gtk-3.0/gtk.css b/themes/Adwaita/gtk-3.0/gtk.css
index 6626921..7869f08 100644
--- a/themes/Adwaita/gtk-3.0/gtk.css
+++ b/themes/Adwaita/gtk-3.0/gtk.css
@@ -726,7 +726,7 @@ GtkComboBox.button {
 /* primary toolbar buttons */
 .primary-toolbar.toolbar.button {
     border-style: none;
-    border-width: 0;
+    border-width: 1;
     background-image: none;
     background-color: alpha (@theme_base_color, 0.0);
 
@@ -738,7 +738,6 @@ GtkComboBox.button {
 
 .primary-toolbar.toolbar.button:insensitive {
     border-style: none;
-    border-width: 0;
     background-image: none;
     background-color: alpha (@theme_base_color, 0.0);
     -GtkWidget-focus-line-width: 0;
@@ -746,7 +745,6 @@ GtkComboBox.button {
 
 .primary-toolbar.toolbar.button:hover {
     border-style: none;
-    border-width: 0;
     background-image: -gtk-gradient (linear,
 				     left top, left bottom,
 				     from (alpha (@theme_base_color, 0.0)),
@@ -755,28 +753,42 @@ GtkComboBox.button {
 }
 
 .primary-toolbar.toolbar.button:active {
-    border-style: none;
-    border-width: 0;
+    border-style: solid;
+    border-radius: 4;
+    -adwaita-border-gradient: -gtk-gradient (linear,
+                                             left top, left bottom,
+                                             from (@toolbar_active_button_color),
+                                             to (shade (@toolbar_active_button_color, 1.83)));
+
     background-image: -gtk-gradient (linear,
 				     left top, left bottom,
-				     from (alpha (@theme_base_color, 0.0)),
-				     color-stop (0.54, alpha (shade (@theme_base_color, 0.92), 0.85)),
-			             to (alpha (@theme_base_color, 0.0)));
+				     from (shade (@toolbar_gradient_base, 0.85)),
+			             to (alpha (shade (@toolbar_gradient_base, 0.85), 0.0)));
+
+    color: @theme_base_color;
 }
 
 .primary-toolbar.toolbar.button:active:prelight {
-    border-style: none;
-    border-width: 0;
+    border-style: solid;
+    border-radius: 3;
     background-image: -gtk-gradient (linear,
 				     left top, left bottom,
 				     from (alpha (shade (@toolbar_gradient_base, 0.76), 0.7)),
-			             to (alpha (shade (@toolbar_gradient_base, 1.14), 0.0)));    
+			             to (alpha (shade (@toolbar_gradient_base, 1.14), 0.0)));
+
+    color: @theme_base_color;
+}
+
+.primary-toolbar.toolbar.button:active:insensitive {
+    border-style: solid;
+    border-radius: 3;
+    border-color: @inactive_frame_color;
+    -adwaita-border-gradient: none;
 }
 
 .primary-toolbar.toolbar.separator {
     border-style: solid;
     border-color: shade (@theme_bg_color, 0.56);
-    border-width: 1;
 
     background-image: none;
 }



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