added AppType window for when a single application is selected
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4306 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
aa4dee1bda
commit
ed9b1292f5
18
src/add-ons/tracker/filetype/AppTypeVersionInfoView.cpp
Normal file
18
src/add-ons/tracker/filetype/AppTypeVersionInfoView.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#include <AppTypeVersionInfoView.h>
|
||||||
|
|
||||||
|
AppTypeVersionInfoView::AppTypeVersionInfoView(BRect viewFrame)
|
||||||
|
: BView(viewFrame, "AppTypeVersionInfoView", B_FOLLOW_ALL,
|
||||||
|
B_FRAME_EVENTS|B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTypeVersionInfoView::~AppTypeVersionInfoView()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AppTypeVersionInfoView::IsClean() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
47
src/add-ons/tracker/filetype/AppTypeVersionInfoView.h
Normal file
47
src/add-ons/tracker/filetype/AppTypeVersionInfoView.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#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 * fVersionInfoBox;
|
||||||
|
BMenu * fVersionKindMenu;
|
||||||
|
BMenuItem * fVersionApplicationMenuItem;
|
||||||
|
BMenuItem * fVersionSystemMenuItem;
|
||||||
|
BMenuField * fVersionKindMenuField;
|
||||||
|
BStringView * fVersionStringView;
|
||||||
|
BTextControl * fVersionMajorTextControl;
|
||||||
|
BTextControl * fVersionMiddleTextControl;
|
||||||
|
BTextControl * fVersionMinorTextControl;
|
||||||
|
BMenu * fVarietyMenu;
|
||||||
|
BMenuItem * fVarietyDevelopmentMenuItem;
|
||||||
|
BMenuItem * fVarietyAlphaMenuItem;
|
||||||
|
BMenuItem * fVarietyBetaMenuItem;
|
||||||
|
BMenuItem * fVarietyGammaMenuItem;
|
||||||
|
BMenuItem * fVarietyGoldenMasterMenuItem;
|
||||||
|
BMenuItem * fVarietyFinalMenuItem;
|
||||||
|
BMenuField * fVarietyMenuField;
|
||||||
|
BStringView * fSlashStringView;
|
||||||
|
BTextControl * fInternalTextControl;
|
||||||
|
BStringView * fShortDescriptionStringView;
|
||||||
|
BTextControl * fShortDescriptionTextControl;
|
||||||
|
BStringView * fLongDescriptionStringView;
|
||||||
|
BTextView * fLongDescriptionTextView;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // APP_TYPE_VERSION_INFO_VIEW_H
|
29
src/add-ons/tracker/filetype/AppTypeView.cpp
Normal file
29
src/add-ons/tracker/filetype/AppTypeView.cpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#include <AppTypeView.h>
|
||||||
|
#include <AppTypeVersionInfoView.h>
|
||||||
|
|
||||||
|
AppTypeView::AppTypeView(BRect viewFrame)
|
||||||
|
: BView(viewFrame, "AppTypeView", B_FOLLOW_ALL,
|
||||||
|
B_FRAME_EVENTS|B_WILL_DRAW)
|
||||||
|
{
|
||||||
|
fVersionInfoView = 0;
|
||||||
|
SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
|
||||||
|
|
||||||
|
BRect versionInfoViewFrame = Bounds();
|
||||||
|
versionInfoViewFrame.top = Bounds().Height()/2;
|
||||||
|
fVersionInfoView = new AppTypeVersionInfoView(versionInfoViewFrame);
|
||||||
|
AddChild(fVersionInfoView);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppTypeView::~AppTypeView()
|
||||||
|
{
|
||||||
|
delete fVersionInfoView;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
AppTypeView::IsClean() const
|
||||||
|
{
|
||||||
|
if (!fVersionInfoView->IsClean()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
40
src/add-ons/tracker/filetype/AppTypeView.h
Normal file
40
src/add-ons/tracker/filetype/AppTypeView.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
#ifndef APP_TYPE_VIEW_H
|
||||||
|
#define APP_TYPE_VIEW_H
|
||||||
|
|
||||||
|
#include <Box.h>
|
||||||
|
#include <Button.h>
|
||||||
|
#include <MenuField.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TextControl.h>
|
||||||
|
#include <View.h>
|
||||||
|
|
||||||
|
class AppTypeVersionInfoView;
|
||||||
|
|
||||||
|
class AppTypeView : public BView {
|
||||||
|
public:
|
||||||
|
AppTypeView(BRect viewFrame);
|
||||||
|
~AppTypeView();
|
||||||
|
|
||||||
|
bool IsClean() const;
|
||||||
|
private:
|
||||||
|
|
||||||
|
BTextControl * fSignatureTextControl;
|
||||||
|
|
||||||
|
BBox * fAppFlagsBox;
|
||||||
|
BCheckBox * fAppFlagsCheckBox;
|
||||||
|
BRadioButton * fAppFlagsSingleRadioButton;
|
||||||
|
BRadioButton * fAppFlagsMultipleRadioButton;
|
||||||
|
BRadioButton * fAppFlagsExclusiveRadioButton;
|
||||||
|
BCheckBox * fAppFlagsArgvOnlyCheckBox;
|
||||||
|
BCheckBox * fAppFlagsBackOnlyCheckBox;
|
||||||
|
|
||||||
|
BBox * fSupportedTypesBox;
|
||||||
|
BListView * fSupportedTypesListView;
|
||||||
|
BScrollView * fSupportedTypesScrollView;
|
||||||
|
BButton * fSupportedTypesAddButton;
|
||||||
|
BButton * fSupportedTypesRemoveButton;
|
||||||
|
|
||||||
|
AppTypeVersionInfoView * fVersionInfoView;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // APP_TYPE_VIEW_H
|
138
src/add-ons/tracker/filetype/AppTypeWindow.cpp
Normal file
138
src/add-ons/tracker/filetype/AppTypeWindow.cpp
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
#include <Alert.h>
|
||||||
|
#include <Autolock.h>
|
||||||
|
#include <Debug.h>
|
||||||
|
#include <Entry.h>
|
||||||
|
#include <Node.h>
|
||||||
|
#include <NodeInfo.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t
|
||||||
|
AppTypeWindow::SaveRequested()
|
||||||
|
{
|
||||||
|
status_t result = B_OK;
|
||||||
|
|
||||||
|
// TODO : save new settings
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
39
src/add-ons/tracker/filetype/AppTypeWindow.h
Normal file
39
src/add-ons/tracker/filetype/AppTypeWindow.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#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
|
@ -1,7 +1,10 @@
|
|||||||
|
#include <Node.h>
|
||||||
|
#include <NodeInfo.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <Roster.h>
|
#include <Roster.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <AppTypeWindow.h>
|
||||||
#include <FileTypeApp.h>
|
#include <FileTypeApp.h>
|
||||||
#include <FileTypeConstants.h>
|
#include <FileTypeConstants.h>
|
||||||
#include <FileTypeWindow.h>
|
#include <FileTypeWindow.h>
|
||||||
@ -38,6 +41,20 @@ void FileTypeApp::DispatchMessage(BMessage * msg, BHandler * handler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypeApp::MessageReceived(BMessage *message)
|
||||||
|
{
|
||||||
|
switch(message->what) {
|
||||||
|
case B_CANCEL:
|
||||||
|
if (fWindow == 0) {
|
||||||
|
Quit();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BApplication::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FileTypeApp::RefsReceived(BMessage * message)
|
FileTypeApp::RefsReceived(BMessage * message)
|
||||||
@ -57,6 +74,28 @@ FileTypeApp::RefsReceived(BMessage * message)
|
|||||||
if (entryList.CountItems() == 0) {
|
if (entryList.CountItems() == 0) {
|
||||||
return;
|
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);
|
FileTypeWindow * window = new FileTypeWindow(&entryList);
|
||||||
if (window->InitCheck() == B_OK) {
|
if (window->InitCheck() == B_OK) {
|
||||||
fWindow = window;
|
fWindow = window;
|
||||||
|
@ -11,6 +11,7 @@ class FileTypeApp
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileTypeApp();
|
FileTypeApp();
|
||||||
|
virtual void MessageReceived(BMessage *message);
|
||||||
virtual void ArgvReceived(int32 argc, const char *argv[], const char * cwd);
|
virtual void ArgvReceived(int32 argc, const char *argv[], const char * cwd);
|
||||||
virtual void RefsReceived(BMessage *message);
|
virtual void RefsReceived(BMessage *message);
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
@ -21,7 +22,7 @@ private:
|
|||||||
BFilePanel * OpenPanel();
|
BFilePanel * OpenPanel();
|
||||||
void PrintUsage(const char * execname);
|
void PrintUsage(const char * execname);
|
||||||
|
|
||||||
FileTypeWindow * fWindow;
|
BWindow * fWindow;
|
||||||
BFilePanel * fOpenPanel;
|
BFilePanel * fOpenPanel;
|
||||||
|
|
||||||
bool fArgvOkay;
|
bool fArgvOkay;
|
||||||
|
@ -170,9 +170,10 @@ FileTypeWindow::SetEntries(const BList * entryList)
|
|||||||
continue; // can't proceed with an invalid nodeinfo
|
continue; // can't proceed with an invalid nodeinfo
|
||||||
}
|
}
|
||||||
char string[MAXPATHLEN];
|
char string[MAXPATHLEN];
|
||||||
if (nodeInfo.GetType(string) != B_OK) {
|
switch (nodeInfo.GetType(string)) {
|
||||||
// errors are ignored: there's usually no good way for the user to recover
|
case B_ENTRY_NOT_FOUND:
|
||||||
} else {
|
strcpy(string,"");
|
||||||
|
case B_OK:
|
||||||
if (fileType == 0) {
|
if (fileType == 0) {
|
||||||
fileType = new BString(string);
|
fileType = new BString(string);
|
||||||
} else if (fileType->Compare(string) != 0) {
|
} else if (fileType->Compare(string) != 0) {
|
||||||
@ -181,10 +182,15 @@ FileTypeWindow::SetEntries(const BList * entryList)
|
|||||||
break; // stop now, don't waste time checking the rest
|
break; // stop now, don't waste time checking the rest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
if (nodeInfo.GetPreferredApp(string) != B_OK) {
|
default:
|
||||||
// errors are ignored: there's usually no good way for the user to recover
|
// errors are ignored: there's usually no good way for the user to recover
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
switch (nodeInfo.GetPreferredApp(string)) {
|
||||||
|
case B_ENTRY_NOT_FOUND:
|
||||||
|
strcpy(string,"");
|
||||||
|
case B_OK:
|
||||||
if (preferredApplication == 0) {
|
if (preferredApplication == 0) {
|
||||||
preferredApplication = new BString(string);
|
preferredApplication = new BString(string);
|
||||||
} else if (preferredApplication->Compare(string) != 0) {
|
} else if (preferredApplication->Compare(string) != 0) {
|
||||||
@ -193,13 +199,17 @@ FileTypeWindow::SetEntries(const BList * entryList)
|
|||||||
break; // stop now, don't waste time checking the rest
|
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) {
|
if (fileType != 0) {
|
||||||
fView->SetFileType(fileType->String());
|
fView->SetFileType(fileType->String());
|
||||||
delete fileType;
|
delete fileType;
|
||||||
}
|
}
|
||||||
if (preferredApplication != 0) {
|
if ((preferredApplication != 0) && (preferredApplication->Length() > 0)) {
|
||||||
fView->SetPreferredApplication(preferredApplication->String());
|
fView->SetPreferredApplication(preferredApplication->String());
|
||||||
delete preferredApplication;
|
delete preferredApplication;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ App FileType-F :
|
|||||||
FileTypeApp.cpp
|
FileTypeApp.cpp
|
||||||
FileTypeView.cpp
|
FileTypeView.cpp
|
||||||
FileTypeWindow.cpp
|
FileTypeWindow.cpp
|
||||||
|
AppTypeWindow.cpp
|
||||||
|
AppTypeView.cpp
|
||||||
|
AppTypeVersionInfoView.cpp
|
||||||
process_refs.cpp
|
process_refs.cpp
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user