Exemplo n.º 1
0
/* This function fetches the required values (Name, Exec, Categories, NoDisplay etc)
 * and then assigns the results to the appropriate instance variables or passes the results
 * to the appropriate function */
void DesktopFile::populate(vector<string> showFromDesktops, bool useIcons, vector<string> iconpaths, vector<Category>& cats, string iconSize)
{	string line;
	string iconDef;
	vector<string> onlyShowInDesktops;
	vector<string> foundCategories;
	bool started = false;

	while (!dfile.eof())
	{	getline(dfile, line);
		if (line.size() == 0) continue;
		string id = getID(line);
		/* .desktop files can contain more than just desktop entries. On getting
		 * the id [Desktop Entry] we know we've started looking at an entry */
		if (id == "[Desktop Entry]")
		{	started = true;
			continue;
		}
		/* If we get another line beginning with [, it probably means we've found
		 * a desktop action as opposed to a desktop entry. We should break here 
		 * to avoid the entry data being overwritten with action data */
		if (id[0] == '[' && started == true) break;
		if (id == "Name")
		{	name = getSingleValue(line);
			continue;
		}
		if (id == "Exec")
		{	exec = getSingleValue(line);
			continue;
		}
		if (id == "Categories")
		{	foundCategories = getMultiValue(line);
			continue;
		}
		if (id == "NoDisplay")
		{	string value = getSingleValue(line);
			if (value == "True" || value == "true")
				nodisplay = true;
			continue;
		}
		if (id == "OnlyShowIn")
		{	onlyShowInDesktops = getMultiValue(line);
			continue;
		}
		if (id == "Icon")
		{	iconDef = getSingleValue(line);
			continue;
		}
	}

	processCategories(cats, foundCategories);
	if (useIcons && iconDef != "\0") matchIcon(iconDef, iconpaths, iconSize);
	if (!onlyShowInDesktops.empty()) processDesktops(showFromDesktops, onlyShowInDesktops);
}
Exemplo n.º 2
0
std::string OptionsWrapper::getSingleValue(const std::string& key) const
{
	for (int g = 0; g < Enum::LastOption; g++) {
		const std::string tmp = getSingleValue(key, (Enum::GameOption)g);
		if (tmp != "")
			return tmp;
	}
	return "";
}