[gnome-themes-standard] progressbar: add a progressbar-pattern style property



commit 697b9e3385ae6b3d64bc96bb562a87e4e8f4f1d4
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Fri May 6 15:15:41 2011 -0400

    progressbar: add a progressbar-pattern style property
    
    This allows us to remove the hardcoded pattern in the engine, and easily
    enable/disable its rendering from the CSS for progressbars inside
    special widgets.

 src/adwaita_engine.c                   |   34 ++++++++++++++++++-------------
 themes/Adwaita/gtk-3.0/gtk-dark.css    |    1 +
 themes/Adwaita/gtk-3.0/gtk-widgets.css |   14 ++++++++++++-
 themes/Adwaita/gtk-3.0/gtk.css         |    1 +
 4 files changed, 35 insertions(+), 15 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index 09a2ef0..1de8b80 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -1011,9 +1011,11 @@ adwaita_engine_render_activity (GtkThemingEngine *engine,
 				gdouble           height)
 {
 	const GtkWidgetPath *path;
+	GtkStateFlags state;
 
 	cairo_save (cr);
 	path = gtk_theming_engine_get_path (engine);
+	state = gtk_theming_engine_get_state (engine);
 
 	if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
 	    gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
@@ -1034,23 +1036,22 @@ adwaita_engine_render_activity (GtkThemingEngine *engine,
 	GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity (engine, cr,
 										 x, y, width, height);
 
-	if (gtk_widget_path_is_type (path, GTK_TYPE_PROGRESS_BAR) &&
-	    gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
+	if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR))
 	{
-		cairo_pattern_t *pattern;
+		cairo_pattern_t *pattern = NULL;
 
-		pattern = cairo_pattern_create_linear (0, 0, 20, 20);
-		cairo_pattern_add_color_stop_rgba (pattern, 0, 0, 0, 0, 0);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.49, 0, 0, 0, 0);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.5, 0, 0, 0, 0.1);
-		cairo_pattern_add_color_stop_rgba (pattern, 0.99, 0, 0, 0, 0.1);
+		gtk_theming_engine_get (engine, state,
+					"-adwaita-progressbar-pattern", &pattern,
+					NULL);
 
-		cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
-		cairo_rectangle (cr, x, y, width, height);
-		cairo_set_source (cr, pattern);
-		cairo_fill (cr);
+		if (pattern != NULL) {
+			style_pattern_set_matrix (pattern, 20, 20, TRUE);
+			cairo_rectangle (cr, x, y, width, height);
+			cairo_set_source (cr, pattern);
+			cairo_fill (cr);
 
-		cairo_pattern_destroy (pattern);
+			cairo_pattern_destroy (pattern);
+		}
 	}
 
 	cairo_restore (cr);
@@ -1672,7 +1673,12 @@ adwaita_engine_class_init (AdwaitaEngineClass *klass)
 					      g_param_spec_boxed ("inset-bottom",
 								  "Inset line bottom",
 								  "Inset line bottom",
-								  GDK_TYPE_RGBA, 0));	
+								  GDK_TYPE_RGBA, 0));
+	gtk_theming_engine_register_property (ADWAITA_NAMESPACE, NULL,
+					      g_param_spec_boxed ("progressbar-pattern",
+								  "Progressbar pattern",
+								  "Progressbar pattern",
+								  CAIRO_GOBJECT_TYPE_PATTERN, 0));
 }
 
 static void
diff --git a/themes/Adwaita/gtk-3.0/gtk-dark.css b/themes/Adwaita/gtk-3.0/gtk-dark.css
index 6ab6aec..afe7131 100644
--- a/themes/Adwaita/gtk-3.0/gtk-dark.css
+++ b/themes/Adwaita/gtk-3.0/gtk-dark.css
@@ -45,6 +45,7 @@
 @define-color progressbar_background_a alpha (@theme_fg_color, 0.70);
 @define-color progressbar_background_b alpha (@theme_fg_color, 0.45);
 @define-color progressbar_border alpha (@theme_fg_color, 0.60);
+ define-color progressbar_pattern #000000;
 
 @define-color focused_entry_border @theme_selected_bg_color;
 @define-color focused_entry_inset alpha (@theme_selected_bg_color, 0.50);
diff --git a/themes/Adwaita/gtk-3.0/gtk-widgets.css b/themes/Adwaita/gtk-3.0/gtk-widgets.css
index 3773272..b064340 100644
--- a/themes/Adwaita/gtk-3.0/gtk-widgets.css
+++ b/themes/Adwaita/gtk-3.0/gtk-widgets.css
@@ -165,6 +165,8 @@
     border-width: 1;
     border-radius: 1;
     border-color: @progressbar_border;
+
+    -adwaita-progressbar-pattern: none;
 }
 
 /*****************
@@ -198,9 +200,16 @@ GtkProgressBar.progressbar {
 
     border-radius: 3;
     border-style: solid;
+    border-width: 1;
     border-color: @progressbar_border;
 
     -adwaita-inset-top: alpha (@theme_base_color, 0.20);
+    -adwaita-progressbar-pattern: -gtk-gradient (linear,
+                                                 left top, right bottom,
+                                                 from (alpha (@progressbar_pattern, 0.00)),
+                                                 color-stop (0.49, alpha (@progressbar_pattern, 0.00)),
+                                                 color-stop (0.50, alpha (@progressbar_pattern, 0.10)),
+                                                 to (alpha (@progressbar_pattern, 0.10)));
 }
 
 GtkProgressBar.trough {
@@ -310,7 +319,8 @@ GtkScale.progressbar {
     -adwaita-border-gradient: -gtk-gradient (linear,
                                              left top, left bottom,
                                              from (@scale_progress_border_a),
-                                             to (@scale_progress_border_b));    
+                                             to (@scale_progress_border_b));
+    -adwaita-progressbar-pattern: none;
 }
 
 GtkScale.mark {
@@ -830,6 +840,8 @@ GtkComboBox .button:prelight {
     border-width: 0;
     border-radius: 2;
     border-color: shade (@inactive_frame_color, 0.925);
+
+    -adwaita-progressbar-pattern: none;
 }
 
 /*******************
diff --git a/themes/Adwaita/gtk-3.0/gtk.css b/themes/Adwaita/gtk-3.0/gtk.css
index 334f186..a1eb610 100644
--- a/themes/Adwaita/gtk-3.0/gtk.css
+++ b/themes/Adwaita/gtk-3.0/gtk.css
@@ -78,6 +78,7 @@
 @define-color progressbar_background_a #76b0ec;
 @define-color progressbar_background_b #1f72c6;
 @define-color progressbar_border #3277bf;
+ define-color progressbar_pattern #000000;
 
 @define-color internal_element_color #888a85;
 



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