[gnome-themes-standard] adwaita: factor out some common code into utils
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-themes-standard] adwaita: factor out some common code into utils
- Date: Mon, 9 May 2011 18:55:24 +0000 (UTC)
commit 0439fd602c2d90b01db1fe689bdab4f5ecf42bfe
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon May 9 14:31:37 2011 -0400
adwaita: factor out some common code into utils
src/adwaita_engine.c | 61 +++++++------------------------------------------
src/adwaita_utils.c | 29 +++++++++++++++++++++++
src/adwaita_utils.h | 9 ++++++-
3 files changed, 46 insertions(+), 53 deletions(-)
---
diff --git a/src/adwaita_engine.c b/src/adwaita_engine.c
index 48146d6..fc43cb6 100644
--- a/src/adwaita_engine.c
+++ b/src/adwaita_engine.c
@@ -707,22 +707,9 @@ adwaita_engine_render_frame (GtkThemingEngine *engine,
}
else
{
- if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
- gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
- {
- /* Render GtkScale trough thinner */
- if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
- {
- y += height / 2.0 - 2.0;
- height = 4;
- }
- else
- {
- x += width / 2.0 - 2.0;
- width = 4;
- }
- }
-
+ adwaita_trim_allocation_for_scale (engine,
+ &x, &y,
+ &width, &height);
render_frame_default (engine, cr, x, y, width, height);
}
@@ -861,10 +848,6 @@ adwaita_engine_render_background (GtkThemingEngine *engine,
gdouble width,
gdouble height)
{
- const GtkWidgetPath *path;
-
- path = gtk_theming_engine_get_path (engine);
-
if (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUITEM) &&
gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_MENUBAR)) {
render_menubar_active_background (engine, cr, x, y, width, height);
@@ -872,21 +855,9 @@ adwaita_engine_render_background (GtkThemingEngine *engine,
return;
}
- if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
- gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH))
- {
- /* Render GtkScale trough thinner */
- if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
- {
- y += height / 2 - 2;
- height = 4;
- }
- else
- {
- x += width / 2 - 2;
- width = 4;
- }
- }
+ adwaita_trim_allocation_for_scale (engine,
+ &x, &y,
+ &width, &height);
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_background (engine, cr, x, y,
width, height);
@@ -966,28 +937,14 @@ adwaita_engine_render_activity (GtkThemingEngine *engine,
gdouble width,
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))
- {
- /* Render GtkScale fill level thinner */
- if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
- {
- y += height / 2.0 - 2.0;
- height = 4;
- }
- else
- {
- x += width / 2.0 - 2.0;
- width = 4;
- }
- }
+ adwaita_trim_allocation_for_scale (engine,
+ &x, &y,
+ &width, &height);
GTK_THEMING_ENGINE_CLASS (adwaita_engine_parent_class)->render_activity (engine, cr,
x, y, width, height);
diff --git a/src/adwaita_utils.c b/src/adwaita_utils.c
index c282dac..9d35dc8 100644
--- a/src/adwaita_utils.c
+++ b/src/adwaita_utils.c
@@ -27,6 +27,35 @@
#include "adwaita_utils.h"
void
+adwaita_trim_allocation_for_scale (GtkThemingEngine *engine,
+ gdouble *x,
+ gdouble *y,
+ gdouble *width,
+ gdouble *height)
+{
+ const GtkWidgetPath *path;
+
+ path = gtk_theming_engine_get_path (engine);
+
+ if (gtk_widget_path_is_type (path, GTK_TYPE_SCALE) &&
+ (gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_TROUGH) ||
+ gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_PROGRESSBAR)))
+ {
+ /* Render GtkScale trough thinner */
+ if (!gtk_theming_engine_has_class (engine, GTK_STYLE_CLASS_VERTICAL))
+ {
+ *y += *height / 2.0 - 2.0;
+ *height = 4;
+ }
+ else
+ {
+ *x += *width / 2.0 - 2.0;
+ *width = 4;
+ }
+ }
+}
+
+void
_cairo_round_rectangle_sides (cairo_t *cr,
gdouble radius,
gdouble x,
diff --git a/src/adwaita_utils.h b/src/adwaita_utils.h
index e926e8a..95e395a 100644
--- a/src/adwaita_utils.h
+++ b/src/adwaita_utils.h
@@ -45,7 +45,14 @@ adwaita_render_from_assets_common (GtkThemingEngine *engine,
gdouble width,
gdouble height);
- void
+void
+adwaita_trim_allocation_for_scale (GtkThemingEngine *engine,
+ gdouble *x,
+ gdouble *y,
+ gdouble *width,
+ gdouble *height);
+
+void
style_pattern_set_matrix (cairo_pattern_t *pattern,
gdouble width,
gdouble height,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]