Changed the progress monitor protocol to path a basic message that will be sent back
instead of having a fixed message code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20746 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
#include "ConfigView.h"
|
#include "ConfigView.h"
|
||||||
#include "RAW.h"
|
#include "RAW.h"
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
#include <TranslatorRoster.h>
|
#include <TranslatorRoster.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -32,12 +33,16 @@ class FreeAllocation {
|
|||||||
void* fBuffer;
|
void* fBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct progress_data {
|
||||||
|
BMessenger monitor;
|
||||||
|
BMessage message;
|
||||||
|
};
|
||||||
|
|
||||||
// Extensions that ShowImage supports
|
// Extensions that ShowImage supports
|
||||||
const char* kDocumentCount = "/documentCount";
|
const char* kDocumentCount = "/documentCount";
|
||||||
const char* kDocumentIndex = "/documentIndex";
|
const char* kDocumentIndex = "/documentIndex";
|
||||||
const char* kProgressMonitor = "/progressMonitor";
|
const char* kProgressMonitor = "/progressMonitor";
|
||||||
|
const char* kProgressMessage = "/progressMessage";
|
||||||
const uint32 kMsgProgressMonitorUpdate = 'SIup';
|
|
||||||
|
|
||||||
// The input formats that this translator supports.
|
// The input formats that this translator supports.
|
||||||
translation_format sInputFormats[] = {
|
translation_format sInputFormats[] = {
|
||||||
@@ -158,16 +163,16 @@ RAWTranslator::DerivedIdentify(BPositionIO *stream,
|
|||||||
|
|
||||||
/*static*/ void
|
/*static*/ void
|
||||||
RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
RAWTranslator::_ProgressMonitor(const char* message, float percentage,
|
||||||
void* data)
|
void* _data)
|
||||||
{
|
{
|
||||||
BMessenger& messenger = *(BMessenger*)data;
|
progress_data& data = *(progress_data*)_data;
|
||||||
|
|
||||||
BMessage update(kMsgProgressMonitorUpdate);
|
BMessage update(data.message);
|
||||||
update.AddString("message", message);
|
update.AddString("message", message);
|
||||||
update.AddFloat("percent", percentage);
|
update.AddFloat("percent", percentage);
|
||||||
update.AddInt64("time", system_time());
|
update.AddInt64("time", system_time());
|
||||||
|
|
||||||
messenger.SendMessage(&update);
|
data.monitor.SendMessage(&update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,14 +189,19 @@ RAWTranslator::DerivedTranslate(BPositionIO* source,
|
|||||||
DCRaw raw(*source);
|
DCRaw raw(*source);
|
||||||
|
|
||||||
bool headerOnly = false;
|
bool headerOnly = false;
|
||||||
|
|
||||||
|
progress_data progressData;
|
||||||
BMessenger monitor;
|
BMessenger monitor;
|
||||||
|
|
||||||
if (settings != NULL) {
|
if (settings != NULL) {
|
||||||
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
settings->FindBool(B_TRANSLATOR_EXT_HEADER_ONLY, &headerOnly);
|
||||||
|
|
||||||
if (settings->FindMessenger(kProgressMonitor, &monitor) == B_OK) {
|
if (settings->FindMessenger(kProgressMonitor,
|
||||||
raw.SetProgressMonitor(&_ProgressMonitor, &monitor);
|
&progressData.monitor) == B_OK
|
||||||
_ProgressMonitor("Reading Image Data", 0, &monitor);
|
&& settings->FindMessage(kProgressMessage,
|
||||||
|
&progressData.message) == B_OK) {
|
||||||
|
raw.SetProgressMonitor(&_ProgressMonitor, &progressData);
|
||||||
|
_ProgressMonitor("Reading Image Data", 0, &progressData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "ProgressWindow.h"
|
#include "ProgressWindow.h"
|
||||||
|
#include "ShowImageConstants.h"
|
||||||
|
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
@@ -15,7 +16,6 @@
|
|||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgShow = 'show';
|
static const uint32 kMsgShow = 'show';
|
||||||
static const uint32 kMsgStatusUpdate = 'SIup';
|
|
||||||
|
|
||||||
|
|
||||||
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
ProgressWindow::ProgressWindow(BWindow* referenceWindow)
|
||||||
@@ -92,7 +92,7 @@ ProgressWindow::MessageReceived(BMessage *message)
|
|||||||
fRetrievedShow = true;
|
fRetrievedShow = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgStatusUpdate:
|
case kMsgProgressStatusUpdate:
|
||||||
float percent;
|
float percent;
|
||||||
if (message->FindFloat("percent", &percent) == B_OK)
|
if (message->FindFloat("percent", &percent) == B_OK)
|
||||||
fStatusBar->Update(percent - fStatusBar->CurrentValue());
|
fStatusBar->Update(percent - fStatusBar->CurrentValue());
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ enum {
|
|||||||
MSG_OPEN_RESIZER_WINDOW = 'mORS',
|
MSG_OPEN_RESIZER_WINDOW = 'mORS',
|
||||||
MSG_RESIZER_WINDOW_QUIT = 'mRSQ',
|
MSG_RESIZER_WINDOW_QUIT = 'mRSQ',
|
||||||
MSG_RESIZE = 'mRSZ',
|
MSG_RESIZE = 'mRSZ',
|
||||||
|
kMsgProgressStatusUpdate = 'SIup'
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SHOW_IMAGE_CONSTANTS_H
|
#endif // SHOW_IMAGE_CONSTANTS_H
|
||||||
|
|||||||
@@ -494,7 +494,9 @@ ShowImageView::SetImage(const entry_ref *ref)
|
|||||||
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
if (ioExtension.AddInt32("/documentIndex", fDocumentIndex) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
if (ioExtension.AddMessenger("/progressMonitor", fProgressWindow) == B_OK)
|
BMessage progress(kMsgProgressStatusUpdate);
|
||||||
|
if (ioExtension.AddMessenger("/progressMonitor", fProgressWindow) == B_OK
|
||||||
|
&& ioExtension.AddMessage("/progressMessage", &progress) == B_OK)
|
||||||
fProgressWindow->Start();
|
fProgressWindow->Start();
|
||||||
|
|
||||||
// Translate image data and create a new ShowImage window
|
// Translate image data and create a new ShowImage window
|
||||||
@@ -1228,7 +1230,7 @@ ShowImageView::SaveToFile(BDirectory* dir, const char* name, BBitmap* bitmap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
BBitmapStream stream(bitmap);
|
BBitmapStream stream(bitmap);
|
||||||
|
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
while (loop) {
|
while (loop) {
|
||||||
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
BTranslatorRoster *roster = BTranslatorRoster::Default();
|
||||||
|
|||||||
Reference in New Issue
Block a user