diff --git a/src/apps/icon-o-matic/MainWindow.cpp b/src/apps/icon-o-matic/MainWindow.cpp index 93cea0a853..8f5276a68e 100644 --- a/src/apps/icon-o-matic/MainWindow.cpp +++ b/src/apps/icon-o-matic/MainWindow.cpp @@ -281,7 +281,6 @@ MainWindow::MessageReceived(BMessage* message) if (message->FindRef("directory", &ref) == B_OK && message->FindString("name", &name) == B_OK) { // this message comes from the file panel - printf("file panel result\n"); BDirectory dir(&ref); BEntry entry; if (dir.InitCheck() >= B_OK @@ -296,6 +295,7 @@ MainWindow::MessageReceived(BMessage* message) fDocument->SetNativeSaver(saver); else fDocument->SetExportSaver(saver); + _UpdateWindowTitle(); fDocument->WriteUnlock(); } saver->Save(fDocument); @@ -305,24 +305,13 @@ MainWindow::MessageReceived(BMessage* message) // TODO: ... // _SyncPanels(fSavePanel, fOpenPanel); } else { - printf("configure file panel\n"); // configure the file panel - const char* saveText = NULL; - FileSaver* saver = dynamic_cast( - fDocument->NativeSaver()); - if (saver != NULL) - saveText = saver->Ref()->name; - uint32 requestRefWhat = MSG_SAVE_AS; bool isExportMode = message->what == MSG_EXPORT_AS || message->what == MSG_EXPORT; - if (isExportMode) { + if (isExportMode) requestRefWhat = MSG_EXPORT_AS; - saver = dynamic_cast( - fDocument->ExportSaver()); - if (saver != NULL && saver->Ref()->name != NULL) - saveText = saver->Ref()->name; - } + const char* saveText = _FileName(isExportMode); BMessage requestRef(requestRefWhat); if (saveText != NULL) @@ -744,6 +733,8 @@ MainWindow::Open(const entry_ref& ref, bool append) locker.Unlock(); SetIcon(icon); + + _UpdateWindowTitle(); } @@ -1369,4 +1360,34 @@ MainWindow::_CreateSaver(const entry_ref& ref, uint32 exportMode) } +const char* +MainWindow::_FileName(bool preferExporter) const +{ + FileSaver* saver1; + FileSaver* saver2; + if (preferExporter) { + saver1 = dynamic_cast(fDocument->ExportSaver()); + saver2 = dynamic_cast(fDocument->NativeSaver()); + } else { + saver1 = dynamic_cast(fDocument->NativeSaver()); + saver2 = dynamic_cast(fDocument->ExportSaver()); + } + const char* fileName = NULL; + if (saver1 != NULL) + fileName = saver1->Ref()->name; + if ((fileName == NULL || fileName[0] == '\0') && saver2 != NULL) + fileName = saver2->Ref()->name; + return fileName; +} + + +void +MainWindow::_UpdateWindowTitle() +{ + const char* fileName = _FileName(false); + if (fileName != NULL) + SetTitle(fileName); + else + SetTitle(B_TRANSLATE_SYSTEM_NAME("Icon-O-Matic")); +} diff --git a/src/apps/icon-o-matic/MainWindow.h b/src/apps/icon-o-matic/MainWindow.h index d859d50c31..432dd1eea7 100644 --- a/src/apps/icon-o-matic/MainWindow.h +++ b/src/apps/icon-o-matic/MainWindow.h @@ -90,6 +90,9 @@ private: DocumentSaver* _CreateSaver(const entry_ref& ref, uint32 exportMode); + const char* _FileName(bool preferExporter) const; + void _UpdateWindowTitle(); + private: IconEditorApp* fApp; Document* fDocument;