Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <gtk/gtk.h>
- #include <cairo.h>
- GtkWidget *window;
- GtkWidget *box, *vbox;
- GtkWidget *menubar;
- GtkWidget *filemenu, *help, *helpmenu;
- GtkWidget *file, *quit, *open, *save, *properties, *about, *test;
- GtkWidget *img;
- void CreateMenu()
- {
- vbox = gtk_vbox_new(FALSE, 0);
- box = gtk_vbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(box), vbox, TRUE, TRUE, 0);
- menubar = gtk_menu_bar_new();
- filemenu = gtk_menu_new();
- file = gtk_menu_item_new_with_label("File");
- quit = gtk_menu_item_new_with_label("Quit");
- open = gtk_menu_item_new_with_label("Open");
- save = gtk_menu_item_new_with_label("Save");
- properties = gtk_menu_item_new_with_label("Properties");
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
- gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), open);
- gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), save);
- gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), properties);
- gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
- gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
- helpmenu = gtk_menu_new();
- about = gtk_menu_item_new_with_label("About");
- help = gtk_menu_item_new_with_label("Help");
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(help), helpmenu);
- gtk_menu_shell_append(GTK_MENU_SHELL(helpmenu), about);
- gtk_menu_shell_append(GTK_MENU_SHELL(menubar), help);
- gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);
- }
- void show_about()
- {
- GtkWidget *dialog;
- const char *author[]={"None yet", "(However, Special thanks to Mehedi Hasan :-) )",NULL};
- dialog=gtk_about_dialog_new();
- gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(dialog),"You just clicked about!");
- gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(dialog),author);
- gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(dialog),"Good job and go to hell");
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER);
- gtk_dialog_run(GTK_DIALOG(dialog));
- }
- int main(int argc, char*argv[])
- {
- 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), 800, 500);
- gtk_window_set_title(GTK_WINDOW(window), "Aaarghhhh");
- CreateMenu();
- img = gtk_image_new_from_file("C:\\Users\\Public\\Pictures\\Sample Pictures\\Penguins.jpg");
- gtk_box_pack_start(GTK_BOX(box), img, TRUE, TRUE, 0);
- gtk_container_add(GTK_CONTAINER(window), box);
- g_signal_connect_swapped(G_OBJECT(about), "activate", G_CALLBACK(show_about), NULL);
- g_signal_connect_swapped(G_OBJECT(window), "destroy",G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(G_OBJECT(quit), "activate",G_CALLBACK(gtk_main_quit), NULL);
- gtk_widget_show_all(window);
- gtk_main();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement