29 from XSLTransform import XSLTransform |
29 from XSLTransform import XSLTransform |
30 from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\ |
30 from svghmi.i18n import EtreeToMessages, SaveCatalog, ReadTranslations,\ |
31 MatchTranslations, TranslationToEtree, open_pofile |
31 MatchTranslations, TranslationToEtree, open_pofile |
32 from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES |
32 from svghmi.hmi_tree import HMI_TYPES, HMITreeNode, SPECIAL_NODES |
33 from svghmi.ui import SVGHMI_UI |
33 from svghmi.ui import SVGHMI_UI |
|
34 from svghmi.fonts import GetFontTypeAndFamilyName, GetCSSFontFaceFromFontFile |
34 |
35 |
35 |
36 |
36 ScriptDirectory = paths.AbsDir(__file__) |
37 ScriptDirectory = paths.AbsDir(__file__) |
37 |
38 |
38 |
39 |
290 "name": _("Import SVG"), |
291 "name": _("Import SVG"), |
291 "tooltip": _("Import SVG"), |
292 "tooltip": _("Import SVG"), |
292 "method": "_ImportSVG" |
293 "method": "_ImportSVG" |
293 }, |
294 }, |
294 { |
295 { |
295 "bitmap": "EditSVG", # should be something different |
296 "bitmap": "EditSVG", |
296 "name": _("Inkscape"), |
297 "name": _("Inkscape"), |
297 "tooltip": _("Edit HMI"), |
298 "tooltip": _("Edit HMI"), |
298 "method": "_StartInkscape" |
299 "method": "_StartInkscape" |
299 }, |
300 }, |
300 { |
301 { |
301 "bitmap": "OpenPOT", # should be something different |
302 "bitmap": "OpenPOT", |
302 "name": _("New lang"), |
303 "name": _("New lang"), |
303 "tooltip": _("Open non translated message catalog (POT) to start new language"), |
304 "tooltip": _("Open non translated message catalog (POT) to start new language"), |
304 "method": "_OpenPOT" |
305 "method": "_OpenPOT" |
305 }, |
306 }, |
306 |
|
307 { |
307 { |
308 "bitmap": "EditPO", # should be something different |
308 "bitmap": "EditPO", |
309 "name": _("Edit lang"), |
309 "name": _("Edit lang"), |
310 "tooltip": _("Edit existing message catalog (PO) for specific language"), |
310 "tooltip": _("Edit existing message catalog (PO) for specific language"), |
311 "method": "_EditPO" |
311 "method": "_EditPO" |
312 }, |
312 }, |
313 |
313 { |
314 # TODO : HMITree button |
314 "bitmap": "AddFont", |
315 # - can drag'n'drop variabes to Inkscape |
315 "name": _("Add Font"), |
|
316 "tooltip": _("Add TTF, OTH or WOFF font to be embedded in HMI"), |
|
317 "method": "_AddFont" |
|
318 }, |
|
319 { |
|
320 "bitmap": "DelFont", |
|
321 "name": _("Delete Font"), |
|
322 "tooltip": _("Remove font previously added to HMI"), |
|
323 "method": "_DelFont" |
|
324 }, |
316 ] |
325 ] |
317 |
326 |
318 def _getSVGpath(self, project_path=None): |
327 def _getSVGpath(self, project_path=None): |
319 if project_path is None: |
328 if project_path is None: |
320 project_path = self.CTNPath() |
329 project_path = self.CTNPath() |
606 if os.path.isfile(POFile): |
615 if os.path.isfile(POFile): |
607 self._StartPOEdit(POFile) |
616 self._StartPOEdit(POFile) |
608 else: |
617 else: |
609 self.GetCTRoot().logger.write_error(_("POT file does not exist, add translatable text (label starting with '_') in Inkscape first\n")) |
618 self.GetCTRoot().logger.write_error(_("POT file does not exist, add translatable text (label starting with '_') in Inkscape first\n")) |
610 |
619 |
|
620 def _AddFont(self): |
|
621 pass |
|
622 |
|
623 def _DelFont(self): |
|
624 pass |
|
625 |
611 def CTNGlobalInstances(self): |
626 def CTNGlobalInstances(self): |
612 # view_name = self.BaseParams.getName() |
627 # view_name = self.BaseParams.getName() |
613 # return [ (view_name + "_" + name, iec_type, "") for name, iec_type in SPECIAL_NODES] |
628 # return [ (view_name + "_" + name, iec_type, "") for name, iec_type in SPECIAL_NODES] |
614 # TODO : move to library level for multiple hmi |
629 # TODO : move to library level for multiple hmi |
615 return [(name, iec_type, "") for name, iec_type in SPECIAL_NODES] |
630 return [(name, iec_type, "") for name, iec_type in SPECIAL_NODES] |