Update gtk3.cpp
This commit is contained in:
parent
ec071f2fad
commit
a3b37d2146
|
@ -3,18 +3,19 @@ void hello(GtkWidget *widget,gpointer data){
|
||||||
g_print("hello\n");
|
g_print("hello\n");
|
||||||
}
|
}
|
||||||
int main(int argc,char *argv[]){
|
int main(int argc,char *argv[]){
|
||||||
GtkWidget *window;
|
GtkWidget *window;//Point to window
|
||||||
GtkWidget *button;
|
GtkWidget *button;//point to button
|
||||||
gtk_init(&argc,&argv);
|
gtk_init(&argc,&argv);//inital
|
||||||
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);
|
g_signal_connect(G_OBJECT(window),"delete_event",G_CALLBACK(gtk_main_quit),NULL);//Create a window
|
||||||
gtk_window_set_title(GTK_WINDOW(window),"Gtk(3) Test");
|
gtk_window_set_title(GTK_WINDOW(window),"Gtk(3) Test");//Window title
|
||||||
gtk_window_set_default_size(GTK_WINDOW(window),40,20);
|
gtk_window_set_default_size(GTK_WINDOW(window),40,20);//Window size
|
||||||
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
|
gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);//Window Position
|
||||||
button=gtk_button_new_with_label("hello");
|
button=gtk_button_new_with_label("hello");//Create button
|
||||||
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(hello),NULL);
|
g_signal_connect(G_OBJECT(button),"clicked",G_CALLBACK(hello),NULL);//Call a function when clicked
|
||||||
gtk_container_add(GTK_CONTAINER(window),button);
|
gtk_container_add(GTK_CONTAINER(window),button);//Add button to window
|
||||||
gtk_widget_show(window);
|
gtk_widget_show(window);//show window
|
||||||
gtk_widget_show(button);
|
gtk_widget_show(button);//show button
|
||||||
gtk_main();
|
gtk_main();//Main Function
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue