[gtk-engines/gnome3] Adapt to recent GTK+ api changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-engines/gnome3] Adapt to recent GTK+ api changes
- Date: Tue, 7 Sep 2010 18:49:01 +0000 (UTC)
commit 023bb8b3ecd45cd8649654226ed3b1f3a14057d6
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Sep 7 14:47:40 2010 -0400
Adapt to recent GTK+ api changes
GtkProgressBar has changed to a GtkOrientable with an inverted flag.
GtkProgressBarOrientation doesn't exist anymore.
engines/clearlooks/src/clearlooks_style.c | 35 +++++++++++-----
engines/crux/src/crux-draw.c | 62 +++++++++++++++++------------
engines/glide/src/glide_gtk2_drawing.c | 15 +------
3 files changed, 63 insertions(+), 49 deletions(-)
---
diff --git a/engines/clearlooks/src/clearlooks_style.c b/engines/clearlooks/src/clearlooks_style.c
index 7d2189a..b972c88 100644
--- a/engines/clearlooks/src/clearlooks_style.c
+++ b/engines/clearlooks/src/clearlooks_style.c
@@ -815,7 +815,20 @@ clearlooks_style_draw_box (DRAW_ARGS)
if (widget && GE_IS_PROGRESS_BAR (widget))
{
- progressbar.orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget));
+ if (gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)))
+ {
+ if (gtk_progress_bar_get_inverted (GTK_PROGRESS_BAR (widget)))
+ progressbar.orientation = CL_ORIENTATION_RIGHT_TO_LEFT;
+ else
+ progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT;
+ }
+ else
+ {
+ if (gtk_progress_bar_get_inverted (GTK_PROGRESS_BAR (widget)))
+ progressbar.orientation = CL_ORIENTATION_BOTTOM_TO_TOP;
+ else
+ progressbar.orientation = CL_ORIENTATION_TOP_TO_BOTTOM;
+ }
progressbar.value = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget));
#warning Assuming non-pulsing progress bars because there is currently no way to query them in GTK+ 3.0.
progressbar.pulsing = FALSE;
@@ -829,10 +842,10 @@ clearlooks_style_draw_box (DRAW_ARGS)
if (!params.ltr)
{
- if (progressbar.orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
- progressbar.orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
- else if (progressbar.orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
- progressbar.orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
+ if (progressbar.orientation == CL_ORIENTATION_LEFT_TO_RIGHT)
+ progressbar.orientation = CL_ORIENTATION_RIGHT_TO_LEFT;
+ else if (progressbar.orientation == CL_ORIENTATION_RIGHT_TO_LEFT)
+ progressbar.orientation = CL_ORIENTATION_LEFT_TO_RIGHT;
}
/* Following is a hack to have a larger clip area, the one passed in
@@ -844,22 +857,22 @@ clearlooks_style_draw_box (DRAW_ARGS)
{
switch (progressbar.orientation)
{
- case GTK_PROGRESS_RIGHT_TO_LEFT:
+ case CL_ORIENTATION_RIGHT_TO_LEFT:
tmp.x -= 1;
- case GTK_PROGRESS_LEFT_TO_RIGHT:
+ case CL_ORIENTATION_LEFT_TO_RIGHT:
tmp.width += 1;
break;
- case GTK_PROGRESS_BOTTOM_TO_TOP:
+ case CL_ORIENTATION_BOTTOM_TO_TOP:
tmp.y -= 1;
- case GTK_PROGRESS_TOP_TO_BOTTOM:
+ case CL_ORIENTATION_TOP_TO_BOTTOM:
tmp.height += 1;
break;
}
}
else
{
- if (progressbar.orientation == GTK_PROGRESS_RIGHT_TO_LEFT ||
- progressbar.orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
+ if (progressbar.orientation == CL_ORIENTATION_RIGHT_TO_LEFT ||
+ progressbar.orientation == CL_ORIENTATION_LEFT_TO_RIGHT)
{
tmp.x -= 1;
tmp.width += 2;
diff --git a/engines/crux/src/crux-draw.c b/engines/crux/src/crux-draw.c
index b587562..482cdbc 100644
--- a/engines/crux/src/crux-draw.c
+++ b/engines/crux/src/crux-draw.c
@@ -625,7 +625,7 @@ paint_scale_trough (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkOr
}
static void
-paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkProgressBarOrientation orientation,
+paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkOrientation orientation, gboolean inverted,
gdouble x, gdouble y, gdouble width, gdouble height, gdouble fraction, CairoColor *base_color)
{
cairo_pattern_t *crp;
@@ -636,7 +636,7 @@ paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkPr
ge_gdk_color_to_cairo (&style->base[GTK_STATE_SELECTED], &c1);
CRUX_DARK(*base_color, c2);
CRUX_LIGHT(*base_color, c1);
- if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT || orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
crp = cairo_pattern_create_linear (x, y, x, y + height);
else
crp = cairo_pattern_create_linear (x, y, x + width, y);
@@ -653,13 +653,22 @@ paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkPr
if (fraction < 1.0)
{
- switch (orientation)
- {
- case GTK_PROGRESS_LEFT_TO_RIGHT: width--; break;
- case GTK_PROGRESS_RIGHT_TO_LEFT: x++; width--; break;
- case GTK_PROGRESS_TOP_TO_BOTTOM: height--; break;
- case GTK_PROGRESS_BOTTOM_TO_TOP: y++; height--; break;
+ if (orientation == GTK_ORIENTATION_HORIZONTAL && !inverted)
+ {
+ width--;
+ }
+ else if (orientation == GTK_ORIENTATION_HORIZONTAL && inverted)
+ {
+ x++; width--;
+ }
+ else if (orientation == GTK_ORIENTATION_VERTICAL && !inverted)
+ {
+ height--;
}
+ else if (orientation == GTK_ORIENTATION_VERTICAL && inverted)
+ {
+ y++; height--;
+ }
}
@@ -680,24 +689,25 @@ paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkPr
if (fraction < 1.0)
{
cairo_set_source_rgb (cr, c2.r, c2.g, c2.b);
- switch (orientation)
- {
- case GTK_PROGRESS_LEFT_TO_RIGHT:
- cairo_move_to (cr, x + width + 1.0, y);
- cairo_line_to (cr, x + width + 1.0, y + height);
- break;
- case GTK_PROGRESS_RIGHT_TO_LEFT:
+ if (orientation == GTK_ORIENTATION_HORIZONTAL && !inverted)
+ {
+ cairo_move_to (cr, x + width + 1.0, y);
+ cairo_line_to (cr, x + width + 1.0, y + height);
+ }
+ else if (orientation == GTK_ORIENTATION_HORIZONTAL && inverted)
+ {
cairo_move_to (cr, x - 1.0, y);
cairo_line_to (cr, x - 1.0, y + height);
- break;
- case GTK_PROGRESS_TOP_TO_BOTTOM:
+ }
+ else if (orientation == GTK_ORIENTATION_VERTICAL && !inverted)
+ {
cairo_move_to (cr, x, y + height + 1.0);
cairo_line_to (cr, x + width, y + height + 1.0);
- break;
- case GTK_PROGRESS_BOTTOM_TO_TOP:
+ }
+ else if (orientation == GTK_ORIENTATION_VERTICAL && inverted)
+ {
cairo_move_to (cr, x, y - 1.0);
cairo_line_to (cr, x + width, y - 1.0);
- break;
}
cairo_stroke (cr);
}
@@ -711,7 +721,7 @@ paint_progress_bar (cairo_t *cr, GtkStyle *style, GtkStateType state_type, GtkPr
* is already drawn by draw_box (), so the corner looks too dark
*/
- if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
+ if (orientation == GTK_ORIENTATION_HORIZONTAL && !inverted)
{
cairo_set_source_rgba (cr, 0, 0, 0, .22);
cairo_move_to (cr, x + width + 2.0, y);
@@ -1022,23 +1032,25 @@ draw_box (GtkStyle *style,
}
else if (DETAIL ("bar") || DETAIL ("entry-progress"))
{
- GtkProgressBarOrientation orientation;
+ GtkOrientation orientation;
+ gboolean inverted = FALSE;
CairoColor base_color;
gdouble fraction = 0;
if (widget && GE_IS_PROGRESS_BAR (widget))
{
- orientation = gtk_progress_bar_get_orientation (GTK_PROGRESS_BAR (widget));
+ orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
+ inverted = gtk_progress_bar_get_inverted (GTK_PROGRESS_BAR (widget));
fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget));
}
else
- orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
+ orientation = GTK_ORIENTATION_HORIZONTAL;
if (DETAIL ("bar"))
ge_gdk_color_to_cairo (&style->base[GTK_STATE_SELECTED], &base_color);
else
ge_gdk_color_to_cairo (&style->bg[state_type], &base_color);
- paint_progress_bar (cr, style, state_type, orientation, x, y, width, height, fraction, &base_color);
+ paint_progress_bar (cr, style, state_type, orientation, inverted, x, y, width, height, fraction, &base_color);
}
else if (DETAIL ("trough") && GE_IS_SCALE (widget))
{
diff --git a/engines/glide/src/glide_gtk2_drawing.c b/engines/glide/src/glide_gtk2_drawing.c
index 3d4cc3e..06f55bf 100644
--- a/engines/glide/src/glide_gtk2_drawing.c
+++ b/engines/glide/src/glide_gtk2_drawing.c
@@ -1303,19 +1303,8 @@ glide_draw_box (GtkStyle * style,
else if ((CHECK_DETAIL (detail, "bar"))
&& (widget && GE_IS_PROGRESS_BAR (widget)))
{
-gboolean vertical = TRUE;
- switch (GTK_PROGRESS_BAR(widget)->orientation)
- {
- case GTK_PROGRESS_LEFT_TO_RIGHT:
- case GTK_PROGRESS_RIGHT_TO_LEFT:
- vertical = FALSE;
- break;
-
- case GTK_PROGRESS_BOTTOM_TO_TOP:
- case GTK_PROGRESS_TOP_TO_BOTTOM:
- vertical = TRUE;
- break;
- }
+gboolean vertical;
+ vertical = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)) == GTK_ORIENTATION_VERTICAL;
ge_cairo_pattern_fill(canvas, DEFAULT_BACKGROUND_PATTERN(glide_style, GTK_STATE_SELECTED, glide_style->bg_gradient[!vertical][GTK_STATE_SELECTED]), x+1, y+1, width-2, height-2);
do_glide_draw_border(canvas, &glide_style->color_cube.bg[GTK_STATE_SELECTED],
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]