|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Splash screen as widgetI am trying to make splash screen as widget.
Problems are: 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? 2) I am inheriting MySplash from GtkWindow: struct _MySplash { GtkWindow window; GtkWidget *label, *progressBar; }; But when I am trying to cast MySplash as GtkWindow --- MySplash * my_splash_new(GdkPixbuf *pixbuf) { MySplash *splash; GtkWidget *vbox, *image; // actual object creation splash = MY_SPLASH(g_object_new(my_splash_get_type(), NULL)); gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER_ALWAYS); ---- I get a run-time warning: GLib-GObject-WARNING **: invalid cast from `MySplash' to `GtkWindow' Gtk-CRITICAL **: gtk_window_set_position: assertion `GTK_IS_WINDOW (window)' failed Same thing with GTK_CONTAINER(splash) or even GTK_CONTAINER(&(splash->window)) 3) Each time label or progress bar is updated on splash screen, it should be updated on the real screen, so I define (by tutorial): void gtk_splash_set_text(GtkWidget *widget, const gchar *text) { MySplash *splash; g_return_if_fail (widget != NULL); g_return_if_fail (IS_MY_SPLASH (widget)); splash = MY_SPLASH (widget); gtk_label_set_text( splash->label, text); while(gtk_events_pending()) { gtk_main_iteration(); } } Do I have to define first parameter here as GtkWidget or can I define it directly as MySplash *splash? Also I am a confused, loop while(gtk_events_pending()) gtk_main_iteration(); will run BEFORE gtk_main_loop(), Since splash screen always shown during initialization phase of application. Will this loop work? _______________________________________________ gtk-list mailing list gtk-list@... http://mail.gnome.org/mailman/listinfo/gtk-list |
|
|
Re: Splash screen as widgetHi,
2008/6/9 George Brink <siberianowl@...>: > 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 ); > 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? > 3) Each time label or progress bar is updated on splash screen, it should be > updated on the real screen, so I define (by tutorial): > while(gtk_events_pending()) { > gtk_main_iteration(); > } That's from a rather old tutorial, better to use: while( g_main_context_iteration( NULL, FALSE ) ) ; > Also I am a confused, loop while(gtk_events_pending()) gtk_main_iteration(); > will run BEFORE gtk_main_loop(), Since splash screen always shown during > initialization phase of application. Will this loop work? Yes, should work fine. Here's the splash class from my app, for what it's worth: http://vips.svn.sourceforge.net/viewvc/vips/nip2/trunk/src/boxes.c?view=markup search for 'splash'. John _______________________________________________ gtk-list mailing list gtk-list@... http://mail.gnome.org/mailman/listinfo/gtk-list |
|
|
Re: Splash screen as widgetJohn,
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 ); 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 :) _______________________________________________ gtk-list mailing list gtk-list@... http://mail.gnome.org/mailman/listinfo/gtk-list |
|
|
Re: Splash screen as widget2008/6/11 George Brink <siberianowl@...>:
> 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... There's one in GNOME, but it's not been pushed down into GTK. There was a discussion about it, I seem to remember, but I forget why it was resisted. The HIG says that your app should start up quickly enough that it doesn't need a splash screen, which is good advice, if not always possible. GIMP still has a splash widget, heh. > 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 The type system used to be in GTK, but for gtk2.0 it was moved down a layer into glib (as the gobject library). So the modern, recommended way is g_type_register_static() and gtk_type_unique() is now just a compatibility stub. You still see it sometimes in code that's been ported from gtk-1.2. >>> 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? Same reason: the main loop used to be part of gtk, but in the 2.0 series it's been pushed down into glib and the gtk functions are just compatibility stubs. John _______________________________________________ gtk-list mailing list gtk-list@... http://mail.gnome.org/mailman/listinfo/gtk-list |
| Free Forum Powered by Nabble | Forum Help |