How to put GTK into a C function?



Hi all,
 
I saw from the tutorial that we can write a simple GTK application like the following:
 
#include <gtk/gtk.h>
 
int main( int   argc,
          char *argv[] )
{
    GtkWidget *window;
   
    gtk_init (&argc, &argv);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
   
    gtk_main ();
   
    return 0;
}
 
But now, I want to put it inside a function that will call to pop up a window. What should I do? What should I need to pass as argc and argv[]?
 
......
......
 
function test()
{
    // some logic are here
    //
    //
 
    int returnCode;
 
    returnCode = openDialog(NULL, NULL);
 
}
 
 
int openDialog( int   argc,
          char *argv[] )
{
    GtkWidget *window;
   
    gtk_init (&argc, &argv);
   
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show  (window);
   
    gtk_main ();
   
    return 0;
}
 
Thanks!
 
Best regards,
Mullin


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