[haiku-commits] r41213 - haiku/trunk/src/apps/icon-o-matic

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 11 Apr 2011 00:53:38 +0200 (CEST)

Author: stippi
Date: 2011-04-11 00:53:38 +0200 (Mon, 11 Apr 2011)
New Revision: 41213
Changeset: https://dev.haiku-os.org/changeset/41213

Modified:
   haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp
   haiku/trunk/src/apps/icon-o-matic/MainWindow.h
Log:
Update window title with file name when it is known.


Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp    2011-04-10 22:32:51 UTC 
(rev 41212)
+++ haiku/trunk/src/apps/icon-o-matic/MainWindow.cpp    2011-04-10 22:53:38 UTC 
(rev 41213)
@@ -281,7 +281,6 @@
                        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 @@
                                                                
fDocument->SetNativeSaver(saver);
                                                        else
                                                                
fDocument->SetExportSaver(saver);
+                                                       _UpdateWindowTitle();
                                                        
fDocument->WriteUnlock();
                                                }
                                                saver->Save(fDocument);
@@ -305,24 +305,13 @@
 // TODO: ...
 //                             _SyncPanels(fSavePanel, fOpenPanel);
                        } else {
-                               printf("configure file panel\n");
                                // configure the file panel
-                               const char* saveText = NULL;
-                               FileSaver* saver = dynamic_cast<FileSaver*>(
-                                       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<FileSaver*>(
-                                               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 @@
        locker.Unlock();
 
        SetIcon(icon);
+
+       _UpdateWindowTitle();
 }
 
 
@@ -1369,4 +1360,34 @@
 }
 
 
+const char*
+MainWindow::_FileName(bool preferExporter) const
+{
+       FileSaver* saver1;
+       FileSaver* saver2;
+       if (preferExporter) {
+               saver1 = dynamic_cast<FileSaver*>(fDocument->ExportSaver());
+               saver2 = dynamic_cast<FileSaver*>(fDocument->NativeSaver());
+       } else {
+               saver1 = dynamic_cast<FileSaver*>(fDocument->NativeSaver());
+               saver2 = dynamic_cast<FileSaver*>(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"));
+}
+

Modified: haiku/trunk/src/apps/icon-o-matic/MainWindow.h
===================================================================
--- haiku/trunk/src/apps/icon-o-matic/MainWindow.h      2011-04-10 22:32:51 UTC 
(rev 41212)
+++ haiku/trunk/src/apps/icon-o-matic/MainWindow.h      2011-04-10 22:53:38 UTC 
(rev 41213)
@@ -90,6 +90,9 @@
                        DocumentSaver*          _CreateSaver(const entry_ref& 
ref,
                                                                        uint32 
exportMode);
 
+                       const char*                     _FileName(bool 
preferExporter) const;
+                       void                            _UpdateWindowTitle();
+
 private:
                        IconEditorApp*          fApp;
                        Document*                       fDocument;


Other related posts:

  • » [haiku-commits] r41213 - haiku/trunk/src/apps/icon-o-matic - superstippi