diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-04-20 15:48:51 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-04-20 15:48:51 +0000 |
| commit | db4aeda163816cad5029f7a4d37ec82afac27a91 (patch) | |
| tree | fccd3fa74175d29196128e8688d8d34aa0def771 /src/display/canvas-grid.cpp | |
| parent | Fix emphasized gridlines bug when zoomed out. (diff) | |
| download | inkscape-db4aeda163816cad5029f7a4d37ec82afac27a91.tar.gz inkscape-db4aeda163816cad5029f7a4d37ec82afac27a91.zip | |
grid: make grid names translatable. use different gridtype names in SVG that are not translated.
(bzr r2936)
Diffstat (limited to 'src/display/canvas-grid.cpp')
| -rw-r--r-- | src/display/canvas-grid.cpp | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index ddc0c7723..30c858dcc 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -31,7 +31,18 @@ namespace Inkscape { #define DEFAULTGRIDCOLOR 0x0000FF20 #define DEFAULTGRIDEMPCOLOR 0x0000FF40 +const gchar *grid_name [] = { + N_("Rectangular grid"), + N_("Axonometric grid") +}; +const gchar *grid_svgname [] = { + "xygrid", + "axonomgrid" +}; + +// ########################################################## +// Grid CanvasItem static void grid_canvasitem_class_init (GridCanvasItemClass *klass); static void grid_canvasitem_init (GridCanvasItem *grid); static void grid_canvasitem_destroy (GtkObject *object); @@ -162,21 +173,60 @@ CanvasGrid::~CanvasGrid() } } + + +const char * +CanvasGrid::getName(GridType type) +{ + return _(grid_name[type]); +} + +const char * +CanvasGrid::getSVGName(GridType type) +{ + return grid_svgname[type]; +} + +GridType +CanvasGrid::getGridTypeFromSVGName(const char * typestr) +{ + if (!typestr) return GRID_RECTANGULAR; + + gint t = 0; + for (t = GRID_MAXTYPENR; t >= 0; t--) { //this automatically defaults to grid0 which is rectangular grid + if (!strcmp(typestr, grid_svgname[t])) break; + } + return (GridType) t; +} + +GridType +CanvasGrid::getGridTypeFromName(const char * typestr) +{ + if (!typestr) return GRID_RECTANGULAR; + + gint t = 0; + for (t = GRID_MAXTYPENR; t >= 0; t--) { //this automatically defaults to grid0 which is rectangular grid + if (!strcmp(typestr, _(grid_name[t]))) break; + } + return (GridType) t; +} + + /* * writes an <inkscape:grid> child to repr. */ void -CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, const char * gridtype) +CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, GridType gridtype) { if (!repr) return; - if (!gridtype) return; + if (gridtype > GRID_MAXTYPENR) return; // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete. Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sp_desktop_document(SP_ACTIVE_DESKTOP)); Inkscape::XML::Node *newnode; newnode = xml_doc->createElement("inkscape:grid"); - newnode->setAttribute("type",gridtype); + newnode->setAttribute("type", getSVGName(gridtype)); repr->appendChild(newnode); @@ -189,15 +239,15 @@ CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, const char * gridtype * Creates a new CanvasGrid object of type gridtype */ CanvasGrid* -CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, const char * gridtype) +CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, GridType gridtype) { if (!in_repr) return NULL; - if (!gridtype) return NULL; - if (!strcmp(gridtype,"xygrid")) { - return (CanvasGrid*) new CanvasXYGrid(nv, in_repr); - } else if (!strcmp(gridtype,"axonometric")) { - return (CanvasGrid*) new CanvasAxonomGrid(nv, in_repr); + switch (gridtype) { + case GRID_RECTANGULAR: + return (CanvasGrid*) new CanvasXYGrid(nv, in_repr); + case GRID_AXONOMETRIC: + return (CanvasGrid*) new CanvasAxonomGrid(nv, in_repr); } return NULL; |
