LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-19-2004, 09:31 PM   #1
Thetargos
Senior Member
 
Registered: Mar 2003
Location: Mexico City
Distribution: Fedora, Ubuntu & Mint
Posts: 1,679

Rep: Reputation: 45
Making a splash screen with GTK+(2.0)


Hi again, guys.

I'm looking for some way to make a splash screen for an application I already have. Following the same logic as to make a pixmap appear on a button, I've managed to write a little function that does something like this (it does not use window decorations and only contains one box which holds the pixmap I want to show). My problem is that (since I did not add any event handler nor callback to it) the window just sits there, how can I make a timed "delete_event" call and at the same time delay a little bit the showing of the main application window?

Thanks!

Last edited by Thetargos; 03-19-2004 at 09:32 PM.
 
Old 03-19-2004, 10:56 PM   #2
Thetargos
Senior Member
 
Registered: Mar 2003
Location: Mexico City
Distribution: Fedora, Ubuntu & Mint
Posts: 1,679

Original Poster
Rep: Reputation: 45
Ok, I've figured out how to make the actual splash screen using an undecorated window, but now I face the fact that the window gets created on the top-left corner, how do I make it appear in the center of the screen always? edit: I should really first look into the API reference before posting


BTW I think the best way to have it temporized would be to do so as the actual callback function, that while it's running the main window will not appear. Here's the code that (thus far) I have:
Code:
/* Test program to see if a splash image can be loaded prior a program window */

#include <gtk/gtk.h>

static GtkWidget *splash (void)
{
	static GtkWidget *splash;
	GtkWidget *imgbox;
	GtkWidget *image;
		
	/* Splash window */
	splash = gtk_window_new (GTK_WINDOW_TOPLEVEL);

		/* Not managed window */
	gtk_window_set_decorated (GTK_WINDOW (splash), FALSE);
        gtk_window_set_psoition (GTK_WINDOW (splash), GTK_WIN_POS_CENTER_ALWAYS);
	
	/* Image container box */
	imgbox = gtk_hbox_new (FALSE, 0);
	gtk_container_add (GTK_CONTAINER (splash), imgbox);
	
	/* Image */
	image = gtk_image_new_from_file ("/path/to/image/image.xpm");
	gtk_box_pack_start (GTK_BOX (imgbox), image, FALSE, FALSE, 0);
	
	/* Set the signals */
	g_signal_connect (G_OBJECT (splash), "destroy", G_CALLBACK (gtk_main_quit),NULL);
	g_signal_connect (G_OBJECT (splash), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
	
	gtk_widget_show_all (splash);
	
}

int main (int argc, char **argv)
{
	
	gtk_init (&argc, &argv);
		
	splash ();
	
	gtk_main ();
	
	return 0;
}
As you can see the only way to destroy the window right now is by catching the delete_event event from the WM (in my case with FC1 and GNOME, alt-F4)

Now I've gotta get to write the code for the timed window kill

Last edited by Thetargos; 03-19-2004 at 11:10 PM.
 
Old 04-19-2004, 01:02 PM   #3
revof11
Member
 
Registered: Nov 2003
Location: Macungie, PA
Distribution: Fedora Core 9, Gentoo 2008.0
Posts: 108

Rep: Reputation: 15
Question timed close


I'm completely new at GTK+... but...

Right now I am just adding a timer to my application.
Here's a snippit of what I am doing:

Before calling gtk_main
gtk_timeout_add(1000, window_timeout, NULL);

The window_timeout function
gint window_timeout(gpointer data)
{
if (++timer == 2)
gtk_main_quit();

return TRUE;
}

Hope that works for you (if you haven't already gotten something)...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating kde splash screen boot screen JUDOLIZARD Linux - Newbie 6 01-30-2009 12:32 PM
Splash Screen dimension8300 SUSE / openSUSE 5 02-20-2005 03:40 PM
Splash screen - What?? Micro420 Mandriva 5 09-07-2003 03:36 PM
splash screen rh 7.3 klod Linux - Software 0 05-09-2003 04:12 AM
splash screen snocked Linux - Newbie 1 01-12-2003 12:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration