diff options
author | Benjamin Berg <benjamin@sipsolutions.net> | 2008-08-26 15:28:18 (GMT) |
---|---|---|
committer | Benjamin Berg <benjamin@sipsolutions.net> | 2008-08-26 15:28:18 (GMT) |
commit | 99eb78f1f8d89d2fedae905ca49ee52ae3005d87 (patch) | |
tree | aa97b3b0f922ed1a916a4b2e2497b33bd9bea0f5 | |
parent | b8a1f426a55fe18b70f8a0c1e465784aa7d60910 (diff) |
Improve the progress bar to match the specification more closely. (Ticket #7646)
-rw-r--r-- | gtk/engine/sugar-drawing.c | 54 | ||||
-rw-r--r-- | gtk/engine/sugar-drawing.h | 2 | ||||
-rw-r--r-- | gtk/engine/sugar-style.c | 5 | ||||
-rw-r--r-- | gtk/theme/gtkrc.em | 28 |
4 files changed, 55 insertions, 34 deletions
diff --git a/gtk/engine/sugar-drawing.c b/gtk/engine/sugar-drawing.c index d74f6b7..512b64e 100644 --- a/gtk/engine/sugar-drawing.c +++ b/gtk/engine/sugar-drawing.c @@ -523,47 +523,47 @@ sugar_draw_check_button (cairo_t *cr, SugarInfo *info) void -sugar_draw_progressbar_trough (cairo_t *cr, SugarInfo *info, gboolean fill) +sugar_draw_progressbar_trough (cairo_t *cr, SugarInfo *info) { - if (info->state == GTK_STATE_INSENSITIVE || !fill) { + if (info->state == GTK_STATE_INSENSITIVE) { gdk_cairo_set_source_color (cr, &info->style->fg[GTK_STATE_INSENSITIVE]); sugar_rounded_inner_stroke (cr, &info->pos, info->rc_style->line_width, info->max_radius, info->corners, info->cont_edges); } else { - gdk_cairo_set_source_color (cr, &info->style->fg[GTK_STATE_INSENSITIVE]); + gdk_cairo_set_source_color (cr, &info->style->bg[GTK_STATE_NORMAL]); sugar_rounded_rectangle (cr, &info->pos, 0, info->max_radius, info->corners); cairo_fill (cr); + + gdk_cairo_set_source_color (cr, &info->style->fg[GTK_STATE_INSENSITIVE]); + sugar_rounded_inner_stroke (cr, &info->pos, info->rc_style->line_width, info->max_radius, info->corners, info->cont_edges); } } void sugar_draw_progressbar_bar (cairo_t *cr, SugarInfo *info, GtkProgressBarOrientation orientation) { - /* Invisible bar for insensitive progress bars. */ - if (info->state != GTK_STATE_INSENSITIVE) { - SugarRectangle pos = info->pos; - - /* Clip from both sides to get the correct region. */ - if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT || orientation == GTK_PROGRESS_RIGHT_TO_LEFT) { - pos.width += 2*info->max_radius; - sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); - cairo_clip(cr); - - pos.x -= 2*info->max_radius; - sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); - cairo_clip(cr); - } else { - pos.height += 2*info->max_radius; - sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); - cairo_clip(cr); - - pos.y -= 2*info->max_radius; - sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); - cairo_clip(cr); - } + SugarRectangle pos = info->pos; - gdk_cairo_set_source_color (cr, &info->style->base[info->state]); - cairo_paint(cr); + /* Clip from both sides to get the correct region. */ + if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT || orientation == GTK_PROGRESS_RIGHT_TO_LEFT) { + pos.width += 2*info->max_radius; + sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); + cairo_clip(cr); + + pos.x -= 2*info->max_radius; + sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); + cairo_clip(cr); + } else { + pos.height += 2*info->max_radius; + sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); + cairo_clip(cr); + + pos.y -= 2*info->max_radius; + sugar_rounded_rectangle (cr, &pos, 0, info->max_radius, info->corners); + cairo_clip(cr); } + + gdk_cairo_set_source_color (cr, &info->style->text[info->state]); + cairo_paint(cr); } diff --git a/gtk/engine/sugar-drawing.h b/gtk/engine/sugar-drawing.h index dce0235..5fe0627 100644 --- a/gtk/engine/sugar-drawing.h +++ b/gtk/engine/sugar-drawing.h @@ -35,7 +35,7 @@ G_GNUC_INTERNAL void sugar_draw_button_default (cairo_t *cr, SugarInfo *info); G_GNUC_INTERNAL void sugar_draw_arrow (cairo_t *cr, SugarArrowInfo *arrow_info); G_GNUC_INTERNAL void sugar_draw_radio_button (cairo_t *cr, SugarInfo *info); G_GNUC_INTERNAL void sugar_draw_check_button (cairo_t *cr, SugarInfo *info); -G_GNUC_INTERNAL void sugar_draw_progressbar_trough (cairo_t *cr, SugarInfo *info, gboolean fill); +G_GNUC_INTERNAL void sugar_draw_progressbar_trough (cairo_t *cr, SugarInfo *info); G_GNUC_INTERNAL void sugar_draw_progressbar_bar (cairo_t *cr, SugarInfo *info, GtkProgressBarOrientation orientation); G_GNUC_INTERNAL void sugar_draw_menu (cairo_t *cr, SugarInfo *info, SugarGapInfo *gap); G_GNUC_INTERNAL void sugar_draw_palette_invoker (cairo_t *cr, SugarInfo *info, SugarGapInfo *gap); diff --git a/gtk/engine/sugar-style.c b/gtk/engine/sugar-style.c index 0ffaf06..e048fc1 100644 --- a/gtk/engine/sugar-style.c +++ b/gtk/engine/sugar-style.c @@ -420,18 +420,15 @@ sugar_style_draw_box (GtkStyle *style, sugar_draw_scrollbar_trough (cr, &range_info); } else { /* Progress bar trough */ SugarInfo info; - gboolean fill; sugar_fill_generic_info (&info, style, state_type, shadow_type, widget, detail, x, y, width, height); if (widget && !GTK_WIDGET_IS_SENSITIVE (widget)) info.state = GTK_STATE_INSENSITIVE; - fill = (gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)) != 0.0); - /* Needed because the trough and bar are cached in a buffer inside GtkProgress. */ sugar_fill_background (cr, &info); - sugar_draw_progressbar_trough (cr, &info, fill); + sugar_draw_progressbar_trough (cr, &info); } } else if (DETAIL ("bar")) { SugarInfo info; diff --git a/gtk/theme/gtkrc.em b/gtk/theme/gtkrc.em index 3efa6ef..6fa1b05 100644 --- a/gtk/theme/gtkrc.em +++ b/gtk/theme/gtkrc.em @@ -628,8 +628,29 @@ style "checkbutton" style "progressbar" { - xthickness = 0 - ythickness = 0 + # text[PRELIGHT] is used for the bar in the sugar engine + text[PRELIGHT] = $white + + # Text on top of the bar + fg[PRELIGHT] = $black + xthickness = $thickness + ythickness = $thickness + + engine "sugar" { + # Someone seems to have decided, that the background fill of a progress + # bar should be done with bg[ACTIVE]. + bg[ACTIVE] = parent_bg_color + + # Color to fill the progress bar ("transparent" usually, except for the + # white background case) + bg[NORMAL] = parent_bg_color + fg[NORMAL] = parent_fg_color + } +} + +style "progressbar-on-white" { + bg[NORMAL] = $panel_grey + fg[NORMAL] = $black } style "menuitem" @@ -792,6 +813,9 @@ widget_class "*<GtkHScale>" style "hscale" widget_class "*<GtkVScale>" style "vscale" widget_class "*<GtkProgressBar>" style "progressbar" +widget_class "*<SugarSectionView>*<GtkProgress>" style "progressbar-on-white" + + # Scrolled window scrollbars widget_class "*<GtkScrolledWindow>.<GtkVScrollbar>" style "vscrollbar-scrolled-window" widget_class "*<GtkScrolledWindow>.<GtkHScrollbar>" style "hscrollbar-scrolled-window" |