annotate console/libgnt/test/menu.c @ 15243:3a13e7e2ed33

[gaim-migrate @ 18032] snactypes.h defines constants for these subtypes (and others). Changed the magic numbers to use the constants, increasing readability. The same should be done for the other families, as well. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 20 Dec 2006 20:29:11 +0000
parents f1f1dcb26d89
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1 #include "gnt.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
2 #include "gntbox.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3 #include "gntlabel.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include "gntmenu.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5 #include "gntmenuitem.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 #include "gntwindow.h"
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
7
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
8 void dothis(GntMenuItem *item, gpointer null)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
9 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
10 GntWidget *w = gnt_vbox_new(FALSE);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 gnt_box_set_toplevel(GNT_BOX(w), TRUE);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12 gnt_box_add_widget(GNT_BOX(w),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
13 gnt_label_new("Callback to a menuitem"));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
14 gnt_widget_show(w);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
15 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
16
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17 int main()
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 freopen(".error", "w", stderr);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 gnt_init();
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 GntWidget *menu = gnt_menu_new(GNT_MENU_TOPLEVEL);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 GObject *item = gnt_menuitem_new("File");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 gnt_menu_add_item(GNT_MENU(menu), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 item = gnt_menuitem_new("Edit");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 gnt_menu_add_item(GNT_MENU(menu), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 item = gnt_menuitem_new("Help");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 gnt_menu_add_item(GNT_MENU(menu), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 gnt_menuitem_set_submenu(GNT_MENUITEM(item), GNT_MENU(sub));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 item = gnt_menuitem_new("Online Help");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 gnt_menu_add_item(GNT_MENU(sub), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 item = gnt_menuitem_new("About");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 gnt_menu_add_item(GNT_MENU(sub), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 sub = gnt_menu_new(GNT_MENU_POPUP);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 gnt_menuitem_set_submenu(GNT_MENUITEM(item), GNT_MENU(sub));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 item = gnt_menuitem_new("Online Help");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46 gnt_menu_add_item(GNT_MENU(sub), GNT_MENUITEM(item));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 gnt_menuitem_set_callback(GNT_MENUITEM(item), dothis, NULL);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 gnt_screen_menu_show(menu);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51 GntWidget *win = gnt_window_new();
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 gnt_box_add_widget(GNT_BOX(win),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 gnt_label_new("..."));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 gnt_box_set_title(GNT_BOX(win), "Title");
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 gnt_window_set_menu(GNT_WINDOW(win), GNT_MENU(menu));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 gnt_widget_show(win);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 gnt_main();
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
59
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
60 gnt_quit();
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 return 0;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
64