I'm making a cross-platform program with GTK+ v2.24 and after a lot of things done, I bumped in a problem. This is what I'm attempting to do:
1) Pressing enter in a GtkEntry, fire an event (done with the "activate" signal);
2) Make a dialog appear with a simple message and no buttons;
3) Make the dialog disappear in a fade-out effect after 1 second.
Note: While the dialog appears and then fades out, the main top level window should continue to work (as I have a video feed running in it).
I've searched all over the internet but to no avail. I was hoping that the geniuses around here could help me out on this one. Thank you!
EDIT: I had already found this question, but it is about GTK# and I cannot convert it to GTK+.
Although I'm asnwering my own question (thus not accepting @user4815162342's one), doesn't mean his is wrong, that it didn't work for me nor my answer is better. I just couldn't figure it out due to lack of skills and time (and I got to my result from @user4815162342 advices actually!).
So this is how I did it:
1) Create popup window with GTK_WINDOW_POPUP;
2) Set the popup's position centered, with a different background color and opacity level and size;
3) Create a label and add it to the CONTAINER(popup);
4) Connected the popup to a timeout with gtk_timeout_add(timeInMS, fadeOutCallback, popup);
5) Create the callback like this:
int MyClass::fadeOutCallback(gpointer caller)
{
gtk_window_set_opacity(GTK_WINDOW(caller), gtk_window_get_opacity(GTK_WINDOW(caller)) - 0.03); //The 0.03 makes the rate at fading out
if(gtk_window_get_opacity(GTK_WINDOW(caller)) == 0) //When the popup is completly opaque
{
gtk_widget_hide(GTK_WIDGET(caller));
gtk_widget_destroy(GTK_WIDGET(caller));
return false; //stop the timer
}
return true; //Keeps on calling the callback until the timer reaches timeInMS
}
There are probably much better ways of doing what I want, but this works charm, even with the background video feed playing. Hope this can help anyone. (and thank you again for your input @user4815162342!).