diff --git a/src/apps/icon-o-matic/Jamfile b/src/apps/icon-o-matic/Jamfile index 5a68abecbb..2334f8a86e 100644 --- a/src/apps/icon-o-matic/Jamfile +++ b/src/apps/icon-o-matic/Jamfile @@ -319,6 +319,7 @@ DoCatalogs Icon-O-Matic : SVGExporter.cpp SVGImporter.cpp Exporter.cpp + FlatIconExporter.cpp AddPathsCommand.cpp AddPointCommand.cpp AddShapesCommand.cpp diff --git a/src/apps/icon-o-matic/import_export/Exporter.cpp b/src/apps/icon-o-matic/import_export/Exporter.cpp index a7a9f66a38..1db49de401 100644 --- a/src/apps/icon-o-matic/import_export/Exporter.cpp +++ b/src/apps/icon-o-matic/import_export/Exporter.cpp @@ -110,11 +110,11 @@ Exporter::_ExportThread() if (ret < B_OK) { // inform user of failure at this point BString helper(B_TRANSLATE("Saving your document failed!")); - helper << "\n\n" << B_TRANSLATE("Error: ") << strerror(ret); + helper << "\n\n" << ErrorCodeToString(ret); BAlert* alert = new BAlert(B_TRANSLATE_CONTEXT("Bad news", "Title of error alert"), helper.String(), B_TRANSLATE_COMMENT("Bleep!", "Exporter - Continue in error dialog"), - NULL, NULL); + NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); // launch alert asynchronously alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); diff --git a/src/apps/icon-o-matic/import_export/Exporter.h b/src/apps/icon-o-matic/import_export/Exporter.h index 047a596660..0fa03269fe 100644 --- a/src/apps/icon-o-matic/import_export/Exporter.h +++ b/src/apps/icon-o-matic/import_export/Exporter.h @@ -6,6 +6,8 @@ #define EXPORTER_H +#include + #include #include @@ -38,7 +40,9 @@ class Exporter { virtual status_t Export(const Icon* icon, BPositionIO* stream) = 0; - + /*! Turns the status_t error code returned by \c Export into a string. */ + virtual const char* ErrorCodeToString(status_t code) + { return strerror(code); } virtual const char* MIMEType() = 0; /*! If \a selfDestroy is true, class deletes itself when export thread is diff --git a/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp b/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp index 5a4479573f..31d2e78068 100644 --- a/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp +++ b/src/apps/icon-o-matic/import_export/flat_icon/FlatIconExporter.cpp @@ -13,7 +13,9 @@ #include #include +#include #include +#include #include #include @@ -33,6 +35,9 @@ #include "Style.h" #include "VectorPath.h" +#undef B_TRANSLATION_CONTEXT +#define B_TRANSLATION_CONTEXT "Icon-O-Matic-FlatIconExporter" + using std::nothrow; @@ -92,6 +97,37 @@ FlatIconExporter::Export(const Icon* icon, BPositionIO* stream) } +const char* +FlatIconExporter::ErrorCodeToString(status_t code) +{ + switch (code) { + case E_TOO_MANY_PATHS: + return B_TRANSLATE("There are too many paths. " + "The HVIF format supports a maximum of 255."); + case E_PATH_TOO_MANY_POINTS: + return B_TRANSLATE("One or more of the paths have too many vertices. " + "The HVIF format supports a maximum of 255 vertices per path."); + case E_TOO_MANY_SHAPES: + return B_TRANSLATE("There are too many shapes. " + "The HVIF format supports a maximum of 255."); + case E_SHAPE_TOO_MANY_PATHS: + return B_TRANSLATE("One or more of the shapes has too many paths. " + "The HVIF format supports a maximum of 255 paths per shape."); + case E_SHAPE_TOO_MANY_TRANSFORMERS: + return B_TRANSLATE("One or more of the shapes have too many transformers. " + "The HVIF format supports a maximum of 255 transformers per shape."); + case E_TOO_MANY_STYLES: + return B_TRANSLATE("There are too many styles. " + "The HVIF format supports a maximum of 255."); + default: + return Exporter::ErrorCodeToString(code); + } +} + + +// #pragma mark - + + status_t FlatIconExporter::Export(const Icon* icon, BNode* node, const char* attrName) @@ -206,7 +242,7 @@ status_t FlatIconExporter::_WriteStyles(LittleEndianBuffer& buffer, const Container