Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added simple code to reproduce gtk3 library issue in windows/msys2 (#…
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ codebox3 | |
columnedit | ||
window_position_get_set.exe | ||
simpletextview.exe | ||
simplemenu.exe | ||
vte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
// gcc -Wall simplemenu.c -o simplemenu `pkg-config --cflags --libs gtk+-3.0` | ||
|
||
// from https://zetcode.com/gui/gtk2/menusandtoolbars/ | ||
|
||
#include <gtk/gtk.h> | ||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
GtkWidget *window; | ||
GtkWidget *vbox; | ||
|
||
GtkWidget *menubar; | ||
GtkWidget *fileMenu; | ||
GtkWidget *fileMi; | ||
GtkWidget *nothingMi; | ||
GtkWidget *label; | ||
|
||
gtk_init(&argc, &argv); | ||
|
||
window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | ||
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); | ||
gtk_window_set_default_size(GTK_WINDOW(window), 300, 200); | ||
gtk_window_set_title(GTK_WINDOW(window), "Simple menu"); | ||
|
||
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); | ||
gtk_container_add(GTK_CONTAINER(window), vbox); | ||
|
||
menubar = gtk_menu_bar_new(); | ||
fileMenu = gtk_menu_new(); | ||
|
||
fileMi = gtk_menu_item_new_with_label("File"); | ||
nothingMi = gtk_menu_item_new_with_label("Do Nothing"); | ||
|
||
label = gtk_label_new("\nIf you hover for the first time the menu item\n\nFile-->Do Nothing\n\nyou see that the menu item changes colour / becomes selected.\n\nBut if you click on it, then you hover it again\nit won't become selected anymore!"); | ||
|
||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu); | ||
gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), nothingMi); | ||
gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi); | ||
gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); | ||
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | ||
|
||
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); | ||
|
||
gtk_widget_show_all(window); | ||
|
||
gtk_main(); | ||
|
||
return 0; | ||
} |