Пример #1
0
void wWorkspaceSaveState(WMPropList * old_state)
{
	WMPropList *parr, *pstr, *wks_state, *old_wks_state, *foo, *bar;
	int i;

	make_keys();

	old_wks_state = WMGetFromPLDictionary(old_state, dWorkspaces);
	parr = WMCreatePLArray(NULL);
	for (i = 0; i < w_global.workspace.count; i++) {
		pstr = WMCreatePLString(w_global.workspace.array[i]->name);
		wks_state = WMCreatePLDictionary(dName, pstr, NULL);
		WMReleasePropList(pstr);
		if (!wPreferences.flags.noclip) {
			pstr = wClipSaveWorkspaceState(i);
			WMPutInPLDictionary(wks_state, dClip, pstr);
			WMReleasePropList(pstr);
		} else if (old_wks_state != NULL) {
			if ((foo = WMGetFromPLArray(old_wks_state, i)) != NULL) {
				if ((bar = WMGetFromPLDictionary(foo, dClip)) != NULL) {
					WMPutInPLDictionary(wks_state, dClip, bar);
				}
			}
		}
		WMAddToPLArray(parr, wks_state);
		WMReleasePropList(wks_state);
	}
	WMPutInPLDictionary(w_global.session_state, dWorkspaces, parr);
	WMReleasePropList(parr);
}
Пример #2
0
static WMPropList *processSubmenu(WEditMenu * menu)
{
	WEditMenuItem *item;
	WMPropList *pmenu;
	WMPropList *pl;
	char *s;
	int i;

	s = WGetEditMenuTitle(menu);
	pl = WMCreatePLString(s);

	pmenu = WMCreatePLArray(pl, NULL);

	i = 0;
	while ((item = WGetEditMenuItem(menu, i++))) {
		WEditMenu *submenu;

		s = WGetEditMenuItemTitle(item);

		submenu = WGetEditMenuSubmenu(item);
		if (submenu) {
			pl = processSubmenu(submenu);
		} else {
			pl = processData(s, WGetEditMenuItemData(item));
		}

		if (!pl)
			continue;

		WMAddToPLArray(pmenu, pl);
	}

	return pmenu;
}
Пример #3
0
static void
storeData(_Panel *panel)
{
    WMPropList *list;
    WMPropList *tmp;
    int i;
    char *p;

    list = WMCreatePLArray(NULL, NULL);
    for (i=0; i<WMGetListNumberOfRows(panel->icoL); i++) {
        p = WMGetListItem(panel->icoL, i)->text;
        tmp = WMCreatePLString(p);
        WMAddToPLArray(list, tmp);
    }
    SetObjectForKey(list, "IconPath");

    list = WMCreatePLArray(NULL, NULL);
    for (i=0; i<WMGetListNumberOfRows(panel->pixL); i++) {
        p = WMGetListItem(panel->pixL, i)->text;
        tmp = WMCreatePLString(p);
        WMAddToPLArray(list, tmp);
    }
    SetObjectForKey(list, "PixmapPath");
}
Пример #4
0
static void
showData(_Panel *panel)
{
    char *gspath;
    char *menuPath;
    WMPropList *pmenu;

    gspath = wusergnusteppath();

    menuPath = wmalloc(strlen(gspath)+32);
    strcpy(menuPath, gspath);
    strcat(menuPath, "/Defaults/WMRootMenu");

    pmenu = WMReadPropListFromFile(menuPath);

    if (!pmenu || !WMIsPLArray(pmenu)) {
        int res;

        res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent,
                              _("Warning"),
                              _("The menu file format currently in use is not supported\n"
                                "by this tool. Do you want to discard the current menu\n"
                                "to use this tool?"),
                              _("Yes, Discard and Update"),
                              _("No, Keep Current Menu"), NULL);

        if (res == WAPRDefault) {
            pmenu = getDefaultMenu(panel);

            if (!pmenu) {
                pmenu = WMCreatePLArray(WMCreatePLString("Applications"),
                                        NULL);
            }
        } else {
            panel->dontSave = True;
            return;
        }
    }

    panel->menuPath = menuPath;

    buildMenuFromPL(panel, pmenu);

    WMReleasePropList(pmenu);
}
Пример #5
0
static WMPropList *processData(const char *title, ItemData * data)
{
	WMPropList *item;
	char *s1;
	static WMPropList *pscut = NULL;
	static WMPropList *pomenu = NULL;
	static WMPropList *poplmenu = NULL;
	int i;

	if (data == NULL)
		return NULL;

	if (!pscut) {
		pscut = WMCreatePLString("SHORTCUT");
		pomenu = WMCreatePLString("OPEN_MENU");
		poplmenu = WMCreatePLString("OPEN_PLMENU");
	}

	item = WMCreatePLArray(WMCreatePLString(title), NULL);

	switch (data->type) {
	case ExecInfo:
		if (data->param.exec.command == NULL)
			goto return_null;
#if 1
		if (strpbrk(data->param.exec.command, "&$*|><?`=;")) {
			s1 = "SHEXEC";
		} else {
			s1 = "EXEC";
		}
#else
		s1 = "SHEXEC";
#endif

		if (notblank(data->param.exec.shortcut)) {
			WMAddToPLArray(item, pscut);
			WMAddToPLArray(item, WMCreatePLString(data->param.exec.shortcut));
		}

		WMAddToPLArray(item, WMCreatePLString(s1));
		WMAddToPLArray(item, WMCreatePLString(data->param.exec.command));
		break;

	case CommandInfo:
		if (notblank(data->param.command.shortcut)) {
			WMAddToPLArray(item, pscut);
			WMAddToPLArray(item, WMCreatePLString(data->param.command.shortcut));
		}

		i = data->param.command.command;

		WMAddToPLArray(item, WMCreatePLString(commandNames[i]));

		switch (i) {
		case 3:
		case 4:
			if (data->param.command.parameter) {
				WMAddToPLArray(item, WMCreatePLString(data->param.command.parameter));
			}
			break;

		case 6:	/* restart */
			if (data->param.command.parameter) {
				WMAddToPLArray(item, WMCreatePLString(data->param.command.parameter));
			}
			break;
		}

		break;

	case PipeInfo:
	case PLPipeInfo:
		if (!data->param.pipe.command)
			goto return_null;
		if (data->type == PLPipeInfo)
			WMAddToPLArray(item, poplmenu);
		else
			WMAddToPLArray(item, pomenu);

		if (data->param.pipe.cached)
			s1 = wstrconcat("| ", data->param.pipe.command);
		else
			s1 = wstrconcat("|| ", data->param.pipe.command);
		WMAddToPLArray(item, WMCreatePLString(s1));
		wfree(s1);
		break;

	case ExternalInfo:
		if (!data->param.external.path)
			goto return_null;
		WMAddToPLArray(item, pomenu);
		WMAddToPLArray(item, WMCreatePLString(data->param.external.path));
		break;

	case DirectoryInfo:
		{
			int l;
			char *tmp;

			if (!data->param.directory.directory || !data->param.directory.command)
				goto return_null;

			l = strlen(data->param.directory.directory);
			l += strlen(data->param.directory.command);
			l += 32;

			WMAddToPLArray(item, pomenu);

			tmp = wmalloc(l);
			sprintf(tmp, "%s%s WITH %s",
				data->param.directory.stripExt ? "-noext " : "",
				data->param.directory.directory, data->param.directory.command);

			WMAddToPLArray(item, WMCreatePLString(tmp));
			wfree(tmp);
		}
		break;

	case WSMenuInfo:
		WMAddToPLArray(item, WMCreatePLString("WORKSPACE_MENU"));
		break;

	case WWindowListInfo:
		WMAddToPLArray(item, WMCreatePLString("WINDOWS_MENU"));
		break;

	default:
		assert(0);
		break;
	}

	return item;

 return_null:
	WMReleasePropList(item);
	return NULL;
}
Пример #6
0
static void showData(_Panel * panel)
{
	const char *gspath;
	char *menuPath, *labelText;
	char buf[1024];
	WMPropList *pmenu;

	gspath = wusergnusteppath();

	menuPath = wmalloc(strlen(gspath) + 32);
	strcpy(menuPath, gspath);
	strcat(menuPath, "/Defaults/WMRootMenu");

	pmenu = WMReadPropListFromFile(menuPath);

	/* check if WMRootMenu references another file, and if so,
	   if that file is in proplist format */
	while (WMIsPLString(pmenu)) {
		char *path = NULL;

		path = wexpandpath(WMGetFromPLString(pmenu));

		if (access(path, F_OK) < 0)
			path = wfindfile(DEF_CONFIG_PATHS, path);

		/* TODO: if needed, concatenate locale suffix to path.
		   See getLocalizedMenuFile() in src/rootmenu.c. */

		if (!path)
			break;

		if (access(path, W_OK) < 0) {
			snprintf(buf, 1024,
				 _("The menu file \"%s\" referenced by "
				   "WMRootMenu is read-only.\n"
				   "You cannot use WPrefs to modify it."),
				 path);
			WMRunAlertPanel(WMWidgetScreen(panel->parent),
					panel->parent,
					_("Warning"), buf,
					_("OK"), NULL, NULL);
			panel->dontSave = True;
			wfree(path);
			return;
		}

		pmenu = WMReadPropListFromFile(path);
		menuPath = path;
	}

	if (!pmenu || !WMIsPLArray(pmenu)) {
		int res;

		res = WMRunAlertPanel(WMWidgetScreen(panel->parent), panel->parent,
				      _("Warning"),
				      _("The menu file format currently in use is not supported\n"
					"by this tool. Do you want to discard the current menu\n"
					"to use this tool?"),
				      _("Yes, Discard and Update"), _("No, Keep Current Menu"), NULL);

		if (res == WAPRDefault) {
			pmenu = getDefaultMenu(panel);

			if (!pmenu) {
				pmenu = WMCreatePLArray(WMCreatePLString("Applications"), NULL);
			}
		} else {
			panel->dontSave = True;
			return;
		}
	}

	panel->menuPath = menuPath;

	snprintf(buf, 1024,
		 _("\n\nWhen saved, the menu will be written to the file\n\"%s\"."),
		 menuPath);
	labelText = WMGetLabelText(panel->sections[NoInfo][0]);
	labelText = wstrconcat(labelText, buf);
	WMSetLabelText(panel->sections[NoInfo][0], labelText);
	wfree(labelText);

	buildMenuFromPL(panel, pmenu);

	WMReleasePropList(pmenu);
}
Пример #7
0
/* creates the proplist menu out of the abstract menu representation in `menu'.
 */
