void
OpenWithPoseView::OpenSelection(BPose *pose, int32 *)
{
	OpenWithContainerWindow *window = ContainerWindow();

	int32 count = fSelectionList->CountItems();
	if (!count)
		return;

	if (!pose)
		pose = fSelectionList->FirstItem();

	ASSERT(pose);

	BEntry entry(pose->TargetModel()->EntryRef());
	if (entry.InitCheck() != B_OK) {
		BString errorString;
		errorString << "Could not find application \""
			<< pose->TargetModel()->Name() << "\"";

		(new BAlert("", errorString.String(), "OK", 0, 0, B_WIDTH_AS_USUAL,
			B_WARNING_ALERT))->Go();
		return;
	}

	if (OpenWithRelation(pose->TargetModel()) == kNoRelation) {
		if (!fIterator->GenericFilesOnly()) {
			BString warning;
			warning << "The application \"" << pose->TargetModel()->Name()
				<< "\" does not support the type of document you are "
				"about to open. Are you sure you want to proceed? If you know that "
				"the application supports the document type, you should contact the "
				"publisher of the application and ask them to update their application "
				"to list the type of your document as supported.";

			if ((new BAlert("", warning.String(), "Cancel", "Open", 0,
				B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go() == 0)
				return;
		}
		// else - once we have an extensible sniffer, tell users to ask
		// publishers to fix up sniffers
	}
		
		
	BMessage message(*window->EntryList());
		// make a clone to send
	message.RemoveName("launchUsingSelector");
		// make sure the old selector is not in the message
	message.AddRef("handler", pose->TargetModel()->EntryRef());
		// add ref of the selected handler

	ASSERT(fSelectionHandler);

	if (fSelectionHandler)
		fSelectionHandler->PostMessage(&message);
		
	window->PostMessage(B_QUIT_REQUESTED);
}
Beispiel #2
0
void
OpenWithPoseView::Pulse()
{
	// disable the Open and make default button if the default
	// app matches the selected app
	//
	// disable the Open button if no apps selected

	OpenWithContainerWindow* window = ContainerWindow();

	if (!fSelectionList->CountItems()) {
		window->SetCanSetAppAsDefault(false);
		window->SetCanOpen(false);
		_inherited::Pulse();
		return;
	}

	// if we selected a non-handling application, don't allow setting
	// it as preferred
	Model* firstSelected = fSelectionList->FirstItem()->TargetModel();
	if (OpenWithRelation(firstSelected) == kNoRelation) {
		window->SetCanSetAppAsDefault(false);
		window->SetCanOpen(true);
		_inherited::Pulse();
		return;
	}

	// make the open button enabled, because we have na app selected
	window->SetCanOpen(true);
	if (!fHaveCommonPreferredApp) {
		window->SetCanSetAppAsDefault(true);
		_inherited::Pulse();
		return;
	}

	ASSERT(fSelectionList->CountItems() == 1);

	// enable the Open and make default if selected application different
	// from preferred app ref
	window->SetCanSetAppAsDefault((*fSelectionList->FirstItem()->
		TargetModel()->EntryRef()) != fPreferredRef);

	_inherited::Pulse();
}
Beispiel #3
0
void
OpenWithPoseView::OpenSelection(BPose* pose, int32*)
{
	OpenWithContainerWindow* window = ContainerWindow();

	int32 count = fSelectionList->CountItems();
	if (count == 0)
		return;

	if (pose == NULL)
		pose = fSelectionList->FirstItem();

	ASSERT(pose != NULL);

	BEntry entry(pose->TargetModel()->EntryRef());
	if (entry.InitCheck() != B_OK) {
		BString errorString(
			B_TRANSLATE("Could not find application \"%appname\""));
		errorString.ReplaceFirst("%appname", pose->TargetModel()->Name());

		BAlert* alert = new BAlert("", errorString.String(), B_TRANSLATE("OK"),
			0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
		return;
	}

	if (OpenWithRelation(pose->TargetModel()) == kNoRelation) {
		if (!fIterator->GenericFilesOnly()) {
			BString warning(B_TRANSLATE(
				"The application \"%appname\" does not support the type of "
				"document you are about to open.\nAre you sure you want to "
				"proceed?\n\nIf you know that the application supports the "
				"document type, you should contact the publisher of the "
				"application and ask them to update their application to list "
				"the type of your document as supported."));
			warning.ReplaceFirst("%appname", pose->TargetModel()->Name());

			BAlert* alert = new BAlert("", warning.String(),
				B_TRANSLATE("Cancel"), B_TRANSLATE("Open"),	0, B_WIDTH_AS_USUAL,
				B_WARNING_ALERT);
			alert->SetShortcut(0, B_ESCAPE);
			if (alert->Go() == 0)
				return;
		}
		// else - once we have an extensible sniffer, tell users to ask
		// publishers to fix up sniffers
	}

	BMessage message(*window->EntryList());
		// make a clone to send
	message.RemoveName("launchUsingSelector");
		// make sure the old selector is not in the message
	message.AddRef("handler", pose->TargetModel()->EntryRef());
		// add ref of the selected handler

	ASSERT(fSelectionHandler != NULL);
	if (fSelectionHandler != NULL)
		fSelectionHandler->PostMessage(&message);

	window->PostMessage(B_QUIT_REQUESTED);
}