Codepage messages related translated & other stuff...
[midnight-commander.git] / gnome / gmenu.c
blob1e99b859d138f747ba88a8102e27d1f6f1bdbea8
1 /*
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)
7 */
9 #include <config.h>
10 #include <string.h>
11 #include "global.h"
12 #include "main.h"
13 #include "menu.h"
14 #include "x.h"
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)
22 Menu menu;
24 menu = (Menu) g_malloc (sizeof (*menu));
25 menu->count = count;
26 menu->max_entry_len = 0;
27 menu->entries = entries;
28 menu->name = name;
29 return menu;
32 static int menubar_callback (Dlg_head *h, WMenu *menubar, int msg, int par)
34 if (msg == WIDGET_FOCUS)
35 return 0;
37 return default_proc (h, msg, par);
40 int menubar_event (Gpm_Event *event, WMenu *menubar)
42 return MOU_NORMAL;
45 static void menubar_destroy (WMenu *menubar)
47 /* nothing yet */
50 WMenu *menubar_new (int y, int x, int cols, Menu menu [], int items)
52 WMenu *menubar = g_new (WMenu, 1);
53 GtkWidget *g_menubar;
54 int i, j;
56 init_widget (&menubar->widget, y, x, 1, cols, (callback_fn) menubar_callback,
57 (destroy_fn) menubar_destroy, (mouse_h) menubar_event, NULL);
58 menubar->menu = menu;
59 menubar->active = 0;
60 menubar->dropped = 0;
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++){
70 GtkWidget *child;
72 child = gtk_menu_new ();
73 for (j = 0; j < menu [i]->count; j++){
74 GtkWidget *entry;
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);
85 return menubar;
88 void
89 menubar_arrange(WMenu* menubar)
93 void
94 destroy_menu (Menu menu)