From 83522e5648fc1535ac4af1eb5cd8429c87c1988a Mon Sep 17 00:00:00 2001 From: martinRenou Date: Fri, 29 Nov 2024 15:53:14 +0100 Subject: [PATCH 1/4] Add freecad icon for files --- src/plugins.ts | 12 +++++++++++- src/svg.d.ts | 4 ++++ style/freecad.svg | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/svg.d.ts create mode 100644 style/freecad.svg diff --git a/src/plugins.ts b/src/plugins.ts index f73a3c7..176e24a 100644 --- a/src/plugins.ts +++ b/src/plugins.ts @@ -19,6 +19,7 @@ import { showErrorMessage, WidgetTracker } from '@jupyterlab/apputils'; +import { LabIcon } from '@jupyterlab/ui-components'; import { JupyterCadWidgetFactory } from '@jupytercad/jupytercad-core'; import { @@ -28,6 +29,13 @@ import { } from '@jupytercad/schema'; import { requestAPI } from '@jupytercad/base'; import { JupyterCadFCModelFactory } from './modelfactory'; +import freecadIconSvg from '../style/freecad.svg'; + +const freecadIcon = new LabIcon({ + name: 'jupytercad:stp', + svgstr: freecadIconSvg +}); + const FACTORY = 'Jupytercad Freecad Factory'; @@ -84,7 +92,8 @@ const activate = async ( mimeTypes: ['application/octet-stream'], extensions: ['.FCStd', 'fcstd'], fileFormat: 'base64', - contentType: 'FCStd' + contentType: 'FCStd', + icon: freecadIcon }); const FCStdSharedModelFactory: SharedDocumentFactory = () => { @@ -96,6 +105,7 @@ const activate = async ( ); widgetFactory.widgetCreated.connect((sender, widget) => { + widget.title.icon = freecadIcon; // Notify the instance tracker if restore data needs to update. widget.context.pathChanged.connect(() => { tracker.save(widget); diff --git a/src/svg.d.ts b/src/svg.d.ts new file mode 100644 index 0000000..d4627e5 --- /dev/null +++ b/src/svg.d.ts @@ -0,0 +1,4 @@ +declare module '*.svg' { + const value: string; // @ts-ignore + export default value; +} diff --git a/style/freecad.svg b/style/freecad.svg new file mode 100644 index 0000000..805b45f --- /dev/null +++ b/style/freecad.svg @@ -0,0 +1,33 @@ + + + +FreeCADFreeCAD From 868ed402fb6a5cc5bc3e8c30eea5dabcd1d76663 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 2 Dec 2024 17:22:02 +0100 Subject: [PATCH 2/4] Selectable icon --- style/freecad.svg | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/style/freecad.svg b/style/freecad.svg index 805b45f..81ffa8a 100644 --- a/style/freecad.svg +++ b/style/freecad.svg @@ -17,17 +17,25 @@ id="defs1" />FreeCAD From 8e8c5e620ae0c5aa4b4d840282c35138ef140f5f Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 2 Dec 2024 17:23:56 +0100 Subject: [PATCH 3/4] Empty 'f' --- style/freecad.svg | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/style/freecad.svg b/style/freecad.svg index 81ffa8a..986e7f3 100644 --- a/style/freecad.svg +++ b/style/freecad.svg @@ -31,11 +31,7 @@ d="M 6,0 2,4 V 20 L 6,16 V 4 h 8 l 4,-4 z" fill="#cb333b" style="fill-rule:evenodd;stroke-width:2.64567;stroke-linecap:square" - id="path3" />