* whitespace cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27857 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
#define CONNECT FPRINTF
|
#define CONNECT FPRINTF
|
||||||
#define WINDOW FPRINTF
|
#define WINDOW FPRINTF
|
||||||
|
|
||||||
// default window positioning
|
// default window positioning
|
||||||
static const float MIN_WIDTH = 400.0f;
|
static const float MIN_WIDTH = 400.0f;
|
||||||
static const float MIN_HEIGHT = 336.0f;
|
static const float MIN_HEIGHT = 336.0f;
|
||||||
static const float XPOS = 100.0f;
|
static const float XPOS = 100.0f;
|
||||||
@@ -64,27 +64,27 @@ static const float YPOS = 200.0f;
|
|||||||
#define FOURCC(a,b,c,d) ((((uint32)(d)) << 24) | (((uint32)(c)) << 16) | (((uint32)(b)) << 8) | ((uint32)(a)))
|
#define FOURCC(a,b,c,d) ((((uint32)(d)) << 24) | (((uint32)(c)) << 16) | (((uint32)(b)) << 8) | ((uint32)(a)))
|
||||||
|
|
||||||
struct riff_struct
|
struct riff_struct
|
||||||
{
|
{
|
||||||
uint32 riff_id; // 'RIFF'
|
uint32 riff_id; // 'RIFF'
|
||||||
uint32 len;
|
uint32 len;
|
||||||
uint32 wave_id; // 'WAVE'
|
uint32 wave_id; // 'WAVE'
|
||||||
};
|
};
|
||||||
|
|
||||||
struct chunk_struct
|
struct chunk_struct
|
||||||
{
|
{
|
||||||
uint32 fourcc;
|
uint32 fourcc;
|
||||||
uint32 len;
|
uint32 len;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct format_struct
|
struct format_struct
|
||||||
{
|
{
|
||||||
uint16 format_tag;
|
uint16 format_tag;
|
||||||
uint16 channels;
|
uint16 channels;
|
||||||
uint32 samples_per_sec;
|
uint32 samples_per_sec;
|
||||||
uint32 avg_bytes_per_sec;
|
uint32 avg_bytes_per_sec;
|
||||||
uint16 block_align;
|
uint16 block_align;
|
||||||
uint16 bits_per_sample;
|
uint16 bits_per_sample;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct wave_struct
|
struct wave_struct
|
||||||
@@ -97,7 +97,7 @@ struct wave_struct
|
|||||||
|
|
||||||
|
|
||||||
RecorderWindow::RecorderWindow() :
|
RecorderWindow::RecorderWindow() :
|
||||||
BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "SoundRecorder", B_TITLED_WINDOW,
|
BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "SoundRecorder", B_TITLED_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
|
||||||
fPlayer(NULL),
|
fPlayer(NULL),
|
||||||
fSoundList(NULL),
|
fSoundList(NULL),
|
||||||
@@ -122,7 +122,7 @@ RecorderWindow::RecorderWindow() :
|
|||||||
fButtonState = btnPaused;
|
fButtonState = btnPaused;
|
||||||
|
|
||||||
CalcSizes(MIN_WIDTH, MIN_HEIGHT);
|
CalcSizes(MIN_WIDTH, MIN_HEIGHT);
|
||||||
|
|
||||||
fInitCheck = InitWindow();
|
fInitCheck = InitWindow();
|
||||||
if (fInitCheck != B_OK) {
|
if (fInitCheck != B_OK) {
|
||||||
ErrorAlert("connect to media server", fInitCheck);
|
ErrorAlert("connect to media server", fInitCheck);
|
||||||
@@ -141,14 +141,14 @@ RecorderWindow::~RecorderWindow()
|
|||||||
if (fPlayer) {
|
if (fPlayer) {
|
||||||
delete fPlayer;
|
delete fPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlayTrack && fPlayFile)
|
if (fPlayTrack && fPlayFile)
|
||||||
fPlayFile->ReleaseTrack(fPlayTrack);
|
fPlayFile->ReleaseTrack(fPlayTrack);
|
||||||
if (fPlayFile)
|
if (fPlayFile)
|
||||||
delete fPlayFile;
|
delete fPlayFile;
|
||||||
fPlayTrack = NULL;
|
fPlayTrack = NULL;
|
||||||
fPlayFile = NULL;
|
fPlayFile = NULL;
|
||||||
|
|
||||||
// Clean up items in list view.
|
// Clean up items in list view.
|
||||||
if (fSoundList) {
|
if (fSoundList) {
|
||||||
fSoundList->DeselectAll();
|
fSoundList->DeselectAll();
|
||||||
@@ -200,7 +200,7 @@ RecorderWindow::InitWindow()
|
|||||||
{
|
{
|
||||||
BPopUpMenu * popup = 0;
|
BPopUpMenu * popup = 0;
|
||||||
status_t error;
|
status_t error;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Find temp directory for recorded sounds.
|
// Find temp directory for recorded sounds.
|
||||||
BPath path;
|
BPath path;
|
||||||
@@ -241,21 +241,21 @@ RecorderWindow::InitWindow()
|
|||||||
B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
B_WILL_DRAW|B_FRAME_EVENTS|B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
|
||||||
AddChild(background);
|
AddChild(background);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
r = background->Bounds();
|
r = background->Bounds();
|
||||||
r.left = 2;
|
r.left = 2;
|
||||||
r.right = r.left + 37;
|
r.right = r.left + 37;
|
||||||
r.bottom = r.top + 104;
|
r.bottom = r.top + 104;
|
||||||
fVUView = new VUView(r, B_FOLLOW_LEFT|B_FOLLOW_TOP);
|
fVUView = new VUView(r, B_FOLLOW_LEFT|B_FOLLOW_TOP);
|
||||||
background->AddChild(fVUView);
|
background->AddChild(fVUView);
|
||||||
|
|
||||||
r = background->Bounds();
|
r = background->Bounds();
|
||||||
r.left = r.left + 40;
|
r.left = r.left + 40;
|
||||||
r.bottom = r.top + 104;
|
r.bottom = r.top + 104;
|
||||||
fScopeView = new ScopeView(r, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
|
fScopeView = new ScopeView(r, B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
|
||||||
background->AddChild(fScopeView);
|
background->AddChild(fScopeView);
|
||||||
|
|
||||||
r = background->Bounds();
|
r = background->Bounds();
|
||||||
r.left = 2;
|
r.left = 2;
|
||||||
r.right -= 26;
|
r.right -= 26;
|
||||||
@@ -263,89 +263,89 @@ RecorderWindow::InitWindow()
|
|||||||
r.bottom = r.top + 30;
|
r.bottom = r.top + 30;
|
||||||
fTrackSlider = new TrackSlider(r, "trackSlider", new BMessage(POSITION_CHANGED), B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
|
fTrackSlider = new TrackSlider(r, "trackSlider", new BMessage(POSITION_CHANGED), B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP);
|
||||||
background->AddChild(fTrackSlider);
|
background->AddChild(fTrackSlider);
|
||||||
|
|
||||||
BRect buttonRect;
|
BRect buttonRect;
|
||||||
|
|
||||||
// Button for rewinding
|
// Button for rewinding
|
||||||
buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
|
buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-7, 25));
|
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-7, 25));
|
||||||
fRewindButton = new TransportButton(buttonRect, "Rewind",
|
fRewindButton = new TransportButton(buttonRect, "Rewind",
|
||||||
kSkipBackBitmapBits, kPressedSkipBackBitmapBits, kDisabledSkipBackBitmapBits,
|
kSkipBackBitmapBits, kPressedSkipBackBitmapBits, kDisabledSkipBackBitmapBits,
|
||||||
new BMessage(REWIND));
|
new BMessage(REWIND));
|
||||||
background->AddChild(fRewindButton);
|
background->AddChild(fRewindButton);
|
||||||
|
|
||||||
// Button for stopping recording or playback
|
// Button for stopping recording or playback
|
||||||
buttonRect = BRect(BPoint(0,0), kStopButtonSize);
|
buttonRect = BRect(BPoint(0,0), kStopButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-48, 25));
|
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-48, 25));
|
||||||
fStopButton = new TransportButton(buttonRect, "Stop",
|
fStopButton = new TransportButton(buttonRect, "Stop",
|
||||||
kStopButtonBitmapBits, kPressedStopButtonBitmapBits, kDisabledStopButtonBitmapBits,
|
kStopButtonBitmapBits, kPressedStopButtonBitmapBits, kDisabledStopButtonBitmapBits,
|
||||||
new BMessage(STOP));
|
new BMessage(STOP));
|
||||||
background->AddChild(fStopButton);
|
background->AddChild(fStopButton);
|
||||||
|
|
||||||
// Button for starting playback of selected sound
|
// Button for starting playback of selected sound
|
||||||
BRect playRect(BPoint(0,0), kPlayButtonSize);
|
BRect playRect(BPoint(0,0), kPlayButtonSize);
|
||||||
playRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-82, 25));
|
playRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-82, 25));
|
||||||
fPlayButton = new PlayPauseButton(playRect, "Play",
|
fPlayButton = new PlayPauseButton(playRect, "Play",
|
||||||
new BMessage(PLAY), new BMessage(PLAY_PERIOD), ' ', 0);
|
new BMessage(PLAY), new BMessage(PLAY_PERIOD), ' ', 0);
|
||||||
background->AddChild(fPlayButton);
|
background->AddChild(fPlayButton);
|
||||||
|
|
||||||
// Button for forwarding
|
// Button for forwarding
|
||||||
buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
|
buttonRect = BRect(BPoint(0,0), kSkipButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-133, 25));
|
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-133, 25));
|
||||||
fForwardButton = new TransportButton(buttonRect, "Forward",
|
fForwardButton = new TransportButton(buttonRect, "Forward",
|
||||||
kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits, kDisabledSkipForwardBitmapBits,
|
kSkipForwardBitmapBits, kPressedSkipForwardBitmapBits, kDisabledSkipForwardBitmapBits,
|
||||||
new BMessage(FORWARD));
|
new BMessage(FORWARD));
|
||||||
background->AddChild(fForwardButton);
|
background->AddChild(fForwardButton);
|
||||||
|
|
||||||
// Button to start recording (or waiting for sound)
|
// Button to start recording (or waiting for sound)
|
||||||
buttonRect = BRect(BPoint(0,0), kRecordButtonSize);
|
buttonRect = BRect(BPoint(0,0), kRecordButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-174, 25));
|
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-174, 25));
|
||||||
fRecordButton = new RecordButton(buttonRect, "Record",
|
fRecordButton = new RecordButton(buttonRect, "Record",
|
||||||
new BMessage(RECORD), new BMessage(RECORD_PERIOD));
|
new BMessage(RECORD), new BMessage(RECORD_PERIOD));
|
||||||
background->AddChild(fRecordButton);
|
background->AddChild(fRecordButton);
|
||||||
|
|
||||||
// Button for saving selected sound
|
// Button for saving selected sound
|
||||||
buttonRect = BRect(BPoint(0,0), kDiskButtonSize);
|
buttonRect = BRect(BPoint(0,0), kDiskButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-250, 21));
|
buttonRect.OffsetTo(background->Bounds().LeftBottom() - BPoint(-250, 21));
|
||||||
fSaveButton = new TransportButton(buttonRect, "Save",
|
fSaveButton = new TransportButton(buttonRect, "Save",
|
||||||
kDiskButtonBitmapsBits, kPressedDiskButtonBitmapsBits, kDisabledDiskButtonBitmapsBits, new BMessage(SAVE));
|
kDiskButtonBitmapsBits, kPressedDiskButtonBitmapsBits, kDisabledDiskButtonBitmapsBits, new BMessage(SAVE));
|
||||||
fSaveButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
fSaveButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
background->AddChild(fSaveButton);
|
background->AddChild(fSaveButton);
|
||||||
|
|
||||||
// Button Loop
|
// Button Loop
|
||||||
buttonRect = BRect(BPoint(0,0), kArrowSize);
|
buttonRect = BRect(BPoint(0,0), kArrowSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(23, 48));
|
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(23, 48));
|
||||||
fLoopButton = new DrawButton(buttonRect, "Loop",
|
fLoopButton = new DrawButton(buttonRect, "Loop",
|
||||||
kLoopArrowBits, kArrowBits, new BMessage(LOOP));
|
kLoopArrowBits, kArrowBits, new BMessage(LOOP));
|
||||||
fLoopButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
fLoopButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
fLoopButton->SetTarget(this);
|
fLoopButton->SetTarget(this);
|
||||||
background->AddChild(fLoopButton);
|
background->AddChild(fLoopButton);
|
||||||
|
|
||||||
buttonRect = BRect(BPoint(0,0), kSpeakerIconBitmapSize);
|
buttonRect = BRect(BPoint(0,0), kSpeakerIconBitmapSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(121, 17));
|
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(121, 17));
|
||||||
SpeakerView *speakerView = new SpeakerView(buttonRect, B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
SpeakerView *speakerView = new SpeakerView(buttonRect, B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
||||||
speakerView->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
speakerView->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
background->AddChild(speakerView);
|
background->AddChild(speakerView);
|
||||||
|
|
||||||
buttonRect = BRect(BPoint(0,0), BPoint(84, 19));
|
buttonRect = BRect(BPoint(0,0), BPoint(84, 19));
|
||||||
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(107, 20));
|
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(107, 20));
|
||||||
fVolumeSlider = new VolumeSlider(buttonRect, "volumeSlider", B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
fVolumeSlider = new VolumeSlider(buttonRect, "volumeSlider", B_FOLLOW_LEFT | B_FOLLOW_TOP);
|
||||||
fVolumeSlider->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
fVolumeSlider->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
background->AddChild(fVolumeSlider);
|
background->AddChild(fVolumeSlider);
|
||||||
|
|
||||||
// Button to mask/see sounds list
|
// Button to mask/see sounds list
|
||||||
buttonRect = BRect(BPoint(0,0), kUpDownButtonSize);
|
buttonRect = BRect(BPoint(0,0), kUpDownButtonSize);
|
||||||
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(21, 25));
|
buttonRect.OffsetTo(background->Bounds().RightBottom() - BPoint(21, 25));
|
||||||
fUpDownButton = new UpDownButton(buttonRect, new BMessage(VIEW_LIST));
|
fUpDownButton = new UpDownButton(buttonRect, new BMessage(VIEW_LIST));
|
||||||
fUpDownButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
fUpDownButton->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
|
||||||
background->AddChild(fUpDownButton);
|
background->AddChild(fUpDownButton);
|
||||||
|
|
||||||
r = Bounds();
|
r = Bounds();
|
||||||
r.top = background->Bounds().bottom + 1;
|
r.top = background->Bounds().bottom + 1;
|
||||||
fBottomBox = new BBox(r, "bottomBox", B_FOLLOW_ALL);
|
fBottomBox = new BBox(r, "bottomBox", B_FOLLOW_ALL);
|
||||||
fBottomBox->SetBorder(B_NO_BORDER);
|
fBottomBox->SetBorder(B_NO_BORDER);
|
||||||
AddChild(fBottomBox);
|
AddChild(fBottomBox);
|
||||||
|
|
||||||
// The actual list of recorded sounds (initially empty) sits
|
// The actual list of recorded sounds (initially empty) sits
|
||||||
// below the header with the controls.
|
// below the header with the controls.
|
||||||
r = fBottomBox->Bounds();
|
r = fBottomBox->Bounds();
|
||||||
@@ -361,7 +361,7 @@ RecorderWindow::InitWindow()
|
|||||||
BScrollView *scroller = new BScrollView("scroller", fSoundList, B_FOLLOW_ALL,
|
BScrollView *scroller = new BScrollView("scroller", fSoundList, B_FOLLOW_ALL,
|
||||||
0, false, true, B_FANCY_BORDER);
|
0, false, true, B_FANCY_BORDER);
|
||||||
fBottomBox->AddChild(scroller);
|
fBottomBox->AddChild(scroller);
|
||||||
|
|
||||||
r = fBottomBox->Bounds();
|
r = fBottomBox->Bounds();
|
||||||
r.right = r.left + 190;
|
r.right = r.left + 190;
|
||||||
r.bottom -= 25;
|
r.bottom -= 25;
|
||||||
@@ -369,7 +369,7 @@ RecorderWindow::InitWindow()
|
|||||||
r.top -= 1;
|
r.top -= 1;
|
||||||
fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||||
fFileInfoBox->SetLabel("File Info");
|
fFileInfoBox->SetLabel("File Info");
|
||||||
|
|
||||||
r = fFileInfoBox->Bounds();
|
r = fFileInfoBox->Bounds();
|
||||||
r.left = 8;
|
r.left = 8;
|
||||||
r.top = 13;
|
r.top = 13;
|
||||||
@@ -401,13 +401,13 @@ RecorderWindow::InitWindow()
|
|||||||
r.bottom = r.top + 15;
|
r.bottom = r.top + 15;
|
||||||
fDuration = new BStringView(r, "duration", "Duration:");
|
fDuration = new BStringView(r, "duration", "Duration:");
|
||||||
fFileInfoBox->AddChild(fDuration);
|
fFileInfoBox->AddChild(fDuration);
|
||||||
|
|
||||||
// Input selection lists all available physical inputs that produce
|
// Input selection lists all available physical inputs that produce
|
||||||
// buffers with B_MEDIA_RAW_AUDIO format data.
|
// buffers with B_MEDIA_RAW_AUDIO format data.
|
||||||
popup = new BPopUpMenu("Input");
|
popup = new BPopUpMenu("Input");
|
||||||
int max_input_count = 64;
|
int max_input_count = 64;
|
||||||
dormant_node_info dni[max_input_count];
|
dormant_node_info dni[max_input_count];
|
||||||
|
|
||||||
int32 real_count = max_input_count;
|
int32 real_count = max_input_count;
|
||||||
media_format output_format;
|
media_format output_format;
|
||||||
output_format.type = B_MEDIA_RAW_AUDIO;
|
output_format.type = B_MEDIA_RAW_AUDIO;
|
||||||
@@ -436,7 +436,7 @@ RecorderWindow::InitWindow()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the actual widget
|
// Create the actual widget
|
||||||
BRect frame(fBottomBox->Bounds());
|
BRect frame(fBottomBox->Bounds());
|
||||||
r = frame;
|
r = frame;
|
||||||
@@ -463,16 +463,16 @@ RecorderWindow::InitWindow()
|
|||||||
r.bottom -= 1;
|
r.bottom -= 1;
|
||||||
BStringView* lenUnits = new BStringView(r, "Seconds", "seconds");
|
BStringView* lenUnits = new BStringView(r, "Seconds", "seconds");
|
||||||
fBottomBox->AddChild(lenUnits);
|
fBottomBox->AddChild(lenUnits);
|
||||||
|
|
||||||
fBottomBox->AddChild(fFileInfoBox);
|
fBottomBox->AddChild(fFileInfoBox);
|
||||||
|
|
||||||
fBottomBox->Hide();
|
fBottomBox->Hide();
|
||||||
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
||||||
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
||||||
|
|
||||||
|
|
||||||
popup->Superitem()->SetLabel(selected_name);
|
popup->Superitem()->SetLabel(selected_name);
|
||||||
|
|
||||||
// Make sure the save panel is happy.
|
// Make sure the save panel is happy.
|
||||||
fSavePanel = new BFilePanel(B_SAVE_PANEL);
|
fSavePanel = new BFilePanel(B_SAVE_PANEL);
|
||||||
fSavePanel->SetTarget(this);
|
fSavePanel->SetTarget(this);
|
||||||
@@ -491,7 +491,7 @@ bad_mojo:
|
|||||||
if (fRecordNode) {
|
if (fRecordNode) {
|
||||||
fRecordNode->Release();
|
fRecordNode->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fPlayer;
|
delete fPlayer;
|
||||||
if (!fInputField) {
|
if (!fInputField) {
|
||||||
delete popup;
|
delete popup;
|
||||||
@@ -565,7 +565,7 @@ RecorderWindow::MessageReceived(BMessage * message)
|
|||||||
fBottomBox->Hide();
|
fBottomBox->Hide();
|
||||||
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
||||||
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UPDATE_TRACKSLIDER:
|
case UPDATE_TRACKSLIDER:
|
||||||
@@ -613,7 +613,7 @@ RecorderWindow::MessageReceived(BMessage * message)
|
|||||||
|
|
||||||
void
|
void
|
||||||
RecorderWindow::Record(BMessage * message)
|
RecorderWindow::Record(BMessage * message)
|
||||||
{
|
{
|
||||||
// User pressed Record button
|
// User pressed Record button
|
||||||
fRecording = true;
|
fRecording = true;
|
||||||
int seconds = atoi(fLengthControl->Text());
|
int seconds = atoi(fLengthControl->Text());
|
||||||
@@ -693,29 +693,29 @@ RecorderWindow::Play(BMessage * message)
|
|||||||
fPlayer->SetHasData(!fPlayer->HasData());
|
fPlayer->SetHasData(!fPlayer->HasData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetButtonState(btnPlaying);
|
SetButtonState(btnPlaying);
|
||||||
fPlayButton->SetPlaying();
|
fPlayButton->SetPlaying();
|
||||||
|
|
||||||
if (!fPlayTrack) {
|
if (!fPlayTrack) {
|
||||||
ErrorAlert("get the file to play", B_ERROR);
|
ErrorAlert("get the file to play", B_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fPlayLimit = MIN(fPlayFrames, (off_t)(fTrackSlider->RightTime()*fPlayFormat.u.raw_audio.frame_rate/1000000LL));
|
fPlayLimit = MIN(fPlayFrames, (off_t)(fTrackSlider->RightTime()*fPlayFormat.u.raw_audio.frame_rate/1000000LL));
|
||||||
fPlayTrack->SeekToTime(fTrackSlider->MainTime());
|
fPlayTrack->SeekToTime(fTrackSlider->MainTime());
|
||||||
fPlayFrame = fPlayTrack->CurrentFrame();
|
fPlayFrame = fPlayTrack->CurrentFrame();
|
||||||
|
|
||||||
// Create our internal Node which plays sound, and register it.
|
// Create our internal Node which plays sound, and register it.
|
||||||
fPlayer = new BSoundPlayer(fAudioMixerNode, &fPlayFormat.u.raw_audio, "Sound Player");
|
fPlayer = new BSoundPlayer(fAudioMixerNode, &fPlayFormat.u.raw_audio, "Sound Player");
|
||||||
status_t err = fPlayer->InitCheck();
|
status_t err = fPlayer->InitCheck();
|
||||||
if (err < B_OK) {
|
if (err < B_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fVolumeSlider->SetSoundPlayer(fPlayer);
|
fVolumeSlider->SetSoundPlayer(fPlayer);
|
||||||
fPlayer->SetCallbacks(PlayFile, NotifyPlayFile, this);
|
fPlayer->SetCallbacks(PlayFile, NotifyPlayFile, this);
|
||||||
|
|
||||||
// And get it going...
|
// And get it going...
|
||||||
fPlayer->Start();
|
fPlayer->Start();
|
||||||
fPlayer->SetHasData(true);
|
fPlayer->SetHasData(true);
|
||||||
@@ -741,14 +741,14 @@ RecorderWindow::Save(BMessage * message)
|
|||||||
if ((! pItem) || (pItem->Entry().InitCheck() != B_OK)) {
|
if ((! pItem) || (pItem->Entry().InitCheck() != B_OK)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the save panel and show it.
|
// Update the save panel and show it.
|
||||||
char filename[B_FILE_NAME_LENGTH];
|
char filename[B_FILE_NAME_LENGTH];
|
||||||
pItem->Entry().GetName(filename);
|
pItem->Entry().GetName(filename);
|
||||||
BMessage saveMsg(B_SAVE_REQUESTED);
|
BMessage saveMsg(B_SAVE_REQUESTED);
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
pItem->Entry().GetRef(&ref);
|
pItem->Entry().GetRef(&ref);
|
||||||
|
|
||||||
saveMsg.AddPointer("sound list item", pItem);
|
saveMsg.AddPointer("sound list item", pItem);
|
||||||
fSavePanel->SetSaveText(filename);
|
fSavePanel->SetSaveText(filename);
|
||||||
fSavePanel->SetMessage(&saveMsg);
|
fSavePanel->SetMessage(&saveMsg);
|
||||||
@@ -765,7 +765,7 @@ RecorderWindow::DoSave(BMessage * message)
|
|||||||
entry_ref old_ref, new_dir_ref;
|
entry_ref old_ref, new_dir_ref;
|
||||||
const char* new_name;
|
const char* new_name;
|
||||||
SoundListItem* pItem;
|
SoundListItem* pItem;
|
||||||
|
|
||||||
if ((message->FindPointer("sound list item", (void**) &pItem) == B_OK)
|
if ((message->FindPointer("sound list item", (void**) &pItem) == B_OK)
|
||||||
&& (message->FindRef("directory", &new_dir_ref) == B_OK)
|
&& (message->FindRef("directory", &new_dir_ref) == B_OK)
|
||||||
&& (message->FindString("name", &new_name) == B_OK))
|
&& (message->FindString("name", &new_name) == B_OK))
|
||||||
@@ -778,15 +778,15 @@ RecorderWindow::DoSave(BMessage * message)
|
|||||||
BDirectory newDir(&new_dir_ref);
|
BDirectory newDir(&new_dir_ref);
|
||||||
if (newDir.InitCheck() != B_OK)
|
if (newDir.InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BFile newFile;
|
BFile newFile;
|
||||||
newDir.CreateFile(new_name, &newFile);
|
newDir.CreateFile(new_name, &newFile);
|
||||||
|
|
||||||
if (newFile.InitCheck() != B_OK)
|
if (newFile.InitCheck() != B_OK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
status_t err = CopyFile(newFile, oldFile);
|
status_t err = CopyFile(newFile, oldFile);
|
||||||
|
|
||||||
if (err == B_OK) {
|
if (err == B_OK) {
|
||||||
// clean up the sound list and item
|
// clean up the sound list and item
|
||||||
if (pItem->IsTemp())
|
if (pItem->IsTemp())
|
||||||
@@ -840,7 +840,7 @@ RecorderWindow::Input(BMessage * message)
|
|||||||
if (message->FindData("node", B_RAW_TYPE, (const void **)&dni, &size)) {
|
if (message->FindData("node", B_RAW_TYPE, (const void **)&dni, &size)) {
|
||||||
return; // bad input selection message
|
return; // bad input selection message
|
||||||
}
|
}
|
||||||
|
|
||||||
media_node_id node_id;
|
media_node_id node_id;
|
||||||
status_t error = fRoster->GetInstancesFor(dni->addon, dni->flavor_id, &node_id);
|
status_t error = fRoster->GetInstancesFor(dni->addon, dni->flavor_id, &node_id);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
@@ -862,7 +862,7 @@ status_t
|
|||||||
RecorderWindow::MakeRecordConnection(const media_node & input)
|
RecorderWindow::MakeRecordConnection(const media_node & input)
|
||||||
{
|
{
|
||||||
CONNECT((stderr, "RecorderWindow::MakeRecordConnection()\n"));
|
CONNECT((stderr, "RecorderWindow::MakeRecordConnection()\n"));
|
||||||
|
|
||||||
// Find an available output for the given input node.
|
// Find an available output for the given input node.
|
||||||
int32 count = 0;
|
int32 count = 0;
|
||||||
status_t err = fRoster->GetFreeOutputsFor(input, &fAudioOutput, 1, &count, B_MEDIA_RAW_AUDIO);
|
status_t err = fRoster->GetFreeOutputsFor(input, &fAudioOutput, 1, &count, B_MEDIA_RAW_AUDIO);
|
||||||
@@ -968,7 +968,7 @@ RecorderWindow::StopRecording()
|
|||||||
BreakRecordConnection();
|
BreakRecordConnection();
|
||||||
fRecordNode->SetHooks(NULL,NULL,NULL);
|
fRecordNode->SetHooks(NULL,NULL,NULL);
|
||||||
if (fRecSize > 0) {
|
if (fRecSize > 0) {
|
||||||
|
|
||||||
wave_struct header;
|
wave_struct header;
|
||||||
header.riff.riff_id = FOURCC('R','I','F','F');
|
header.riff.riff_id = FOURCC('R','I','F','F');
|
||||||
header.riff.len = fRecSize + 36;
|
header.riff.len = fRecSize + 36;
|
||||||
@@ -985,7 +985,7 @@ RecorderWindow::StopRecording()
|
|||||||
header.data_chunk.len = fRecSize;
|
header.data_chunk.len = fRecSize;
|
||||||
fRecFile.Seek(0, SEEK_SET);
|
fRecFile.Seek(0, SEEK_SET);
|
||||||
fRecFile.Write(&header, sizeof(header));
|
fRecFile.Write(&header, sizeof(header));
|
||||||
|
|
||||||
fRecFile.SetSize(fRecSize + sizeof(header)); // We reserve space; make sure we cut off any excess at the end.
|
fRecFile.SetSize(fRecSize + sizeof(header)); // We reserve space; make sure we cut off any excess at the end.
|
||||||
AddSoundItem(fRecEntry, true);
|
AddSoundItem(fRecEntry, true);
|
||||||
}
|
}
|
||||||
@@ -1001,7 +1001,7 @@ RecorderWindow::StopRecording()
|
|||||||
fRecSize = 0;
|
fRecSize = 0;
|
||||||
SetButtonState(btnPaused);
|
SetButtonState(btnPaused);
|
||||||
fRecordButton->SetStopped();
|
fRecordButton->SetStopped();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1020,7 +1020,7 @@ RecorderWindow::StopPlaying()
|
|||||||
fPlayButton->SetStopped();
|
fPlayButton->SetStopped();
|
||||||
fTrackSlider->ResetMainTime();
|
fTrackSlider->ResetMainTime();
|
||||||
fScopeView->SetMainTime(*fTrackSlider->MainTime());
|
fScopeView->SetMainTime(*fTrackSlider->MainTime());
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1050,7 +1050,7 @@ RecorderWindow::UpdateButtons()
|
|||||||
extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format);
|
extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
RecorderWindow::UpdatePlayFile()
|
RecorderWindow::UpdatePlayFile()
|
||||||
{
|
{
|
||||||
// Get selection.
|
// Get selection.
|
||||||
@@ -1059,7 +1059,7 @@ RecorderWindow::UpdatePlayFile()
|
|||||||
if (! pItem) {
|
if (! pItem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlayTrack && fPlayFile)
|
if (fPlayTrack && fPlayFile)
|
||||||
fPlayFile->ReleaseTrack(fPlayTrack);
|
fPlayFile->ReleaseTrack(fPlayTrack);
|
||||||
if (fPlayFile)
|
if (fPlayFile)
|
||||||
@@ -1077,12 +1077,12 @@ RecorderWindow::UpdatePlayFile()
|
|||||||
delete fPlayFile;
|
delete fPlayFile;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int ix=0; ix<fPlayFile->CountTracks(); ix++) {
|
for (int ix=0; ix<fPlayFile->CountTracks(); ix++) {
|
||||||
BMediaTrack * track = fPlayFile->TrackAt(ix);
|
BMediaTrack * track = fPlayFile->TrackAt(ix);
|
||||||
fPlayFormat.type = B_MEDIA_RAW_AUDIO;
|
fPlayFormat.type = B_MEDIA_RAW_AUDIO;
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
if ((track->DecodedFormat(&fPlayFormat) == B_OK)
|
if ((track->DecodedFormat(&fPlayFormat) == B_OK)
|
||||||
#else
|
#else
|
||||||
if ((DecodedFormat__11BMediaTrackP12media_format(track, &fPlayFormat) == B_OK)
|
if ((DecodedFormat__11BMediaTrackP12media_format(track, &fPlayFormat) == B_OK)
|
||||||
#endif
|
#endif
|
||||||
@@ -1093,13 +1093,13 @@ RecorderWindow::UpdatePlayFile()
|
|||||||
if (track)
|
if (track)
|
||||||
fPlayFile->ReleaseTrack(track);
|
fPlayFile->ReleaseTrack(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fPlayTrack) {
|
if (!fPlayTrack) {
|
||||||
ErrorAlert("get the file to play", err);
|
ErrorAlert("get the file to play", err);
|
||||||
delete fPlayFile;
|
delete fPlayFile;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BString filename = "File Name: ";
|
BString filename = "File Name: ";
|
||||||
filename << ref.name;
|
filename << ref.name;
|
||||||
fFilename->SetText(filename.String());
|
fFilename->SetText(filename.String());
|
||||||
@@ -1124,22 +1124,22 @@ RecorderWindow::UpdatePlayFile()
|
|||||||
samplerate << (int)fPlayFormat.u.raw_audio.frame_rate;
|
samplerate << (int)fPlayFormat.u.raw_audio.frame_rate;
|
||||||
BString durationString = "Duration: ";
|
BString durationString = "Duration: ";
|
||||||
bigtime_t duration = fPlayTrack->Duration();
|
bigtime_t duration = fPlayTrack->Duration();
|
||||||
durationString << (float)(duration / 1000000.0) << " seconds";
|
durationString << (float)(duration / 1000000.0) << " seconds";
|
||||||
|
|
||||||
fFormat->SetText(format.String());
|
fFormat->SetText(format.String());
|
||||||
fCompression->SetText(compression.String());
|
fCompression->SetText(compression.String());
|
||||||
fChannels->SetText(channels.String());
|
fChannels->SetText(channels.String());
|
||||||
fSampleSize->SetText(samplesize.String());
|
fSampleSize->SetText(samplesize.String());
|
||||||
fSampleRate->SetText(samplerate.String());
|
fSampleRate->SetText(samplerate.String());
|
||||||
fDuration->SetText(durationString.String());
|
fDuration->SetText(durationString.String());
|
||||||
|
|
||||||
fTrackSlider->SetTotalTime(duration, true);
|
fTrackSlider->SetTotalTime(duration, true);
|
||||||
fScopeView->SetMainTime(fTrackSlider->LeftTime());
|
fScopeView->SetMainTime(fTrackSlider->LeftTime());
|
||||||
fScopeView->SetTotalTime(duration);
|
fScopeView->SetTotalTime(duration);
|
||||||
fScopeView->SetRightTime(fTrackSlider->RightTime());
|
fScopeView->SetRightTime(fTrackSlider->RightTime());
|
||||||
fScopeView->SetLeftTime(fTrackSlider->LeftTime());
|
fScopeView->SetLeftTime(fTrackSlider->LeftTime());
|
||||||
fScopeView->RenderTrack(fPlayTrack, fPlayFormat);
|
fScopeView->RenderTrack(fPlayTrack, fPlayFormat);
|
||||||
|
|
||||||
fPlayFrames = fPlayTrack->CountFrames();
|
fPlayFrames = fPlayTrack->CountFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,7 +1204,7 @@ RecorderWindow::RecordFile(void * cookie, bigtime_t timestamp, void * data, size
|
|||||||
// Callback called from the SoundConsumer when receiving buffers.
|
// Callback called from the SoundConsumer when receiving buffers.
|
||||||
assert((format.format & 0x02) && format.channel_count);
|
assert((format.format & 0x02) && format.channel_count);
|
||||||
RecorderWindow * window = (RecorderWindow *)cookie;
|
RecorderWindow * window = (RecorderWindow *)cookie;
|
||||||
|
|
||||||
if (window->fRecording) {
|
if (window->fRecording) {
|
||||||
// Write the data to file (we don't buffer or guard file access
|
// Write the data to file (we don't buffer or guard file access
|
||||||
// or anything)
|
// or anything)
|
||||||
@@ -1234,12 +1234,12 @@ RecorderWindow::NotifyRecordFile(void * cookie, int32 code, ...)
|
|||||||
|
|
||||||
void
|
void
|
||||||
RecorderWindow::PlayFile(void * cookie, void * data, size_t size, const media_raw_audio_format & format)
|
RecorderWindow::PlayFile(void * cookie, void * data, size_t size, const media_raw_audio_format & format)
|
||||||
{
|
{
|
||||||
// Callback called from the SoundProducer when producing buffers.
|
// Callback called from the SoundProducer when producing buffers.
|
||||||
RecorderWindow * window = (RecorderWindow *)cookie;
|
RecorderWindow * window = (RecorderWindow *)cookie;
|
||||||
int32 frame_size = (window->fPlayFormat.u.raw_audio.format & 0xf) *
|
int32 frame_size = (window->fPlayFormat.u.raw_audio.format & 0xf) *
|
||||||
window->fPlayFormat.u.raw_audio.channel_count;
|
window->fPlayFormat.u.raw_audio.channel_count;
|
||||||
|
|
||||||
if ((window->fPlayFrame < window->fPlayLimit) || window->fLooping) {
|
if ((window->fPlayFrame < window->fPlayLimit) || window->fLooping) {
|
||||||
if (window->fPlayFrame >= window->fPlayLimit) {
|
if (window->fPlayFrame >= window->fPlayLimit) {
|
||||||
bigtime_t left = window->fTrackSlider->LeftTime();
|
bigtime_t left = window->fTrackSlider->LeftTime();
|
||||||
@@ -1269,22 +1269,22 @@ RecorderWindow::NotifyPlayFile(void * cookie, BSoundPlayer::sound_player_notific
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RecorderWindow::RefsReceived(BMessage *msg)
|
RecorderWindow::RefsReceived(BMessage *msg)
|
||||||
{
|
{
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
|
|
||||||
while (msg->FindRef("refs", i++, &ref) == B_OK) {
|
while (msg->FindRef("refs", i++, &ref) == B_OK) {
|
||||||
|
|
||||||
BEntry entry(&ref, true);
|
BEntry entry(&ref, true);
|
||||||
BPath path(&entry);
|
BPath path(&entry);
|
||||||
BNode node(&entry);
|
BNode node(&entry);
|
||||||
|
|
||||||
if (node.IsFile()) {
|
if (node.IsFile()) {
|
||||||
AddSoundItem(entry, false);
|
AddSoundItem(entry, false);
|
||||||
} else if(node.IsDirectory()) {
|
} else if(node.IsDirectory()) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+106
-106
@@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998-2007 Matthijs Hollemans
|
* Copyright (c) 1998-2007 Matthijs Hollemans
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
* to deal in the Software without restriction, including without limitation
|
* to deal in the Software without restriction, including without limitation
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* The above copyright notice and this permission notice shall be included in
|
* The above copyright notice and this permission notice shall be included in
|
||||||
* all copies or substantial portions of the Software.
|
* all copies or substantial portions of the Software.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
* DEALINGS IN THE SOFTWARE.
|
* DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "GrepWindow.h"
|
#include "GrepWindow.h"
|
||||||
@@ -141,7 +141,7 @@ GrepWindow::GrepWindow(BMessage* message)
|
|||||||
_LoadPrefs();
|
_LoadPrefs();
|
||||||
_TileIfMultipleWindows();
|
_TileIfMultipleWindows();
|
||||||
|
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ GrepWindow::_SetWindowTitle()
|
|||||||
|
|
||||||
if (!title.Length())
|
if (!title.Length())
|
||||||
title = APP_NAME;
|
title = APP_NAME;
|
||||||
|
|
||||||
SetTitle(title.String());
|
SetTitle(title.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,34 +419,34 @@ GrepWindow::_CreateMenus()
|
|||||||
fPreferencesMenu = new BMenu(_T("Preferences"));
|
fPreferencesMenu = new BMenu(_T("Preferences"));
|
||||||
fHistoryMenu = new BMenu(_T("History"));
|
fHistoryMenu = new BMenu(_T("History"));
|
||||||
fEncodingMenu = new BMenu(_T("Encoding"));
|
fEncodingMenu = new BMenu(_T("Encoding"));
|
||||||
|
|
||||||
fNew = new BMenuItem(
|
fNew = new BMenuItem(
|
||||||
_T("New Window"), new BMessage(MSG_NEW_WINDOW), 'N');
|
_T("New Window"), new BMessage(MSG_NEW_WINDOW), 'N');
|
||||||
|
|
||||||
fOpen = new BMenuItem(
|
fOpen = new BMenuItem(
|
||||||
_T("Set Which Files to Search"), new BMessage(MSG_OPEN_PANEL), 'F');
|
_T("Set Which Files to Search"), new BMessage(MSG_OPEN_PANEL), 'F');
|
||||||
|
|
||||||
fClose = new BMenuItem(
|
fClose = new BMenuItem(
|
||||||
_T("Close"), new BMessage(B_QUIT_REQUESTED), 'W');
|
_T("Close"), new BMessage(B_QUIT_REQUESTED), 'W');
|
||||||
|
|
||||||
fAbout = new BMenuItem(
|
fAbout = new BMenuItem(
|
||||||
_T("About"), new BMessage(B_ABOUT_REQUESTED));
|
_T("About"), new BMessage(B_ABOUT_REQUESTED));
|
||||||
|
|
||||||
fQuit = new BMenuItem(
|
fQuit = new BMenuItem(
|
||||||
_T("Quit"), new BMessage(MSG_QUIT_NOW), 'Q');
|
_T("Quit"), new BMessage(MSG_QUIT_NOW), 'Q');
|
||||||
|
|
||||||
fSearch = new BMenuItem(
|
fSearch = new BMenuItem(
|
||||||
_T("Search"), new BMessage(MSG_START_CANCEL), 'S');
|
_T("Search"), new BMessage(MSG_START_CANCEL), 'S');
|
||||||
|
|
||||||
fSelectAll = new BMenuItem(
|
fSelectAll = new BMenuItem(
|
||||||
_T("Select All"), new BMessage(MSG_SELECT_ALL), 'A');
|
_T("Select All"), new BMessage(MSG_SELECT_ALL), 'A');
|
||||||
|
|
||||||
fTrimSelection = new BMenuItem(
|
fTrimSelection = new BMenuItem(
|
||||||
_T("Trim to Selection"), new BMessage(MSG_TRIM_SELECTION), 'T');
|
_T("Trim to Selection"), new BMessage(MSG_TRIM_SELECTION), 'T');
|
||||||
|
|
||||||
fOpenSelection = new BMenuItem(
|
fOpenSelection = new BMenuItem(
|
||||||
_T("Open Selection"), new BMessage(MSG_OPEN_SELECTION), 'O');
|
_T("Open Selection"), new BMessage(MSG_OPEN_SELECTION), 'O');
|
||||||
|
|
||||||
fSelectInTracker = new BMenuItem(
|
fSelectInTracker = new BMenuItem(
|
||||||
_T("Show Files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K');
|
_T("Show Files in Tracker"), new BMessage(MSG_SELECT_IN_TRACKER), 'K');
|
||||||
|
|
||||||
@@ -477,12 +477,12 @@ GrepWindow::_CreateMenus()
|
|||||||
fShowLinesMenuitem = new BMenuItem(
|
fShowLinesMenuitem = new BMenuItem(
|
||||||
_T("Show Lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L');
|
_T("Show Lines"), new BMessage(MSG_MENU_SHOW_LINES), 'L');
|
||||||
fShowLinesMenuitem->SetMarked(true);
|
fShowLinesMenuitem->SetMarked(true);
|
||||||
|
|
||||||
fUTF8 = new BMenuItem("UTF8", new BMessage('utf8'));
|
fUTF8 = new BMenuItem("UTF8", new BMessage('utf8'));
|
||||||
fShiftJIS = new BMenuItem("ShiftJIS", new BMessage(B_SJIS_CONVERSION));
|
fShiftJIS = new BMenuItem("ShiftJIS", new BMessage(B_SJIS_CONVERSION));
|
||||||
fEUC = new BMenuItem("EUC", new BMessage(B_EUC_CONVERSION));
|
fEUC = new BMenuItem("EUC", new BMessage(B_EUC_CONVERSION));
|
||||||
fJIS = new BMenuItem("JIS", new BMessage(B_JIS_CONVERSION));
|
fJIS = new BMenuItem("JIS", new BMessage(B_JIS_CONVERSION));
|
||||||
|
|
||||||
fFileMenu->AddItem(fNew);
|
fFileMenu->AddItem(fNew);
|
||||||
fFileMenu->AddSeparatorItem();
|
fFileMenu->AddSeparatorItem();
|
||||||
fFileMenu->AddItem(fOpen);
|
fFileMenu->AddItem(fOpen);
|
||||||
@@ -491,7 +491,7 @@ GrepWindow::_CreateMenus()
|
|||||||
fFileMenu->AddItem(fAbout);
|
fFileMenu->AddItem(fAbout);
|
||||||
fFileMenu->AddSeparatorItem();
|
fFileMenu->AddSeparatorItem();
|
||||||
fFileMenu->AddItem(fQuit);
|
fFileMenu->AddItem(fQuit);
|
||||||
|
|
||||||
fActionMenu->AddItem(fSearch);
|
fActionMenu->AddItem(fSearch);
|
||||||
fActionMenu->AddSeparatorItem();
|
fActionMenu->AddSeparatorItem();
|
||||||
fActionMenu->AddItem(fSelectAll);
|
fActionMenu->AddItem(fSelectAll);
|
||||||
@@ -500,7 +500,7 @@ GrepWindow::_CreateMenus()
|
|||||||
fActionMenu->AddItem(fOpenSelection);
|
fActionMenu->AddItem(fOpenSelection);
|
||||||
fActionMenu->AddItem(fSelectInTracker);
|
fActionMenu->AddItem(fSelectInTracker);
|
||||||
fActionMenu->AddItem(fCopyText);
|
fActionMenu->AddItem(fCopyText);
|
||||||
|
|
||||||
fPreferencesMenu->AddItem(fRecurseLinks);
|
fPreferencesMenu->AddItem(fRecurseLinks);
|
||||||
fPreferencesMenu->AddItem(fRecurseDirs);
|
fPreferencesMenu->AddItem(fRecurseDirs);
|
||||||
fPreferencesMenu->AddItem(fSkipDotDirs);
|
fPreferencesMenu->AddItem(fSkipDotDirs);
|
||||||
@@ -510,7 +510,7 @@ GrepWindow::_CreateMenus()
|
|||||||
fPreferencesMenu->AddItem(fInvokePe);
|
fPreferencesMenu->AddItem(fInvokePe);
|
||||||
fPreferencesMenu->AddSeparatorItem();
|
fPreferencesMenu->AddSeparatorItem();
|
||||||
fPreferencesMenu->AddItem(fShowLinesMenuitem);
|
fPreferencesMenu->AddItem(fShowLinesMenuitem);
|
||||||
|
|
||||||
fEncodingMenu->AddItem(fUTF8);
|
fEncodingMenu->AddItem(fUTF8);
|
||||||
fEncodingMenu->AddItem(fShiftJIS);
|
fEncodingMenu->AddItem(fShiftJIS);
|
||||||
fEncodingMenu->AddItem(fEUC);
|
fEncodingMenu->AddItem(fEUC);
|
||||||
@@ -526,10 +526,10 @@ GrepWindow::_CreateMenus()
|
|||||||
fMenuBar->AddItem(fPreferencesMenu);
|
fMenuBar->AddItem(fPreferencesMenu);
|
||||||
fMenuBar->AddItem(fHistoryMenu);
|
fMenuBar->AddItem(fHistoryMenu);
|
||||||
fMenuBar->AddItem(fEncodingMenu);
|
fMenuBar->AddItem(fEncodingMenu);
|
||||||
|
|
||||||
AddChild(fMenuBar);
|
AddChild(fMenuBar);
|
||||||
SetKeyMenuBar(fMenuBar);
|
SetKeyMenuBar(fMenuBar);
|
||||||
|
|
||||||
fSearch->SetEnabled(false);
|
fSearch->SetEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,16 +537,16 @@ GrepWindow::_CreateMenus()
|
|||||||
void
|
void
|
||||||
GrepWindow::_CreateViews()
|
GrepWindow::_CreateViews()
|
||||||
{
|
{
|
||||||
// The search pattern entry field does not send a message when
|
// The search pattern entry field does not send a message when
|
||||||
// <Enter> is pressed, because the "Search/Cancel" button already
|
// <Enter> is pressed, because the "Search/Cancel" button already
|
||||||
// does this and we don't want to send the same message twice.
|
// does this and we don't want to send the same message twice.
|
||||||
|
|
||||||
fSearchText = new BTextControl(
|
fSearchText = new BTextControl(
|
||||||
BRect(0, 0, 0, 1), "SearchText", NULL, NULL, NULL,
|
BRect(0, 0, 0, 1), "SearchText", NULL, NULL, NULL,
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE);
|
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_NAVIGABLE);
|
||||||
|
|
||||||
fSearchText->TextView()->SetMaxBytes(1000);
|
fSearchText->TextView()->SetMaxBytes(1000);
|
||||||
fSearchText->ResizeToPreferred();
|
fSearchText->ResizeToPreferred();
|
||||||
// because it doesn't have a label
|
// because it doesn't have a label
|
||||||
|
|
||||||
@@ -555,23 +555,23 @@ GrepWindow::_CreateViews()
|
|||||||
fButton = new BButton(
|
fButton = new BButton(
|
||||||
BRect(0, 1, 80, 1), "Button", _T("Search"),
|
BRect(0, 1, 80, 1), "Button", _T("Search"),
|
||||||
new BMessage(MSG_START_CANCEL), B_FOLLOW_RIGHT);
|
new BMessage(MSG_START_CANCEL), B_FOLLOW_RIGHT);
|
||||||
|
|
||||||
fButton->MakeDefault(true);
|
fButton->MakeDefault(true);
|
||||||
fButton->ResizeToPreferred();
|
fButton->ResizeToPreferred();
|
||||||
fButton->SetEnabled(false);
|
fButton->SetEnabled(false);
|
||||||
|
|
||||||
fShowLinesCheckbox = new BCheckBox(
|
fShowLinesCheckbox = new BCheckBox(
|
||||||
BRect(0, 0, 1, 1), "ShowLines", _T("Show Lines"),
|
BRect(0, 0, 1, 1), "ShowLines", _T("Show Lines"),
|
||||||
new BMessage(MSG_CHECKBOX_SHOW_LINES), B_FOLLOW_LEFT);
|
new BMessage(MSG_CHECKBOX_SHOW_LINES), B_FOLLOW_LEFT);
|
||||||
|
|
||||||
fShowLinesCheckbox->SetValue(B_CONTROL_ON);
|
fShowLinesCheckbox->SetValue(B_CONTROL_ON);
|
||||||
fShowLinesCheckbox->ResizeToPreferred();
|
fShowLinesCheckbox->ResizeToPreferred();
|
||||||
|
|
||||||
fSearchResults = new GrepListView();
|
fSearchResults = new GrepListView();
|
||||||
|
|
||||||
fSearchResults->SetInvocationMessage(new BMessage(MSG_INVOKE_ITEM));
|
fSearchResults->SetInvocationMessage(new BMessage(MSG_INVOKE_ITEM));
|
||||||
fSearchResults->ResizeToPreferred();
|
fSearchResults->ResizeToPreferred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -581,13 +581,13 @@ GrepWindow::_LayoutViews()
|
|||||||
fMenuBar->GetPreferredSize(&menubarWidth, &menubarHeight);
|
fMenuBar->GetPreferredSize(&menubarWidth, &menubarHeight);
|
||||||
|
|
||||||
BBox *background = new BBox(
|
BBox *background = new BBox(
|
||||||
BRect(0, menubarHeight + 1, 2, menubarHeight + 2), B_EMPTY_STRING,
|
BRect(0, menubarHeight + 1, 2, menubarHeight + 2), B_EMPTY_STRING,
|
||||||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
|
||||||
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
|
||||||
B_PLAIN_BORDER);
|
B_PLAIN_BORDER);
|
||||||
|
|
||||||
BScrollView *scroller = new BScrollView(
|
BScrollView *scroller = new BScrollView(
|
||||||
"ScrollSearchResults", fSearchResults, B_FOLLOW_ALL_SIDES,
|
"ScrollSearchResults", fSearchResults, B_FOLLOW_ALL_SIDES,
|
||||||
B_FULL_UPDATE_ON_RESIZE, true, true, B_NO_BORDER);
|
B_FULL_UPDATE_ON_RESIZE, true, true, B_NO_BORDER);
|
||||||
|
|
||||||
scroller->ResizeToPreferred();
|
scroller->ResizeToPreferred();
|
||||||
@@ -601,7 +601,7 @@ GrepWindow::_LayoutViews()
|
|||||||
float backgroundHeight = 8 + fSearchText->Frame().Height()
|
float backgroundHeight = 8 + fSearchText->Frame().Height()
|
||||||
+ 8 + fButton->Frame().Height() + 8;
|
+ 8 + fButton->Frame().Height() + 8;
|
||||||
|
|
||||||
ResizeTo(width, height);
|
ResizeTo(width, height);
|
||||||
|
|
||||||
AddChild(background);
|
AddChild(background);
|
||||||
background->ResizeTo(width, backgroundHeight);
|
background->ResizeTo(width, backgroundHeight);
|
||||||
@@ -641,15 +641,15 @@ GrepWindow::_TileIfMultipleWindows()
|
|||||||
if (be_app->Lock()) {
|
if (be_app->Lock()) {
|
||||||
int32 windowCount = be_app->CountWindows();
|
int32 windowCount = be_app->CountWindows();
|
||||||
be_app->Unlock();
|
be_app->Unlock();
|
||||||
|
|
||||||
if (windowCount > 1)
|
if (windowCount > 1)
|
||||||
MoveBy(20,20);
|
MoveBy(20,20);
|
||||||
}
|
}
|
||||||
|
|
||||||
BScreen screen(this);
|
BScreen screen(this);
|
||||||
BRect screenFrame = screen.Frame();
|
BRect screenFrame = screen.Frame();
|
||||||
BRect windowFrame = Frame();
|
BRect windowFrame = Frame();
|
||||||
|
|
||||||
if (windowFrame.left > screenFrame.right
|
if (windowFrame.left > screenFrame.right
|
||||||
|| windowFrame.top > screenFrame.bottom
|
|| windowFrame.top > screenFrame.bottom
|
||||||
|| windowFrame.right < screenFrame.left
|
|| windowFrame.right < screenFrame.left
|
||||||
@@ -788,16 +788,16 @@ GrepWindow::_OnStartCancel()
|
|||||||
fPreferencesMenu->SetEnabled(false);
|
fPreferencesMenu->SetEnabled(false);
|
||||||
fHistoryMenu->SetEnabled(false);
|
fHistoryMenu->SetEnabled(false);
|
||||||
fEncodingMenu->SetEnabled(false);
|
fEncodingMenu->SetEnabled(false);
|
||||||
|
|
||||||
fSearchText->SetEnabled(false);
|
fSearchText->SetEnabled(false);
|
||||||
|
|
||||||
fButton->MakeFocus(true);
|
fButton->MakeFocus(true);
|
||||||
fButton->SetLabel(_T("Cancel"));
|
fButton->SetLabel(_T("Cancel"));
|
||||||
fSearch->SetEnabled(false);
|
fSearch->SetEnabled(false);
|
||||||
|
|
||||||
// We need to remember the search pattern, because during
|
// We need to remember the search pattern, because during
|
||||||
// the grepping, the text control's text will be replaced
|
// the grepping, the text control's text will be replaced
|
||||||
// by the name of the file that's currently being grepped.
|
// by the name of the file that's currently being grepped.
|
||||||
// When the grepping finishes, we need to restore the old
|
// When the grepping finishes, we need to restore the old
|
||||||
// search pattern.
|
// search pattern.
|
||||||
|
|
||||||
@@ -1102,7 +1102,7 @@ GrepWindow::_OnRecurseDirs()
|
|||||||
_ModelChanged();
|
_ModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GrepWindow::_OnSkipDotDirs()
|
GrepWindow::_OnSkipDotDirs()
|
||||||
{
|
{
|
||||||
@@ -1120,7 +1120,7 @@ GrepWindow::_OnEscapeText()
|
|||||||
_ModelChanged();
|
_ModelChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GrepWindow::_OnCaseSensitive()
|
GrepWindow::_OnCaseSensitive()
|
||||||
{
|
{
|
||||||
@@ -1154,30 +1154,30 @@ GrepWindow::_OnCheckboxShowLines()
|
|||||||
// toggle checkbox and menuitem
|
// toggle checkbox and menuitem
|
||||||
fModel->fShowContents = !fModel->fShowContents;
|
fModel->fShowContents = !fModel->fShowContents;
|
||||||
fShowLinesMenuitem->SetMarked(!fShowLinesMenuitem->IsMarked());
|
fShowLinesMenuitem->SetMarked(!fShowLinesMenuitem->IsMarked());
|
||||||
|
|
||||||
// Selection in BOutlineListView in multiple selection mode
|
// Selection in BOutlineListView in multiple selection mode
|
||||||
// gets weird when collapsing. I've tried all sorts of things.
|
// gets weird when collapsing. I've tried all sorts of things.
|
||||||
// It seems impossible to make it behave just right.
|
// It seems impossible to make it behave just right.
|
||||||
|
|
||||||
// Going from collapsed to expande mode, the superitems
|
// Going from collapsed to expande mode, the superitems
|
||||||
// keep their selection, the subitems don't (yet) have
|
// keep their selection, the subitems don't (yet) have
|
||||||
// a selection. This works as expected, AFAIK.
|
// a selection. This works as expected, AFAIK.
|
||||||
|
|
||||||
// Going from expanded to collapsed mode, I would like
|
// Going from expanded to collapsed mode, I would like
|
||||||
// for a selected subitem (line) to select its superitem,
|
// for a selected subitem (line) to select its superitem,
|
||||||
// (its file) and the subitem be unselected.
|
// (its file) and the subitem be unselected.
|
||||||
|
|
||||||
// I've successfully tried code patches that apply the
|
// I've successfully tried code patches that apply the
|
||||||
// selection pattern that I want, but with weird effects
|
// selection pattern that I want, but with weird effects
|
||||||
// on subsequent manual selection.
|
// on subsequent manual selection.
|
||||||
// Lines stay selected while the user tries to select
|
// Lines stay selected while the user tries to select
|
||||||
// some other line. It just gets weird.
|
// some other line. It just gets weird.
|
||||||
|
|
||||||
// It's as though listItem->Select() and Deselect()
|
// It's as though listItem->Select() and Deselect()
|
||||||
// put the items in some semi-selected state.
|
// put the items in some semi-selected state.
|
||||||
// Or maybe I've got it all wrong.
|
// Or maybe I've got it all wrong.
|
||||||
|
|
||||||
// So, here's the plain basic collapse/expand.
|
// So, here's the plain basic collapse/expand.
|
||||||
// I think it's the least bad of what's possible on BeOS R5,
|
// I think it's the least bad of what's possible on BeOS R5,
|
||||||
// but perhaps someone comes along with a patch of magic.
|
// but perhaps someone comes along with a patch of magic.
|
||||||
|
|
||||||
@@ -1214,7 +1214,7 @@ void
|
|||||||
GrepWindow::_OnInvokeItem()
|
GrepWindow::_OnInvokeItem()
|
||||||
{
|
{
|
||||||
for (int32 selectionIndex = 0; ; selectionIndex++) {
|
for (int32 selectionIndex = 0; ; selectionIndex++) {
|
||||||
int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex);
|
int32 itemIndex = fSearchResults->CurrentSelection(selectionIndex);
|
||||||
BListItem* item = fSearchResults->ItemAt(itemIndex);
|
BListItem* item = fSearchResults->ItemAt(itemIndex);
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
@@ -1298,7 +1298,7 @@ GrepWindow::_OnTrimSelection()
|
|||||||
fSearchResults->ItemAt(index));
|
fSearchResults->ItemAt(index));
|
||||||
if (item == NULL)
|
if (item == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!item->IsSelected() || item->OutlineLevel() != 0)
|
if (!item->IsSelected() || item->OutlineLevel() != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -1327,7 +1327,7 @@ void
|
|||||||
GrepWindow::_OnCopyText()
|
GrepWindow::_OnCopyText()
|
||||||
{
|
{
|
||||||
bool onlyCopySelection = true;
|
bool onlyCopySelection = true;
|
||||||
|
|
||||||
if (fSearchResults->CurrentSelection() < 0)
|
if (fSearchResults->CurrentSelection() < 0)
|
||||||
onlyCopySelection = false;
|
onlyCopySelection = false;
|
||||||
|
|
||||||
@@ -1352,11 +1352,11 @@ GrepWindow::_OnCopyText()
|
|||||||
|
|
||||||
if (be_clipboard->Lock()) {
|
if (be_clipboard->Lock()) {
|
||||||
be_clipboard->Clear();
|
be_clipboard->Clear();
|
||||||
|
|
||||||
clip = be_clipboard->Data();
|
clip = be_clipboard->Data();
|
||||||
|
|
||||||
clip->AddData("text/plain", B_MIME_TYPE, buffer.String(),
|
clip->AddData("text/plain", B_MIME_TYPE, buffer.String(),
|
||||||
buffer.Length());
|
buffer.Length());
|
||||||
|
|
||||||
status = be_clipboard->Commit();
|
status = be_clipboard->Commit();
|
||||||
|
|
||||||
@@ -1408,7 +1408,7 @@ GrepWindow::_OnSelectInTracker()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
message.AddRef("refs", &file_ref);
|
message.AddRef("refs", &file_ref);
|
||||||
|
|
||||||
// add parent folder to list of folders to open
|
// add parent folder to list of folders to open
|
||||||
folderPath.SetTo(filePath.String());
|
folderPath.SetTo(filePath.String());
|
||||||
if (folderPath.GetParent(&folderPath) == B_OK) {
|
if (folderPath.GetParent(&folderPath) == B_OK) {
|
||||||
@@ -1434,7 +1434,7 @@ GrepWindow::_OnSelectInTracker()
|
|||||||
snooze(aShortWhile);
|
snooze(aShortWhile);
|
||||||
_OpenFoldersInTracker(&folderList);
|
_OpenFoldersInTracker(&folderList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_AreAllFoldersOpenInTracker(&folderList)) {
|
if (!_AreAllFoldersOpenInTracker(&folderList)) {
|
||||||
BAlert* alert = new BAlert(NULL,
|
BAlert* alert = new BAlert(NULL,
|
||||||
@@ -1448,7 +1448,7 @@ GrepWindow::_OnSelectInTracker()
|
|||||||
|
|
||||||
_SelectFilesInTracker(&folderList, &message);
|
_SelectFilesInTracker(&folderList, &message);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
// delete folderList contents
|
// delete folderList contents
|
||||||
int32 folderCount = folderList.CountItems();
|
int32 folderCount = folderList.CountItems();
|
||||||
for (int32 x = 0; x < folderCount; x++)
|
for (int32 x = 0; x < folderCount; x++)
|
||||||
@@ -1476,7 +1476,7 @@ GrepWindow::_OnAboutRequested()
|
|||||||
BString fAppVersion;
|
BString fAppVersion;
|
||||||
|
|
||||||
if (be_app->Lock()) {
|
if (be_app->Lock()) {
|
||||||
be_app->GetAppInfo(&appInfo);
|
be_app->GetAppInfo(&appInfo);
|
||||||
appFile.SetTo(&appInfo.ref, B_READ_ONLY);
|
appFile.SetTo(&appInfo.ref, B_READ_ONLY);
|
||||||
appFileInfo.SetTo(&appFile);
|
appFileInfo.SetTo(&appFile);
|
||||||
if (appFileInfo.GetVersionInfo(&vInfo, B_APP_VERSION_KIND) == B_OK)
|
if (appFileInfo.GetVersionInfo(&vInfo, B_APP_VERSION_KIND) == B_OK)
|
||||||
@@ -1484,7 +1484,7 @@ GrepWindow::_OnAboutRequested()
|
|||||||
be_app->Unlock();
|
be_app->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
BString text;
|
BString text;
|
||||||
text << APP_NAME << " " << fAppVersion << "\n";
|
text << APP_NAME << " " << fAppVersion << "\n";
|
||||||
int32 titleLength = text.Length();
|
int32 titleLength = text.Length();
|
||||||
text << _T("Get a grip on grep.") << "\n\n";
|
text << _T("Get a grip on grep.") << "\n\n";
|
||||||
@@ -1498,10 +1498,10 @@ GrepWindow::_OnAboutRequested()
|
|||||||
text << _T("Peter Hinely, Serge Fantino, Hideki Naito, Oscar Lesta, "
|
text << _T("Peter Hinely, Serge Fantino, Hideki Naito, Oscar Lesta, "
|
||||||
"Oliver Tappe, Luc Schrijvers and momoziro.");
|
"Oliver Tappe, Luc Schrijvers and momoziro.");
|
||||||
text << "\n";
|
text << "\n";
|
||||||
|
|
||||||
BAlert* alert = new BAlert("Tracker Grep", text.String(), _T("Ok"), NULL,
|
BAlert* alert = new BAlert("Tracker Grep", text.String(), _T("Ok"), NULL,
|
||||||
NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
NULL, B_WIDTH_AS_USUAL, B_INFO_ALERT);
|
||||||
|
|
||||||
BTextView* view = alert->TextView();
|
BTextView* view = alert->TextView();
|
||||||
BFont font;
|
BFont font;
|
||||||
view->SetStylable(true);
|
view->SetStylable(true);
|
||||||
@@ -1558,7 +1558,7 @@ GrepWindow::_OnOpenPanel()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(NULL, this),
|
fFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(NULL, this),
|
||||||
&path, B_FILE_NODE|B_DIRECTORY_NODE|B_SYMLINK_NODE,
|
&path, B_FILE_NODE|B_DIRECTORY_NODE|B_SYMLINK_NODE,
|
||||||
true, new BMessage(MSG_REFS_RECEIVED), NULL, true, true);
|
true, new BMessage(MSG_REFS_RECEIVED), NULL, true, true);
|
||||||
|
|
||||||
fFilePanel->Show();
|
fFilePanel->Show();
|
||||||
@@ -1660,7 +1660,7 @@ GrepWindow::_RemoveFolderListDuplicates(BList* folderList)
|
|||||||
y--;
|
y--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1669,11 +1669,11 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList)
|
|||||||
{
|
{
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
BMessage refsMsg(B_REFS_RECEIVED);
|
BMessage refsMsg(B_REFS_RECEIVED);
|
||||||
|
|
||||||
int32 folderCount = folderList->CountItems();
|
int32 folderCount = folderList->CountItems();
|
||||||
for (int32 index = 0; index < folderCount; index++) {
|
for (int32 index = 0; index < folderCount; index++) {
|
||||||
BPath* path = static_cast<BPath*>(folderList->ItemAt(index));
|
BPath* path = static_cast<BPath*>(folderList->ItemAt(index));
|
||||||
|
|
||||||
entry_ref folderRef;
|
entry_ref folderRef;
|
||||||
status = get_ref_for_path(path->Path(), &folderRef);
|
status = get_ref_for_path(path->Path(), &folderRef);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
@@ -1682,7 +1682,7 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList)
|
|||||||
status = refsMsg.AddRef("refs", &folderRef);
|
status = refsMsg.AddRef("refs", &folderRef);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = be_roster->Launch(TRACKER_SIGNATURE, &refsMsg);
|
status = be_roster->Launch(TRACKER_SIGNATURE, &refsMsg);
|
||||||
if (status != B_OK && status != B_ALREADY_RUNNING)
|
if (status != B_OK && status != B_ALREADY_RUNNING)
|
||||||
@@ -1695,7 +1695,7 @@ GrepWindow::_OpenFoldersInTracker(BList* folderList)
|
|||||||
bool
|
bool
|
||||||
GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList)
|
GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList)
|
||||||
{
|
{
|
||||||
// Compare the folders we want open in Tracker to
|
// Compare the folders we want open in Tracker to
|
||||||
// the actual Tracker windows currently open.
|
// the actual Tracker windows currently open.
|
||||||
|
|
||||||
// We build a list of open Tracker windows, and compare
|
// We build a list of open Tracker windows, and compare
|
||||||
@@ -1711,12 +1711,12 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList)
|
|||||||
BList windowList;
|
BList windowList;
|
||||||
|
|
||||||
if (!trackerMessenger.IsValid())
|
if (!trackerMessenger.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int32 count = 1; ; count++) {
|
for (int32 count = 1; ; count++) {
|
||||||
sendMessage.MakeEmpty();
|
sendMessage.MakeEmpty();
|
||||||
replyMessage.MakeEmpty();
|
replyMessage.MakeEmpty();
|
||||||
|
|
||||||
sendMessage.what = B_GET_PROPERTY;
|
sendMessage.what = B_GET_PROPERTY;
|
||||||
sendMessage.AddSpecifier("Path");
|
sendMessage.AddSpecifier("Path");
|
||||||
sendMessage.AddSpecifier("Poses");
|
sendMessage.AddSpecifier("Poses");
|
||||||
@@ -1725,7 +1725,7 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList)
|
|||||||
status = trackerMessenger.SendMessage(&sendMessage, &replyMessage);
|
status = trackerMessenger.SendMessage(&sendMessage, &replyMessage);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
entry_ref* trackerRef = new (nothrow) entry_ref;
|
entry_ref* trackerRef = new (nothrow) entry_ref;
|
||||||
status = replyMessage.FindRef("result", trackerRef);
|
status = replyMessage.FindRef("result", trackerRef);
|
||||||
if (status != B_OK || !windowList.AddItem(trackerRef)) {
|
if (status != B_OK || !windowList.AddItem(trackerRef)) {
|
||||||
@@ -1752,18 +1752,18 @@ GrepWindow::_AreAllFoldersOpenInTracker(BList *folderList)
|
|||||||
// Loop over the two lists and see if all folders exist as window
|
// Loop over the two lists and see if all folders exist as window
|
||||||
for (int32 x = 0; x < folderCount; x++) {
|
for (int32 x = 0; x < folderCount; x++) {
|
||||||
for (int32 y = 0; y < windowCount; y++) {
|
for (int32 y = 0; y < windowCount; y++) {
|
||||||
|
|
||||||
folderPath = static_cast<BPath*>(folderList->ItemAt(x));
|
folderPath = static_cast<BPath*>(folderList->ItemAt(x));
|
||||||
windowRef = static_cast<entry_ref*>(windowList.ItemAt(y));
|
windowRef = static_cast<entry_ref*>(windowList.ItemAt(y));
|
||||||
|
|
||||||
if (folderPath == NULL)
|
if (folderPath == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (windowRef == NULL)
|
if (windowRef == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
folderString = folderPath->Path();
|
folderString = folderPath->Path();
|
||||||
|
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
BPath path;
|
BPath path;
|
||||||
|
|
||||||
@@ -1803,16 +1803,16 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage)
|
|||||||
BMessage windowReplyMessage;
|
BMessage windowReplyMessage;
|
||||||
BMessage selectionSendMessage;
|
BMessage selectionSendMessage;
|
||||||
BMessage selectionReplyMessage;
|
BMessage selectionReplyMessage;
|
||||||
|
|
||||||
if (!trackerMessenger.IsValid())
|
if (!trackerMessenger.IsValid())
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
// loop over Tracker windows
|
// loop over Tracker windows
|
||||||
for (int32 windowCount = 1; ; windowCount++) {
|
for (int32 windowCount = 1; ; windowCount++) {
|
||||||
|
|
||||||
windowSendMessage.MakeEmpty();
|
windowSendMessage.MakeEmpty();
|
||||||
windowReplyMessage.MakeEmpty();
|
windowReplyMessage.MakeEmpty();
|
||||||
|
|
||||||
windowSendMessage.what = B_GET_PROPERTY;
|
windowSendMessage.what = B_GET_PROPERTY;
|
||||||
windowSendMessage.AddSpecifier("Path");
|
windowSendMessage.AddSpecifier("Path");
|
||||||
windowSendMessage.AddSpecifier("Poses");
|
windowSendMessage.AddSpecifier("Poses");
|
||||||
@@ -1861,7 +1861,7 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage)
|
|||||||
selectionSendMessage.MakeEmpty();
|
selectionSendMessage.MakeEmpty();
|
||||||
selectionSendMessage.what = B_SET_PROPERTY;
|
selectionSendMessage.what = B_SET_PROPERTY;
|
||||||
selectionReplyMessage.MakeEmpty();
|
selectionReplyMessage.MakeEmpty();
|
||||||
|
|
||||||
// loop over refs and add to message
|
// loop over refs and add to message
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
for (int32 index = 0; ; index++) {
|
for (int32 index = 0; ; index++) {
|
||||||
@@ -1877,11 +1877,11 @@ GrepWindow::_SelectFilesInTracker(BList* folderList, BMessage* refsMessage)
|
|||||||
|
|
||||||
// finish selection message
|
// finish selection message
|
||||||
selectionSendMessage.AddSpecifier("Selection");
|
selectionSendMessage.AddSpecifier("Selection");
|
||||||
selectionSendMessage.AddSpecifier("Poses");
|
selectionSendMessage.AddSpecifier("Poses");
|
||||||
selectionSendMessage.AddSpecifier("Window", windowCount);
|
selectionSendMessage.AddSpecifier("Window", windowCount);
|
||||||
|
|
||||||
trackerMessenger.SendMessage(&selectionSendMessage,
|
trackerMessenger.SendMessage(&selectionSendMessage,
|
||||||
&selectionReplyMessage);
|
&selectionReplyMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ class TrackingView : public BControl {
|
|||||||
bool fMouseInView;
|
bool fMouseInView;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AttributeView : public BView {
|
class AttributeView : public BView {
|
||||||
public:
|
public:
|
||||||
AttributeView(BRect, Model *);
|
AttributeView(BRect, Model *);
|
||||||
~AttributeView();
|
~AttributeView();
|
||||||
@@ -229,7 +229,7 @@ OpenParentAndSelectOriginal(const entry_ref *ref)
|
|||||||
BEntry entry(ref);
|
BEntry entry(ref);
|
||||||
node_ref node;
|
node_ref node;
|
||||||
entry.GetNodeRef(&node);
|
entry.GetNodeRef(&node);
|
||||||
|
|
||||||
BEntry parent;
|
BEntry parent;
|
||||||
entry.GetParent(&parent);
|
entry.GetParent(&parent);
|
||||||
entry_ref parentRef;
|
entry_ref parentRef;
|
||||||
@@ -238,7 +238,7 @@ OpenParentAndSelectOriginal(const entry_ref *ref)
|
|||||||
BMessage message(B_REFS_RECEIVED);
|
BMessage message(B_REFS_RECEIVED);
|
||||||
message.AddRef("refs", &parentRef);
|
message.AddRef("refs", &parentRef);
|
||||||
message.AddData("nodeRefToSelect", B_RAW_TYPE, &node, sizeof(node_ref));
|
message.AddData("nodeRefToSelect", B_RAW_TYPE, &node, sizeof(node_ref));
|
||||||
|
|
||||||
be_app->PostMessage(&message);
|
be_app->PostMessage(&message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ void
|
|||||||
BInfoWindow::MessageReceived(BMessage *message)
|
BInfoWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
case kRestoreState:
|
case kRestoreState:
|
||||||
Show();
|
Show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
{
|
{
|
||||||
BMessage refsMessage(B_REFS_RECEIVED);
|
BMessage refsMessage(B_REFS_RECEIVED);
|
||||||
refsMessage.AddRef("refs", fModel->EntryRef());
|
refsMessage.AddRef("refs", fModel->EntryRef());
|
||||||
|
|
||||||
// add a messenger to the launch message that will be used to
|
// add a messenger to the launch message that will be used to
|
||||||
// dispatch scripting calls from apps to the PoseView
|
// dispatch scripting calls from apps to the PoseView
|
||||||
refsMessage.AddMessenger("TrackerViewToken", BMessenger(this));
|
refsMessage.AddMessenger("TrackerViewToken", BMessenger(this));
|
||||||
@@ -443,7 +443,7 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
BEntry entry;
|
BEntry entry;
|
||||||
if (entry.SetTo(fModel->EntryRef(), true) == B_OK) {
|
if (entry.SetTo(fModel->EntryRef(), true) == B_OK) {
|
||||||
BPath path;
|
BPath path;
|
||||||
if (entry.GetPath(&path) == B_OK)
|
if (entry.GetPath(&path) == B_OK)
|
||||||
update_mime_info(path.Path(), true, false, force ? 2 : 1);
|
update_mime_info(path.Path(), true, false, force ? 2 : 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -452,29 +452,29 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
case kRecalculateSize:
|
case kRecalculateSize:
|
||||||
{
|
{
|
||||||
fStopCalc = true;
|
fStopCalc = true;
|
||||||
|
|
||||||
// Wait until any current CalcSize thread has terminated before
|
// Wait until any current CalcSize thread has terminated before
|
||||||
// starting a new one
|
// starting a new one
|
||||||
status_t result;
|
status_t result;
|
||||||
wait_for_thread(fCalcThreadID, &result);
|
wait_for_thread(fCalcThreadID, &result);
|
||||||
|
|
||||||
// Start recalculating..
|
// Start recalculating..
|
||||||
fStopCalc = false;
|
fStopCalc = false;
|
||||||
SetSizeStr("calculating" B_UTF8_ELLIPSIS);
|
SetSizeStr("calculating" B_UTF8_ELLIPSIS);
|
||||||
fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", B_NORMAL_PRIORITY, this);
|
fCalcThreadID = spawn_thread(BInfoWindow::CalcSize, "CalcSize", B_NORMAL_PRIORITY, this);
|
||||||
resume_thread(fCalcThreadID);
|
resume_thread(fCalcThreadID);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kSetLinkTarget:
|
case kSetLinkTarget:
|
||||||
OpenFilePanel(fModel->EntryRef());
|
OpenFilePanel(fModel->EntryRef());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// An item was dropped into the window
|
// An item was dropped into the window
|
||||||
case B_SIMPLE_DATA:
|
case B_SIMPLE_DATA:
|
||||||
// If we are not a SymLink, just ignore the request
|
// If we are not a SymLink, just ignore the request
|
||||||
if (!fModel->IsSymLink())
|
if (!fModel->IsSymLink())
|
||||||
break;
|
break;
|
||||||
// supposed to fall through
|
// supposed to fall through
|
||||||
|
|
||||||
@@ -537,16 +537,16 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
AttributeStreamFileNode newNode(TargetModel()->Node());
|
AttributeStreamFileNode newNode(TargetModel()->Node());
|
||||||
newNode << memoryNode;
|
newNode << memoryNode;
|
||||||
|
|
||||||
// Start watching this again
|
// Start watching this again
|
||||||
TTracker::WatchNode(TargetModel()->NodeRef(), B_WATCH_ALL | B_WATCH_MOUNT, this);
|
TTracker::WatchNode(TargetModel()->NodeRef(), B_WATCH_ALL | B_WATCH_MOUNT, this);
|
||||||
|
|
||||||
// Tell the attribute view about this new model
|
// Tell the attribute view about this new model
|
||||||
fAttributeView->ReLinkTargetModel(TargetModel());
|
fAttributeView->ReLinkTargetModel(TargetModel());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_CANCEL:
|
case B_CANCEL:
|
||||||
// File panel window has closed
|
// File panel window has closed
|
||||||
delete fFilePanel;
|
delete fFilePanel;
|
||||||
fFilePanel = NULL;
|
fFilePanel = NULL;
|
||||||
@@ -572,7 +572,7 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kEmptyTrash:
|
case kEmptyTrash:
|
||||||
FSEmptyTrash();
|
FSEmptyTrash();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -584,14 +584,14 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
message->FindInt32("device", &itemNode.device);
|
message->FindInt32("device", &itemNode.device);
|
||||||
message->FindInt64("node", &itemNode.node);
|
message->FindInt64("node", &itemNode.node);
|
||||||
// our window itself may be deleted
|
// our window itself may be deleted
|
||||||
if (*TargetModel()->NodeRef() == itemNode)
|
if (*TargetModel()->NodeRef() == itemNode)
|
||||||
Close();
|
Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_ENTRY_MOVED:
|
case B_ENTRY_MOVED:
|
||||||
case B_STAT_CHANGED:
|
case B_STAT_CHANGED:
|
||||||
case B_ATTR_CHANGED:
|
case B_ATTR_CHANGED:
|
||||||
fAttributeView->ModelChanged(TargetModel(), message);
|
fAttributeView->ModelChanged(TargetModel(), message);
|
||||||
// must be called before the FilePermissionView::ModelChanged()
|
// must be called before the FilePermissionView::ModelChanged()
|
||||||
// call, because it changes the model... (bad style!)
|
// call, because it changes the model... (bad style!)
|
||||||
@@ -613,7 +613,7 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -623,7 +623,7 @@ BInfoWindow::MessageReceived(BMessage *message)
|
|||||||
// Only true on first call.
|
// Only true on first call.
|
||||||
fPermissionsView = new FilePermissionsView(BRect(kBorderWidth + 1,
|
fPermissionsView = new FilePermissionsView(BRect(kBorderWidth + 1,
|
||||||
fAttributeView->Bounds().bottom, fAttributeView->Bounds().right,
|
fAttributeView->Bounds().bottom, fAttributeView->Bounds().right,
|
||||||
fAttributeView->Bounds().bottom+80), fModel);
|
fAttributeView->Bounds().bottom+80), fModel);
|
||||||
|
|
||||||
ResizeBy(0, fPermissionsView->Bounds().Height());
|
ResizeBy(0, fPermissionsView->Bounds().Height());
|
||||||
fAttributeView->AddChild(fPermissionsView);
|
fAttributeView->AddChild(fPermissionsView);
|
||||||
@@ -661,7 +661,7 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
|
|||||||
charsTillComma = 3;
|
charsTillComma = 3;
|
||||||
|
|
||||||
uint32 numberIndex = 0;
|
uint32 numberIndex = 0;
|
||||||
|
|
||||||
while (numStr[numberIndex]) {
|
while (numStr[numberIndex]) {
|
||||||
bytes += numStr[numberIndex++];
|
bytes += numStr[numberIndex++];
|
||||||
if (--charsTillComma == 0 && numStr[numberIndex]) {
|
if (--charsTillComma == 0 && numStr[numberIndex]) {
|
||||||
@@ -671,8 +671,8 @@ BInfoWindow::GetSizeString(BString &result, off_t size, int32 fileCount)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
bytes = numStr;
|
bytes = numStr;
|
||||||
|
|
||||||
if (size >= kGBSize)
|
if (size >= kGBSize)
|
||||||
PrintFloat(result, (float)size / kGBSize) << " GB";
|
PrintFloat(result, (float)size / kGBSize) << " GB";
|
||||||
else if (size >= kMBSize)
|
else if (size >= kMBSize)
|
||||||
PrintFloat(result, (float)size / kMBSize) << " MB";
|
PrintFloat(result, (float)size / kMBSize) << " MB";
|
||||||
@@ -700,7 +700,7 @@ BInfoWindow::CalcSize(void *castToWindow)
|
|||||||
BInfoWindow *window = static_cast<BInfoWindow *>(castToWindow);
|
BInfoWindow *window = static_cast<BInfoWindow *>(castToWindow);
|
||||||
BDirectory dir(window->TargetModel()->EntryRef());
|
BDirectory dir(window->TargetModel()->EntryRef());
|
||||||
BDirectory trashDir;
|
BDirectory trashDir;
|
||||||
FSGetTrashDir(&trashDir, window->TargetModel()->EntryRef()->device);
|
FSGetTrashDir(&trashDir, window->TargetModel()->EntryRef()->device);
|
||||||
if (dir.InitCheck() != B_OK) {
|
if (dir.InitCheck() != B_OK) {
|
||||||
if (window->StopCalc())
|
if (window->StopCalc())
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -749,13 +749,13 @@ BInfoWindow::CalcSize(void *castToWindow)
|
|||||||
|
|
||||||
BDirectory trashDir;
|
BDirectory trashDir;
|
||||||
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
|
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
|
||||||
FSRecursiveCalcSize(window, &trashDir, ¤tSize,
|
FSRecursiveCalcSize(window, &trashDir, ¤tSize,
|
||||||
¤tFileCount, ¤tDirCount);
|
¤tFileCount, ¤tDirCount);
|
||||||
totalSize += currentSize;
|
totalSize += currentSize;
|
||||||
totalFileCount += currentFileCount;
|
totalFileCount += currentFileCount;
|
||||||
totalDirCount += currentDirCount;
|
totalDirCount += currentDirCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetSizeString(sizeString, totalSize, totalFileCount);
|
GetSizeString(sizeString, totalSize, totalFileCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,7 +764,7 @@ BInfoWindow::CalcSize(void *castToWindow)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
AutoLock<BWindow> lock(window);
|
AutoLock<BWindow> lock(window);
|
||||||
if (lock.IsLocked())
|
if (lock.IsLocked())
|
||||||
window->SetSizeStr(sizeString.String());
|
window->SetSizeStr(sizeString.String());
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -850,7 +850,7 @@ AttributeView::AttributeView(BRect rect, Model *model)
|
|||||||
// The title rect
|
// The title rect
|
||||||
// The magic numbers are used to properly calculate the rect so that
|
// The magic numbers are used to properly calculate the rect so that
|
||||||
// when the editing text view is displayed, the position of the text
|
// when the editing text view is displayed, the position of the text
|
||||||
// does not change.
|
// does not change.
|
||||||
BFont currentFont;
|
BFont currentFont;
|
||||||
font_height fontMetrics;
|
font_height fontMetrics;
|
||||||
GetFont(¤tFont);
|
GetFont(¤tFont);
|
||||||
@@ -931,7 +931,7 @@ AttributeView::AttributeView(BRect rect, Model *model)
|
|||||||
|
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
result = new BMenuItem(signature, itemMessage);
|
result = new BMenuItem(signature, itemMessage);
|
||||||
else
|
else
|
||||||
result = new BMenuItem(entry.name, itemMessage);
|
result = new BMenuItem(entry.name, itemMessage);
|
||||||
|
|
||||||
result->SetTarget(this);
|
result->SetTarget(this);
|
||||||
@@ -981,7 +981,7 @@ AttributeView::~AttributeView()
|
|||||||
if (fModel->IsSymLink() && fIconModel != fModel)
|
if (fModel->IsSymLink() && fIconModel != fModel)
|
||||||
delete fIconModel;
|
delete fIconModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeView::InitStrings(const Model *model)
|
AttributeView::InitStrings(const Model *model)
|
||||||
@@ -1019,7 +1019,7 @@ AttributeView::InitStrings(const Model *model)
|
|||||||
BEntry entry(traversedPath.Path(), false); // look at the target itself
|
BEntry entry(traversedPath.Path(), false); // look at the target itself
|
||||||
if (entry.InitCheck() == B_OK && entry.Exists())
|
if (entry.InitCheck() == B_OK && entry.Exists())
|
||||||
linked = true;
|
linked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// always show the target as it is: absolute or relative!
|
// always show the target as it is: absolute or relative!
|
||||||
@@ -1109,7 +1109,7 @@ AttributeView::ModelChanged(Model *model, BMessage *message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_STAT_CHANGED:
|
case B_STAT_CHANGED:
|
||||||
if (model->OpenNode() == B_OK) {
|
if (model->OpenNode() == B_OK) {
|
||||||
WidgetAttributeText::AttrAsString(model, &fCreatedStr,
|
WidgetAttributeText::AttrAsString(model, &fCreatedStr,
|
||||||
kAttrStatCreated, B_TIME_TYPE, drawBounds.Width() - kBorderMargin, this);
|
kAttrStatCreated, B_TIME_TYPE, drawBounds.Width() - kBorderMargin, this);
|
||||||
@@ -1298,21 +1298,21 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (fTrackingState) {
|
switch (fTrackingState) {
|
||||||
case link_track:
|
case link_track:
|
||||||
if (fLinkRect.Contains(point) != fMouseDown) {
|
if (fLinkRect.Contains(point) != fMouseDown) {
|
||||||
fMouseDown = !fMouseDown;
|
fMouseDown = !fMouseDown;
|
||||||
InvertRect(fLinkRect);
|
InvertRect(fLinkRect);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case path_track:
|
case path_track:
|
||||||
if (fPathRect.Contains(point) != fMouseDown) {
|
if (fPathRect.Contains(point) != fMouseDown) {
|
||||||
fMouseDown = !fMouseDown;
|
fMouseDown = !fMouseDown;
|
||||||
InvertRect(fPathRect);
|
InvertRect(fPathRect);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case size_track:
|
case size_track:
|
||||||
if (fSizeRect.Contains(point) != fMouseDown) {
|
if (fSizeRect.Contains(point) != fMouseDown) {
|
||||||
fMouseDown = !fMouseDown;
|
fMouseDown = !fMouseDown;
|
||||||
InvertRect(fSizeRect);
|
InvertRect(fSizeRect);
|
||||||
@@ -1354,7 +1354,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message)
|
|||||||
|
|
||||||
// See if we need to truncate the string
|
// See if we need to truncate the string
|
||||||
BString nameString(fModel->Name());
|
BString nameString(fModel->Name());
|
||||||
if (view->StringWidth(fModel->Name()) > rect.Width())
|
if (view->StringWidth(fModel->Name()) > rect.Width())
|
||||||
view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5);
|
view->TruncateString(&nameString, B_TRUNCATE_END, rect.Width() - 5);
|
||||||
|
|
||||||
// Draw the label
|
// Draw the label
|
||||||
@@ -1367,7 +1367,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message)
|
|||||||
|
|
||||||
view->Sync();
|
view->Sync();
|
||||||
dragBitmap->Unlock();
|
dragBitmap->Unlock();
|
||||||
|
|
||||||
BMessage message(B_REFS_RECEIVED);
|
BMessage message(B_REFS_RECEIVED);
|
||||||
message.AddPoint("click_pt", fClickPoint);
|
message.AddPoint("click_pt", fClickPoint);
|
||||||
BPoint tmpLoc;
|
BPoint tmpLoc;
|
||||||
@@ -1452,7 +1452,7 @@ AttributeView::MouseMoved(BPoint point, uint32, const BMessage *message)
|
|||||||
void
|
void
|
||||||
AttributeView::OpenLinkSource()
|
AttributeView::OpenLinkSource()
|
||||||
{
|
{
|
||||||
OpenParentAndSelectOriginal(fModel->EntryRef());
|
OpenParentAndSelectOriginal(fModel->EntryRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1473,14 +1473,14 @@ AttributeView::OpenLinkTarget()
|
|||||||
if (entry.InitCheck() != B_OK || !entry.Exists()) {
|
if (entry.InitCheck() != B_OK || !entry.Exists()) {
|
||||||
// Open a file dialog panel to allow the user to relink.
|
// Open a file dialog panel to allow the user to relink.
|
||||||
BInfoWindow *window = dynamic_cast<BInfoWindow *>(Window());
|
BInfoWindow *window = dynamic_cast<BInfoWindow *>(Window());
|
||||||
if (window)
|
if (window)
|
||||||
window->OpenFilePanel(fModel->EntryRef());
|
window->OpenFilePanel(fModel->EntryRef());
|
||||||
} else {
|
} else {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
BPath path(&ref);
|
BPath path(&ref);
|
||||||
printf("Opening link target: %s\n", path.Path());
|
printf("Opening link target: %s\n", path.Path());
|
||||||
OpenParentAndSelectOriginal(&ref);
|
OpenParentAndSelectOriginal(&ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1520,7 +1520,7 @@ AttributeView::MouseUp(BPoint point)
|
|||||||
fMouseDown = false;
|
fMouseDown = false;
|
||||||
fDragging = false;
|
fDragging = false;
|
||||||
fTrackingState = no_track;
|
fTrackingState = no_track;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1654,7 +1654,7 @@ AttributeView::Draw(BRect)
|
|||||||
float lineHeight = 0;
|
float lineHeight = 0;
|
||||||
float lineBase = 0;
|
float lineBase = 0;
|
||||||
// Draw the main title if the user is not currently editing it
|
// Draw the main title if the user is not currently editing it
|
||||||
if (fTitleEditView == NULL) {
|
if (fTitleEditView == NULL) {
|
||||||
SetFont(be_bold_font);
|
SetFont(be_bold_font);
|
||||||
SetFontSize(kTitleFontHeight);
|
SetFontSize(kTitleFontHeight);
|
||||||
GetFont(¤tFont);
|
GetFont(¤tFont);
|
||||||
@@ -1715,7 +1715,7 @@ AttributeView::Draw(BRect)
|
|||||||
lineBase += lineHeight;
|
lineBase += lineHeight;
|
||||||
|
|
||||||
// Created
|
// Created
|
||||||
SetHighColor(kAttrTitleColor);
|
SetHighColor(kAttrTitleColor);
|
||||||
MovePenTo(BPoint(fDivider - (StringWidth("Created:")), lineBase));
|
MovePenTo(BPoint(fDivider - (StringWidth("Created:")), lineBase));
|
||||||
SetHighColor(kAttrTitleColor);
|
SetHighColor(kAttrTitleColor);
|
||||||
DrawString("Created:");
|
DrawString("Created:");
|
||||||
@@ -1759,7 +1759,7 @@ AttributeView::Draw(BRect)
|
|||||||
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
||||||
Bounds().Width() - (fDivider + kBorderMargin));
|
Bounds().Width() - (fDivider + kBorderMargin));
|
||||||
DrawString(nameString.String());
|
DrawString(nameString.String());
|
||||||
} else
|
} else
|
||||||
DrawString(fPathStr.String());
|
DrawString(fPathStr.String());
|
||||||
|
|
||||||
// Cache the position of the path
|
// Cache the position of the path
|
||||||
@@ -1781,7 +1781,7 @@ AttributeView::Draw(BRect)
|
|||||||
// Check for truncation
|
// Check for truncation
|
||||||
if (StringWidth(fLinkToStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) {
|
if (StringWidth(fLinkToStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) {
|
||||||
BString nameString(fLinkToStr.String());
|
BString nameString(fLinkToStr.String());
|
||||||
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
||||||
Bounds().Width() - (fDivider + kBorderMargin));
|
Bounds().Width() - (fDivider + kBorderMargin));
|
||||||
DrawString(nameString.String());
|
DrawString(nameString.String());
|
||||||
} else
|
} else
|
||||||
@@ -1818,10 +1818,10 @@ AttributeView::Draw(BRect)
|
|||||||
// Check for truncation
|
// Check for truncation
|
||||||
if (StringWidth(fDescStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) {
|
if (StringWidth(fDescStr.String()) > (Bounds().Width() - (fDivider + kBorderMargin))) {
|
||||||
BString nameString(fDescStr.String());
|
BString nameString(fDescStr.String());
|
||||||
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
TruncateString(&nameString, B_TRUNCATE_MIDDLE,
|
||||||
Bounds().Width() - (fDivider + kBorderMargin));
|
Bounds().Width() - (fDivider + kBorderMargin));
|
||||||
DrawString(nameString.String());
|
DrawString(nameString.String());
|
||||||
} else
|
} else
|
||||||
DrawString(fDescStr.String());
|
DrawString(fDescStr.String());
|
||||||
|
|
||||||
// Cache the position of the description field
|
// Cache the position of the description field
|
||||||
@@ -1868,9 +1868,9 @@ AttributeView::BeginEditingTitle()
|
|||||||
|
|
||||||
BScrollView *scrollView = new BScrollView("BorderView",
|
BScrollView *scrollView = new BScrollView("BorderView",
|
||||||
fTitleEditView, 0, 0, false, false, B_PLAIN_BORDER);
|
fTitleEditView, 0, 0, false, false, B_PLAIN_BORDER);
|
||||||
AddChild(scrollView);
|
AddChild(scrollView);
|
||||||
fTitleEditView->SelectAll();
|
fTitleEditView->SelectAll();
|
||||||
fTitleEditView->MakeFocus();
|
fTitleEditView->MakeFocus();
|
||||||
|
|
||||||
Window()->UpdateIfNeeded();
|
Window()->UpdateIfNeeded();
|
||||||
}
|
}
|
||||||
@@ -1925,7 +1925,7 @@ AttributeView::FinishEditingTitle(bool commit)
|
|||||||
delete scrollView;
|
delete scrollView;
|
||||||
fTitleEditView = NULL;
|
fTitleEditView = NULL;
|
||||||
|
|
||||||
if (reopen)
|
if (reopen)
|
||||||
BeginEditingTitle();
|
BeginEditingTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1995,10 +1995,10 @@ AttributeView::BuildContextMenu(BMenu *parent)
|
|||||||
navigate = entry.IsDirectory();
|
navigate = entry.IsDirectory();
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
}
|
}
|
||||||
} else if (model.IsDirectory() || model.IsVolume())
|
} else if (model.IsDirectory() || model.IsVolume())
|
||||||
navigate = true;
|
navigate = true;
|
||||||
}
|
}
|
||||||
ModelMenuItem *navigationItem = NULL;
|
ModelMenuItem *navigationItem = NULL;
|
||||||
if (navigate) {
|
if (navigate) {
|
||||||
navigationItem = new ModelMenuItem(new Model(model),
|
navigationItem = new ModelMenuItem(new Model(model),
|
||||||
new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, Window()));
|
new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, Window()));
|
||||||
@@ -2036,7 +2036,7 @@ AttributeView::BuildContextMenu(BMenu *parent)
|
|||||||
item->SetEnabled(false);
|
item->SetEnabled(false);
|
||||||
} else
|
} else
|
||||||
parent->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry)));
|
parent->AddItem(new BMenuItem("Identify", new BMessage(kIdentifyEntry)));
|
||||||
} else if (FSIsTrashDir(&entry))
|
} else if (FSIsTrashDir(&entry))
|
||||||
parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash)));
|
parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash)));
|
||||||
|
|
||||||
BMenuItem *sizeItem = NULL;
|
BMenuItem *sizeItem = NULL;
|
||||||
@@ -2087,7 +2087,7 @@ AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *fi
|
|||||||
attribView->TextView()->SetTextRect(nuRect);
|
attribView->TextView()->SetTextRect(nuRect);
|
||||||
|
|
||||||
// Make sure the cursor is in view
|
// Make sure the cursor is in view
|
||||||
attribView->TextView()->ScrollToSelection();
|
attribView->TextView()->ScrollToSelection();
|
||||||
if (message->FindInt8("byte", (int8 *)&key) != B_OK)
|
if (message->FindInt8("byte", (int8 *)&key) != B_OK)
|
||||||
return B_DISPATCH_MESSAGE;
|
return B_DISPATCH_MESSAGE;
|
||||||
|
|
||||||
@@ -2100,25 +2100,25 @@ AttributeView::TextViewFilter(BMessage *message, BHandler **, BMessageFilter *fi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t
|
off_t
|
||||||
AttributeView::LastSize() const
|
AttributeView::LastSize() const
|
||||||
{
|
{
|
||||||
return fLastSize;
|
return fLastSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeView::SetLastSize(off_t lastSize)
|
AttributeView::SetLastSize(off_t lastSize)
|
||||||
{
|
{
|
||||||
fLastSize = lastSize;
|
fLastSize = lastSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AttributeView::SetSizeStr(const char *sizeStr)
|
AttributeView::SetSizeStr(const char *sizeStr)
|
||||||
{
|
{
|
||||||
fSizeStr = sizeStr;
|
fSizeStr = sizeStr;
|
||||||
|
|
||||||
BRect bounds(Bounds());
|
BRect bounds(Bounds());
|
||||||
float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6;
|
float lineHeight = CurrentFontHeight(kAttribFontHeight) + 6;
|
||||||
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight);
|
bounds.Set(fDivider, fIconRect.bottom, bounds.right, fIconRect.bottom + lineHeight);
|
||||||
|
|||||||
Reference in New Issue
Block a user