Re: Background images in window



On Mon, 12 Apr 2004, Chris wrote:
I'm new to this list, so please forgive me if I'm asking the wrong
questions! I was wondering how I can make an image in a window a background
image, so that I can superimpose another widget on top of it. I have an
image that I want to use in a splash screen and I want to put a progress bar
on top of it to make it look like it's doing something constructive.  I've
got the image rendered in a window, but I can't figure out how to add the
progress bar.
Hello Chris!
I never tried something like this myself, but I can image two approaches:
1) Use the theming engine: Set a RCstyle for your splash-screen-widget
where you change the bg_pixmap property (See
http://developer.gnome.org/doc/API/2.0/gtk/gtk-Resource-Files.html)
2) If the first solution doesn't work you may try a more intrusive
approach: Create a GtkTable like this:

  0         1
0 -----------
  |         |
1 -----------
  |         |
2 -----------

Then put your background image in (0,0)x(1,2) so that it fills the
complete space. Put the progress bar in (0,1)x(1,2) to fill the lower
line. Both widgets are then drawn on top of each other. To make this work
it is important in which order you add the widgets to the table, so if you
can't see the progress bar try to change the order of adding them to the
table.
I don't know whether this (still) works, I only read about something like
this some time ago. You should try do use the first approach anyway.

I'm also having problems using g_timeout_add so that I can destroy the
splash screen after x-seconds. It appears to refresh the widget rather than
destroy it i.e. every x seconds I will see it flicker.
Hmmm, first you have to add the timeout function:

gtk_timeout_add(2000, (GtkFunction)CbTimeout, pWidget);

This will call CbTimeout() after 2 seconds. In the timeout function close
the window:

gboolean CbTimeout(
  GtkWidget *pWidget)
{
  // close the window
  gtk_widget_hide(pWidget);

  // remove this function so that it won't be called again after next
  // timeout
  return FALSE;
}

To make this work your gtk_main() must already be running.

Regards,
                             Peter
-- 
====================================================================
Peter Krüger

applied software solutions (appss) GmbH
Sandtorstr. 23
D-39106 Magdeburg
Germany

Phone:  +49-(0)391-54486-19388
Fax:    +49-(0)391-54486-19222
email:  krueger appss de
URL:    http://www.appss.de

Managing Director: Uwe Hess, Dietmar Schäfer
Register: HRB12386, AG Mageburg

"Virtual business becomes reality!"

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient (or have received this e-mail in
error) please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
====================================================================




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