void PosixProcess::SetArguments(SharedKList args)
	{
#if defined(OS_OSX)
		std::string cmd = args->At(0)->ToString();
		size_t found = cmd.rfind(".app");
		if (found != std::string::npos)
		{
			Poco::Path p(cmd);
			std::string fn = p.getFileName();
			found = fn.find(".app");
			fn = fn.substr(0,found);
			fn = kroll::FileUtils::Join(cmd.c_str(),"Contents","MacOS",fn.c_str(),NULL);
			if (FileUtils::IsFile(fn))
			{
				cmd = fn;
			}
		}
		args->At(0)->SetString(cmd.c_str());
#endif
		Process::SetArguments(args);
	}
Exemple #2
0
void UserWindow::ReadChooserDialogObject(
	SharedKObject o,
	bool& multiple,
	std::string& title,
	std::string& path,
	std::string& defaultName,
	std::vector<std::string>& types,
	std::string& typesDescription)

{
	// Pass in a set of properties for chooser dialogs like this:
	// var selected = Titanium.UI.OpenFileChooserDialog(callback,
	// {
	//    multiple:true,
	//    title: "Select file to delete...",
	//    defaultFile: "autoexec.bat",
	//    path: "C:\"
	//    types:['js','html']
	// });
	multiple = o->GetBool("multiple", true);
	title = o->GetString("title", title);
	path = o->GetString("path", path);
	defaultName = o->GetString("defaultName", defaultName);

	SharedKList listTypes = new StaticBoundList();
	listTypes = o->GetList("types", listTypes);
	for (size_t i = 0; i < listTypes->Size(); i++)
	{
		if (listTypes->At(i)->IsString())
		{
			types.push_back(listTypes->At(i)->ToString());
			std::cout << "Found " << listTypes->At(i)->ToString() << std::endl;
		}
	}
	typesDescription = o->GetString("typesDescription", defaultName);

}
Exemple #3
0
	static VALUE RubyKListEach(VALUE self)
	{
		SharedValue* dval = NULL;
		Data_Get_Struct(self, SharedValue, dval);
		SharedKList list = (*dval)->ToList();

		if (list.isNull() || !rb_block_given_p())
			return Qnil;

		for (unsigned int i = 0; i < list->Size(); i++)
		{
			VALUE rubyValue = RubyUtils::ToRubyValue(list->At(i));
			rb_yield(rubyValue);
		}
		return self;
	}
Exemple #4
0
	void KObject::GetStringList(const char *name, std::vector<std::string> &list)
	{
		SharedValue prop = this->Get(name);
		if(!prop->IsUndefined() && prop->IsList())
		{
			SharedKList values = prop->ToList();
			if (values->Size() > 0)
			{
				for (unsigned int c = 0; c < values->Size(); c++)
				{
					SharedValue v = values->At(c);
					if (v->IsString())
					{
						const char *s = v->ToString();
						list.push_back(s);
					}
				}
			}
		}
	}
Exemple #5
0
	static VALUE RubyKListGetElt(int argc, VALUE *argv, VALUE self)
	{
		SharedValue* dval = NULL;
		Data_Get_Struct(self, SharedValue, dval);
		SharedKList list = (*dval)->ToList();

		// TODO: We should raise an exception instead
		if (list.isNull() || argc < 1)
			return Qnil;

		int idx = -1;
		if (TYPE(argv[0]) != T_FIXNUM || ((idx = NUM2INT(argv[0])) < 0))
			return Qnil;

		if (idx >= 0 && idx < (int) list->Size())
		{
			SharedValue v = list->At(idx);
			return RubyUtils::ToRubyValue(v);
		}
		else
		{
			return Qnil;
		}
	}