Re: Splash screen as widget



John,
Thank you for quick reply.

By the way, why splash screen is not in the default set of library widgets? I believe it is very common thing for almost all modern applications...

1) I think command
       splash = MY_SPLASH(g_object_new(my_splash_get_type(), NULL));
should create new window (since GtkWindow is a parent) but how can I set to
this new window GTK_WINDOW_POPUP as GtkWindowType?

In your _init() function, do

       gtk_window_set_type_hint( GTK_WINDOW( splash ),
               GDK_WINDOW_TYPE_HINT_SPLASHSCREEN );
Sorry, it did not do anything useful. I still get the normal window with title and max/min/close icons. And I see splash window in task-bar (which is the main reason I'd like to open window with GTK_WINDOW_POPUP).

2) I am inheriting MySplash from GtkWindow:
But when I am trying to cast MySplash as GtkWindow
I get a run-time warning:
GLib-GObject-WARNING **: invalid cast from `MySplash' to `GtkWindow'
Are you setting GtkWindow as the parent class in your type creator?
Found mistake... I thought it would be enough to use GtkWindow & GtkWindowClass as first members of my own structures, and forget about the first parameter to gtk_type_unique(), I did set it up to GTK_TYPE_WIDGET (copy-paste from tutorial). As soon as I change it to GTK_TYPE_WINDOW - everything starts to work.

That rises another question: Tutorial I read, suggests to use g_type_register_static() with GTypeInfo structure instead of gtk_type_unique() with GtkTypeInfo. Author of tutorial does not explain why he prefer g_type_register_static() over gtk_type_unique(). I guess, first function registers class on GLib level and second on GTK level? My question is what is the difference between this two approaches? Which one better to use and when?


       while(gtk_events_pending()) {
               gtk_main_iteration();
       }

That's from a rather old tutorial, better to use:

       while( g_main_context_iteration( NULL, FALSE ) )
               ;
Why is that better? One is for gtk events only, other also works with glib events?


Here's the splash class from my app, for what it's worth:
Thank you, it gave me some ideas :)





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