diff --git a/src/apps/stylededit/Constants.h b/src/apps/stylededit/Constants.h index 2711073324..4b9af01153 100644 --- a/src/apps/stylededit/Constants.h +++ b/src/apps/stylededit/Constants.h @@ -82,6 +82,7 @@ const uint32 SAVE_THEN_QUIT = 'FPsq'; // Update StatusView const uint32 UPDATE_STATUS = 'UPSt'; +const uint32 UPDATE_STATUS_REF = 'UPSr'; const uint32 UNLOCK_FILE = 'UNLk'; const uint32 UPDATE_LINE_SELECTION = 'UPls'; diff --git a/src/apps/stylededit/Jamfile b/src/apps/stylededit/Jamfile index 8d264d1cf7..789cca7ee4 100644 --- a/src/apps/stylededit/Jamfile +++ b/src/apps/stylededit/Jamfile @@ -1,7 +1,11 @@ SubDir HAIKU_TOP src apps stylededit ; UsePrivateHeaders textencoding ; +UsePrivateSystemHeaders ; +UsePrivateHeaders tracker shared ; UsePublicHeaders [ FDirName be_apps Tracker ] ; +SubDirHdrs $(HAIKU_TOP) src kits tracker ; +UseHeaders [ FDirName $(HAIKU_TOP) src kits tracker ] : false ; local styled_edit_rsrc = [ FGristFiles StyledEdit.rsrc ] @@ -18,7 +22,7 @@ Application StyledEdit : StyledEditApp.cpp StyledEditView.cpp StyledEditWindow.cpp - : be translation tracker libtextencoding.so localestub + : libshared.a be translation tracker libtextencoding.so localestub [ TargetLibsupc++ ] : $(styled_edit_rsrc) ; diff --git a/src/apps/stylededit/StatusView.cpp b/src/apps/stylededit/StatusView.cpp index d9501a1a38..dbe1bcf12c 100644 --- a/src/apps/stylededit/StatusView.cpp +++ b/src/apps/stylededit/StatusView.cpp @@ -25,6 +25,9 @@ #include #include +#include +#include "DirMenu.h" + #include "Constants.h" @@ -156,6 +159,11 @@ StatusView::Draw(BRect updateRect) void StatusView::MouseDown(BPoint where) { + if (where.x < fCellWidth[kPositionCell]) { + _ShowDirMenu(); + return; + } + if (!fReadOnly || !fCanUnlock) return; @@ -228,6 +236,13 @@ StatusView::SetStatus(BMessage* message) } +void +StatusView::SetRef(const entry_ref& ref) +{ + fRef = ref; +} + + void StatusView::_ValidatePreferredSize() { @@ -264,3 +279,27 @@ StatusView::_ValidatePreferredSize() scrollBar->MoveBy(delta, 0); } + +void +StatusView::_ShowDirMenu() +{ + BEntry entry; + status_t status = entry.SetTo(&fRef); + + if (status != B_OK || !entry.Exists()) + return; + + BPrivate::BDirMenu* menu = new BDirMenu(NULL, + BMessenger(kTrackerSignature), B_REFS_RECEIVED); + + menu->Populate(&entry, Window(), false, false, true, false, true); + + BPoint point = Bounds().LeftBottom(); + point.y += 3; + ConvertToScreen(&point); + BRect clickToOpenRect(Bounds()); + ConvertToScreen(&clickToOpenRect); + menu->Go(point, true, true, clickToOpenRect); + delete menu; +} + diff --git a/src/apps/stylededit/StatusView.h b/src/apps/stylededit/StatusView.h index b32d6a82c0..fae6b35966 100644 --- a/src/apps/stylededit/StatusView.h +++ b/src/apps/stylededit/StatusView.h @@ -10,6 +10,7 @@ #define STATUS_VIEW_H +#include #include #include @@ -30,6 +31,7 @@ public: ~StatusView(); void SetStatus(BMessage* mesage); + void SetRef(const entry_ref& ref); virtual void AttachedToWindow(); virtual void GetPreferredSize(float* _width, float* _height); virtual void ResizeToPreferred(); @@ -38,6 +40,7 @@ public: private: void _ValidatePreferredSize(); + void _ShowDirMenu(); private: BScrollView* fScrollView; @@ -47,6 +50,7 @@ private: bool fReadOnly; bool fCanUnlock; BString fEncoding; + entry_ref fRef; }; #endif // STATUS_VIEW_H diff --git a/src/apps/stylededit/StyledEditWindow.cpp b/src/apps/stylededit/StyledEditWindow.cpp index 04cc20bd61..0932c90020 100644 --- a/src/apps/stylededit/StyledEditWindow.cpp +++ b/src/apps/stylededit/StyledEditWindow.cpp @@ -558,6 +558,27 @@ StyledEditWindow::MessageReceived(BMessage* message) break; } + case UPDATE_STATUS_REF: + { + entry_ref ref; + const char* name; + + if (fSaveMessage != NULL + && fSaveMessage->FindRef("directory", &ref) == B_OK + && fSaveMessage->FindString("name", &name) == B_OK) { + + BDirectory dir(&ref); + status_t status = dir.InitCheck(); + BEntry entry; + if (status == B_OK) + status = entry.SetTo(&dir, name); + if (status == B_OK) + status = entry.GetRef(&ref); + } + fStatusView->SetRef(ref); + break; + } + case UNLOCK_FILE: { status_t status = _UnlockFile(); @@ -801,6 +822,8 @@ StyledEditWindow::Save(BMessage* message) fNagOnNodeChange = true; PostMessage(UPDATE_STATUS); + PostMessage(UPDATE_STATUS_REF); + return status; } @@ -888,6 +911,8 @@ StyledEditWindow::OpenFile(entry_ref* ref) _SwitchNodeMonitor(true, ref); + PostMessage(UPDATE_STATUS_REF); + fReloadItem->SetEnabled(fSaveMessage != NULL); fEncodingItem->SetEnabled(fSaveMessage != NULL); } @@ -2053,6 +2078,7 @@ StyledEditWindow::_HandleNodeMonitorEvent(BMessage *message) _SwitchNodeMonitor(false); _SwitchNodeMonitor(true); } + PostMessage(UPDATE_STATUS_REF); } break; @@ -2099,6 +2125,7 @@ StyledEditWindow::_HandleNodeMonitorEvent(BMessage *message) name = "Unknown"; _ShowNodeChangeAlert(name, true); + PostMessage(UPDATE_STATUS_REF); } break;