The new file type add-on. It just starts the FileTypes application for

the files.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16633 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-07 16:31:01 +00:00
parent 507514408c
commit 33cec98da1
24 changed files with 98 additions and 1741 deletions

View File

@ -1,106 +0,0 @@
#include "AppTypeAppFlagsView.h"
AppTypeAppFlagsView::AppTypeAppFlagsView(BRect viewFrame)
: BView(viewFrame, "AppTypeAppFlagsView", B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW)
{
float width = 0, height = 0;
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
fAppFlagsBox = new BBox(Bounds(),"box",
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
AddChild(fAppFlagsBox);
const char * appFlagsCheckBoxLabel = "Application Flags";
float appFlagsCheckBoxStringWidth = StringWidth(appFlagsCheckBoxLabel);
fAppFlagsCheckBox = new BCheckBox(fAppFlagsBox->Bounds(),
appFlagsCheckBoxLabel,
appFlagsCheckBoxLabel,NULL,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
fAppFlagsBox->SetLabel(fAppFlagsCheckBox);
const char * singleRadioButtonLabel = "Single Launch";
float singleRadioButtonStringWidth = StringWidth(singleRadioButtonLabel);
BRect singleRadioButtonFrame = fAppFlagsBox->Bounds();
singleRadioButtonFrame.top = fAppFlagsCheckBox->Bounds().Height()/2 + 10;
singleRadioButtonFrame.left = 10;
singleRadioButtonFrame.right -= 10;
fAppFlagsSingleRadioButton = new BRadioButton(singleRadioButtonFrame,
singleRadioButtonLabel,
singleRadioButtonLabel,NULL);
fAppFlagsBox->AddChild(fAppFlagsSingleRadioButton);
fAppFlagsSingleRadioButton->GetPreferredSize(&width,&height);
fAppFlagsSingleRadioButton->ResizeTo(width,height);
float leftWidth = width;
const char * multipleRadioButtonLabel = "Multiple Launch";
float multipleRadioButtonStringWidth = StringWidth(multipleRadioButtonLabel);
BRect multipleRadioButtonFrame = fAppFlagsBox->Bounds();
multipleRadioButtonFrame.top = fAppFlagsSingleRadioButton->Frame().bottom;
multipleRadioButtonFrame.left = 10;
multipleRadioButtonFrame.right -= 10;
fAppFlagsMultipleRadioButton = new BRadioButton(multipleRadioButtonFrame,
multipleRadioButtonLabel,
multipleRadioButtonLabel,NULL);
fAppFlagsBox->AddChild(fAppFlagsMultipleRadioButton);
fAppFlagsMultipleRadioButton->GetPreferredSize(&width,&height);
fAppFlagsMultipleRadioButton->ResizeTo(width,height);
if (width > leftWidth) leftWidth = width;
const char * exclusiveRadioButtonLabel = "Exclusive Launch";
float exclusiveRadioButtonStringWidth = StringWidth(exclusiveRadioButtonLabel);
BRect exclusiveRadioButtonFrame = fAppFlagsBox->Bounds();
exclusiveRadioButtonFrame.top = fAppFlagsMultipleRadioButton->Frame().bottom;
exclusiveRadioButtonFrame.left = 10;
exclusiveRadioButtonFrame.right -= 10;
fAppFlagsExclusiveRadioButton = new BRadioButton(exclusiveRadioButtonFrame,
exclusiveRadioButtonLabel,
exclusiveRadioButtonLabel,NULL);
fAppFlagsBox->AddChild(fAppFlagsExclusiveRadioButton);
fAppFlagsExclusiveRadioButton->GetPreferredSize(&width,&height);
fAppFlagsExclusiveRadioButton->ResizeTo(width,height);
if (width > leftWidth) leftWidth = width;
const char * argvOnlyCheckBoxLabel = "Argv Only";
float argvOnlyCheckBoxStringWidth = StringWidth(argvOnlyCheckBoxLabel);
BRect argvOnlyCheckBoxFrame = fAppFlagsBox->Bounds();
argvOnlyCheckBoxFrame.top = fAppFlagsSingleRadioButton->Frame().top - 1;
argvOnlyCheckBoxFrame.left = 10 + leftWidth;
argvOnlyCheckBoxFrame.right -= 10;
fAppFlagsArgvOnlyCheckBox = new BCheckBox(argvOnlyCheckBoxFrame,
argvOnlyCheckBoxLabel,
argvOnlyCheckBoxLabel,NULL);
fAppFlagsBox->AddChild(fAppFlagsArgvOnlyCheckBox);
fAppFlagsArgvOnlyCheckBox->GetPreferredSize(&width,&height);
fAppFlagsArgvOnlyCheckBox->ResizeTo(width,height);
float rightWidth = width;
const char * backgroundCheckBoxLabel = "Background App";
float backgroundCheckBoxStringWidth = StringWidth(backgroundCheckBoxLabel);
BRect backgroundCheckBoxFrame = fAppFlagsBox->Bounds();
backgroundCheckBoxFrame.top = fAppFlagsArgvOnlyCheckBox->Frame().bottom - 1;
backgroundCheckBoxFrame.left = 10 + leftWidth;
backgroundCheckBoxFrame.right -= 10;
fAppFlagsBackgroundCheckBox = new BCheckBox(backgroundCheckBoxFrame,
backgroundCheckBoxLabel,
backgroundCheckBoxLabel,NULL);
fAppFlagsBox->AddChild(fAppFlagsBackgroundCheckBox);
fAppFlagsBackgroundCheckBox->GetPreferredSize(&width,&height);
fAppFlagsBackgroundCheckBox->ResizeTo(width,height);
if (width > rightWidth) rightWidth = width;
width = 10 + leftWidth + rightWidth + 5;
height = fAppFlagsExclusiveRadioButton->Frame().bottom + 5;
fAppFlagsBox->ResizeTo(width,height);
ResizeTo(width,height);
}
AppTypeAppFlagsView::~AppTypeAppFlagsView()
{
}
bool
AppTypeAppFlagsView::IsClean() const
{
return true;
}

View File

@ -1,26 +0,0 @@
#ifndef APP_TYPE_APP_FLAGS_VIEW_H
#define APP_TYPE_APP_FLAGS_VIEW_H
#include <Box.h>
#include <CheckBox.h>
#include <RadioButton.h>
#include <View.h>
class AppTypeAppFlagsView : public BView {
public:
AppTypeAppFlagsView(BRect viewFrame);
~AppTypeAppFlagsView();
bool IsClean() const;
private:
BBox * fAppFlagsBox;
BCheckBox * fAppFlagsCheckBox;
BRadioButton * fAppFlagsSingleRadioButton;
BRadioButton * fAppFlagsMultipleRadioButton;
BRadioButton * fAppFlagsExclusiveRadioButton;
BCheckBox * fAppFlagsArgvOnlyCheckBox;
BCheckBox * fAppFlagsBackgroundCheckBox;
};
#endif // APP_TYPE_APP_FLAGS_VIEW_H

View File

@ -1,57 +0,0 @@
#include "AppTypeSupportedTypesView.h"
#include <SupportDefs.h>
AppTypeSupportedTypesView::AppTypeSupportedTypesView(BRect viewFrame)
: BView(viewFrame, "AppTypeSupportedTypesView",
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,
B_FRAME_EVENTS|B_WILL_DRAW)
{
font_height fontHeight;
GetFontHeight(&fontHeight);
float lineHeight = fontHeight.ascent+fontHeight.descent+fontHeight.leading;
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
fBox = new BBox(Bounds(),"box",B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
fBox->SetLabel("Supported Types:");
AddChild(fBox);
const char * addButtonLabel = "Add...";
fAddButton = new BButton(Bounds(),addButtonLabel,addButtonLabel,NULL);
float addButtonWidth = 0, addButtonHeight = 0;
fAddButton->GetPreferredSize(&addButtonWidth,&addButtonHeight);
const char * removeButtonLabel = "Remove";
fRemoveButton = new BButton(Bounds(),removeButtonLabel,removeButtonLabel,NULL);
float removeButtonWidth = 0, removeButtonHeight = 0;
fRemoveButton->GetPreferredSize(&removeButtonWidth,&removeButtonHeight);
float buttonWidth = max_c(addButtonWidth,removeButtonWidth);
float buttonHeight = max_c(addButtonHeight,removeButtonHeight);
fRemoveButton->ResizeTo(buttonWidth,buttonHeight);
fAddButton->ResizeTo(buttonWidth,buttonHeight);
fAddButton->MoveTo(fBox->Bounds().Width() - 60 - fAddButton->Bounds().Width(),14);
fRemoveButton->MoveTo(fAddButton->Frame().left,fAddButton->Frame().bottom);
fListView = new BListView(Bounds(),"listview");
fListView->ResizeTo(fAddButton->Frame().left - 20 - B_V_SCROLL_BAR_WIDTH,
max_c(1*lineHeight,2*buttonHeight - 2));
fListView->MoveTo(12,fAddButton->Frame().top+2);
fScrollView = new BScrollView("scrollview",fListView,B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW,false,true);
fBox->AddChild(fScrollView);
fBox->AddChild(fAddButton);
fBox->AddChild(fRemoveButton);
fBox->ResizeTo(Bounds().Width(),fScrollView->Frame().bottom+8);
ResizeTo(fBox->Bounds().Width(),fBox->Bounds().Height());
}
AppTypeSupportedTypesView::~AppTypeSupportedTypesView()
{
}
bool
AppTypeSupportedTypesView::IsClean() const
{
return true;
}

View File

@ -1,25 +0,0 @@
#ifndef APP_TYPE_SUPPORTED_TYPES_VIEW_H
#define APP_TYPE_SUPPORTED_TYPES_VIEW_H
#include <Box.h>
#include <Button.h>
#include <ListView.h>
#include <ScrollView.h>
#include <View.h>
class AppTypeSupportedTypesView : public BView {
public:
AppTypeSupportedTypesView(BRect viewFrame);
~AppTypeSupportedTypesView();
bool IsClean() const;
private:
BBox * fBox;
BListView * fListView;
BScrollView * fScrollView;
BButton * fAddButton;
BButton * fRemoveButton;
};
#endif // APP_TYPE_SUPPORTED_TYPES_VIEW_H

View File

@ -1,180 +0,0 @@
#include "AppTypeVersionInfoView.h"
#include <SupportDefs.h>
#include <stdio.h>
AppTypeVersionInfoView::AppTypeVersionInfoView(BRect viewFrame)
: BView(viewFrame, "AppTypeVersionInfoView", B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW)
{
font_height fontHeight;
GetFontHeight(&fontHeight);
float lineHeight = fontHeight.ascent+fontHeight.descent+fontHeight.leading;
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
fBox = new BBox(Bounds(),"box",B_FOLLOW_ALL);
fBox->SetLabel("Version Info:");
AddChild(fBox);
// Version kind row
fKindMenu = new BMenu("kind");
fApplicationMenuItem = new BMenuItem("Application",NULL);
fKindMenu->AddItem(fApplicationMenuItem);
fSystemMenuItem = new BMenuItem("System",NULL);
fKindMenu->AddItem(fSystemMenuItem);
fKindMenu->SetRadioMode(true);
fKindMenu->SetLabelFromMarked(true);
fApplicationMenuItem->SetMarked(true);
fKindMenuField = new BMenuField(Bounds(),"kindField",NULL,fKindMenu);
const char * kindMenuLabel = "Version kind:";
float kindMenuStringWidth = StringWidth(kindMenuLabel);
fKindMenuField->SetLabel(kindMenuLabel);
fKindMenuField->SetDivider(kindMenuStringWidth+5);
float kindMenuFieldWidth = 0, kindMenuFieldHeight = 0;
fKindMenuField->GetPreferredSize(&kindMenuFieldWidth,&kindMenuFieldHeight);
fKindMenuField->ResizeTo(kindMenuFieldWidth,lineHeight+8);
fKindMenuField->MoveTo(8,10);
fBox->AddChild(fKindMenuField);
// Version row
fStringView = new BStringView(Bounds(),"version","Version:");
float stringViewWidth = 0, stringViewHeight = 0;
fStringView->GetPreferredSize(&stringViewWidth,&stringViewHeight);
fStringView->ResizeTo(stringViewWidth,stringViewHeight);
fStringView->MoveTo(9,fKindMenuField->Frame().bottom+5);
fBox->AddChild(fStringView);
fMajorTextControl = new BTextControl(BRect(0,0,21,21),"major",NULL,NULL,NULL);
float majorTextControlWidth = 0, majorTextControlHeight = 0;
fMajorTextControl->GetPreferredSize(&majorTextControlWidth,&majorTextControlHeight);
fMajorTextControl->ResizeTo(20,majorTextControlHeight);
fMajorTextControl->MoveTo(fStringView->Frame().right,fStringView->Frame().top-2);
fBox->AddChild(fMajorTextControl);
fDot1StringView = new BStringView(Bounds(),"dot1",".");
float dot1stringViewWidth = 0, dot1stringViewHeight = 0;
fDot1StringView->GetPreferredSize(&dot1stringViewWidth,&dot1stringViewHeight);
fDot1StringView->ResizeTo(dot1stringViewWidth-2,dot1stringViewHeight);
fDot1StringView->MoveTo(fMajorTextControl->Frame().right+3,fStringView->Frame().top);
fBox->AddChild(fDot1StringView);
fMiddleTextControl = new BTextControl(BRect(0,0,21,21),"middle",NULL,NULL,NULL);
float middleTextControlWidth = 0, middleTextControlHeight = 0;
fMiddleTextControl->GetPreferredSize(&middleTextControlWidth,&middleTextControlHeight);
fMiddleTextControl->ResizeTo(20,middleTextControlHeight);
fMiddleTextControl->MoveTo(fDot1StringView->Frame().right,fStringView->Frame().top-2);
fBox->AddChild(fMiddleTextControl);
fDot2StringView = new BStringView(Bounds(),"dot2",".");
float dot2stringViewWidth = 0, dot2stringViewHeight = 0;
fDot2StringView->GetPreferredSize(&dot2stringViewWidth,&dot2stringViewHeight);
fDot2StringView->ResizeTo(dot2stringViewWidth-2,dot2stringViewHeight);
fDot2StringView->MoveTo(fMiddleTextControl->Frame().right+3,fStringView->Frame().top);
fBox->AddChild(fDot2StringView);
fMinorTextControl = new BTextControl(BRect(0,0,21,21),"minor",NULL,NULL,NULL);
float minorTextControlWidth = 0, minorTextControlHeight = 0;
fMinorTextControl->GetPreferredSize(&minorTextControlWidth,&minorTextControlHeight);
fMinorTextControl->ResizeTo(20,minorTextControlHeight);
fMinorTextControl->MoveTo(fDot2StringView->Frame().right,fStringView->Frame().top-2);
fBox->AddChild(fMinorTextControl);
float varietyMenuFieldWidth = 0;
fVarietyMenu = new BMenu("variety");
const char * developmentMenuItemLabel = "Development";
varietyMenuFieldWidth = max_c(StringWidth(developmentMenuItemLabel),varietyMenuFieldWidth);
fDevelopmentMenuItem = new BMenuItem(developmentMenuItemLabel,NULL);
fVarietyMenu->AddItem(fDevelopmentMenuItem);
const char * alphaMenuItemLabel = "Alpha";
varietyMenuFieldWidth = max_c(StringWidth(alphaMenuItemLabel),varietyMenuFieldWidth);
fAlphaMenuItem = new BMenuItem(alphaMenuItemLabel,NULL);
fVarietyMenu->AddItem(fAlphaMenuItem);
const char * betaMenuItemLabel = "Beta";
varietyMenuFieldWidth = max_c(StringWidth(betaMenuItemLabel),varietyMenuFieldWidth);
fBetaMenuItem = new BMenuItem(betaMenuItemLabel,NULL);
fVarietyMenu->AddItem(fBetaMenuItem);
const char * gammaMenuItemLabel = "Gamma";
varietyMenuFieldWidth = max_c(StringWidth(gammaMenuItemLabel),varietyMenuFieldWidth);
fGammaMenuItem = new BMenuItem(gammaMenuItemLabel,NULL);
fVarietyMenu->AddItem(fGammaMenuItem);
const char * goldenMasterMenuItemLabel = "Golden master";
varietyMenuFieldWidth = max_c(StringWidth(goldenMasterMenuItemLabel),varietyMenuFieldWidth);
fGoldenMasterMenuItem = new BMenuItem(goldenMasterMenuItemLabel,NULL);
fVarietyMenu->AddItem(fGoldenMasterMenuItem);
const char * finalMenuItemLabel = "Final";
varietyMenuFieldWidth = max_c(StringWidth(finalMenuItemLabel),varietyMenuFieldWidth);
fFinalMenuItem = new BMenuItem(finalMenuItemLabel,NULL);
fVarietyMenu->AddItem(fFinalMenuItem);
fVarietyMenu->SetRadioMode(true);
fVarietyMenu->SetLabelFromMarked(true);
fDevelopmentMenuItem->SetMarked(true);
fVarietyMenuField = new BMenuField(Bounds(),"varietyField",NULL,fVarietyMenu);
fVarietyMenuField->ResizeTo(varietyMenuFieldWidth+18,lineHeight+8);
fVarietyMenuField->MoveTo(fMinorTextControl->Frame().right+5,fStringView->Frame().top-3);
fBox->AddChild(fVarietyMenuField);
fSlashStringView = new BStringView(Bounds(),"slash","/");
float slashStringViewWidth = 0, slashStringViewHeight = 0;
fSlashStringView->GetPreferredSize(&slashStringViewWidth,&slashStringViewHeight);
fSlashStringView->ResizeTo(slashStringViewWidth,slashStringViewHeight);
fSlashStringView->MoveTo(fVarietyMenuField->Frame().right+5,fStringView->Frame().top);
fBox->AddChild(fSlashStringView);
fInternalTextControl = new BTextControl(BRect(0,0,21,21),"internal",NULL,NULL,NULL);
float internalTextControlWidth = 0, internalTextControlHeight = 0;
fInternalTextControl->GetPreferredSize(&internalTextControlWidth,&internalTextControlHeight);
fInternalTextControl->ResizeTo(20,internalTextControlHeight);
fInternalTextControl->MoveTo(fSlashStringView->Frame().right-2,fStringView->Frame().top-2);
fBox->AddChild(fInternalTextControl);
// Short description row
const char * shortTextControlLabel = "Short Description:";
float shortTextControlStringWidth = StringWidth(shortTextControlLabel);
fShortTextControl = new BTextControl(BRect(0,0,fBox->Bounds().Width()-16,21),
shortTextControlLabel,
shortTextControlLabel,NULL,NULL,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
float shortTextControlWidth = 0, shortTextControlHeight = 0;
fShortTextControl->GetPreferredSize(&shortTextControlWidth,&shortTextControlHeight);
fShortTextControl->ResizeTo(fBox->Bounds().Width()-17,shortTextControlHeight);
fShortTextControl->MoveTo(8,fVarietyMenuField->Frame().bottom+4);
fShortTextControl->SetDivider(shortTextControlStringWidth+5);
fBox->AddChild(fShortTextControl);
const char * longStringViewLabel = "Long Description:";
fLongStringView = new BStringView(Bounds(),longStringViewLabel,longStringViewLabel);
float longStringViewWidth = 0, longStringViewHeight = 0;
fLongStringView->GetPreferredSize(&longStringViewWidth,&longStringViewHeight);
fLongStringView->ResizeTo(longStringViewWidth,longStringViewHeight);
fLongStringView->MoveTo(9,fShortTextControl->Frame().bottom);
fBox->AddChild(fLongStringView);
BRect leftovers = fBox->Bounds();
leftovers.InsetBy(8,8);
leftovers.left += 1;
leftovers.top = fLongStringView->Frame().bottom;
BBox * textViewBox = new BBox(leftovers,"textbox",B_FOLLOW_ALL);
fBox->AddChild(textViewBox);
BRect textViewFrame = textViewBox->Bounds();
textViewFrame.InsetBy(2,2);
BRect textFrame = leftovers;
textFrame.OffsetTo(0,0);
fLongTextView = new BTextView(textViewFrame,"description",textFrame,B_FOLLOW_ALL,
B_NAVIGABLE|B_WILL_DRAW|B_PULSE_NEEDED|B_FRAME_EVENTS);
textViewBox->AddChild(fLongTextView);
}
AppTypeVersionInfoView::~AppTypeVersionInfoView()
{
}
bool
AppTypeVersionInfoView::IsClean() const
{
return true;
}

View File

@ -1,48 +0,0 @@
#ifndef APP_TYPE_VERSION_INFO_VIEW_H
#define APP_TYPE_VERSION_INFO_VIEW_H
#include <Box.h>
#include <Menu.h>
#include <MenuField.h>
#include <MenuItem.h>
#include <String.h>
#include <StringView.h>
#include <TextControl.h>
#include <TextView.h>
#include <View.h>
class AppTypeVersionInfoView : public BView {
public:
AppTypeVersionInfoView(BRect viewFrame);
~AppTypeVersionInfoView();
bool IsClean() const;
private:
BBox * fBox;
BMenu * fKindMenu;
BMenuItem * fApplicationMenuItem;
BMenuItem * fSystemMenuItem;
BMenuField * fKindMenuField;
BStringView * fStringView;
BTextControl * fMajorTextControl;
BStringView * fDot1StringView;
BTextControl * fMiddleTextControl;
BStringView * fDot2StringView;
BTextControl * fMinorTextControl;
BMenu * fVarietyMenu;
BMenuItem * fDevelopmentMenuItem;
BMenuItem * fAlphaMenuItem;
BMenuItem * fBetaMenuItem;
BMenuItem * fGammaMenuItem;
BMenuItem * fGoldenMasterMenuItem;
BMenuItem * fFinalMenuItem;
BMenuField * fVarietyMenuField;
BStringView * fSlashStringView;
BTextControl * fInternalTextControl;
BTextControl * fShortTextControl;
BStringView * fLongStringView;
BTextView * fLongTextView;
};
#endif // APP_TYPE_VERSION_INFO_VIEW_H

View File

@ -1,59 +0,0 @@
#include "AppTypeView.h"
#include "AppTypeAppFlagsView.h"
#include "AppTypeSupportedTypesView.h"
#include "AppTypeVersionInfoView.h"
AppTypeView::AppTypeView(BRect viewFrame)
: BBox(viewFrame, "AppTypeView", B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW, B_PLAIN_BORDER)
{
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
BRect signatureTextControlFrame = Bounds();
signatureTextControlFrame.top += 10;
signatureTextControlFrame.left += 10;
signatureTextControlFrame.right -= 60;
const char * signatureTextControlLabel = "Signature:";
float signatureTextControlStringWidth = StringWidth(signatureTextControlLabel);
fSignatureTextControl = new BTextControl(signatureTextControlFrame,
signatureTextControlLabel,
signatureTextControlLabel,NULL,NULL,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
fSignatureTextControl->SetDivider(signatureTextControlStringWidth+5);
AddChild(fSignatureTextControl);
BRect appFlagsViewFrame = Bounds();
appFlagsViewFrame.top = fSignatureTextControl->Bounds().bottom + 10;
appFlagsViewFrame.left += 10;
appFlagsViewFrame.right -= 60;
fAppFlagsView = new AppTypeAppFlagsView(appFlagsViewFrame);
AddChild(fAppFlagsView);
BRect appSupportedTypesViewFrame = Bounds();
appSupportedTypesViewFrame.top = fAppFlagsView->Frame().bottom + 10;
appSupportedTypesViewFrame.left = appFlagsViewFrame.left;
appSupportedTypesViewFrame.right -= 10;
fSupportedTypesView = new AppTypeSupportedTypesView(appSupportedTypesViewFrame);
AddChild(fSupportedTypesView);
BRect versionInfoViewFrame = Bounds();
versionInfoViewFrame.top = fSupportedTypesView->Frame().bottom + 10;
versionInfoViewFrame.left = appSupportedTypesViewFrame.left;
versionInfoViewFrame.right = appSupportedTypesViewFrame.right;
versionInfoViewFrame.bottom -= 10;
fVersionInfoView = new AppTypeVersionInfoView(versionInfoViewFrame);
AddChild(fVersionInfoView);
}
AppTypeView::~AppTypeView()
{
}
bool
AppTypeView::IsClean() const
{
if (!fVersionInfoView->IsClean()) {
return false;
}
return true;
}

View File

@ -1,25 +0,0 @@
#ifndef APP_TYPE_VIEW_H
#define APP_TYPE_VIEW_H
#include <Box.h>
#include <TextControl.h>
class AppTypeAppFlagsView;
class AppTypeSupportedTypesView;
class AppTypeVersionInfoView;
class AppTypeView : public BBox {
public:
AppTypeView(BRect viewFrame);
~AppTypeView();
bool IsClean() const;
private:
BTextControl * fSignatureTextControl;
AppTypeAppFlagsView * fAppFlagsView;
AppTypeSupportedTypesView * fSupportedTypesView;
AppTypeVersionInfoView * fVersionInfoView;
};
#endif // APP_TYPE_VIEW_H

View File

@ -1,149 +0,0 @@
#include <Alert.h>
#include <Autolock.h>
#include <Debug.h>
#include <Entry.h>
#include <Node.h>
#include <NodeInfo.h>
#include <String.h>
#include <unistd.h>
#include "FileTypeApp.h"
#include "AppTypeView.h"
#include "AppTypeWindow.h"
AppTypeWindow::AppTypeWindow(const BEntry * entry)
: BWindow(BRect(100,100,400,520),"Application Type",B_TITLED_WINDOW,
B_NOT_ZOOMABLE|B_NOT_RESIZABLE|B_ASYNCHRONOUS_CONTROLS)
{
initStatus = B_ERROR;
fEntry = 0;
if (entry == 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 AppTypeView(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);
SetEntry(entry);
initStatus = B_OK;
Show();
}
AppTypeWindow::~AppTypeWindow()
{
delete fEntry;
}
status_t
AppTypeWindow::InitCheck() const
{
return initStatus;
}
void
AppTypeWindow::MessageReceived(BMessage * message)
{
switch (message->what) {
case B_SAVE_REQUESTED:
SaveRequested();
break;
default:
BWindow::MessageReceived(message);
break;
}
}
void
AppTypeWindow::Quit()
{
{
// This is in its own scope because it must be released
// before the call to BWindow::Quit()
BAutolock lock(file_type_app);
file_type_app->Quit();
}
BWindow::Quit();
}
bool
AppTypeWindow::QuitRequested()
{
if (fView->IsClean()) {
return true;
}
if (!fEntry) {
// no entry to save to!
return true;
}
BAlert * saveAlert;
char name[MAXPATHLEN];
fEntry->GetName(name);
BString alertText("Would you like to save changes to file type attributes of ");
alertText << name << "?";
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;
}
}
static const char * application_file_types = "BEOS:FILE_TYPES";
static const char * application_flags_name = "BEOS:APP_FLAGS";
static const char * application_large_standard_icon_name = "BEOS:L:STD_ICON";
static const char * application_median_standard_icon_name = "BEOS:M:STD_ICON";
static const char * application_signature_name = "BEOS:APP_SIG";
static const char * application_version_name = "BEOS:APP_VERSION";
status_t
AppTypeWindow::SaveRequested()
{
status_t result = B_OK;
// TODO : save new settings to all attributes and resources matching the name
return result;
}
void
AppTypeWindow::SetEntry(const BEntry * entry)
{
fEntry = new BEntry(*entry);
char name[MAXPATHLEN];
entry->GetName(name);
BString title(name);
title.Append(" Application Type");
SetTitle(strdup(title.String()));
// TODO : set old settings
}

View File

@ -1,39 +0,0 @@
#ifndef APP_TYPE_WINDOW_H
#define APP_TYPE_WINDOW_H
#include <EntryList.h>
#include <List.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <Window.h>
class AppTypeView;
class AppTypeWindow
: public BWindow
{
public:
AppTypeWindow(const BEntry * entry);
~AppTypeWindow();
virtual void Quit();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage * message);
status_t InitCheck() const;
private:
status_t SaveRequested();
void SetEntry(const BEntry * entry);
BMenuBar * fMenuBar;
BMenu * fFileMenu;
BMenuItem * fSaveItem;
BMenuItem * fCloseItem;
AppTypeView * fView;
BEntry * fEntry;
status_t initStatus;
};
#endif // APP_TYPE_WINDOW_H

View File

@ -0,0 +1,17 @@
/*
* Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <Roster.h>
/*!
\brief Tracker add-on entry
*/
extern "C" void
process_refs(entry_ref dir, BMessage* refs, void* /*reserved*/)
{
be_roster->Launch("application/x-vnd.haiku-filetypes", refs);
}

View File

@ -1,166 +0,0 @@
/*
** 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"
};

View File

@ -1,13 +1,80 @@
/*
** FileType.rdef
**
*/
* FileType.rdef
*/
resource app_signature "application/x-vnd.obos.file-type";
resource app_flags B_MULTIPLE_LAUNCH;
//resource app_signature "application/x-vnd.Haiku-FileType";
//resource app_flags B_MULTIPLE_LAUNCH;
resource file_types message {
"types" = "application/x-be-resource",
"types" = "application/octet-stream"
};
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 = "FileType",
long_info = "FileType, Copyright 2006 Haiku Inc."
};
resource mini_icon array {
$"FFFFFFFFFFFFFFFF020200FFFFFFFFFF"
$"FFFFFFFFFFFFFF04151E1500FFFFFFFF"
$"FFFFFFFFFFFFFF021D1E1C00FFFFFFFF"
$"FFFFFFFF00FFFF00151B1600FFFFFFFF"
$"FFFFFF003F0000FA0000000000FFFFFF"
$"FFFF003FFD0000F9F9FAFAFAFA00FFFF"
$"FF003FFEFDFD00F9F9F9F97D7D00FFFF"
$"003F62FE89FD00F9F9F900007D00FFFF"
$"FF003FB0FD89FA00F90060600000FFFF"
$"FF003FFEB0FD620000606060606000FF"
$"FFFF003FFD89FA003F3F606060D500FF"
$"FFFF003FFDFDFA00ACAC3F3FD5D5000E"
$"FFFFFF003FFD0000ACACACACD5D5000E"
$"FFFFFF003F000E00ACACACACD5D5000E"
$"FFFFFFFF000E0E0E0000ACACD5000E0E"
$"FFFFFFFFFFFFFFFFFFFF0000000E0EFF"
};
resource large_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"
};

View File

@ -1,20 +0,0 @@
/*
** 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"
};

View File

@ -1,240 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <Node.h>
#include <NodeInfo.h>
#include <Path.h>
#include <Roster.h>
#include "AppTypeWindow.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::MessageReceived(BMessage *message)
{
switch(message->what) {
case B_CANCEL:
if (fWindow == 0) {
Quit();
}
break;
default:
BApplication::MessageReceived(message);
break;
}
}
void
FileTypeApp::RefsReceived(BMessage * message)
{
BList entryList;
int32 i = 0;
entry_ref ref;
while (message->FindRef("refs",i++,&ref) == B_OK) {
BEntry * entry = new BEntry(&ref,true);
if (!entry || (entry->InitCheck() != B_OK) || (!entry->Exists())) {
// ignore bogus refs
delete entry;
continue;
}
entryList.AddItem(entry);
}
if (entryList.CountItems() == 0) {
return;
}
if (entryList.CountItems() == 1) {
BEntry * entry = static_cast<BEntry*>(entryList.FirstItem());
BNode node(entry);
if (node.InitCheck() != B_OK) {
delete entry;
return;
}
BNodeInfo nodeInfo(&node);
if (nodeInfo.InitCheck() != B_OK) {
delete entry;
return;
}
char string[MAXPATHLEN];
if ((nodeInfo.GetType(string) == B_OK)
&& (strcmp(string,"application/x-vnd.Be-elfexecutable") == 0)) {
AppTypeWindow * window = new AppTypeWindow(entry);
if (window->InitCheck() == B_OK) {
fWindow = window;
}
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 [OPTIONS] [FILES]\n",execname);
fprintf(stderr,"Open a FileType window for the given FILES.\n");
fprintf(stderr,"\n");
fprintf(stderr," -h, --help print this help\n");
fprintf(stderr,"\n");
fprintf(stderr,"Report bugs to shatty@myrealbox.com\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;
}
BEntry * entry = new BEntry(path.Path(),true);
if (!entry || (entry->InitCheck() != B_OK)) {
printf("failed to allocate BEntry: \"");
if (argv[i][0] == '/') {
printf("%s",argv[i]);
} else {
printf("%s/%s",cwd,argv[i]);
}
printf("\".\n");
delete entry;
continue;
}
if (!entry->Exists()) {
if ((strcmp(argv[i],"-h") == 0) ||
(strcmp(argv[i],"-H") == 0) ||
(strcmp(argv[i],"-help") == 0) ||
(strcmp(argv[i],"--help") == 0)) {
for (int32 i = 0 ; (i < entryList.CountItems()) ; i++) {
delete static_cast<BEntry*>(entryList.ItemAt(i));
}
entryList.MakeEmpty();
delete entry;
break;
} else {
printf("file does not exist: \"");
if (argv[i][0] == '/') {
printf("%s",argv[i]);
} else {
printf("%s/%s",cwd,argv[i]);
}
printf("\".\n");
delete entry;
continue;
}
}
entryList.AddItem(entry);
}
if (entryList.CountItems() == 0) {
PrintUsage(argv[0]);
return;
}
if (entryList.CountItems() == 1) {
BEntry * entry = static_cast<BEntry*>(entryList.FirstItem());
BNode node(entry);
if (node.InitCheck() != B_OK) {
delete entry;
return;
}
BNodeInfo nodeInfo(&node);
if (nodeInfo.InitCheck() != B_OK) {
delete entry;
return;
}
char string[MAXPATHLEN];
if ((nodeInfo.GetType(string) == B_OK)
&& (strcmp(string,"application/x-vnd.Be-elfexecutable") == 0)) {
AppTypeWindow * window = new AppTypeWindow(entry);
if (window->InitCheck() == B_OK) {
fWindow = window;
fArgvOkay = true;
} else {
printf("Failed to create AppTypeWindow\n");
}
return;
}
}
FileTypeWindow * window = new FileTypeWindow(&entryList);
if (window->InitCheck() != B_OK) {
printf("Failed to create FileTypeWindow\n");
return;
}
fWindow = window;
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,NULL,NULL,B_FILE_NODE|B_DIRECTORY_NODE);
}
return fOpenPanel;
}

View File

@ -1,33 +0,0 @@
#ifndef FILE_TYPE_APP
#define FILE_TYPE_APP
#include <Application.h>
#include <FilePanel.h>
class FileTypeWindow;
class FileTypeApp
: public BApplication
{
public:
FileTypeApp();
virtual void MessageReceived(BMessage *message);
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);
BWindow * fWindow;
BFilePanel * fOpenPanel;
bool fArgvOkay;
};
extern FileTypeApp * file_type_app;
#endif // FILE_TYPE_APP

View File

@ -1,15 +0,0 @@
#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

View File

@ -1,200 +0,0 @@
#include <MenuItem.h>
#include <Message.h>
#include <Mime.h>
#include <Window.h>
#include "FileTypeView.h"
FileTypeView::FileTypeView(BRect viewFrame)
: BBox(viewFrame, "FileTypeView", B_FOLLOW_ALL,
B_FRAME_EVENTS|B_WILL_DRAW, B_PLAIN_BORDER)
{
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
const char * fileTypeLabel = "File Type";
BRect fileTypeRect(10,10,viewFrame.Width()-55,90);
fFileTypeBox = new BBox(fileTypeRect,fileTypeLabel,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP, B_WILL_DRAW);
fFileTypeBox->SetLabel(fileTypeLabel);
AddChild(fFileTypeBox);
BRect fileTypeTextControlRect(10,18,fileTypeRect.Width()-10,fileTypeRect.Height());
fFileTypeTextControl = new BTextControl(fileTypeTextControlRect,"mime",
NULL,NULL,NULL,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
fFileTypeBox->AddChild(fFileTypeTextControl);
const char * preferredAppLabel = "Preferred Application";
BRect preferredAppRect(10,95,viewFrame.Width()-55,170);
fPreferredAppBox = new BBox(preferredAppRect,preferredAppLabel,
B_FOLLOW_LEFT_RIGHT|B_FOLLOW_BOTTOM, B_WILL_DRAW);
fPreferredAppBox->SetLabel(preferredAppLabel);
AddChild(fPreferredAppBox);
fPreferredAppMenu = new BMenu("app");
fPreferredAppMenuItemNone = new BMenuItem("None",NULL);
fPreferredAppMenu->AddItem(fPreferredAppMenuItemNone);
fPreferredAppMenu->AddSeparatorItem();
fPreferredAppMenu->SetRadioMode(true);
fPreferredAppMenu->SetLabelFromMarked(true);
fPreferredAppMenuItemNone->SetMarked(true);
BRect preferredAppMenuFieldRect(10,15,preferredAppRect.Width()-10,
preferredAppRect.Height());
fPreferredAppMenuField = new BMenuField(preferredAppMenuFieldRect,
"appField",NULL,fPreferredAppMenu);
fPreferredAppBox->AddChild(fPreferredAppMenuField);
}
FileTypeView::~FileTypeView()
{
}
class BAppMenuItem : public BMenuItem {
private:
const char * fMimestr;
BAppMenuItem(const char * label)
: BMenuItem(label,NULL) {
fMimestr = 0;
}
void SetMime(const char * mimestr) {
fMimestr = mimestr;
}
~BAppMenuItem() {
if (fMimestr != Label()) {
delete fMimestr;
}
}
public:
const char * Mime() {
return fMimestr;
}
static BAppMenuItem * CreateItemForMime(const char * mimestr) {
BMimeType mime(mimestr);
entry_ref ref;
const char * label = mimestr;
if (mime.InitCheck() == B_OK) {
if (mime.GetAppHint(&ref) == B_OK) {
label = ref.name;
}
}
BAppMenuItem * item = new BAppMenuItem(label);
item->SetMime(strdup(mimestr));
return item;
}
};
void
FileTypeView::SetFileType(const char * fileType)
{
bool fast = (fFileType.Compare(fileType) == 0);
fFileType.SetTo(fileType);
fFileTypeTextControl->SetText(fileType);
if (fast)
return;
BWindow * window = Window();
if (window) {
window->DisableUpdates();
}
for (int i = fPreferredAppMenu->CountItems() ; (i > 1) ; i--) {
BMenuItem * item = fPreferredAppMenu->ItemAt(i);
fPreferredAppMenu->RemoveItem(i);
delete item;
}
BMimeType mime(fileType);
BMessage applications;
if (mime.InitCheck() == B_OK) {
if (mime.GetSupportingApps(&applications) != B_OK) {
BMimeType super;
if (mime.GetSupertype(&super) == B_OK) {
if (super.GetSupportingApps(&applications) != B_OK) {
applications.MakeEmpty();
}
}
}
}
int32 subs = 0;
if (applications.FindInt32("be:sub", &subs) != B_OK) {
subs = 0;
}
int32 supers = 0;
if (applications.FindInt32("be:super", &supers) != B_OK) {
supers = 0;
}
bool separator = false;
for (int i = 0 ; (i < subs+supers) ; i++) {
const char * str;
if (applications.FindString("applications", i, &str) == B_OK) {
if (i < subs) {
separator = true;
} else if (separator) {
fPreferredAppMenu->AddSeparatorItem();
separator = false;
}
fPreferredAppMenu->AddItem(BAppMenuItem::CreateItemForMime(str));
}
}
if (window) {
window->EnableUpdates();
}
}
void
FileTypeView::SetPreferredApplication(const char * preferredApplication)
{
fPreferredApp.SetTo(preferredApplication);
if ((preferredApplication == NULL) ||
(strlen(preferredApplication) == 0)) {
fPreferredAppMenuItemNone->SetMarked(true);
} else {
for (int i = 0 ; (i < fPreferredAppMenu->CountItems()) ; i++) {
BAppMenuItem * item
= dynamic_cast<BAppMenuItem*>(fPreferredAppMenu->ItemAt(i));
if (item) {
if ((strcmp(item->Label(),preferredApplication) == 0) ||
(strcmp(item->Mime(),preferredApplication) == 0)) {
if (!item->IsMarked()) {
item->SetMarked(true);
}
return;
}
}
}
BAppMenuItem * item = BAppMenuItem::CreateItemForMime(preferredApplication);
fPreferredAppMenu->AddItem(item);
item->SetMarked(true);
}
}
bool
FileTypeView::IsClean() const
{
if (fFileType.Compare(GetFileType()) != 0) {
return false;
}
if (fPreferredApp.Compare(GetPreferredApplication()) != 0) {
return false;
}
return true;
}
const char *
FileTypeView::GetFileType() const
{
return fFileTypeTextControl->Text();
}
const char *
FileTypeView::GetPreferredApplication() const
{
BAppMenuItem * item
= dynamic_cast<BAppMenuItem*>(fPreferredAppMenu->FindMarked());
if (item == 0) {
return 0;
}
if (item == fPreferredAppMenuItemNone) {
return 0;
}
return item->Mime();
}

View File

@ -1,38 +0,0 @@
#ifndef FILE_TYPE_VIEW_H
#define FILE_TYPE_VIEW_H
#include <Box.h>
#include <Button.h>
#include <MenuField.h>
#include <String.h>
#include <TextControl.h>
#include <View.h>
class FileTypeView : public BBox {
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 fPreferredApp;
BBox * fFileTypeBox;
BTextControl * fFileTypeTextControl;
BButton * fFileTypeSelectButton;
BButton * fFileTypeSameAsButton;
BBox * fPreferredAppBox;
BMenu * fPreferredAppMenu;
BMenuItem * fPreferredAppMenuItemNone;
BMenuField * fPreferredAppMenuField;
BButton * fPreferredAppSelectButton;
BButton * fPreferredAppSameAsButton;
};
#endif // FILE_TYPE_VIEW_H

View File

@ -1,234 +0,0 @@
#include <Alert.h>
#include <Autolock.h>
#include <Debug.h>
#include <Entry.h>
#include <Node.h>
#include <NodeInfo.h>
#include "FileTypeApp.h"
#include "FileTypeView.h"
#include "FileTypeWindow.h"
FileTypeWindow::FileTypeWindow(const BList * entryList)
: BWindow(BRect(100,100,380,300),"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) {
for (int32 i = 0 ; (i < fEntryList->CountItems()) ; i++) {
delete static_cast<BEntry*>(fEntryList->ItemAt(i));
}
fEntryList->MakeEmpty();
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;
}
}
void
FileTypeWindow::Quit()
{
{
// This is in its own scope because it must be released
// before the call to BWindow::Quit()
BAutolock lock(file_type_app);
file_type_app->Quit();
}
BWindow::Quit();
}
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;
BString fileType(fView->GetFileType());
BString 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.String())) != B_OK) {
// save errors are ignored: there's usually no good way for the user to recover
}
if ((result = nodeInfo.SetPreferredApp(preferredApplication.String())) != B_OK) {
// save errors are ignored: there's usually no good way for the user to recover
}
}
}
fView->SetFileType(fileType.String());
fView->SetPreferredApplication(preferredApplication.String());
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];
switch (nodeInfo.GetType(string)) {
case B_ENTRY_NOT_FOUND:
strcpy(string,"");
case B_OK:
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
}
}
break;
default:
// errors are ignored: there's usually no good way for the user to recover
break;
}
switch (nodeInfo.GetPreferredApp(string)) {
case B_ENTRY_NOT_FOUND:
strcpy(string,"");
case B_OK:
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
}
}
break;
default:
// errors are ignored: there's usually no good way for the user to recover
break;
}
}
if (fileType != 0) {
fView->SetFileType(fileType->String());
delete fileType;
}
if ((preferredApplication != 0) && (preferredApplication->Length() > 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]";
}
}

View File

@ -1,40 +0,0 @@
#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 void Quit();
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

View File

@ -1,21 +1,12 @@
SubDir HAIKU_TOP src add-ons tracker filetype ;
AddResources FileType-F :
FileType.rdef FileType.icons.rdef FileType.version.rdef
;
Application FileType-F :
main.cpp
FileTypeApp.cpp
FileTypeView.cpp
FileTypeWindow.cpp
AppTypeWindow.cpp
AppTypeView.cpp
AppTypeAppFlagsView.cpp
AppTypeSupportedTypesView.cpp
AppTypeVersionInfoView.cpp
process_refs.cpp
;
SetSubDirSupportedPlatformsBeOSCompatible ;
LinkAgainst FileType-F : be tracker ;
AddResources FileType-F : FileType.rdef ;
Addon FileType-F : Tracker :
FileType.cpp
: false
: be tracker
;

View File

@ -1,9 +0,0 @@
#include "FileTypeApp.h"
int
main()
{
FileTypeApp fileType;
fileType.Run();
return 0;
}

View File

@ -1,9 +0,0 @@
#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);
}