'How to display an additional window with a gtk C query?
I would like a window to appear when I start a program in C using GTK+ 3.0, asking for a number to be entered, once entered this window closes and the main window opens, where the actual program takes place using the parameter specified by the user. I have no idea how to do this, I would appreciate any help.
int main( int argc,char *argv[] ){
gtk_init(&argc,&argv);
GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window),"Sudoku");
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
gtk_container_set_border_width(GTK_CONTAINER(window),8);
g_signal_connect(G_OBJECT(window),"destroy",G_CALLBACK(gtk_main_quit),NULL);
GtkWidget *box1=gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
gtk_container_add(GTK_CONTAINER(window),box1);
CreateBoard(box1); //my function
CreateControl(box1); //my function
gtk_widget_show_all(window);
srand(time(NULL));
StartGame(); //my function
gtk_main();
return 0;
}
Above is my main function, I create the main window in it. Using which functions from GTK can I create another window which is displayed before the main one?
Solution 1:[1]
Try to first convert the query into a fixed length char array[1024], then make another char array (signed or unsigned, it doesn't matter).
Use the strlen() defined in <stdlib.h> function to find the length of the array, which you can then use to output as a short.
Assign each short to a particular char array, and since each array is of a different length, that is essentially an identifier for that char array, which you can just call upon during the runtime. That should make it easier to query the variables.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bilberto |
