File: gmenu.c

package info (click to toggle)
mc 4.1.35-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 6,924 kB
  • ctags: 9,665
  • sloc: ansic: 84,273; tcl: 1,779; makefile: 1,266; sh: 864; perl: 262; awk: 148; sed: 93; csh: 1
file content (97 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*
 * GNU Midnight Commander/GNOME edition: Pulldown menu code
 *
 * Copyright (C) 1997 the Free Software Foundation.
 *
 * Author: Miguel de Icaza (miguel@gnu.org)
 */

#include <config.h>
#include <string.h>
#include <malloc.h>
#include "main.h"
#include "mad.h"
#include "menu.h"
#include "x.h"

/* Unused but required by the rest of the code */
int menubar_visible = 1;

/* We assume that menu titles are only one word length */
Menu create_menu (char *name, menu_entry *entries, int count)
{
    Menu menu;

    menu = (Menu) xmalloc (sizeof (*menu), "create_menu");
    menu->count = count;
    menu->max_entry_len = 0;
    menu->entries = entries;
    menu->name = name;
    return menu;
}

static int menubar_callback (Dlg_head *h, WMenu *menubar, int msg, int par)
{
    if (msg == WIDGET_FOCUS)
	return 0;
    
    return default_proc (h, msg, par);
}

int menubar_event (Gpm_Event *event, WMenu *menubar)
{
    return MOU_NORMAL;
}

static void menubar_destroy (WMenu *menubar)
{
    /* nothing yet */
}

WMenu *menubar_new (int y, int x, int cols, Menu menu [], int items)
{
    WMenu *menubar = (WMenu *) xmalloc (sizeof (WMenu), "menubar_new");
    GtkWidget *g_menubar;
    int i, j;
    
    init_widget (&menubar->widget, y, x, 1, cols, (callback_fn) menubar_callback,
		 (destroy_fn)  menubar_destroy, (mouse_h) menubar_event, NULL);
    menubar->menu = menu;
    menubar->active = 0;
    menubar->dropped = 0;
    menubar->items = items;
    menubar->selected = 0;
    widget_want_cursor (menubar->widget, 0);
    
    g_menubar = gtk_menu_bar_new ();
    gtk_widget_show (g_menubar);
    menubar->widget.wdata = (unsigned long) g_menubar;

    for (i = 0; i < items; i++){
	    GtkWidget *child;

	    child = gtk_menu_new ();
	    for (j = 0; j < menu [i]->count; j++){
		    GtkWidget *entry;
		    
		    entry = gtk_label_new (menu [i]->entries->text);
		    gtk_object_set_data (GTK_OBJECT(entry), "callback", &menu [i]->entries);
		    gtk_widget_show (entry);
		    gtk_menu_append (GTK_MENU (child), entry);

		    /* FIXME: gtk_signal_connect (.... "activate", blah blah, */
	    }
	    gtk_menu_bar_append (GTK_MENU_BAR(g_menubar), child);
    }
    return menubar;
}

void
menubar_arrange(WMenu* menubar)
{
}

void
destroy_menu (Menu menu)
{
}