Beispiel #1
0
static WEditMenu*
buildSubmenu(_Panel *panel, WMPropList *pl)
{
    WMScreen *scr = WMWidgetScreen(panel->parent);
    WEditMenu *menu;
    WEditMenuItem *item;
    char *title;
    WMPropList *tp, *bp;
    int i;

    tp = WMGetFromPLArray(pl, 0);
    title = WMGetFromPLString(tp);

    menu = WCreateEditMenu(scr, title);

    for (i = 1; i < WMGetPropListItemCount(pl); i++) {
        WMPropList *pi;

        pi = WMGetFromPLArray(pl, i);

        tp = WMGetFromPLArray(pi, 0);
        bp = WMGetFromPLArray(pi, 1);

        title = WMGetFromPLString(tp);

        if (!bp || WMIsPLArray(bp)) {	       /* it's a submenu */
            WEditMenu *submenu;

            submenu = buildSubmenu(panel, pi);

            item = WAddMenuItemWithTitle(menu, title);

            WSetEditMenuSubmenu(menu, item, submenu);
        } else {
            ItemData *data;

            item = WAddMenuItemWithTitle(menu, title);

            data = parseCommand(pi);

            if (panel->markerPix[data->type])
                WSetEditMenuItemImage(item, panel->markerPix[data->type]);
            WSetEditMenuItemData(item, data, (WMCallback*)freeItemData);
        }
    }

    WSetEditMenuAcceptsDrop(menu, True);
    WSetEditMenuDelegate(menu, &menuDelegate);

    WMRealizeWidget(menu);

    return menu;
}
Beispiel #2
0
static ItemData *putNewItem(_Panel * panel, WEditMenu * menu, int type, const char *title)
{
	WEditMenuItem *item;
	ItemData *data;

	item = WAddMenuItemWithTitle(menu, title);

	data = wmalloc(sizeof(ItemData));
	data->type = type;
	WSetEditMenuItemData(item, data, (WMCallback *) freeItemData);
	WSetEditMenuItemImage(item, panel->markerPix[type]);

	return data;
}
Beispiel #3
0
static WEditMenu *putNewSubmenu(WEditMenu * menu, const char *title)
{
	WEditMenu *tmp;
	WEditMenuItem *item;

	item = WAddMenuItemWithTitle(menu, title);

	tmp = WCreateEditMenu(WMWidgetScreen(menu), title);
	WSetEditMenuAcceptsDrop(tmp, True);
	WSetEditMenuDelegate(tmp, &menuDelegate);
	WSetEditMenuSubmenu(menu, item, tmp);

	return tmp;
}
Beispiel #4
0
static WEditMenu *buildSubmenu(_Panel * panel, WMPropList * pl)
{
	WMScreen *scr = WMWidgetScreen(panel->parent);
	WEditMenu *menu;
	WEditMenuItem *item;
	char *title;
	WMPropList *tp, *bp;
	int i;

	tp = WMGetFromPLArray(pl, 0);
	title = WMGetFromPLString(tp);

	menu = WCreateEditMenu(scr, title);

	for (i = 1; i < WMGetPropListItemCount(pl); i++) {
		WMPropList *pi;

		pi = WMGetFromPLArray(pl, i);

		tp = WMGetFromPLArray(pi, 0);
		bp = WMGetFromPLArray(pi, 1);

		title = WMGetFromPLString(tp);

		if (!bp || WMIsPLArray(bp)) {	/* it's a submenu */
			WEditMenu *submenu;

			submenu = buildSubmenu(panel, pi);

			item = WAddMenuItemWithTitle(menu, title);

			WSetEditMenuSubmenu(menu, item, submenu);
		} else {
			ItemData *data;

			data = parseCommand(pi);

			if (data != NULL) {
				item = WAddMenuItemWithTitle(menu, title);
				if (panel->markerPix[data->type])
					WSetEditMenuItemImage(item, panel->markerPix[data->type]);
				WSetEditMenuItemData(item, data, (WMCallback *) freeItemData);
			} else {
				char *buf = wmalloc(1024);
				snprintf(buf, 1024, _("Invalid menu command \"%s\" with label \"%s\" cleared"),
					WMGetFromPLString(WMGetFromPLArray(pi, 1)),
					WMGetFromPLString(WMGetFromPLArray(pi, 0)));
				WMRunAlertPanel(scr, panel->parent, _("Warning"), buf, _("OK"), NULL, NULL);
				wfree(buf);
			}

		}
	}

	WSetEditMenuAcceptsDrop(menu, True);
	WSetEditMenuDelegate(menu, &menuDelegate);

	WMRealizeWidget(menu);

	return menu;
}