2 * GNU Midnight Commander/GNOME edition: Pulldown menu code
4 * Copyright (C) 1997 the Free Software Foundation.
6 * Author: Miguel de Icaza (miguel@gnu.org)
16 /* Unused but required by the rest of the code */
17 int menubar_visible
= 1;
19 /* We assume that menu titles are only one word length */
20 Menu
create_menu (char *name
, menu_entry
*entries
, int count
)
24 menu
= (Menu
) g_malloc (sizeof (*menu
));
26 menu
->max_entry_len
= 0;
27 menu
->entries
= entries
;
32 static int menubar_callback (Dlg_head
*h
, WMenu
*menubar
, int msg
, int par
)
34 if (msg
== WIDGET_FOCUS
)
37 return default_proc (h
, msg
, par
);
40 int menubar_event (Gpm_Event
*event
, WMenu
*menubar
)
45 static void menubar_destroy (WMenu
*menubar
)
50 WMenu
*menubar_new (int y
, int x
, int cols
, Menu menu
[], int items
)
52 WMenu
*menubar
= g_new (WMenu
, 1);
56 init_widget (&menubar
->widget
, y
, x
, 1, cols
, (callback_fn
) menubar_callback
,
57 (destroy_fn
) menubar_destroy
, (mouse_h
) menubar_event
, NULL
);
61 menubar
->items
= items
;
62 menubar
->selected
= 0;
63 widget_want_cursor (menubar
->widget
, 0);
65 g_menubar
= gtk_menu_bar_new ();
66 gtk_widget_show (g_menubar
);
67 menubar
->widget
.wdata
= (unsigned long) g_menubar
;
69 for (i
= 0; i
< items
; i
++){
72 child
= gtk_menu_new ();
73 for (j
= 0; j
< menu
[i
]->count
; j
++){
76 entry
= gtk_label_new (menu
[i
]->entries
->text
);
77 gtk_object_set_data (GTK_OBJECT(entry
), "callback", &menu
[i
]->entries
);
78 gtk_widget_show (entry
);
79 gtk_menu_append (GTK_MENU (child
), entry
);
81 /* FIXME: gtk_signal_connect (.... "activate", blah blah, */
83 gtk_menu_bar_append (GTK_MENU_BAR(g_menubar
), child
);
89 menubar_arrange(WMenu
* menubar
)
94 destroy_menu (Menu menu
)