Question

My program takes a few seconds to start up. I am using clutter for the GUI, and I decided to try and make something pop up to indicate that the program is starting up. I wanted to just have a logo pop up and rotate, then disappear when the program starts.

So in clutter, I figured I could just make a new stage (window) add an actor to it, make the and actor spin, in the first section of the main function. The window will pop up right away, but with no content, but the content wont show until you launch the clutter main loop.

So I was just wondering how I might be able to achieve this using clutter or GTK+.

If you are familar with reaper 4, the audio recording program, this program does something similar to what I want to mine to do.

Was it helpful?

Solution

What you want is called a splash screen. I'm unfamiliar with clutter, but I found this GTK splash screen example.

However, I think you're taking the problem the wrong way. Splash screens are a bad idea because you just add overhead. What you need is improving your startup performance, by doing some CPU and/or IO profiling. Loading stuff on-demand, and not all at once will help.

OTHER TIPS

Unfortunately I'm unfamiliar with Clutter. But I'm pretty sure it will be difficult to render an animation without a main loop running in any high level library. I'd try to put the code that causes the delay into a separate thread and inform the main loop when the startup is done.

Something like this is what i use:

string splashfile = path_templ + "/splashimg.png";

GtkWidget *image=gtk_image_new_from_file(splashfile.c_str());
gtk_container_add(GTK_CONTAINER(SplashWindow), image);


gtk_widget_show_all(SplashWindow);

//Cycle through all iterations (refresh everything in the GUI)
while (gtk_events_pending()){
    gtk_main_iteration();
}
sleep(1);

(... rest of code ...)

gtk_main ();
gdk_threads_leave ();

Especially that last part of while events pending is the key

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top