{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":694400710,"defaultBranch":"main","name":"slint-dotnet","ownerLogin":"microhobby","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2023-09-20T23:44:03.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/2633321?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1723335640.0","currentOid":""},"activityList":{"items":[{"before":"752322a4968571727230c1335b0db88fca350134","after":"271c25f12e1b45ce77ca93fceee3a68ad7a6317b","ref":"refs/heads/main","pushedAt":"2024-08-11T00:19:03.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: update to 1.7.1\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: update to 1.7.1"}},{"before":"1fe98de6db6b429a2a623c45c036cace6f118b1e","after":"752322a4968571727230c1335b0db88fca350134","ref":"refs/heads/main","pushedAt":"2024-08-11T00:17:27.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"tasks: Fixes for the tests and build process\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"tasks: Fixes for the tests and build process"}},{"before":"304fc0d484b08ef598a6be327454b6dfcbcd3f62","after":"1fe98de6db6b429a2a623c45c036cace6f118b1e","ref":"refs/heads/main","pushedAt":"2024-07-27T22:06:11.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"README: Add support for arrays of strings\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"README: Add support for arrays of strings"}},{"before":"7582a45abdf7a2919c7adb2746a1b11ef709ac7a","after":"304fc0d484b08ef598a6be327454b6dfcbcd3f62","ref":"refs/heads/main","pushedAt":"2024-07-27T21:48:40.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"lib: Bump and release 1.7.0\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"lib: Bump and release 1.7.0"}},{"before":"0096b267eaa983d49df9425bfcad2bf3b22fb0e2","after":"7582a45abdf7a2919c7adb2746a1b11ef709ac7a","ref":"refs/heads/main","pushedAt":"2024-07-23T17:23:37.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"vscode: tasks: Also build the amd64 lib using containers\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"vscode: tasks: Also build the amd64 lib using containers"}},{"before":"315f17a50b9b570cfe2ae286916877b1cc785eca","after":"0096b267eaa983d49df9425bfcad2bf3b22fb0e2","ref":"refs/heads/main","pushedAt":"2024-07-23T00:59:44.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"vscode: Sync the package version on the project file\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"vscode: Sync the package version on the project file"}},{"before":"3e9795b9935d64cd4c46746254d6e46e2988c9ec","after":"315f17a50b9b570cfe2ae286916877b1cc785eca","ref":"refs/heads/main","pushedAt":"2024-07-23T00:58:53.000Z","pushType":"push","commitsCount":3,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Bump Microsoft.CodeAnalysis.CSharp to 4.5.0\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Bump Microsoft.CodeAnalysis.CSharp to 4.5.0"}},{"before":"117282b573b1682605c0bbffe3e6ad8522baa4cb","after":"3e9795b9935d64cd4c46746254d6e46e2988c9ec","ref":"refs/heads/main","pushedAt":"2024-07-22T14:16:59.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"vscode: Add a workspace file\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"vscode: Add a workspace file"}},{"before":"473f7c9a7fd38a0c5c8be1fbc79b231da413ce9c","after":"117282b573b1682605c0bbffe3e6ad8522baa4cb","ref":"refs/heads/main","pushedAt":"2024-07-22T14:16:15.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Add Array support\n\nSigned-off-by: Matheus Castello \n\ndiff --git a/SlintDotnet/Array.cs b/SlintDotnet/Array.cs\nnew file mode 100644\nindex 0000000..a90b950\n--- /dev/null\n+++ b/SlintDotnet/Array.cs\n@@ -0,0 +1,66 @@\n+using System.Threading;\n+using static SlintDotnet.SlintDotnet;\n+using SlintAPI = SlintDotnet.SlintDotnet;\n+\n+namespace Slint;\n+\n+public class Array : List, SlintInitialization {\n+ private DotNetValue _dotnetArray;\n+ private string _varName;\n+ private bool _isInitialized = false;\n+\n+ public Array(string varName) : base() {\n+ _varName = varName;\n+ SlintInitializationPool.POOL.Add(this);\n+ }\n+\n+ /**\n+ * This method should be called only after the Slint UI is ready\n+ */\n+ public void Init() {\n+ _dotnetArray = SlintAPI.GetArray(_varName);\n+\n+ // check if the slint one already have items and update this one\n+ foreach (var item in _dotnetArray.arrayItems) {\n+ if (item.typeType == (int)SlintType.STRING) {\n+ // call the base because we do not need to call the Slint side\n+ base.Add((T)(object)item.typeValue);\n+ }\n+ }\n+\n+ _isInitialized = true;\n+ }\n+\n+ private void _syncData() {\n+ if (!_isInitialized) {\n+ throw new System.Exception(\"Array not initialized yet\");\n+ }\n+\n+ _dotnetArray.arrayItems.Clear();\n+\n+ foreach (var item in this) {\n+ _dotnetArray.arrayItems.Add(new DotNetValue {\n+ arrayItems = new List(),\n+ isArray = false,\n+ isStruct = false,\n+ structProps = new List(),\n+ typeName = \"\",\n+ typeType = (int)SlintType.STRING,\n+ typeValue = item!.ToString()\n+ });\n+ }\n+\n+ // update the slint side\n+ SlintAPI.SetArray(_dotnetArray);\n+ }\n+\n+ public new void Add(T item) {\n+ base.Add(item);\n+ _syncData();\n+ }\n+\n+ public new void Remove(T item) {\n+ base.Remove(item);\n+ _syncData();\n+ }\n+}\ndiff --git a/SlintDotnet/Generator.cs b/SlintDotnet/Generator.cs\nindex e7a3224..3e1b463 100644\n--- a/SlintDotnet/Generator.cs\n+++ b/SlintDotnet/Generator.cs\n@@ -3,6 +3,7 @@ using SlintAPI = SlintDotnet.SlintDotnet;\n using Microsoft.CodeAnalysis;\n using Microsoft.CodeAnalysis.Text;\n using System.Runtime.InteropServices;\n+using System.Diagnostics;\n\n namespace SlintDotnet.SourceGenerator;\n\n@@ -10,7 +11,7 @@ namespace SlintDotnet.SourceGenerator;\n public class Generator : ISourceGenerator\n {\n // TODO: do not forget to update the version\n- private static string PACKAGE_VERSION = \"1.5.4\";\n+ private static string PACKAGE_VERSION = \"1.5.7\";\n\n protected struct struct_info {\n public int index;\n@@ -28,6 +29,8 @@ public class Generator : ISourceGenerator\n 1 => \"float\",\n 2 => \"bool\",\n 3 => \"Image\",\n+ 4 => \"class\",\n+ 5 => \"Array\",\n _ => \"string\"\n };\n\n@@ -37,14 +40,16 @@ public class Generator : ISourceGenerator\n 1 => \"Number\",\n 2 => \"Bool\",\n 3 => \"Image\",\n+ 4 => \"Struct\",\n+ 5 => \"Array\",\n _ => \"String\"\n };\n\n // add the properties\n sourceCodeStr.Append($@\"\n\n- private {valType} _{property.typeName};\n- public {valType} {property.typeName} {{\n+ private {valType}{(property.isArray ? \"\" : \"\")} _{property.typeName}{(property.isArray ? $\" = new Array(\\\"{property.typeName}\\\")\" : \"\")};\n+ public {valType}{(property.isArray ? \"\" : \"\")} {property.typeName} {{\n get {{\n \");\n\n@@ -53,7 +58,7 @@ sourceCodeStr.Append($@\"\n sourceCodeStr.Append($@\"\n var sT = SlintAPI.GetStruct(\"\"{strtI.Value.struct_name}\"\");\n \");\n- } else if (valType != \"Image\") {\n+ } else if (valType != \"Image\" && valType != \"Array\") {\n // for the primitive types\n sourceCodeStr.Append($@\"\n var rT = SlintAPI.GetProperty(\"\"{property.typeName}\"\")\n@@ -62,7 +67,7 @@ sourceCodeStr.Append($@\"\n .Replace(\"\")\"\", \"\"\"\");\n\n \");\n- } else {\n+ } else if (valType != \"Array\") {\n // for image only, return the Image object\n sourceCodeStr.Append($@\"\n var rT = _{property.typeName};\n@@ -96,8 +101,12 @@ sourceCodeStr.Append($@\"\n } else if (valType == \"class\") {\n sourceCodeStr.Append($@\"\n var sT = SlintAPI.GetStruct(\"\"{property.typeName}\"\");\n- this._{valType} = sT;\n- return this._{valType};\n+ this._{property.typeName} = sT;\n+ return this._{property.typeName};\n+\");\n+ } else if (valType == \"Array\") {\n+sourceCodeStr.Append($@\"\n+ return this._{property.typeName};\n \");\n } else {\n sourceCodeStr.Append($@\"\n@@ -110,6 +119,7 @@ sourceCodeStr.Append($@\"\n\n \");\n\n+ if (property.isArray == false) {\n sourceCodeStr.Append($@\"\n set {{\n _{property.typeName} = value;\n@@ -128,6 +138,7 @@ sourceCodeStr.Append($@\"\n typeName = \"\"{strtI.Value.struct_name}\"\",\n typeType = 4,\n isStruct = true,\n+ isArray = false,\n typeValue = \"\"\"\",\n structProps = new List\n {{\n@@ -142,35 +153,40 @@ sourceCodeStr.Append($@\"\n typeType = 0,\n typeValue = value.ToString(),\n isStruct = false,\n- structProps = new List()\n+ structProps = new List(),\n+ arrayItems = new List()\n \");\n } else if (valType == \"float\") {\n sourceCodeStr.Append($@\"\n typeType = 1,\n typeValue = value.ToString(),\n isStruct = false,\n- structProps = new List()\n+ structProps = new List(),\n+ arrayItems = new List()\n \");\n } else if (valType == \"bool\") {\n sourceCodeStr.Append($@\"\n typeType = 2,\n typeValue = value.ToString(),\n isStruct = false,\n- structProps = new List()\n+ structProps = new List(),\n+ arrayItems = new List()\n \");\n } else if (valType == \"Image\") {\n sourceCodeStr.Append($@\"\n typeType = 3,\n typeValue = value.Path,\n isStruct = false,\n- structProps = new List()\n+ structProps = new List(),\n+ arrayItems = new List()\n \");\n } else {\n sourceCodeStr.Append($@\"\n typeType = 0,\n typeValue = value.ToString(),\n isStruct = false,\n- structProps = new List()\n+ structProps = new List(),\n+ arrayItems = new List()\n \");\n }\n\n@@ -186,8 +202,13 @@ sourceCodeStr.Append($@\"\n }}\n }}\n\n+\");\n+ } else {\n+sourceCodeStr.Append($@\"\n+ }}\n \");\n }\n+ }\n\n return sourceCodeStr.ToString();\n }\n@@ -221,7 +242,10 @@ sourceCodeStr.Append($@\"\n var home = Environment.GetEnvironmentVariable(\"HOME\");\n var arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();\n\n+ // FIXME: FOR PROD\n string assemblyProbeDirectory = $\"{home}/.nuget/packages/slintdotnet/{PACKAGE_VERSION}/runtimes/linux-{arch}/native/\";\n+ // FIXME: FOR DEBUG\n+ // string assemblyProbeDirectory = $\"{home}/projects/D/slint-dotnet/target/debug/\";\n Directory.SetCurrentDirectory(assemblyProbeDirectory);\n\n var sourceCodeStrWin = new StringBuilder(\"\");\n@@ -345,6 +369,14 @@ sourceCodeStrWin.Append($@\"\n public Window()\n {{\n SlintAPI.Create(_slintFile);\n+\n+ // this will run only after the UI is ready\n+ Slint.Timer.Start(TimerMode.SingleShot, 1, () => {{\n+ // then we can call the Init method\n+ SlintInitializationPool.POOL.ForEach(i => {{\n+ i.Init();\n+ }});\n+ }});\n }}\n\n public void Run()\ndiff --git a/SlintDotnet/Types.cs b/SlintDotnet/Types.cs\nnew file mode 100644\nindex 0000000..a38ae6a\n--- /dev/null\n+++ b/SlintDotnet/Types.cs\n@@ -0,0 +1,20 @@\n+\n+namespace Slint;\n+\n+public enum SlintType {\n+ STRING = 0,\n+ NUMBER = 1,\n+ BOOL = 2,\n+ IMAGE = 3,\n+ STRUCT = 4,\n+ ARRAY = 5\n+}\n+\n+\n+public interface SlintInitialization {\n+ void Init();\n+}\n+\n+public class SlintInitializationPool {\n+ public static List POOL = new();\n+}","shortMessageHtmlLink":"SlintDotnet: Add Array<string> support"}},{"before":"ca40c4bc02c90042f7f46a295215d77a2ab9e154","after":"473f7c9a7fd38a0c5c8be1fbc79b231da413ce9c","ref":"refs/heads/main","pushedAt":"2024-07-22T14:14:35.000Z","pushType":"push","commitsCount":2,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"settings: Enable type hints for C# inlay hints\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"settings: Enable type hints for C# inlay hints"}},{"before":"ced3b545d2a3d35d9bc1df3e9812cc43006f11d9","after":"ca40c4bc02c90042f7f46a295215d77a2ab9e154","ref":"refs/heads/main","pushedAt":"2024-07-21T02:51:25.000Z","pushType":"push","commitsCount":3,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"lib: Add support for arrays in the DotNetValue\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"lib: Add support for arrays in the DotNetValue"}},{"before":"8230a3403124567552048177f3ecadfbe2e4bdba","after":"ced3b545d2a3d35d9bc1df3e9812cc43006f11d9","ref":"refs/heads/main","pushedAt":"2024-04-15T14:13:51.000Z","pushType":"push","commitsCount":2,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Fix path to slint ui file\n\nNow the path to the slint ui file is relative to the binary path, this\nway it will work when the binary is executed from another directory.\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Fix path to slint ui file"}},{"before":"f01cf3ff36eeec58eb57979b5ff4f231d889b7c4","after":"8230a3403124567552048177f3ecadfbe2e4bdba","ref":"refs/heads/main","pushedAt":"2024-04-01T02:29:19.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"Upgrade to Slint 1.5.1\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"Upgrade to Slint 1.5.1"}},{"before":"693c01ea90234fe9f757b29f2a19183697081a7f","after":"f01cf3ff36eeec58eb57979b5ff4f231d889b7c4","ref":"refs/heads/main","pushedAt":"2024-02-06T16:22:57.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"lib/SlintDotnet: bump Slint to v1.4.1\n\nThis was very straightforward, I just had to update the version,\nand done!\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"lib/SlintDotnet: bump Slint to v1.4.1"}},{"before":"a9cd66a73380eb34bd4b1491cccafa643e3c4c7c","after":"693c01ea90234fe9f757b29f2a19183697081a7f","ref":"refs/heads/main","pushedAt":"2024-01-02T11:56:22.000Z","pushType":"push","commitsCount":3,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Implement the get method for the callback\n\nNow we can invoke the callback from the C# code.\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Implement the get method for the callback"}},{"before":"b52a7b635c77ed45284fc558f2a324a2cca264e8","after":"a9cd66a73380eb34bd4b1491cccafa643e3c4c7c","ref":"refs/heads/main","pushedAt":"2023-12-31T19:37:44.000Z","pushType":"push","commitsCount":2,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Bump to version 1.2.28\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Bump to version 1.2.28"}},{"before":"c992a4e3cabc31867801ffc154246afd3549ac22","after":"b52a7b635c77ed45284fc558f2a324a2cca264e8","ref":"refs/heads/main","pushedAt":"2023-12-30T23:14:38.000Z","pushType":"push","commitsCount":4,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"Release v1.2.26\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"Release v1.2.26"}},{"before":"2f49573aa8ed864b1b129f453dfc3cb282b65d67","after":"c992a4e3cabc31867801ffc154246afd3549ac22","ref":"refs/heads/main","pushedAt":"2023-12-21T17:58:28.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Bump the libslint_dotnet version to 1.2.22\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Bump the libslint_dotnet version to 1.2.22"}},{"before":"ee7177fbdb294b39c35279fc22ec23673fbfb5cc","after":"2f49573aa8ed864b1b129f453dfc3cb282b65d67","ref":"refs/heads/main","pushedAt":"2023-12-21T15:22:45.000Z","pushType":"push","commitsCount":3,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"cargo: Rollback to Slint v1.2.2\n\nThere are some issues with Slint v1.3 and WSL 2, what make\ndifficult to follow the development flow of SlintDotnet\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"cargo: Rollback to Slint v1.2.2"}},{"before":"2235ffe479ccc73821613ad27264a15cc58d56d3","after":"ee7177fbdb294b39c35279fc22ec23673fbfb5cc","ref":"refs/heads/main","pushedAt":"2023-12-20T03:19:30.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"cargo: Bump slint to 1.3.2\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"cargo: Bump slint to 1.3.2"}},{"before":"f22c78064c247f418badd3a246afbb90c34dfcb1","after":"2235ffe479ccc73821613ad27264a15cc58d56d3","ref":"refs/heads/main","pushedAt":"2023-12-20T03:18:46.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"lib: Remove trailing whitespaces\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"lib: Remove trailing whitespaces"}},{"before":"52121dd8e993ae2575109dc922f6b2bd5f7289c2","after":"f22c78064c247f418badd3a246afbb90c34dfcb1","ref":"refs/heads/main","pushedAt":"2023-09-25T20:57:31.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Update the README\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Update the README"}},{"before":"728e63c5bdc0c062ea1ffd07ddef26e93927cd15","after":"52121dd8e993ae2575109dc922f6b2bd5f7289c2","ref":"refs/heads/main","pushedAt":"2023-09-25T04:04:23.000Z","pushType":"push","commitsCount":2,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Implement struct set\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet: Implement struct set"}},{"before":"dc79bd11ca95fa1dda94d6abb3183fe8d27a4804","after":"728e63c5bdc0c062ea1ffd07ddef26e93927cd15","ref":"refs/heads/main","pushedAt":"2023-09-23T01:22:35.000Z","pushType":"push","commitsCount":6,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet 1.2.20\n\n- New timer stop and restart methods;\n- New RunOnUiThread method;\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"SlintDotnet 1.2.20"}},{"before":"c8a0dc8d09b8e6af7693da959e80656b6fc42fe4","after":"dc79bd11ca95fa1dda94d6abb3183fe8d27a4804","ref":"refs/heads/main","pushedAt":"2023-09-21T02:15:02.000Z","pushType":"push","commitsCount":1,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"Add a README.md file\n\nSigned-off-by: Matheus Castello ","shortMessageHtmlLink":"Add a README.md file"}},{"before":null,"after":"c8a0dc8d09b8e6af7693da959e80656b6fc42fe4","ref":"refs/heads/main","pushedAt":"2023-09-20T23:58:36.000Z","pushType":"branch_creation","commitsCount":0,"pusher":{"login":"microhobby","name":"Matheus Castello","path":"/microhobby","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/2633321?s=80&v=4"},"commit":{"message":"SlintDotnet: Add the C# source generator\n\nWe should create some more easy to use Window class that will be\ngenerated by the source generator.\n\nSigned-off-by: Matheus Castello \n\ndiff --git a/SlintDotnet/Generator.cs b/SlintDotnet/Generator.cs\nnew file mode 100644\nindex 0000000..2bfd969\n--- /dev/null\n+++ b/SlintDotnet/Generator.cs\n@@ -0,0 +1,208 @@\n+using System.Text;\n+using SlintAPI = SlintDotnet.SlintDotnet;\n+using Microsoft.CodeAnalysis;\n+using Microsoft.CodeAnalysis.Text;\n+using System.Runtime.InteropServices;\n+\n+namespace SlintDotnet.SourceGenerator;\n+\n+[Generator]\n+public class Generator : ISourceGenerator\n+{\n+ public void Execute(GeneratorExecutionContext context)\n+ {\n+ // FUCK OFF ROSLYN\n+ var home = Environment.GetEnvironmentVariable(\"HOME\");\n+ var arch = RuntimeInformation.OSArchitecture.ToString().ToLowerInvariant();\n+\n+ string assemblyProbeDirectory = $\"{home}/.nuget/packages/slintdotnet/1.2.19/runtimes/linux-{arch}/native/\";\n+ Directory.SetCurrentDirectory(assemblyProbeDirectory);\n+\n+ var sourceCodeStrWin = new StringBuilder(\"\");\n+ // get the context file without the extension and path\n+ var path = context.AdditionalFiles\n+ .Single(t => t.Path.EndsWith(\".slint\"))\n+ .Path;\n+ // get the slint filename\n+ var fileName = Path.GetFileNameWithoutExtension(path);\n+\n+ var tokens = SlintAPI.Interprete(path);\n+\n+// add the namespace and class\n+sourceCodeStrWin.Append($@\"\n+using Slint;\n+using SlintAPI = SlintDotnet.SlintDotnet;\n+\n+namespace {fileName};\n+\n+public class Window\n+{{\n+ private string _slintFile = \"\"./ui/{fileName}.slint\"\";\n+\");\n+\n+ var properties = tokens.props;\n+\n+ foreach (var property in properties)\n+ {\n+ var valType = property.typeType switch\n+ {\n+ 0 => \"string\",\n+ 1 => \"float\",\n+ 2 => \"bool\",\n+ 3 => \"Image\",\n+ _ => \"string\"\n+ };\n+\n+ var valTypeRust = property.typeType switch\n+ {\n+ 0 => \"String\",\n+ 1 => \"Number\",\n+ 2 => \"Bool\",\n+ 3 => \"Image\",\n+ _ => \"String\"\n+ };\n+\n+// add the properties\n+sourceCodeStrWin.Append($@\"\n+\n+ private {valType} _{property.typeName};\n+ public {valType} {property.typeName} {{\n+ get {{\n+\");\n+\n+ if (valType != \"Image\") {\n+sourceCodeStrWin.Append($@\"\n+ var rT = SlintAPI.GetProperty(\"\"{property.typeName}\"\")\n+ .typeValue\n+ .Replace(\"\"Value::{valTypeRust}(\"\", \"\"\"\")\n+ .Replace(\"\")\"\", \"\"\"\");\n+\n+\");\n+ } else {\n+sourceCodeStrWin.Append($@\"\n+ var rT = _{property.typeName};\n+\");\n+ }\n+\n+ if (valType == \"string\") {\n+sourceCodeStrWin.Append($@\"\n+ return rT;\n+\");\n+ } else if (valType == \"float\") {\n+sourceCodeStrWin.Append($@\"\n+ return float.Parse(rT);\n+\");\n+ } else if (valType == \"bool\") {\n+sourceCodeStrWin.Append($@\"\n+ return bool.Parse(rT);\n+\");\n+ } else {\n+sourceCodeStrWin.Append($@\"\n+ return rT;\n+\");\n+ }\n+\n+sourceCodeStrWin.Append($@\"\n+ }}\n+\n+ set {{\n+ _{property.typeName} = value;\n+ SlintAPI.SetProperty(new SlintAPI.DotNetValue {{\n+ typeName = \"\"{property.typeName}\"\",\n+\");\n+\n+ if (valType == \"string\") {\n+sourceCodeStrWin.Append($@\"\n+ typeType = 0,\n+ typeValue = value.ToString()\n+\");\n+ } else if (valType == \"float\") {\n+sourceCodeStrWin.Append($@\"\n+ typeType = 1,\n+ typeValue = value.ToString()\n+\");\n+ } else if (valType == \"bool\") {\n+sourceCodeStrWin.Append($@\"\n+ typeType = 2,\n+ typeValue = value.ToString()\n+\");\n+ } else if (valType == \"Image\") {\n+sourceCodeStrWin.Append($@\"\n+ typeType = 3,\n+ typeValue = value.Path\n+\");\n+ } else {\n+sourceCodeStrWin.Append($@\"\n+ typeType = 0,\n+ typeValue = value.ToString()\n+\");\n+ }\n+\n+sourceCodeStrWin.Append($@\"\n+ }});\n+ }}\n+ }}\n+\n+\");\n+ }\n+\n+ var methods = tokens.calls;\n+\n+ foreach (var method in methods)\n+ {\n+ // convert to camel case\n+ var parts = method.Split('-');\n+ var camelName = \"\";\n+ foreach (var part in parts) {\n+ camelName += Char.ToUpperInvariant(part[0]) + part.Substring(1);\n+ }\n+\n+// methods\n+sourceCodeStrWin.Append($@\"\n+ private Action _{camelName};\n+ public Action {camelName} {{\n+ set {{\n+ _{camelName} = value;\n+ SlintAPI.SetCallback(\"\"{method}\"\", () => {{\n+ _{camelName}?.Invoke();\n+ return true;\n+ }});\n+ }}\n+ }}\n+\");\n+\n+ }\n+\n+// constructor and run\n+sourceCodeStrWin.Append($@\"\n+\n+ public Window()\n+ {{\n+ Console.WriteLine(\"\"Hello from {fileName}!\"\");\n+ SlintAPI.Create(_slintFile);\n+ }}\n+\n+ public void Run()\n+ {{\n+ SlintAPI.Run();\n+ }}\n+\");\n+\n+\n+// end\n+sourceCodeStrWin.Append($@\"\n+}}\n+\");\n+\n+ var sourceCode = SourceText.From(\n+ sourceCodeStrWin.ToString(),\n+ Encoding.UTF8\n+ );\n+\n+ context.AddSource($\"{fileName}.g.cs\", sourceCode);\n+ }\n+\n+ public void Initialize(GeneratorInitializationContext context)\n+ {\n+ }\n+}","shortMessageHtmlLink":"SlintDotnet: Add the C# source generator"}}],"hasNextPage":false,"hasPreviousPage":false,"activityType":"all","actor":null,"timePeriod":"all","sort":"DESC","perPage":30,"cursor":"djE6ks8AAAAElylKtgA","startCursor":null,"endCursor":null}},"title":"Activity · microhobby/slint-dotnet"}