Re: Arbitrary widgets superimposed onto GtkProgressBar

On Fri, 2007-02-23 at 13:49 +0200, Gabriel Schulhof wrote:
> Hi!
> I am trying to implement something similar to the GNOME splash screen.
> There, icons appear at the bottom of the image, as different parts of the
> desktop are loaded.
> In a similar vein, I would like to create a screen where a set of labels
> and their corresponding icons are already present at the bottom, and a
> progress bar appears behind the set as the process progresses. Please see
> the animated GIF that illustrates this behaviour available here:
> I have implemented this by adding a GtkHBox to a GtkEventBox that I have
> set ( ..., "app-paintable", TRUE, "visible-window", TRUE, ...). I handle
> the expose event, and imitate the actions of a GtkProgressBar:
> gtk_paint_box (widget->style, widget->window, GTK_STATE_PRELIGHT,
> GTK_SHADOW_OUT, &rc, widget, "bar", rc.x, rc.y, rc.width, rc.height) ;
> Above, "widget" is the GtkEventBox.
> This seems to work well enough in some cases, but it's theme-dependent.
> That is, there are themes where, instead of getting the nice, shimmering
> GtkProgressBar style, I get naught but an ugly GTK_SHADOW_OUT box.
> In an attempt to solve this problem, I tried to create my own GtkContainer
> subclass that overlaps a GtkProgressBar and the GtkHBox with the widgets.
> Unfortunately, GtkProgressBar creates its own child window, so my widgets
> will always appear behind it :o(
> In a second attempt, I tried to treat the GtkProgressBar as a container
> (which it's not), by setting it as the GtkHBox's parent. GTK+ refuses to
> do this.
> Is there a way to render into a pixmap a real GtkProgressBar, whose
> allocation width and height is the same as that of the GtkHBox ? If I can
> do that, I can make the GtkHBox app-paintable, and render the picture of
> the progress bar in the GtkHBox's background.

Disclaimer: I know nothing..... and haven't tried this myself.

But, is it possible for you to create a subclass of the GtkProgressBar,
catch provide implementations of the appropriate methods / paint /
expose events, and draw ontop of the GtkProgressBar's window?

Perhaps the window is hidden in the implementation of GtkProgressBar, so
you can't do that, but conceptually, I think you're trying to extend the
progress bar.

I took a quick look at the source: gtkprogressbar.[ch] and

Take a look at over-riding the class's "paint" method, which now uses
gtk_progress_bar_paint(). You could call the original from your
implementation, then draw on top of 

OTOH: This appears to require access to GTK internals which are #defined


In general... as a question to the GTK people. How is it possible to
subclass GTK widgets where a lot of the implementation detail is hidden
away like this. I realise there may be no contract to keep the internal
implementation constant, but does this mean the only alternative is to
copy-paste and the code for the whole widget to make the changes wanted?

Peter Clifton

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