SHARE
TWEET

Untitled

a guest Nov 9th, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <gtk/gtk.h>
  2. #include <gdk/gdkkeysyms.h>
  3.  
  4. int main(int argc, char *argv[]) {
  5.  
  6.   GtkWidget *window;
  7.   GtkWidget *vbox;
  8.  
  9.   GtkWidget *menubar;
  10.   GtkWidget *fileMenu;
  11.   GtkWidget *fileMi;
  12.   GtkWidget *newMi;
  13.   GtkWidget *openMi;
  14.   GtkWidget *quitMi;
  15.  
  16.   GtkWidget *sep;
  17.  
  18.   GtkAccelGroup *accel_group = NULL;
  19.  
  20.   gtk_init(&argc, &argv);
  21.  
  22.   window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  23.   gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  24.   gtk_window_set_default_size(GTK_WINDOW(window), 300, 200);
  25.   gtk_window_set_title(GTK_WINDOW(window), "Images");
  26.  
  27.   vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
  28.   gtk_container_add(GTK_CONTAINER(window), vbox);
  29.  
  30.   menubar = gtk_menu_bar_new();
  31.   fileMenu = gtk_menu_new();
  32.  
  33.   accel_group = gtk_accel_group_new();
  34.   gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);
  35.  
  36.   fileMi = gtk_menu_item_new_with_mnemonic("_File");
  37.   newMi = gtk_menu_item_new_with_mnemonic("_New");
  38.   openMi = gtk_menu_item_new_with_mnemonic("_Open");
  39.   sep = gtk_separator_menu_item_new();
  40.   quitMi = gtk_menu_item_new_with_mnemonic("_Quit");
  41.  
  42.   gtk_widget_add_accelerator(quitMi, "activate", accel_group,
  43.       GDK_OK, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
  44.  
  45.   gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileMi), fileMenu);
  46.   gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), newMi);
  47.   gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), openMi);
  48.   gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), sep);
  49.   gtk_menu_shell_append(GTK_MENU_SHELL(fileMenu), quitMi);
  50.   gtk_menu_shell_append(GTK_MENU_SHELL(menubar), fileMi);
  51.   gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
  52.  
  53.   g_signal_connect(G_OBJECT(window), "destroy",
  54.       G_CALLBACK(gtk_main_quit), NULL);
  55.  
  56.   g_signal_connect(G_OBJECT(quitMi), "activate",
  57.       G_CALLBACK(gtk_main_quit), NULL);
  58.  
  59.   gtk_widget_show_all(window);
  60.  
  61.   gtk_main();
  62.  
  63.   return 0;
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top