The FileType window now filters out application drops, and make them the preferred
app for the file(s). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16620 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <Bitmap.h>
|
||||
#include <Box.h>
|
||||
#include <Button.h>
|
||||
#include <File.h>
|
||||
#include <MenuField.h>
|
||||
#include <MenuItem.h>
|
||||
#include <Mime.h>
|
||||
@@ -375,7 +376,6 @@ FileTypeWindow::MessageReceived(BMessage* message)
|
||||
be_app_messenger.SendMessage(&panel);
|
||||
break;
|
||||
}
|
||||
case B_SIMPLE_DATA:
|
||||
case kMsgSameTypeAsOpened:
|
||||
_AdoptType(message);
|
||||
break;
|
||||
@@ -422,6 +422,22 @@ FileTypeWindow::MessageReceived(BMessage* message)
|
||||
_AdoptPreferredApp(message, true);
|
||||
break;
|
||||
|
||||
// Other
|
||||
|
||||
case B_SIMPLE_DATA:
|
||||
{
|
||||
entry_ref ref;
|
||||
if (message->FindRef("refs", &ref) != B_OK)
|
||||
break;
|
||||
|
||||
BFile file(&ref, B_READ_ONLY);
|
||||
if (is_application(file))
|
||||
_AdoptPreferredApp(message, false);
|
||||
else
|
||||
_AdoptType(message);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_META_MIME_CHANGED:
|
||||
const char* type;
|
||||
int32 which;
|
||||
|
||||
@@ -97,13 +97,12 @@ FileTypes::RefsReceived(BMessage *message)
|
||||
entry_ref ref;
|
||||
while (message->FindRef("refs", index++, &ref) == B_OK) {
|
||||
BEntry entry;
|
||||
status_t status = entry.SetTo(&ref, traverseLinks);
|
||||
if (status == B_OK) {
|
||||
// TODO: open FileType window
|
||||
}
|
||||
|
||||
BFile file;
|
||||
status = file.SetTo(&ref, B_READ_ONLY);
|
||||
|
||||
status_t status = entry.SetTo(&ref, traverseLinks);
|
||||
if (status == B_OK)
|
||||
status = file.SetTo(&entry, B_READ_ONLY);
|
||||
|
||||
if (status != B_OK) {
|
||||
// file cannot be opened
|
||||
|
||||
@@ -120,14 +119,12 @@ FileTypes::RefsReceived(BMessage *message)
|
||||
message->RemoveData("refs", --index);
|
||||
continue;
|
||||
}
|
||||
|
||||
BAppFileInfo appInfo(&file);
|
||||
if (appInfo.InitCheck() != B_OK)
|
||||
continue;
|
||||
|
||||
char signature[B_MIME_TYPE_LENGTH];
|
||||
if (appInfo.GetSignature(signature) != B_OK)
|
||||
|
||||
if (!is_application(file)) {
|
||||
if (entry.GetRef(&ref) == B_OK)
|
||||
message->ReplaceRef("refs", index - 1, &ref);
|
||||
continue;
|
||||
}
|
||||
|
||||
// remove application from list
|
||||
message->RemoveData("refs", --index);
|
||||
@@ -309,6 +306,21 @@ FileTypes::QuitRequested()
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
bool
|
||||
is_application(BFile& file)
|
||||
{
|
||||
BAppFileInfo appInfo(&file);
|
||||
if (appInfo.InitCheck() != B_OK)
|
||||
return false;
|
||||
|
||||
char signature[B_MIME_TYPE_LENGTH];
|
||||
if (appInfo.GetSignature(signature) != B_OK)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
error_alert(const char* message, status_t status, alert_type type)
|
||||
{
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include <Alert.h>
|
||||
|
||||
class BFile;
|
||||
|
||||
|
||||
extern const char* kSignature;
|
||||
|
||||
@@ -23,6 +25,9 @@ static const uint32 kMsgTypeWindowClosed = 'cltw';
|
||||
static const uint32 kMsgWindowClosed = 'WiCl';
|
||||
|
||||
|
||||
// exported functions
|
||||
|
||||
extern bool is_application(BFile& file);
|
||||
extern void error_alert(const char* message, status_t status = B_OK,
|
||||
alert_type type = B_WARNING_ALERT);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user