Re: Hello and Help Pleaseeeee :)

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

 



Hi,

NunO fELICIO wrote:
But my problem is that the windows only appear as the program execution
reach gtk_main :(

i want just to do like this....
start:
show_splash_window();
wait_5_seconds();
while(NO_KEY)
show_inactive_window(); // window that show some thing like ("Please press
any key...." )
show_first_window();
show_second_window();
goto start;

You need to call gtk_main() every time you show a window, and gtk_main_quit() to exit gtk_main().


Something like this:

#include <stdio.h>
#include <gtk/gtk.h>

void
button_click( GtkWidget *button )
{
       /* This will make the gtk_main() which called us return.
        */
       gtk_main_quit();
}

GtkWidget *
make_window( int n )
{
       GtkWidget *window;
       GtkWidget *button;
       char label[256];

window = gtk_window_new( GTK_WINDOW_TOPLEVEL );

       snprintf( label, 256, "Loop #%d", n );
       button = gtk_button_new_with_label( label );
       g_signal_connect( G_OBJECT( button ), "clicked",
               G_CALLBACK( button_click ), NULL );
       gtk_container_add( GTK_CONTAINER( window ), button );

       return( window );
}

int
main( int argc, char **argv )
{
       int i;

       gtk_set_locale();
       gtk_init( &argc, &argv );

       for( i = 0; i < 10; i++ ) {
               GtkWidget *window;

               window = make_window( i );
               gtk_widget_show_all( window );
               gtk_main();
               gtk_widget_destroy( window );
       }

       return( 0 );
}

Use timeouts and event handlers to spot key presses and the 5 sec thing you were asking about.

John
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux