Now listens to file/attribute changes.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6825 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7a2702788f
commit
3ef37dbe51
@ -954,10 +954,46 @@ DataEditor::UpdateIfNeeded(bool *_updated = NULL)
|
||||
status_t
|
||||
DataEditor::ForceUpdate()
|
||||
{
|
||||
BAutolock locker(this);
|
||||
|
||||
status_t status = B_OK;
|
||||
|
||||
off_t newSize = fSize;
|
||||
if (IsAttribute()) {
|
||||
// update attribute size (we ignore the type for now)
|
||||
attr_info info;
|
||||
status = fFile.GetAttrInfo(fAttribute, &info);
|
||||
if (status != B_OK) {
|
||||
// The attribute may have just been removed before
|
||||
// it gets rewritten, so we don't do anything
|
||||
// else here (we just set the file size to 0)
|
||||
newSize = 0;
|
||||
} else
|
||||
newSize = info.size;
|
||||
} else if (!IsDevice()) {
|
||||
// update file size
|
||||
|
||||
if (fFile.GetSize(&newSize) != B_OK)
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (fSize != newSize) {
|
||||
fSize = newSize;
|
||||
|
||||
// update observers
|
||||
BMessage update;
|
||||
update.AddInt64("file_size", newSize);
|
||||
SendNotices(kMsgDataEditorParameterChange, &update);
|
||||
}
|
||||
|
||||
if (fView == NULL)
|
||||
status = SetViewOffset(fViewOffset);
|
||||
else {
|
||||
BMessage update;
|
||||
update.AddInt64("offset", fViewOffset);
|
||||
update.AddInt64("size", fViewSize);
|
||||
SendNotices(kMsgDataEditorUpdate, &update);
|
||||
}
|
||||
|
||||
if (status == B_OK)
|
||||
status = Update();
|
||||
|
@ -137,8 +137,6 @@ DataView::UpdateFromEditor(BMessage *message)
|
||||
// ToDo: copy only the relevant part
|
||||
memcpy(fData, data, fDataSize);
|
||||
|
||||
fEditor.Unlock();
|
||||
|
||||
InvalidateRange(start, end);
|
||||
|
||||
// we notify our selection listeners also if the
|
||||
@ -175,6 +173,8 @@ DataView::MessageReceived(BMessage *message)
|
||||
fData = (uint8 *)realloc(fData, fDataSize);
|
||||
UpdateScroller();
|
||||
}
|
||||
if (message->FindInt64("file_size", &offset) == B_OK)
|
||||
UpdateFromEditor();
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -122,6 +122,8 @@ class HeaderView : public BView, public BInvoker {
|
||||
uint32 BlockSize() const { return fBlockSize; }
|
||||
void SetTo(off_t position, uint32 blockSize);
|
||||
|
||||
void UpdateIcon();
|
||||
|
||||
private:
|
||||
void FormatValue(char *buffer, size_t bufferSize, off_t value);
|
||||
void UpdatePositionViews(bool all = true);
|
||||
@ -593,6 +595,13 @@ HeaderView::GetPreferredSize(float *_width, float *_height)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderView::UpdateIcon()
|
||||
{
|
||||
fIconView->UpdateIcon();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value)
|
||||
{
|
||||
@ -1721,14 +1730,32 @@ ProbeView::MessageReceived(BMessage *message)
|
||||
case B_NODE_MONITOR:
|
||||
{
|
||||
switch (message->FindInt32("opcode")) {
|
||||
case B_STAT_CHANGED:
|
||||
fEditor.ForceUpdate();
|
||||
break;
|
||||
case B_ATTR_CHANGED:
|
||||
{
|
||||
BMenuBar *bar = Window()->KeyMenuBar();
|
||||
if (bar != NULL) {
|
||||
BMenuItem *item = bar->FindItem("Attributes");
|
||||
if (item != NULL && item->Submenu() != NULL)
|
||||
UpdateAttributesMenu(item->Submenu());
|
||||
const char *name;
|
||||
if (message->FindString("attr", &name) != B_OK)
|
||||
break;
|
||||
|
||||
if (fEditor.IsAttribute()) {
|
||||
if (!strcmp(name, fEditor.Attribute()))
|
||||
fEditor.ForceUpdate();
|
||||
} else {
|
||||
BMenuBar *bar = Window()->KeyMenuBar();
|
||||
if (bar != NULL) {
|
||||
BMenuItem *item = bar->FindItem("Attributes");
|
||||
if (item != NULL && item->Submenu() != NULL)
|
||||
UpdateAttributesMenu(item->Submenu());
|
||||
}
|
||||
}
|
||||
|
||||
// There might be a new icon
|
||||
if (!strcmp(name, "BEOS:TYPE")
|
||||
|| !strcmp(name, "BEOS:M:STD_ICON")
|
||||
|| !strcmp(name, "BEOS:L:STD_ICON"))
|
||||
fHeaderView->UpdateIcon();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user