Пример #1
0
bool
Settings::get_value(const synfig::String& key, synfig::String& value)const
{
	// Search for the value in any children domains
	DomainMap::const_iterator iter;
	for(iter=domain_map.begin();iter!=domain_map.end();++iter)
	{
		// if we have a domain hit
		if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first)
		{
			synfig::String key_(key.begin()+iter->first.size()+1,key.end());

			// If the domain has it, then we have got a hit
			if(iter->second->get_value(key_,value))
				return true;
		}
	}

	// Search for the value in our simple map
	if(simple_value_map.count(key))
	{
		value=simple_value_map.find(key)->second;
		return true;
	}

	// key not found
	return false;
}
Пример #2
0
bool
Settings::set_value(const synfig::String& key,const synfig::String& value)
{
	// Search for the key in any children domains
	DomainMap::iterator iter;
	for(iter=domain_map.begin();iter!=domain_map.end();++iter)
	{
		// if we have a domain hit
		if(key.size()>iter->first.size() && String(key.begin(),key.begin()+iter->first.size())==iter->first)
		{
			synfig::String key_(key.begin()+iter->first.size()+1,key.end());

			return iter->second->set_value(key_,value);
		}
	}

	simple_value_map[key]=value;
	return true;
}
Пример #3
0
bool
IPC::process_command(const synfig::String& command_line)
{
	if(command_line.empty())
		return false;

	char cmd = command_line[0];

	String args(command_line.begin()+1,command_line.end());

	// erase leading spaces
	while (!args.empty() && args[0] == ' ')
		args.erase(args.begin());

	// erase trailing newlines and spaces
	while (!args.empty() && (args[args.size()-1] == '\n' || args[args.size()-1] == ' '))
		args.erase(args.end()-1);

	switch(toupper(cmd))
	{
		case 'F': // Focus/Foreground
			App::signal_present_all()();
			break;
		case 'N': // New file
			App::signal_present_all()();
			App::new_instance();
			break;
		case 'O': // Open <arg>
			App::signal_present_all()();
			App::open(args);
			break;
		case 'X': // Quit
		case 'Q': // Quit
			App::quit();
			break;
		default:
			synfig::warning("Received unknown command '%c' with arg '%s'",cmd,args.c_str());
			break;
	}

	return true;
}