forked from AuroraMiddleware/gtk
Break this function into simpler functions: gtk_progress_bar_paint_text(),
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk> * gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this function into simpler functions: gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(), gtk_progress_bar_paint_continous(), gtk_progress_bar_paint_activity().
This commit is contained in:
parent
5e17ddfb11
commit
5ff0d3d467
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -1,3 +1,11 @@
|
||||
Mon Nov 25 18:56:55 2002 Soeren Sandmann <sandmann@daimi.au.dk>
|
||||
|
||||
* gtk/gtkprogressbar.c (gtk_progress_bar_paint): Break this
|
||||
function into simpler functions:
|
||||
gtk_progress_bar_paint_text(), gtk_progress_bar_paint_discrete(),
|
||||
gtk_progress_bar_paint_continous(),
|
||||
gtk_progress_bar_paint_activity().
|
||||
|
||||
Mon Nov 25 12:34:44 2002 Owen Taylor <otaylor@redhat.com>
|
||||
|
||||
* gtk/gtkdialog.c (gtk_dialog_set_default_response):
|
||||
|
@ -581,256 +581,157 @@ gtk_progress_bar_act_mode_enter (GtkProgress *progress)
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_paint (GtkProgress *progress)
|
||||
gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
|
||||
GtkProgressBarOrientation orientation)
|
||||
{
|
||||
GtkProgressBar *pbar;
|
||||
GtkWidget *widget;
|
||||
gint amount;
|
||||
gint block_delta = 0;
|
||||
gint space = 0;
|
||||
gint i;
|
||||
gint x;
|
||||
gint y;
|
||||
gdouble percentage;
|
||||
gint size;
|
||||
GtkProgressBarOrientation orientation;
|
||||
GtkWidget *widget = GTK_WIDGET (pbar);
|
||||
GtkProgress *progress = GTK_PROGRESS (pbar);
|
||||
gint x, y, w, h;
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
|
||||
|
||||
pbar = GTK_PROGRESS_BAR (progress);
|
||||
widget = GTK_WIDGET (progress);
|
||||
|
||||
orientation = pbar->orientation;
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
|
||||
orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
|
||||
else if (pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
|
||||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
space = widget->allocation.width -
|
||||
2 * widget->style->xthickness;
|
||||
else
|
||||
space = widget->allocation.height -
|
||||
2 * widget->style->ythickness;
|
||||
|
||||
percentage = gtk_progress_get_current_percentage (progress);
|
||||
|
||||
if (progress->offscreen_pixmap)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
NULL, widget, "trough",
|
||||
0, 0,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
|
||||
if (progress->activity_mode)
|
||||
{
|
||||
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
|
||||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
{
|
||||
size = MAX (2, widget->allocation.width / pbar->activity_blocks);
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
pbar->activity_pos,
|
||||
widget->style->ythickness,
|
||||
size,
|
||||
widget->allocation.height - widget->style->ythickness * 2);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
size = MAX (2, widget->allocation.height / pbar->activity_blocks);
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
pbar->activity_pos,
|
||||
widget->allocation.width - widget->style->xthickness * 2,
|
||||
size);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
amount = percentage * space;
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
switch (orientation)
|
||||
{
|
||||
|
||||
case GTK_PROGRESS_LEFT_TO_RIGHT:
|
||||
|
||||
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
widget->style->ythickness,
|
||||
amount,
|
||||
widget->allocation.height - widget->style->ythickness * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = widget->style->xthickness;
|
||||
|
||||
for (i = 0; i <= pbar->in_block; i++)
|
||||
{
|
||||
block_delta = (((i + 1) * space) / pbar->blocks)
|
||||
- ((i * space) / pbar->blocks);
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
x,
|
||||
widget->style->ythickness,
|
||||
block_delta,
|
||||
widget->allocation.height - widget->style->ythickness * 2);
|
||||
|
||||
x += block_delta;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_PROGRESS_RIGHT_TO_LEFT:
|
||||
|
||||
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->allocation.width -
|
||||
widget->style->xthickness - amount,
|
||||
widget->style->ythickness,
|
||||
amount,
|
||||
widget->allocation.height -
|
||||
widget->style->ythickness * 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = widget->allocation.width -
|
||||
widget->style->xthickness;
|
||||
|
||||
for (i = 0; i <= pbar->in_block; i++)
|
||||
{
|
||||
block_delta = (((i + 1) * space) / pbar->blocks) -
|
||||
((i * space) / pbar->blocks);
|
||||
|
||||
x -= block_delta;
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
x,
|
||||
widget->style->ythickness,
|
||||
block_delta,
|
||||
widget->allocation.height -
|
||||
widget->style->ythickness * 2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_PROGRESS_BOTTOM_TO_TOP:
|
||||
|
||||
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
widget->allocation.height -
|
||||
widget->style->ythickness - amount,
|
||||
widget->allocation.width -
|
||||
widget->style->xthickness * 2,
|
||||
amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = widget->allocation.height -
|
||||
widget->style->ythickness;
|
||||
|
||||
for (i = 0; i <= pbar->in_block; i++)
|
||||
{
|
||||
block_delta = (((i + 1) * space) / pbar->blocks) -
|
||||
((i * space) / pbar->blocks);
|
||||
|
||||
y -= block_delta;
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
y,
|
||||
widget->allocation.width -
|
||||
widget->style->xthickness * 2,
|
||||
block_delta);
|
||||
}
|
||||
}
|
||||
x = pbar->activity_pos;
|
||||
y = widget->style->ythickness;
|
||||
w = MAX (2, widget->allocation.width / pbar->activity_blocks);
|
||||
h = widget->allocation.height - 2 * widget->style->ythickness;
|
||||
break;
|
||||
|
||||
case GTK_PROGRESS_TOP_TO_BOTTOM:
|
||||
|
||||
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
widget->style->ythickness,
|
||||
widget->allocation.width -
|
||||
widget->style->xthickness * 2,
|
||||
amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = widget->style->ythickness;
|
||||
|
||||
for (i = 0; i <= pbar->in_block; i++)
|
||||
{
|
||||
|
||||
block_delta = (((i + 1) * space) / pbar->blocks)
|
||||
- ((i * space) / pbar->blocks);
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
widget->style->xthickness,
|
||||
y,
|
||||
widget->allocation.width -
|
||||
widget->style->xthickness * 2,
|
||||
block_delta);
|
||||
|
||||
y += block_delta;
|
||||
}
|
||||
}
|
||||
case GTK_PROGRESS_BOTTOM_TO_TOP:
|
||||
x = widget->style->xthickness;
|
||||
y = pbar->activity_pos;
|
||||
w = widget->allocation.width - 2 * widget->style->xthickness;
|
||||
h = MAX (2, widget->allocation.height / pbar->activity_blocks);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_paint_continous (GtkProgressBar *pbar,
|
||||
GtkProgressBarOrientation orientation)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (pbar);
|
||||
gint space;
|
||||
gint amount;
|
||||
gint x, y, w, h;
|
||||
|
||||
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
|
||||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
space = widget->allocation.width - 2 * widget->style->xthickness;
|
||||
else
|
||||
space = widget->allocation.height - 2 * widget->style->ythickness;
|
||||
|
||||
amount = space * gtk_progress_get_current_percentage (GTK_PROGRESS (pbar));
|
||||
|
||||
if (amount <= 0)
|
||||
return;
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
case GTK_PROGRESS_LEFT_TO_RIGHT:
|
||||
case GTK_PROGRESS_RIGHT_TO_LEFT:
|
||||
w = amount;
|
||||
h = widget->allocation.height - widget->style->ythickness * 2;
|
||||
y = widget->style->ythickness;
|
||||
|
||||
x = widget->style->xthickness;
|
||||
if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
x = widget->allocation.width - amount - x;
|
||||
break;
|
||||
|
||||
case GTK_PROGRESS_TOP_TO_BOTTOM:
|
||||
case GTK_PROGRESS_BOTTOM_TO_TOP:
|
||||
w = widget->allocation.width - widget->style->xthickness * 2;
|
||||
h = amount;
|
||||
x = widget->style->xthickness;
|
||||
|
||||
y = widget->style->ythickness;
|
||||
if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP)
|
||||
y = widget->allocation.height - amount - y;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
|
||||
gtk_paint_box (widget->style,
|
||||
GTK_PROGRESS (pbar)->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
x, y, w, h);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_paint_discrete (GtkProgressBar *pbar,
|
||||
GtkProgressBarOrientation orientation)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (pbar);
|
||||
gint i;
|
||||
|
||||
for (i = 0; i <= pbar->in_block; i++)
|
||||
{
|
||||
gint x, y, w, h, space;
|
||||
|
||||
switch (orientation)
|
||||
{
|
||||
case GTK_PROGRESS_LEFT_TO_RIGHT:
|
||||
case GTK_PROGRESS_RIGHT_TO_LEFT:
|
||||
space = widget->allocation.width - 2 * widget->style->xthickness;
|
||||
|
||||
x = widget->style->xthickness + (i * space) / pbar->blocks;
|
||||
y = widget->style->ythickness;
|
||||
w = widget->style->xthickness + ((i + 1) * space) / pbar->blocks - x;
|
||||
h = widget->allocation.height - 2 * widget->style->ythickness;
|
||||
|
||||
if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
x = widget->allocation.width - w - x;
|
||||
break;
|
||||
|
||||
case GTK_PROGRESS_TOP_TO_BOTTOM:
|
||||
case GTK_PROGRESS_BOTTOM_TO_TOP:
|
||||
space = widget->allocation.height - 2 * widget->style->ythickness;
|
||||
|
||||
x = widget->style->xthickness;
|
||||
y = widget->style->ythickness + (i * space) / pbar->blocks;
|
||||
w = widget->allocation.width - 2 * widget->style->xthickness;
|
||||
h = widget->style->ythickness + ((i + 1) * space) / pbar->blocks - y;
|
||||
|
||||
if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP)
|
||||
y = widget->allocation.height - h - y;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_paint_box (widget->style,
|
||||
GTK_PROGRESS (pbar)->offscreen_pixmap,
|
||||
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
|
||||
NULL, widget, "bar",
|
||||
x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_paint_text (GtkProgressBar *pbar)
|
||||
{
|
||||
GtkProgress *progress = GTK_PROGRESS (pbar);
|
||||
GtkWidget *widget = GTK_WIDGET (pbar);
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
gchar *buf;
|
||||
@ -872,6 +773,53 @@ gtk_progress_bar_paint (GtkProgress *progress)
|
||||
|
||||
g_object_unref (layout);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_progress_bar_paint (GtkProgress *progress)
|
||||
{
|
||||
GtkProgressBar *pbar;
|
||||
GtkWidget *widget;
|
||||
|
||||
GtkProgressBarOrientation orientation;
|
||||
|
||||
g_return_if_fail (GTK_IS_PROGRESS_BAR (progress));
|
||||
|
||||
pbar = GTK_PROGRESS_BAR (progress);
|
||||
widget = GTK_WIDGET (progress);
|
||||
|
||||
orientation = pbar->orientation;
|
||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
|
||||
{
|
||||
if (pbar->orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
|
||||
orientation = GTK_PROGRESS_RIGHT_TO_LEFT;
|
||||
else if (pbar->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
|
||||
orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
|
||||
}
|
||||
|
||||
if (progress->offscreen_pixmap)
|
||||
{
|
||||
gtk_paint_box (widget->style,
|
||||
progress->offscreen_pixmap,
|
||||
GTK_STATE_NORMAL, GTK_SHADOW_IN,
|
||||
NULL, widget, "trough",
|
||||
0, 0,
|
||||
widget->allocation.width,
|
||||
widget->allocation.height);
|
||||
|
||||
if (progress->activity_mode)
|
||||
{
|
||||
gtk_progress_bar_paint_activity (pbar, orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pbar->bar_style == GTK_PROGRESS_CONTINUOUS)
|
||||
gtk_progress_bar_paint_continous (pbar, orientation);
|
||||
else
|
||||
gtk_progress_bar_paint_discrete (pbar, orientation);
|
||||
|
||||
if (progress->show_text && pbar->bar_style != GTK_PROGRESS_DISCRETE)
|
||||
gtk_progress_bar_paint_text (pbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user