annotate console/libgnt/gntmenu.c @ 15765:51dd9ae01585

pass the correct domain to cyrus sasl (sf patch 1663064)
author Nathan Walp <nwalp@pidgin.im>
date Sat, 03 Mar 2007 19:18:38 +0000
parents 1bd0456fe1c3
children 682022b8a129
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 "gntmenu.h"
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
2 #include "gntmenuitemcheck.h"
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
3
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
4 #include <string.h>
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
5
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
6 enum
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 SIGS = 1,
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
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
11 static GntTreeClass *parent_class = NULL;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
12
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
13 static void (*org_draw)(GntWidget *wid);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
14 static void (*org_destroy)(GntWidget *wid);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
15 static void (*org_map)(GntWidget *wid);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
16 static gboolean (*org_key_pressed)(GntWidget *w, const char *t);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
17
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
18 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
19 gnt_menu_draw(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
20 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
21 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
22 GList *iter;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
23 chtype type;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
24 int i;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 if (menu->type == GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
28 werase(widget->window);
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 for (i = 0, iter = menu->list; iter; iter = iter->next, i++) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 GntMenuItem *item = GNT_MENUITEM(iter->data);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 type = ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33 if (i == menu->selected)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
34 type |= A_REVERSE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 item->priv.x = getcurx(widget->window) + widget->priv.x;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 item->priv.y = getcury(widget->window) + widget->priv.y + 1;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 wbkgdset(widget->window, type);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 wprintw(widget->window, " %s ", item->text);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 org_draw(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 GNTDEBUG;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
46
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
47 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
48 gnt_menu_size_request(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
50 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
51
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
52 if (menu->type == GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 widget->priv.height = 1;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 widget->priv.width = getmaxx(stdscr);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 widget->priv.height = g_list_length(menu->list) + 2;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
57 widget->priv.width = 25; /* XXX: */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
58 }
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
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
61 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
62 menu_tree_add(GntMenu *menu, GntMenuItem *item, GntMenuItem *parent)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
63 {
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
64 if (GNT_IS_MENUITEM_CHECK(item)) {
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
65 gnt_tree_add_choice(GNT_TREE(menu), item,
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
66 gnt_tree_create_row(GNT_TREE(menu), item->text, " "), parent, NULL);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
67 gnt_tree_set_choice(GNT_TREE(menu), item, gnt_menuitem_check_get_checked(GNT_MENUITEM_CHECK(item)));
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
68 } else
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
69 gnt_tree_add_row_last(GNT_TREE(menu), item,
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
70 gnt_tree_create_row(GNT_TREE(menu), item->text, item->submenu ? ">" : " "), parent);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
71
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
72 if (0 && item->submenu) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
73 GntMenu *sub = GNT_MENU(item->submenu);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
74 GList *iter;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
75 for (iter = sub->list; iter; iter = iter->next) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 GntMenuItem *it = GNT_MENUITEM(iter->data);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 menu_tree_add(menu, it, item);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 gnt_menu_map(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87 if (menu->type == GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 gnt_widget_size_request(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 /* Populate the tree */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 GList *iter;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92 gnt_tree_remove_all(GNT_TREE(widget));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 for (iter = menu->list; iter; iter = iter->next) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 GntMenuItem *item = GNT_MENUITEM(iter->data);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95 menu_tree_add(menu, item, NULL);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 org_map(widget);
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
98 gnt_tree_adjust_columns(GNT_TREE(widget));
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 GNTDEBUG;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104 menuitem_activate(GntMenu *menu, GntMenuItem *item)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 if (item) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 if (item->submenu) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
108 GntMenu *sub = GNT_MENU(item->submenu);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
109 menu->submenu = sub;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
110 sub->type = GNT_MENU_POPUP; /* Submenus are *never* toplevel */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
111 sub->parentmenu = menu;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
112 if (menu->type != GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
113 GntWidget *widget = GNT_WIDGET(menu);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
114 item->priv.x = widget->priv.x + widget->priv.width - 1;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
115 item->priv.y = widget->priv.y + gnt_tree_get_selection_visible_line(GNT_TREE(menu));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
116 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
117 gnt_widget_set_position(GNT_WIDGET(sub), item->priv.x, item->priv.y);
14906
1bd0456fe1c3 [gaim-migrate @ 17678]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14900
diff changeset
118 GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(sub), GNT_WIDGET_INVISIBLE);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
119 gnt_widget_draw(GNT_WIDGET(sub));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 } else if (item->callback) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 item->callback(item, item->callbackdata);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122 while (menu) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 gnt_widget_hide(GNT_WIDGET(menu));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 menu = menu->parentmenu;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 static gboolean
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131 gnt_menu_key_pressed(GntWidget *widget, const char *text)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 int current = menu->selected;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 if (menu->submenu) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137 return (gnt_widget_key_pressed(GNT_WIDGET(menu->submenu), text));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 if (text[0] == 27 && text[1] == 0) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 /* Escape closes menu */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142 GntMenu *par = menu->parentmenu;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 if (par != NULL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 par->submenu = NULL;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 gnt_widget_hide(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 } else
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147 gnt_widget_hide(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 return TRUE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
151 if (menu->type == GNT_MENU_TOPLEVEL) {
14876
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
152 if (strcmp(text, GNT_KEY_LEFT) == 0) {
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
153 menu->selected--;
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
154 if (menu->selected < 0)
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
155 menu->selected = g_list_length(menu->list) - 1;
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
156 } else if (strcmp(text, GNT_KEY_RIGHT) == 0) {
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
157 menu->selected++;
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
158 if (menu->selected >= g_list_length(menu->list))
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
159 menu->selected = 0;
70623f0d5cdc [gaim-migrate @ 17645]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14845
diff changeset
160 } else if (strcmp(text, GNT_KEY_ENTER) == 0) {
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 gnt_widget_activate(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164 if (current != menu->selected) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 gnt_widget_draw(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 return TRUE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 return org_key_pressed(widget, text);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 return FALSE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 gnt_menu_destroy(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 GntMenu *menu = GNT_MENU(widget);
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
179 g_list_foreach(menu->list, (GFunc)g_object_unref, NULL);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180 g_list_free(menu->list);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 org_destroy(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 static void
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
185 gnt_menu_toggled(GntTree *tree, gpointer key)
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
186 {
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
187 GntMenuItem *item = GNT_MENUITEM(key);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
188 GntMenu *menu = GNT_MENU(tree);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
189 gboolean check = gnt_menuitem_check_get_checked(GNT_MENUITEM_CHECK(item));
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
190 gnt_menuitem_check_set_checked(GNT_MENUITEM_CHECK(item), !check);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
191 if (item->callback)
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
192 item->callback(item, item->callbackdata);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
193 while (menu) {
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
194 gnt_widget_hide(GNT_WIDGET(menu));
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
195 menu = menu->parentmenu;
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
196 }
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
197 }
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
198
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
199 static void
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200 gnt_menu_activate(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 GntMenuItem *item;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205 if (menu->type == GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 item = g_list_nth_data(menu->list, menu->selected);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 item = gnt_tree_get_selection_data(GNT_TREE(menu));
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
211 if (item) {
14845
b1650510f4b8 [gaim-migrate @ 17614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14843
diff changeset
212 if (GNT_IS_MENUITEM_CHECK(item))
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
213 gnt_menu_toggled(GNT_TREE(widget), item);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
214 else
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
215 menuitem_activate(menu, item);
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
216 }
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
217 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
218
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
219 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
220 gnt_menu_hide(GntWidget *widget)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
221 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
222 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
223 if (menu->parentmenu)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
224 menu->parentmenu->submenu = NULL;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
225 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
226
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
227 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
228 gnt_menu_class_init(GntMenuClass *klass)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
229 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
230 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
231 parent_class = GNT_TREE_CLASS(klass);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
232
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
233 org_destroy = wid_class->destroy;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
234 org_map = wid_class->map;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
235 org_draw = wid_class->draw;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
236 org_key_pressed = wid_class->key_pressed;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
237
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
238 wid_class->destroy = gnt_menu_destroy;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
239 wid_class->draw = gnt_menu_draw;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
240 wid_class->map = gnt_menu_map;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
241 wid_class->size_request = gnt_menu_size_request;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
242 wid_class->key_pressed = gnt_menu_key_pressed;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
243 wid_class->activate = gnt_menu_activate;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
244 wid_class->hide = gnt_menu_hide;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
245
14843
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
246 parent_class->toggled = gnt_menu_toggled;
97977138cf29 [gaim-migrate @ 17612]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14729
diff changeset
247
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
248 GNTDEBUG;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
249 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
250
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
251 static void
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
252 gnt_menu_init(GTypeInstance *instance, gpointer class)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
253 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
254 GntWidget *widget = GNT_WIDGET(instance);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
255 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER |
14900
065e7ac30338 [gaim-migrate @ 17672]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14876
diff changeset
256 GNT_WIDGET_CAN_TAKE_FOCUS | GNT_WIDGET_TRANSIENT);
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
257 GNTDEBUG;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
258 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
259
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
260 /******************************************************************************
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
261 * GntMenu API
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
262 *****************************************************************************/
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
263 GType
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
264 gnt_menu_get_gtype(void)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
265 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
266 static GType type = 0;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
267
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
268 if(type == 0)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
269 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
270 static const GTypeInfo info = {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
271 sizeof(GntMenuClass),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
272 NULL, /* base_init */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
273 NULL, /* base_finalize */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
274 (GClassInitFunc)gnt_menu_class_init,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
275 NULL, /* class_finalize */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
276 NULL, /* class_data */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
277 sizeof(GntMenu),
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
278 0, /* n_preallocs */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
279 gnt_menu_init, /* instance_init */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
280 };
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
281
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
282 type = g_type_register_static(GNT_TYPE_TREE,
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
283 "GntMenu",
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
284 &info, 0);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
285 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
286
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
287 return type;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
288 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
289
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
290 GntWidget *gnt_menu_new(GntMenuType type)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
291 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
292 GntWidget *widget = g_object_new(GNT_TYPE_MENU, NULL);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
293 GntMenu *menu = GNT_MENU(widget);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
294 menu->list = NULL;
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14613
diff changeset
295 menu->selected = 0;
14613
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
296 menu->type = type;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
297
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
298 if (type == GNT_MENU_TOPLEVEL) {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
299 widget->priv.x = 0;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
300 widget->priv.y = 0;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
301 } else {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
302 GNT_TREE(widget)->show_separator = FALSE;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
303 _gnt_tree_init_internals(GNT_TREE(widget), 2);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
304 gnt_tree_set_col_width(GNT_TREE(widget), 1, 1); /* The second column is to indicate that it has a submenu */
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
305 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
306 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
307
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
308 return widget;
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
309 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
310
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
311 void gnt_menu_add_item(GntMenu *menu, GntMenuItem *item)
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
312 {
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
313 menu->list = g_list_append(menu->list, item);
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
314 }
62bb53609a36 [gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
315