GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Intro window

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
genepi
Familiar Face


Joined: 12 Apr 2008
Posts: 6

PostPosted: Sun May 04, 2008 7:09 pm    Post subject: Intro window Reply with quote

Hi,

what is the best way how to make an "intro window"?
More precisely, I have an image I would like to show before main window for 10 seconds. It's png format and I would like only the image and not the whole window to be showed. How can I do that?

Thanks
Back to top
cofcof
Familiar Face


Joined: 02 Apr 2008
Posts: 16

PostPosted: Mon May 05, 2008 1:13 am    Post subject: Reply with quote

Hi Genepi

Easy:

1. Make a new window
2. put a GtkImage on it
3. make sure the GtkImage is your png (I use anjuta so I do it in the IDE)
4. set the propriety of your window correctly, i.e.
set the type_hint of the window to GDK_WINDOW_TYPE_HINT_SPLASHSCREEN
since what you want is a splash screen.

5. in your main, add:
gtk_widget_show(window_10_sec);
g_timeout_add (10000, function_to_call, windows_10_sec);

with for example

Code: (C)
1
2
3
4
5
gboolean function_to_call(gpointer data){
    GtkWidget * window_10_sec = (GtkWidget *) data;
    gtk_widget_hide(window_10_sec);
    return(FALSE);
}


10 sec is quite long I believe!

Note that if you use gtk+- >2.14 you can use the function
g_timeout_add_seconds () instead.
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 427
Location: Portland, OR USA

PostPosted: Mon May 05, 2008 7:22 pm    Post subject: Reply with quote

Also, as a usability note, sometimes a splash screen is annoying. You should allow users to disable it in the preferences for you application.

If you are using a splash screen because your application is loading a lot of data which takes significant time, you don't need a timeout function to display it. Instead, display the splash screen window as the first thing in your app, and then destory it once everything has loaded (after all other routines).
Back to top
genepi
Familiar Face


Joined: 12 Apr 2008
Posts: 6

PostPosted: Mon May 05, 2008 11:32 pm    Post subject: Reply with quote

Thanks a lot. It works perfectly. Just one thing - on the image is logo and the background is transparent - can I somehow keep the transparency of the image?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP