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 <Bitmap.h>
|
||||||
#include <Box.h>
|
#include <Box.h>
|
||||||
#include <Button.h>
|
#include <Button.h>
|
||||||
|
#include <File.h>
|
||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <Mime.h>
|
#include <Mime.h>
|
||||||
@@ -375,7 +376,6 @@ FileTypeWindow::MessageReceived(BMessage* message)
|
|||||||
be_app_messenger.SendMessage(&panel);
|
be_app_messenger.SendMessage(&panel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_SIMPLE_DATA:
|
|
||||||
case kMsgSameTypeAsOpened:
|
case kMsgSameTypeAsOpened:
|
||||||
_AdoptType(message);
|
_AdoptType(message);
|
||||||
break;
|
break;
|
||||||
@@ -422,6 +422,22 @@ FileTypeWindow::MessageReceived(BMessage* message)
|
|||||||
_AdoptPreferredApp(message, true);
|
_AdoptPreferredApp(message, true);
|
||||||
break;
|
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:
|
case B_META_MIME_CHANGED:
|
||||||
const char* type;
|
const char* type;
|
||||||
int32 which;
|
int32 which;
|
||||||
|
|||||||
@@ -97,13 +97,12 @@ FileTypes::RefsReceived(BMessage *message)
|
|||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
while (message->FindRef("refs", index++, &ref) == B_OK) {
|
while (message->FindRef("refs", index++, &ref) == B_OK) {
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
status_t status = entry.SetTo(&ref, traverseLinks);
|
|
||||||
if (status == B_OK) {
|
|
||||||
// TODO: open FileType window
|
|
||||||
}
|
|
||||||
|
|
||||||
BFile file;
|
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) {
|
if (status != B_OK) {
|
||||||
// file cannot be opened
|
// file cannot be opened
|
||||||
|
|
||||||
@@ -121,13 +120,11 @@ FileTypes::RefsReceived(BMessage *message)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BAppFileInfo appInfo(&file);
|
if (!is_application(file)) {
|
||||||
if (appInfo.InitCheck() != B_OK)
|
if (entry.GetRef(&ref) == B_OK)
|
||||||
continue;
|
message->ReplaceRef("refs", index - 1, &ref);
|
||||||
|
|
||||||
char signature[B_MIME_TYPE_LENGTH];
|
|
||||||
if (appInfo.GetSignature(signature) != B_OK)
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// remove application from list
|
// remove application from list
|
||||||
message->RemoveData("refs", --index);
|
message->RemoveData("refs", --index);
|
||||||
@@ -309,6 +306,21 @@ FileTypes::QuitRequested()
|
|||||||
// #pragma mark -
|
// #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
|
void
|
||||||
error_alert(const char* message, status_t status, alert_type type)
|
error_alert(const char* message, status_t status, alert_type type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
|
||||||
|
class BFile;
|
||||||
|
|
||||||
|
|
||||||
extern const char* kSignature;
|
extern const char* kSignature;
|
||||||
|
|
||||||
@@ -23,6 +25,9 @@ static const uint32 kMsgTypeWindowClosed = 'cltw';
|
|||||||
static const uint32 kMsgWindowClosed = 'WiCl';
|
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,
|
extern void error_alert(const char* message, status_t status = B_OK,
|
||||||
alert_type type = B_WARNING_ALERT);
|
alert_type type = B_WARNING_ALERT);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user