/[james]/archive/guilib/menu_gtk.c
ViewVC logotype

Contents of /archive/guilib/menu_gtk.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16 - (show annotations) (download) (as text)
Mon Feb 10 22:56:40 2003 UTC (21 years, 9 months ago) by james
File MIME type: text/x-csrc
File size: 1849 byte(s)
Initial import.

1 /*
2 * menu_riscos.c -- menu creation, RISC OS
3 */
4
5 #include "gui.h"
6
7
8 void gui_menu_activate(GtkMenuItem *menu_item, gpointer data)
9 {
10 struct gui_menu_data *menu = data;
11 unsigned int item, i, j;
12 signed int selection[17];
13
14 for (item = 0; menu->item[item] != menu_item; item++)
15 ;
16
17 printf("gui_menu_activate: menu 0x%x, item %i, selection ", (unsigned int) data, item);
18
19 selection[16] = -1;
20 selection[15] = item;
21 for (i = 14; menu->parent != NULL; menu = menu->parent, i--)
22 selection[i] = menu->i;
23
24 for (j = i + 1; j < 16; j++)
25 printf("%i ", selection[j]);
26 printf("\n");
27
28 gui_window_list[menu_window_id].menu_fn(menu_window_id, &selection[i + 1]);
29 }
30
31
32 struct gui_menu_data *gui_menu(unsigned int base, unsigned int items)
33 {
34 char *text;
35 unsigned int line, i;
36 struct gui_menu_data *menu;
37
38 menu = malloc(sizeof(struct gui_menu_data));
39 if (menu == NULL) gui_raise_error("out of memory");
40
41 menu->item = malloc(sizeof(GtkWidget *) * items);
42 if (menu->item == NULL) gui_raise_error("out of memory");
43
44 menu->menu = gtk_menu_new();
45 menu->size = items;
46 menu->parent = NULL;
47
48 for (i = 0; i < items; i++)
49 {
50 text = gui_message[base + 1 + i];
51
52 line = (text[0] == '-'); if (line) text++;
53
54 menu->item[i] = gtk_menu_item_new_with_label(text);
55 gtk_menu_append(menu->menu, menu->item[i]);
56 gtk_widget_show(menu->item[i]);
57 gtk_signal_connect(menu->item[i], "activate", gui_menu_activate, menu);
58
59 if (line)
60 {
61 GtkWidget *sep = gtk_menu_item_new();
62 gtk_menu_append(menu->menu, sep);
63 gtk_widget_show(sep);
64 }
65 }
66
67 return menu;
68 }
69
70
71 void gui_menu_attach(struct gui_menu_data *menu, unsigned int item,
72 struct gui_menu_data *submenu)
73 {
74 gtk_menu_item_set_submenu(menu->item[item], submenu->menu);
75 submenu->parent = menu;
76 submenu->i = item;
77 }

  ViewVC Help
Powered by ViewVC 1.1.26