static void assemblePLMenuFunc(WMTreeNode *aNode, void *data)
{
	WMMenuEntry *wm;
	WMPropList *pl;
	int pDepth, cDepth;

	wm = (WMMenuEntry *)WMGetDataForTreeNode(aNode);
	cDepth = WMGetTreeNodeDepth(aNode);
	pDepth = *(int *)data;

	if (pDepth > cDepth) {				/* just ascended out of a/several submenu(s) */
		WMPropList *last, *but;			/* merge the tail up to the current position */
		int i;
		for (i = pDepth - cDepth; i > 0; i--) {
			last = WMPopFromArray(plMenuNodes);
			but = WMPopFromArray(plMenuNodes);
			WMAddToPLArray(but, last);
			WMAddToArray(plMenuNodes, but);
		}
	}

	if (!wm->CmdLine) {				/* new submenu */
		WMAddToArray(plMenuNodes, WMCreatePLArray(WMCreatePLString(wm->Name), NULL));
	} else {					/* new menu item */
		pl = WMPopFromArray(plMenuNodes);
		if (wm->Flags & F_RESTART_OTHER) {	/* RESTART, somewm */
			char buf[1024];
			memset(buf, 0, sizeof(buf));
			snprintf(buf, sizeof(buf), "%s %s", _("Restart"), wm->Name);
			WMAddToPLArray(pl, WMCreatePLArray(
				WMCreatePLString(buf),
				WMCreatePLString("RESTART"),
				WMCreatePLString(wm->CmdLine),
				NULL)
			);
		} else if (wm->Flags & F_RESTART_SELF) {/* RESTART */
			WMAddToPLArray(pl, WMCreatePLArray(
				WMCreatePLString(_("Restart Window Maker")),
				WMCreatePLString("RESTART"),
				NULL)
			);
		} else if (wm->Flags & F_QUIT) {	/* EXIT */
			WMAddToPLArray(pl, WMCreatePLArray(
				WMCreatePLString(_("Exit Window Maker")),
				WMCreatePLString("EXIT"),
				NULL)
			);
		} else {				/* plain simple command */
			char buf[1024];

			memset(buf, 0, sizeof(buf));
			if (wm->Flags & F_TERMINAL)	/* XXX: quoting! */
				snprintf(buf, sizeof(buf), "%s -e \"%s\"", terminal, wm->CmdLine);
			else
				snprintf(buf, sizeof(buf), "%s", wm->CmdLine);

			WMAddToPLArray(pl, WMCreatePLArray(
				WMCreatePLString(wm->Name),
				WMCreatePLString("SHEXEC"),
				WMCreatePLString(buf),
				NULL)
			);
		}
		WMAddToArray(plMenuNodes, pl);
	}

	*(int *)data = cDepth;
	return;
}