I would like to write a simple popup contextual menu with C langage using GTK4. I did that with GTK3 but I am lost with hje way to do with GTK4

37 views Asked by At

Here is an extract of GTK3 code. I would like the translation with GTK4.

  GtkWidget *menu, *item1, *item2, *item3;

  menu = gtk_menu_new();
  item1 = gtk_menu_item_new_with_label("Item 1");
  item2 = gtk_menu_item_new_with_label("Item 2");
  item3 = gtk_menu_item_new_with_label("Item 3");

  g_signal_connect(item1, "activate", G_CALLBACK (on_popup_menu_selection), "Item 1");
  g_signal_connect(item3, "activate", G_CALLBACK (on_popup_menu_selection), "Item 2");
  g_signal_connect(item3, "activate", G_CALLBACK (on_popup_menu_selection), "Item 3");

  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item1);
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item2);
  gtk_menu_shell_append(GTK_MENU_SHELL(menu), item3);

  gtk_widget_show_all (menu);

The GTK4 documentation is obsure for me on this subject, and I did not find example in tutorials.

0

There are 0 answers