GTK Filemenu

Training Questions and Answers

Moderators: kitty_webb, Ywsp, joanCruz03, yajra1219, Jayem, shela

Post Reply
User avatar
Ichibane
Posts: 47
Joined: Tue Oct 16, 2018 4:37 am

GTK Filemenu

Post by Ichibane » Wed Jul 17, 2019 5:49 am

Code: Select all

#Define __USE_GTK3__
#include once "gtk/gtk.bi"
#LIBPATH "../../lib"
#Define NULL 0

Dim As GtkWidget Ptr win
Dim As GtkWidget Ptr vbox

Dim As GtkWidget Ptr menubar
Dim As GtkWidget Ptr fileMenu
Dim As GtkWidget Ptr fileMi
Dim As GtkWidget Ptr quitMi

gtk_init(NULL, NULL)

win = gtk_window_new(GTK_WINDOW_TOPLEVEL)
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER)
gtk_window_set_default_size(GTK_WINDOW(win), 300, 200)
gtk_window_set_title(GTK_WINDOW(win), "Simple menu")

vbox = gtk_vbox_new(FALSE, 0)
gtk_container_add(GTK_CONTAINER(win), vbox)

menubar = gtk_menu_bar_new()
fileMenu = gtk_menu_new()

fileMi = gtk_menu_item_new_with_label("File")
quitMi = gtk_menu_item_new_with_label("Quit")

gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu)
gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), quitMi)
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi)
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0)

g_signal_connect(G_OBJECT(win), "destroy",G_CALLBACK(@gtk_main_quit), NULL)

g_signal_connect(G_OBJECT(quitMi), "activate",G_CALLBACK(@gtk_main_quit), NULL)

gtk_widget_show_all(win)

gtk_main()

Post Reply