From 5a1210fbeffef1010c67193dc7faff4d34369b71 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Tue, 12 Jun 2007 03:54:07 +0000 Subject: [PATCH] Moved the BAboutWindow implementation to the shared source directory, which despite being talked about repeatedly, does not currently exist. Adding this required adding some new Jam rules to deal with this shared source directory and headers. I had some fun figuring this out. Despite writing articles about Jam in the Haiku newsletter a few years ago I still find Jam to be a PITA at times. But my solution seems to work pretty well. Basically you just call the rule UseSharedSource and pass the name of the shared source file you want to use. This rule sets up the header directories and the right Jam variables for the source file. You then add the source file to the source list in the Application rule like any other source file. I also made the authors list sent to the about window constructor null terminated instead of passing the size of the array, as suggested by Hugo. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21391 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- build/jam/FileRules | 12 ++++++++++++ build/jam/HeadersRules | 5 +++++ .../{private/interface => shared}/AboutWindow.h | 2 +- src/apps/showimage/Jamfile | 5 ++++- src/apps/showimage/ShowImageApp.cpp | 15 ++++----------- src/kits/interface/Jamfile | 1 - src/{kits/interface => shared}/AboutWindow.cpp | 11 ++++++++--- 7 files changed, 34 insertions(+), 17 deletions(-) rename headers/{private/interface => shared}/AboutWindow.h (86%) rename src/{kits/interface => shared}/AboutWindow.cpp (87%) diff --git a/build/jam/FileRules b/build/jam/FileRules index fceb452e39..c66230a231 100644 --- a/build/jam/FileRules +++ b/build/jam/FileRules @@ -249,3 +249,15 @@ actions CopySetHaikuRevision1 $(2[1]) --data $(2[3]) $(1) && $(2[2]) $(1) ${revision} } + +rule UseSharedSource +{ + UseSharedHeaders ; + + for file in $(1) { + local gristed_file = [ FGristFiles $(file) ] ; + SEARCH on $(gristed_file) = [ FDirName $(HAIKU_TOP) src shared ] ; + LOCATE on $(gristed_file) = [ FDirName $(HAIKU_TOP) src shared ] ; + SEARCH_SOURCE on $(gristed_file) = [ FDirName $(HAIKU_TOP) src shared ] ; + } +} diff --git a/build/jam/HeadersRules b/build/jam/HeadersRules index e7490235d6..652c73a2bd 100644 --- a/build/jam/HeadersRules +++ b/build/jam/HeadersRules @@ -338,6 +338,11 @@ rule UseLegacyObjectHeaders SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers legacy ] : $(2) ; } +rule UseSharedHeaders +{ + UseHeaders [ FDirName $(HAIKU_TOP) headers shared ] ; +} + rule FStandardOSHeaders { local osIncludes = add-ons add-ons/file_system add-ons/graphics diff --git a/headers/private/interface/AboutWindow.h b/headers/shared/AboutWindow.h similarity index 86% rename from headers/private/interface/AboutWindow.h rename to headers/shared/AboutWindow.h index 7b731fcca8..57cf972db8 100644 --- a/headers/private/interface/AboutWindow.h +++ b/headers/shared/AboutWindow.h @@ -15,7 +15,7 @@ class BAboutWindow { public: BAboutWindow(char *appName, int32 firstCopyrightYear, - int32 numAuthors, const char **authors, char *extraInfo = NULL); + const char **authors, char *extraInfo = NULL); virtual ~BAboutWindow(); void Show(); diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index 87d24a0219..1684c91ea3 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -1,10 +1,13 @@ SubDir HAIKU_TOP src apps showimage ; -UsePrivateHeaders tracker interface ; +UsePrivateHeaders tracker ; SetSubDirSupportedPlatformsBeOSCompatible ; +UseSharedSource AboutWindow.cpp ; + Application ShowImage : + AboutWindow.cpp ShowImageApp.cpp ShowImageSettings.cpp ShowImageStatusView.cpp diff --git a/src/apps/showimage/ShowImageApp.cpp b/src/apps/showimage/ShowImageApp.cpp index f924541103..c5e2d139ae 100644 --- a/src/apps/showimage/ShowImageApp.cpp +++ b/src/apps/showimage/ShowImageApp.cpp @@ -10,13 +10,11 @@ */ +#include "AboutWindow.h" // Shared source #include "ShowImageApp.h" #include "ShowImageConstants.h" #include "ShowImageWindow.h" -#ifdef HAIKU_TARGET_PLATFORM_HAIKU -#include -#endif #include #include #include @@ -47,20 +45,15 @@ ShowImageApp::~ShowImageApp() void ShowImageApp::AboutRequested() { -#ifdef HAIKU_TARGET_PLATFORM_HAIKU const char *authors[] = { "Fernando F. Oliveira", "Michael Wilber", "Michael Pfeiffer", - "Ryan Leavengood" + "Ryan Leavengood", + NULL }; - BAboutWindow about("ShowImage", 2003, 4, authors); + BAboutWindow about("ShowImage", 2003, authors); about.Show(); -#else - BAlert* alert = new BAlert("About ShowImage", - "Haiku ShowImage\n\nby Fernando F. Oliveira, Michael Wilber, Michael Pfeiffer and Ryan Leavengood", "OK"); - alert->Go(); -#endif } diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index cfc948f434..abdfbd6c2f 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -37,7 +37,6 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) textview_support ] ; SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; MergeObject interface_kit.o : - AboutWindow.cpp AbstractLayoutItem.cpp Alert.cpp Alignment.cpp diff --git a/src/kits/interface/AboutWindow.cpp b/src/shared/AboutWindow.cpp similarity index 87% rename from src/kits/interface/AboutWindow.cpp rename to src/shared/AboutWindow.cpp index 3a0ff59358..2b014f1a19 100644 --- a/src/kits/interface/AboutWindow.cpp +++ b/src/shared/AboutWindow.cpp @@ -6,17 +6,19 @@ * Ryan Leavengood, leavengood@gmail.com */ -#include +#include "AboutWindow.h" + #include #include #include #include +#include #include BAboutWindow::BAboutWindow(char *appName, int32 firstCopyrightYear, - int32 numAuthors, const char **authors, char *extraInfo) + const char **authors, char *extraInfo) { fAppName = new BString(appName); fText = new BString(); @@ -32,12 +34,15 @@ BAboutWindow::BAboutWindow(char *appName, int32 firstCopyrightYear, text << "\n\nCopyright " B_UTF8_COPYRIGHT " "; text << firstCopyrightYear << "-" << currentYear << " Haiku, Inc.\n\n"; text << "Written by:\n"; - for (int32 i = 0; i < numAuthors; i++) { + for (int32 i = 0; authors[i]; i++) { text << " " << authors[i] << "\n"; } + + // The extra information is optional if (extraInfo != NULL) { text << "\n" << extraInfo << "\n"; } + fText->Adopt(text); }