first cut FileType app/add-on
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4302 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
SubDir OBOS_TOP src add-ons tracker ;
|
SubDir OBOS_TOP src add-ons tracker ;
|
||||||
|
|
||||||
SubInclude OBOS_TOP src add-ons tracker zipomatic ;
|
SubInclude OBOS_TOP src add-ons tracker zipomatic ;
|
||||||
|
SubInclude OBOS_TOP src add-ons tracker filetype ;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
** FileType.icons.rdef
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
resource(0, "BEOS:L:application/x-be-resource") #'ICON' array {
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF02020008FFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF041B17110802FFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF041B3F3F1B150800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF021B3F3F1B150A00FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFF003F00FFFFFFFFFF04151B1B17110800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF003FFD00FFFFFFFFFF02081515150A0800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFF003FFDFDFD00FFFFFF00F9000A0A080A00FFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFF003FFDFDFDFD00FFFF003FF97D000000007D0000FFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFF003FFDFDFDFDFDFD00FF00F93F3F7D7D7D7D7D7DF900FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDFDFD62FDFD00FF00F9F9F93F3FF9F9F9F97D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEFDFDFD62FDFDFDFA0000F9F9F9F9F93F3FF97D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEFEFDFD89FDFDFDFDFA0000F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"003FFEFEFEFDB0FD62FD62FDFAFA00F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEFEB0FD89FD62FD62FAFA00F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEB0FDB0FDB0FD62FAFAFAFA00F9F90000F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEB0FDB0FDB0FDFAFA62FA000000606000007D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEFDFDFD89FD62FD62FAFAFA00606060606000007D00FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDB0FD89FD62FAFAFA0060606060606060600000FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDFDB0FD89FAFAFA00606060606060606060606000FFFFFFFFFF"
|
||||||
|
$"FFFFFFFF003FFDB0FDB0FDFDFA006060606060606060606060D5000EFFFFFFFF"
|
||||||
|
$"FFFFFFFF003FFDFDB0FDFDFD003F60606060606060606060D5D5000EFFFFFFFF"
|
||||||
|
$"FFFFFFFFFF003FFDFDFDFDFD00AC3F3F60606060606060D5D5D5000E0E0EFFFF"
|
||||||
|
$"FFFFFFFFFF003FFDFDFDFDFD00ACACAC3F3F60606060D5D5D5D5000E0E0E0E0E"
|
||||||
|
$"FFFFFFFFFFFF003FFDFDFD0000ACACACACAC3F3F60D5D5D5D5D5000E0E0E0E0E"
|
||||||
|
$"FFFFFFFFFFFF003FFDFD000E00ACACACACACACACD5D5D5D5D5D5000E0E0E0EFF"
|
||||||
|
$"FFFFFFFFFFFFFF00FD000E0E00ACACACACACACACD5D5D5D5D5D5000E0E0EFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFF000E0E0E00ACACACACACACACD5D5D5D5D5000E0E0EFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFF00ACACACACACACACD5D5D5D5000E0E0EFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFF0000ACACACACACD5D5D5000E0E0EFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000ACACACD5D5000E0E0EFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000ACD5000E0E0EFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000E0E0EFFFFFFFFFFFFFFFF"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource(1, "BEOS:L:application/octet-stream") #'ICON' array {
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFF0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFF0060600000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFF0060606060600000FFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFF00603F603F603F603F0000FFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFF00603F603F603F603F603F600000FFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF00603F3F3F3F3F3F3F3F3F3F3F3F3F0000FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFF00603F603F603F603F603F603F603F603F3F0000FFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFF00603F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F0000FFFFFFFF"
|
||||||
|
$"FFFFFFFF00603F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F0000FFFF"
|
||||||
|
$"FFFFFF00603F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F3F603F00FF"
|
||||||
|
$"FFFF00603F603F603F603F603F603F603F603F603F603F603F603F603F00FFFF"
|
||||||
|
$"FF00603F603F603F603F603F603F603F603F603F603F603F603F603F00AEAEAE"
|
||||||
|
$"00003F603F603F603F603F603F603F603F603F603F603F603F603F0000AEAEFF"
|
||||||
|
$"FFAE0000603F603F603F603F603F603F603F603F603F603F603F00AE8700AEFF"
|
||||||
|
$"FFFFAE0000006060606060606060606060601B60606060606000AE87870100AE"
|
||||||
|
$"FFFFFFAE00AE00006060606060606060606060601B60606000AE870000AEAEAE"
|
||||||
|
$"FFFFFFFFAE00AEAE00006087608760876087608760871B29AE0000AEAEFFFFFF"
|
||||||
|
$"FFFFFFFFFFAE0087AEAE000087878787878787878787010000AEAEFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFAE008787AEAE0000878787878787870100AEAEFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFAE00608787AEAE0000AEAEAEAE00AEAEFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFAE0060608787AEAE0000AE00AEAEFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFAE00606060870000AE00AEAEFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFAE00600000AEAEAEAEAEFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFAE00AEAEFFFFFFAEFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFAEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource large_icon array {
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF02020000FFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF041B17110802FFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF041B3F3F1B150800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFF00FFFFFFFFFFFF021B3F3F1B150A00FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFF003F00FFFFFFFFFF04151B1B17110800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF003FFD00FFFFFFFFFF02081515150A0800FFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFF003FFDFDFD00FFFFFF00F9000A0A080A00FFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFF003FFDFDFDFD00FFFF003FF97D000000007D0000FFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFF003FFDFDFDFDFDFD00FF00F93F3F7D7D7D7D7D7DF900FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDFDFD62FDFD00FF00F9F9F93F3FF9F9F9F97D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEFDFDFD62FDFDFDFA0000F9F9F9F9F93F3FF97D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEFEFDFD89FDFDFDFDFA0000F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"003FFEFEFEFDB0FD62FD62FD000000F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEFEB0FD89FD62FD007B7B00F9F9F9F9F9F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FF003FFEB0FDB0FDB0FD6200DA7B7B00F9F90000F9F97D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEB0FDB0FDB0002B2CDA7B000000606000007D7D7D00FFFFFFFFFFFF"
|
||||||
|
$"FFFF003FFEFDFDFD89FD002B2F2F00FA00606060606000007D00FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDB0FD002B2CEB2F000060606060606060600000FFFFFFFFFFFF"
|
||||||
|
$"FFFFFF003FFDFDFDB0002B2F2F0000606060606060606060606000FFFFFFFFFF"
|
||||||
|
$"FFFFFFFF003FFDB0002B2CEB2F006060606060606060606060D5000EFFFFFFFF"
|
||||||
|
$"FFFF0000003FFDFD002B2F2F003F60606060606060606060D5D5000EFFFFFFFF"
|
||||||
|
$"FF007B7B7B003F002B2CEB2F00AC3F3F60606060606060D5D5D5000E0E0EFFFF"
|
||||||
|
$"007B7B7BDA003F002B2F2F0000ACACAC3F3F60606060D5D5D5D5000E0E0E0E0E"
|
||||||
|
$"002B2CDA7B7B002B2CEB2F0000ACACACACAC3F3F60D5D5D5D5D5000E0E0E0E0E"
|
||||||
|
$"FF002B2CDA7B2B2CEB2F000E00ACACACACACACACD5D5D5D5D5D5000E0E0E0EFF"
|
||||||
|
$"FF002B2CDA7B2B2CEB2F000E00ACACACACACACACD5D5D5D5D5D5000E0E0EFFFF"
|
||||||
|
$"FFFF002B2C2B2B2F2F000E0E00ACACACACACACACD5D5D5D5D5000E0E0EFFFFFF"
|
||||||
|
$"FFFF002B2C2B2B2F2F00FFFF00ACACACACACACACD5D5D5D5000E0E0EFFFFFFFF"
|
||||||
|
$"FFFFFF002B2CEB2F00FFFFFFFF0000ACACACACACD5D5D5000E0E0EFFFFFFFFFF"
|
||||||
|
$"FFFFFF002B2CEB2F00FFFFFFFFFFFF0000ACACACD5D5000E0E0EFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFF002B2F000E0F0F0F0F0F0F0F0F0000ACD5000E0E0EFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFF0000000E0F0F0F0F0F0F0F0F0F0F0F00000E0E0EFFFFFFFFFFFFFFFF"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource(0, "BEOS:M:application/x-be-resource") #'MICN' array {
|
||||||
|
$"FFFFFFFFFFFFFFFF020200FFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF04151E1500FFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF021D1E1C00FFFFFFFF"
|
||||||
|
$"FFFFFFFF00FFFF00151B1600FFFFFFFF"
|
||||||
|
$"FFFFFF003F0000FA0000000000FFFFFF"
|
||||||
|
$"FFFF003FFD0000F9F9FAFAFAFA00FFFF"
|
||||||
|
$"FF003FFEFDFD00F9F9F9F97D7D00FFFF"
|
||||||
|
$"003F62FE89FD00F9F9F900007D00FFFF"
|
||||||
|
$"FF003FB0FD89FA00F90060600000FFFF"
|
||||||
|
$"FF003FFEB0FD620000606060606000FF"
|
||||||
|
$"FFFF003FFD89FA003F3F606060D500FF"
|
||||||
|
$"FFFF003FFDFDFA00ACAC3F3FD5D5000E"
|
||||||
|
$"FFFFFF003FFD0000ACACACACD5D5000E"
|
||||||
|
$"FFFFFF003F000E00ACACACACD5D5000E"
|
||||||
|
$"FFFFFFFF000E0E0E0000ACACD5000E0E"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFF0000000E0EFF"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource(1, "BEOS:M:application/octet-stream") #'MICN' array {
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFF00FFFFFFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFF003F0000FFFFFFFFFFFFFF"
|
||||||
|
$"FFFFFFFF003F6060600000FFFFFFFFFF"
|
||||||
|
$"FFFFFF003F6060606060600000FFFFFF"
|
||||||
|
$"FFFF003F3F3F3F3F3F3F3F60600000FF"
|
||||||
|
$"FF003F603F603F603F603F3F60600000"
|
||||||
|
$"00606060606060606060601B600000AE"
|
||||||
|
$"AE000087878787878787878701870000"
|
||||||
|
$"FFAE000000878787878787008700AEAE"
|
||||||
|
$"FFFFAE00AE0000AEAEAE000000AEFFFF"
|
||||||
|
$"FFFFFFAE0087AE00AE00AEAEFFFFFFFF"
|
||||||
|
$"FFFFFFFFAE00000000AEAEFFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFAE00AEFFAEFFFFFFFFFFFF"
|
||||||
|
};
|
||||||
|
|
||||||
|
resource mini_icon array {
|
||||||
|
$"FFFFFFFFFFFFFFFF020200FFFFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF04151E1500FFFFFFFF"
|
||||||
|
$"FFFFFFFFFFFFFF021D1E1C00FFFFFFFF"
|
||||||
|
$"FFFFFFFF00FFFF00151B1600FFFFFFFF"
|
||||||
|
$"FFFFFF003F0000FA0000000000FFFFFF"
|
||||||
|
$"FFFF003FFD0000F9F9FAFAFAFA00FFFF"
|
||||||
|
$"FF003FFEFDFD00F9F9F9F97D7D00FFFF"
|
||||||
|
$"003F62FE89007B00F9F900007D00FFFF"
|
||||||
|
$"FF003FB0FD002F00F90060600000FFFF"
|
||||||
|
$"FF003FFE002F000000606060606000FF"
|
||||||
|
$"FF000000002F00003F3F606060D500FF"
|
||||||
|
$"002B00002F00FA00ACAC3F3FD5D500FF"
|
||||||
|
$"002B7B2CEB000000ACACACACD5D5000E"
|
||||||
|
$"FF002B2F00000E00ACACACACD5D5000E"
|
||||||
|
$"FF002B2F000E0E0F0000ACACD5000E0E"
|
||||||
|
$"FFFF00000E0F0F0F0F0F0000000E0EFF"
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
** FileType.rdef
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
resource app_signature "application/x-vnd.obos.file-type";
|
||||||
|
|
||||||
|
resource app_flags 0x00000001;
|
||||||
|
|
||||||
|
resource file_types message {
|
||||||
|
"types" = "application/x-be-resource",
|
||||||
|
"types" = "application/octet-stream"
|
||||||
|
};
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
** FileType.version.rdef
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
|
||||||
|
resource app_version {
|
||||||
|
|
||||||
|
major = 1,
|
||||||
|
middle = 0,
|
||||||
|
minor = 0,
|
||||||
|
|
||||||
|
/* 0 = development 1 = alpha 2 = beta
|
||||||
|
3 = gamma 4 = golden master 5 = final */
|
||||||
|
variety = 0,
|
||||||
|
|
||||||
|
internal = 1,
|
||||||
|
|
||||||
|
short_info = "R1.0.0d1",
|
||||||
|
long_info = "OpenBeOS 1.0.0d1 ©2002 OpenBeOS Project"
|
||||||
|
};
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
#include <Path.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <FileTypeApp.h>
|
||||||
|
#include <FileTypeConstants.h>
|
||||||
|
#include <FileTypeWindow.h>
|
||||||
|
|
||||||
|
FileTypeApp * file_type_app = 0;
|
||||||
|
|
||||||
|
FileTypeApp::FileTypeApp()
|
||||||
|
: BApplication(APP_SIGNATURE)
|
||||||
|
{
|
||||||
|
file_type_app = this;
|
||||||
|
fArgvOkay = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileTypeApp::DispatchMessage(BMessage * msg, BHandler * handler)
|
||||||
|
{
|
||||||
|
if ( msg->what == B_ARGV_RECEIVED ) {
|
||||||
|
int32 argc;
|
||||||
|
if (msg->FindInt32("argc",&argc) != B_OK) {
|
||||||
|
argc=0;
|
||||||
|
}
|
||||||
|
const char ** argv = new (const char*)[argc];
|
||||||
|
for (int arg = 0; (arg < argc) ; arg++) {
|
||||||
|
if (msg->FindString("argv",arg,&argv[arg]) != B_OK) {
|
||||||
|
argv[arg] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const char * cwd;
|
||||||
|
if (msg->FindString("cwd",&cwd) != B_OK) {
|
||||||
|
cwd = "";
|
||||||
|
}
|
||||||
|
ArgvReceived(argc, argv, cwd);
|
||||||
|
} else {
|
||||||
|
BApplication::DispatchMessage(msg,handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeApp::RefsReceived(BMessage * message)
|
||||||
|
{
|
||||||
|
BList entryList;
|
||||||
|
int32 i;
|
||||||
|
entry_ref ref;
|
||||||
|
while (message->FindRef("refs",i++,&ref) == B_OK) {
|
||||||
|
entryList.AddItem(new BEntry(&ref,true));
|
||||||
|
}
|
||||||
|
if (entryList.CountItems() == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FileTypeWindow * window = new FileTypeWindow(&entryList);
|
||||||
|
if (window->InitCheck() == B_OK) {
|
||||||
|
fWindow = window;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeApp::PrintUsage(const char * execname) {
|
||||||
|
if (execname == 0) {
|
||||||
|
execname = "FileType";
|
||||||
|
}
|
||||||
|
fprintf(stderr,"Usage: %s [FILES]\n",execname);
|
||||||
|
fprintf(stderr,"Open a FileType window for the given FILES.\n");
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
fprintf(stderr,"Report bugs to [email protected]\n");
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeApp::ArgvReceived(int32 argc, const char * argv[], const char * cwd)
|
||||||
|
{
|
||||||
|
fArgvOkay = false;
|
||||||
|
BList entryList;
|
||||||
|
for (int i = 1 ; (i < argc) ; i++) {
|
||||||
|
BPath path;
|
||||||
|
if (argv[i][0] == '/') {
|
||||||
|
path.SetTo(argv[i]);
|
||||||
|
} else {
|
||||||
|
path.SetTo(cwd,argv[i]);
|
||||||
|
}
|
||||||
|
if (path.InitCheck() != B_OK) {
|
||||||
|
printf("path.InitCheck failed: \"");
|
||||||
|
if (argv[i][0] == '/') {
|
||||||
|
printf("%s",argv[i]);
|
||||||
|
} else {
|
||||||
|
printf("%s/%s",cwd,argv[i]);
|
||||||
|
}
|
||||||
|
printf("\".\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
entry_ref ref;
|
||||||
|
if (get_ref_for_path(path.Path(), &ref) != B_OK) {
|
||||||
|
printf("get_ref_for_path failed: \"");
|
||||||
|
printf("%s",path.Path());
|
||||||
|
printf("\".\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
entryList.AddItem(new BEntry(&ref,true));
|
||||||
|
}
|
||||||
|
if (entryList.CountItems() == 0) {
|
||||||
|
PrintUsage(argv[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FileTypeWindow * window = new FileTypeWindow(&entryList);
|
||||||
|
if (window->InitCheck() != B_OK) {
|
||||||
|
printf("Failed to create FileTypeWindow\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fArgvOkay = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeApp::ReadyToRun()
|
||||||
|
{
|
||||||
|
if (!fArgvOkay) {
|
||||||
|
Quit();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fWindow == 0) {
|
||||||
|
OpenPanel()->Show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BFilePanel *
|
||||||
|
FileTypeApp::OpenPanel()
|
||||||
|
{
|
||||||
|
if (fOpenPanel == 0) {
|
||||||
|
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
|
||||||
|
}
|
||||||
|
return fOpenPanel;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef FILE_TYPE_APP
|
||||||
|
#define FILE_TYPE_APP
|
||||||
|
|
||||||
|
#include <Application.h>
|
||||||
|
#include <FilePanel.h>
|
||||||
|
|
||||||
|
class FileTypeWindow;
|
||||||
|
|
||||||
|
class FileTypeApp
|
||||||
|
: public BApplication
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileTypeApp();
|
||||||
|
virtual void ArgvReceived(int32 argc, const char *argv[], const char * cwd);
|
||||||
|
virtual void RefsReceived(BMessage *message);
|
||||||
|
virtual void ReadyToRun();
|
||||||
|
|
||||||
|
virtual void DispatchMessage(BMessage *an_event, BHandler *handler);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BFilePanel * OpenPanel();
|
||||||
|
void PrintUsage(const char * execname);
|
||||||
|
|
||||||
|
FileTypeWindow * fWindow;
|
||||||
|
BFilePanel * fOpenPanel;
|
||||||
|
|
||||||
|
bool fArgvOkay;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern FileTypeApp * file_types_app;
|
||||||
|
|
||||||
|
#endif // FILE_TYPE_APP
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef FILE_TYPES_CONSTANTS_H
|
||||||
|
#define FILE_TYPES_CONSTANTS_H
|
||||||
|
|
||||||
|
#define APP_SIGNATURE "application/x-vnd.obos.file-type"
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
// File menu
|
||||||
|
const uint32 FILE_NEW_RESOURCE_FILE = 'Fnrf' ;
|
||||||
|
const uint32 FILE_OPEN = 'Fopn' ;
|
||||||
|
|
||||||
|
// Settings menu
|
||||||
|
const uint32 SETTINGS_SHOW_ITERNAL_TYPES = 'Ssit' ;
|
||||||
|
|
||||||
|
#endif // FILE_TYPES_CONSTANTS_H
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
#include <FileTypeView.h>
|
||||||
|
|
||||||
|
FileTypeView::FileTypeView(BRect viewFrame)
|
||||||
|
: BView(viewFrame, "FileTypeView", B_FOLLOW_ALL,
|
||||||
|
B_FRAME_EVENTS|B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
fFileTypeBox = new BBox(BRect(25,25,325,175),"File Type");
|
||||||
|
AddChild(fFileTypeBox);
|
||||||
|
|
||||||
|
fPreferredApplicationBox = new BBox(BRect(25,225,325,375),"Preferred Application");
|
||||||
|
AddChild(fPreferredApplicationBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileTypeView::~FileTypeView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeView::SetFileType(const char * fileType)
|
||||||
|
{
|
||||||
|
fFileType.SetTo(fileType);
|
||||||
|
// change UI
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeView::SetPreferredApplication(const char * preferredApplication)
|
||||||
|
{
|
||||||
|
fPreferredApplication.SetTo(preferredApplication);
|
||||||
|
// change UI
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
FileTypeView::IsClean() const
|
||||||
|
{
|
||||||
|
if (fFileType.Compare(GetFileType()) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (fPreferredApplication.Compare(GetPreferredApplication()) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
FileTypeView::GetFileType() const
|
||||||
|
{
|
||||||
|
// return from UI
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
FileTypeView::GetPreferredApplication() const
|
||||||
|
{
|
||||||
|
// return from UI
|
||||||
|
return "";
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
#ifndef FILE_TYPE_VIEW_H
|
||||||
|
#define FILE_TYPE_VIEW_H
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <PopUpMenu.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
class FileTypeView : public BView {
|
||||||
|
public:
|
||||||
|
FileTypeView(BRect viewFrame);
|
||||||
|
~FileTypeView();
|
||||||
|
|
||||||
|
void SetFileType(const char * fileType);
|
||||||
|
void SetPreferredApplication(const char * preferredApplication);
|
||||||
|
|
||||||
|
bool IsClean() const;
|
||||||
|
const char * GetFileType() const;
|
||||||
|
const char * GetPreferredApplication() const;
|
||||||
|
private:
|
||||||
|
BString fFileType;
|
||||||
|
BString fPreferredApplication;
|
||||||
|
|
||||||
|
BBox * fFileTypeBox;
|
||||||
|
BTextView * fFileTypeTextView;
|
||||||
|
BButton * fFileTypeSelectButton;
|
||||||
|
BButton * fFileTypeSameAsButton;
|
||||||
|
BBox * fPreferredApplicationBox;
|
||||||
|
BPopUpMenu * fPreferredApplicationMenu;
|
||||||
|
BButton * fPreferredApplicationSelectButton;
|
||||||
|
BButton * fPreferredApplicationSameAsButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILE_TYPE_VIEW_H
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
#include <Alert.h>
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <Node.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
|
|
||||||
|
#include <FileTypeView.h>
|
||||||
|
#include <FileTypeWindow.h>
|
||||||
|
|
||||||
|
FileTypeWindow::FileTypeWindow(const BList * entryList)
|
||||||
|
: BWindow(BRect(250,150,350,400),"File Type",B_TITLED_WINDOW,
|
||||||
|
B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
{
|
||||||
|
initStatus = B_ERROR;
|
||||||
|
fEntryList = 0;
|
||||||
|
if (entryList == 0) {
|
||||||
|
initStatus = B_BAD_VALUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fMenuBar = new BMenuBar(BRect(0,0,0,0),"menubar");
|
||||||
|
AddChild(fMenuBar);
|
||||||
|
|
||||||
|
BRect viewFrame = Bounds();
|
||||||
|
viewFrame.top = fMenuBar->Bounds().Height()+1;
|
||||||
|
fView = new FileTypeView(viewFrame);
|
||||||
|
AddChild(fView);
|
||||||
|
fView->MakeFocus(true);
|
||||||
|
|
||||||
|
fFileMenu = new BMenu("File");
|
||||||
|
fMenuBar->AddItem(fFileMenu);
|
||||||
|
fSaveItem = new BMenuItem("Save",new BMessage(B_SAVE_REQUESTED), 'S');
|
||||||
|
fFileMenu->AddItem(fSaveItem);
|
||||||
|
fFileMenu->AddSeparatorItem();
|
||||||
|
fCloseItem = new BMenuItem("Close",new BMessage(B_QUIT_REQUESTED), 'W');
|
||||||
|
fFileMenu->AddItem(fCloseItem);
|
||||||
|
|
||||||
|
SetEntries(entryList);
|
||||||
|
initStatus = B_OK;
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
FileTypeWindow::~FileTypeWindow()
|
||||||
|
{
|
||||||
|
if (fEntryList != 0) {
|
||||||
|
void * item;
|
||||||
|
for (int32 i = 0 ; item = fEntryList->ItemAt(i) ; i++) {
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
delete fEntryList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
FileTypeWindow::InitCheck() const
|
||||||
|
{
|
||||||
|
return initStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeWindow::MessageReceived(BMessage * message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case B_SAVE_REQUESTED:
|
||||||
|
SaveRequested();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BWindow::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
FileTypeWindow::QuitRequested()
|
||||||
|
{
|
||||||
|
if (fView->IsClean()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BAlert * saveAlert;
|
||||||
|
BString alertText("Would you like to save changes to file type attributes of ");
|
||||||
|
alertText << SummarizeEntries();
|
||||||
|
alertText << "? ";
|
||||||
|
saveAlert = new BAlert("savealert",alertText.String(), "Cancel", "Don't Save","Save",
|
||||||
|
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
|
||||||
|
saveAlert->SetShortcut(0, B_ESCAPE);
|
||||||
|
saveAlert->SetShortcut(1,'d');
|
||||||
|
saveAlert->SetShortcut(2,'s');
|
||||||
|
int32 buttonIndex = saveAlert->Go();
|
||||||
|
|
||||||
|
if (buttonIndex==0) { //"cancel": dont save, dont close the window
|
||||||
|
return false;
|
||||||
|
} else if (buttonIndex==1) { // "don't save": just close the window
|
||||||
|
return true;
|
||||||
|
} else if (SaveRequested() == B_OK) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// save errors are ignored: there's usually no good way for the user to recover
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
FileTypeWindow::SaveRequested()
|
||||||
|
{
|
||||||
|
status_t result = B_OK;
|
||||||
|
|
||||||
|
const char * fileType = fView->GetFileType();
|
||||||
|
const char * preferredApplication = fView->GetPreferredApplication();
|
||||||
|
|
||||||
|
if (fEntryList != 0) {
|
||||||
|
for (int32 i = 0 ; (i < fEntryList->CountItems()) ; i++) {
|
||||||
|
BNode node(static_cast<BEntry*>(fEntryList->ItemAt(i)));
|
||||||
|
if ((result = node.InitCheck()) != B_OK) {
|
||||||
|
// save errors are ignored: there's usually no good way for the user to recover
|
||||||
|
continue; // can't proceed with an invalid node
|
||||||
|
}
|
||||||
|
BNodeInfo nodeInfo(&node);
|
||||||
|
if ((result = nodeInfo.InitCheck()) != B_OK) {
|
||||||
|
// save errors are ignored: there's usually no good way for the user to recover
|
||||||
|
continue; // can't proceed with an invalid nodeinfo
|
||||||
|
}
|
||||||
|
if ((result = nodeInfo.SetType(fileType)) != B_OK) {
|
||||||
|
// save errors are ignored: there's usually no good way for the user to recover
|
||||||
|
}
|
||||||
|
if ((result = nodeInfo.SetPreferredApp(preferredApplication)) != B_OK) {
|
||||||
|
// save errors are ignored: there's usually no good way for the user to recover
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeWindow::SetEntries(const BList * entryList)
|
||||||
|
{
|
||||||
|
fEntryList = new BList(*entryList);
|
||||||
|
|
||||||
|
BString title = SummarizeEntries();
|
||||||
|
title.Append(" File Type");
|
||||||
|
SetTitle(strdup(title.String()));
|
||||||
|
|
||||||
|
BString * fileType = 0;
|
||||||
|
BString * preferredApplication = 0;
|
||||||
|
for (int32 i = 0 ; (i < fEntryList->CountItems()) ; i++) {
|
||||||
|
BNode node(static_cast<BEntry*>(fEntryList->ItemAt(i)));
|
||||||
|
if (node.InitCheck() != B_OK) {
|
||||||
|
// errors are ignored: there's usually no good way for the user to recover
|
||||||
|
continue; // can't proceed with an invalid node
|
||||||
|
}
|
||||||
|
BNodeInfo nodeInfo(&node);
|
||||||
|
if (nodeInfo.InitCheck() != B_OK) {
|
||||||
|
// errors are ignored: there's usually no good way for the user to recover
|
||||||
|
continue; // can't proceed with an invalid nodeinfo
|
||||||
|
}
|
||||||
|
char string[MAXPATHLEN];
|
||||||
|
if (nodeInfo.GetType(string) != B_OK) {
|
||||||
|
// errors are ignored: there's usually no good way for the user to recover
|
||||||
|
} else {
|
||||||
|
if (fileType == 0) {
|
||||||
|
fileType = new BString(string);
|
||||||
|
} else if (fileType->Compare(string) != 0) {
|
||||||
|
fileType->SetTo("");
|
||||||
|
if (preferredApplication && (preferredApplication->Length() == 0)) {
|
||||||
|
break; // stop now, don't waste time checking the rest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nodeInfo.GetPreferredApp(string) != B_OK) {
|
||||||
|
// errors are ignored: there's usually no good way for the user to recover
|
||||||
|
} else {
|
||||||
|
if (preferredApplication == 0) {
|
||||||
|
preferredApplication = new BString(string);
|
||||||
|
} else if (preferredApplication->Compare(string) != 0) {
|
||||||
|
preferredApplication->SetTo("");
|
||||||
|
if (fileType && (fileType->Length() == 0)) {
|
||||||
|
break; // stop now, don't waste time checking the rest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fileType != 0) {
|
||||||
|
fView->SetFileType(fileType->String());
|
||||||
|
delete fileType;
|
||||||
|
}
|
||||||
|
if (preferredApplication != 0) {
|
||||||
|
fView->SetPreferredApplication(preferredApplication->String());
|
||||||
|
delete preferredApplication;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
FileTypeWindow::SummarizeEntries()
|
||||||
|
{
|
||||||
|
switch (fEntryList->CountItems()) {
|
||||||
|
case 0:
|
||||||
|
return "<error>";
|
||||||
|
break;
|
||||||
|
case 1: {
|
||||||
|
char string[MAXPATHLEN];
|
||||||
|
static_cast<BEntry*>(fEntryList->FirstItem())->GetName(string);
|
||||||
|
return strdup(string);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "[Multiple Files]";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef FILE_TYPE_WINDOW_H
|
||||||
|
#define FILE_TYPE_WINDOW_H
|
||||||
|
|
||||||
|
#include <EntryList.h>
|
||||||
|
#include <List.h>
|
||||||
|
#include <MenuBar.h>
|
||||||
|
#include <MenuItem.h>
|
||||||
|
#include <Window.h>
|
||||||
|
|
||||||
|
class FileTypeView;
|
||||||
|
|
||||||
|
class FileTypeWindow
|
||||||
|
: public BWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FileTypeWindow(const BList * entryList);
|
||||||
|
~FileTypeWindow();
|
||||||
|
|
||||||
|
virtual bool QuitRequested();
|
||||||
|
virtual void MessageReceived(BMessage * message);
|
||||||
|
|
||||||
|
status_t InitCheck() const;
|
||||||
|
private:
|
||||||
|
status_t SaveRequested();
|
||||||
|
void SetEntries(const BList * entryList);
|
||||||
|
const char * SummarizeEntries();
|
||||||
|
|
||||||
|
BMenuBar * fMenuBar;
|
||||||
|
BMenu * fFileMenu;
|
||||||
|
BMenuItem * fSaveItem;
|
||||||
|
BMenuItem * fCloseItem;
|
||||||
|
|
||||||
|
FileTypeView * fView;
|
||||||
|
|
||||||
|
BList * fEntryList;
|
||||||
|
status_t initStatus;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FILE_TYPE_WINDOW_H
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
SubDir OBOS_TOP src add-ons tracker filetype ;
|
||||||
|
|
||||||
|
AddResources FileType-F :
|
||||||
|
FileType.rdef FileType.icons.rdef FileType.version.rdef
|
||||||
|
;
|
||||||
|
|
||||||
|
App FileType-F :
|
||||||
|
main.cpp
|
||||||
|
FileTypeApp.cpp
|
||||||
|
FileTypeView.cpp
|
||||||
|
FileTypeWindow.cpp
|
||||||
|
process_refs.cpp
|
||||||
|
;
|
||||||
|
|
||||||
|
MakeLocate FileType-F : [ FDirName $(OBOS_ADDON_DIR) Tracker ] ;
|
||||||
|
|
||||||
|
LinkSharedOSLibs FileType-F : be tracker ;
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <FileTypeApp.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
FileTypeApp fileType;
|
||||||
|
fileType.Run();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include <FileTypeConstants.h>
|
||||||
|
#include <TrackerAddOn.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
|
extern "C" void
|
||||||
|
process_refs(entry_ref dir_ref, BMessage * message, void *)
|
||||||
|
{
|
||||||
|
be_roster->Launch(APP_SIGNATURE,message);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user