Mercurial > pidgin
annotate console/libgnt/gntmenu.c @ 14827:02b70dc43044
[gaim-migrate @ 17594]
Fix the bindings for scrolling through the histories in the entrybox.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 28 Oct 2006 04:59:07 +0000 |
parents | b7e145ea9076 |
children | 97977138cf29 |
rev | line source |
---|---|
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include "gntmenu.h" |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include <string.h> |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 enum |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 SIGS = 1, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 }; |
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 static GntTreeClass *parent_class = NULL; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
12 static void (*org_draw)(GntWidget *wid); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
13 static void (*org_destroy)(GntWidget *wid); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
14 static void (*org_map)(GntWidget *wid); |
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
15 static gboolean (*org_key_pressed)(GntWidget *w, const char *t); |
14613
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 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 gnt_menu_draw(GntWidget *widget) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 GList *iter; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 chtype type; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 int i; |
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 if (menu->type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 wbkgdset(widget->window, '\0' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 werase(widget->window); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 for (i = 0, iter = menu->list; iter; iter = iter->next, i++) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 GntMenuItem *item = GNT_MENUITEM(iter->data); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 type = ' ' | COLOR_PAIR(GNT_COLOR_HIGHLIGHT); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 if (i == menu->selected) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 type |= A_REVERSE; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 item->priv.x = getcurx(widget->window) + widget->priv.x; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 item->priv.y = getcury(widget->window) + widget->priv.y + 1; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 wbkgdset(widget->window, type); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 wprintw(widget->window, " %s ", item->text); |
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 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 org_draw(widget); |
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 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 GNTDEBUG; |
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 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 gnt_menu_size_request(GntWidget *widget) |
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 GntMenu *menu = GNT_MENU(widget); |
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 if (menu->type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 widget->priv.height = 1; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 widget->priv.width = getmaxx(stdscr); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 widget->priv.height = g_list_length(menu->list) + 2; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 widget->priv.width = 25; /* XXX: */ |
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 } |
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 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 menu_tree_add(GntMenu *menu, GntMenuItem *item, GntMenuItem *parent) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 gnt_tree_add_row_last(GNT_TREE(menu), item, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 gnt_tree_create_row(GNT_TREE(menu), item->text, item->submenu ? ">" : " "), parent); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 if (0 && item->submenu) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 GntMenu *sub = GNT_MENU(item->submenu); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 GList *iter; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 for (iter = sub->list; iter; iter = iter->next) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 GntMenuItem *it = GNT_MENUITEM(iter->data); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 menu_tree_add(menu, it, item); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 gnt_menu_map(GntWidget *widget) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 GntMenu *menu = GNT_MENU(widget); |
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 if (menu->type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 gnt_widget_size_request(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 /* Populate the tree */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 GList *iter; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 gnt_tree_remove_all(GNT_TREE(widget)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 for (iter = menu->list; iter; iter = iter->next) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 GntMenuItem *item = GNT_MENUITEM(iter->data); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 menu_tree_add(menu, item, NULL); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 org_map(widget); |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
91 gnt_tree_adjust_columns(GNT_TREE(widget)); |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 GNTDEBUG; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 menuitem_activate(GntMenu *menu, GntMenuItem *item) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 if (item) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 if (item->submenu) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 GntMenu *sub = GNT_MENU(item->submenu); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 menu->submenu = sub; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 sub->type = GNT_MENU_POPUP; /* Submenus are *never* toplevel */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 sub->parentmenu = menu; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 if (menu->type != GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 GntWidget *widget = GNT_WIDGET(menu); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 item->priv.x = widget->priv.x + widget->priv.width - 1; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 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
|
109 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 gnt_widget_set_position(GNT_WIDGET(sub), item->priv.x, item->priv.y); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 gnt_widget_draw(GNT_WIDGET(sub)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 } else if (item->callback) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 item->callback(item, item->callbackdata); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 while (menu) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 gnt_widget_hide(GNT_WIDGET(menu)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 menu = menu->parentmenu; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 static gboolean |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 gnt_menu_key_pressed(GntWidget *widget, const char *text) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 int current = menu->selected; |
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 if (menu->submenu) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 /*if (gnt_widget_key_pressed(GNT_WIDGET(menu->submenu), text))*/ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 /*return TRUE;*/ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 return (gnt_widget_key_pressed(GNT_WIDGET(menu->submenu), 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 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 if (text[0] == 27 && text[1] == 0) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 /* Escape closes menu */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 GntMenu *par = menu->parentmenu; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 if (par != NULL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 par->submenu = NULL; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 gnt_widget_hide(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 } else |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 gnt_widget_hide(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 return TRUE; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 if (menu->type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 if (text[0] == 27) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 if (strcmp(text + 1, GNT_KEY_LEFT) == 0) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 menu->selected--; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 if (menu->selected < 0) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 menu->selected = g_list_length(menu->list) - 1; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 } else if (strcmp(text + 1, GNT_KEY_RIGHT) == 0) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 menu->selected++; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 if (menu->selected >= g_list_length(menu->list)) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 menu->selected = 0; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 } else if (text[0] == '\r' && text[1] == 0) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 gnt_widget_activate(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 if (current != menu->selected) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 gnt_widget_draw(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 return TRUE; |
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 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 return org_key_pressed(widget, text); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 } |
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 return FALSE; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 } |
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 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 gnt_menu_destroy(GntWidget *widget) |
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 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 g_list_foreach(menu->list, (GFunc)g_object_run_dispose, NULL); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
176 g_list_free(menu->list); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
177 org_destroy(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 gnt_menu_activate(GntWidget *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 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 GntMenuItem *item; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 if (menu->type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 item = g_list_nth_data(menu->list, menu->selected); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 item = gnt_tree_get_selection_data(GNT_TREE(menu)); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 if (item) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 menuitem_activate(menu, item); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 gnt_menu_hide(GntWidget *widget) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 if (menu->parentmenu) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 menu->parentmenu->submenu = NULL; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 gnt_menu_class_init(GntMenuClass *klass) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 GntWidgetClass *wid_class = GNT_WIDGET_CLASS(klass); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 parent_class = GNT_TREE_CLASS(klass); |
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 org_destroy = wid_class->destroy; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 org_map = wid_class->map; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 org_draw = wid_class->draw; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 org_key_pressed = wid_class->key_pressed; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 wid_class->destroy = gnt_menu_destroy; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 wid_class->draw = gnt_menu_draw; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 wid_class->map = gnt_menu_map; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 wid_class->size_request = gnt_menu_size_request; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 wid_class->key_pressed = gnt_menu_key_pressed; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 wid_class->activate = gnt_menu_activate; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 wid_class->hide = gnt_menu_hide; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 GNTDEBUG; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 } |
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 static void |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
227 gnt_menu_init(GTypeInstance *instance, gpointer class) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
228 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
229 GntWidget *widget = GNT_WIDGET(instance); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
230 GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_SHADOW | GNT_WIDGET_NO_BORDER | |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
231 GNT_WIDGET_CAN_TAKE_FOCUS); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
232 GNTDEBUG; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
233 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
235 /****************************************************************************** |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 * GntMenu API |
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 GType |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 gnt_menu_get_gtype(void) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 static GType type = 0; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 if(type == 0) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 static const GTypeInfo info = { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 sizeof(GntMenuClass), |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 NULL, /* base_init */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 NULL, /* base_finalize */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 (GClassInitFunc)gnt_menu_class_init, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 NULL, /* class_finalize */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 NULL, /* class_data */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 sizeof(GntMenu), |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 0, /* n_preallocs */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 gnt_menu_init, /* instance_init */ |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 }; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 type = g_type_register_static(GNT_TYPE_TREE, |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 "GntMenu", |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 &info, 0); |
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 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 return type; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 } |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 GntWidget *gnt_menu_new(GntMenuType type) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
267 GntWidget *widget = g_object_new(GNT_TYPE_MENU, NULL); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 GntMenu *menu = GNT_MENU(widget); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 menu->list = NULL; |
14616
f1f1dcb26d89
[gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14613
diff
changeset
|
270 menu->selected = 0; |
14613
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 menu->type = type; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 if (type == GNT_MENU_TOPLEVEL) { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 widget->priv.x = 0; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 widget->priv.y = 0; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 } else { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 GNT_TREE(widget)->show_separator = FALSE; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 _gnt_tree_init_internals(GNT_TREE(widget), 2); |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 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
|
280 GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_NO_BORDER); |
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 |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
283 return widget; |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 } |
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 void gnt_menu_add_item(GntMenu *menu, GntMenuItem *item) |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 { |
62bb53609a36
[gaim-migrate @ 17341]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
288 menu->list = g_list_append(menu->list, item); |
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 |