Replies: 28 comments 1 reply
-
The Gtk backend in Xamarin.Forms and MAUI is maintained by the community. We could update GtkSharp to use gtk 3 with .NET Standard. It is something that could fit into Xamarin.Forms earlier. Before should do tests and validate that there is no problems in the gtk bindings in something necessary by the Backend https://github.com/gtksharp/gtksharp/issues
On the other hand, other dependencies such as WebKit, etc. would have to be updated too. |
Beta Was this translation helpful? Give feedback.
-
community : whats your suggestion? If there would be an PR into Xamarin.Forms / Gtk , would it be accepted (if working, of cause) and later come into MAUI? Or PR here? WebKit: this works with https://github.com/gtksharp/gtksharp : |
Beta Was this translation helpful? Give feedback.
-
Which gtksharp 2 do you use to be compatible with .net core? We thought gtksharp for net core only supported 3. It would be awesome for us to still support 2 because that would greatly help migrating our guis to net core before jumping to 3. |
Beta Was this translation helpful? Give feedback.
-
as far as i know, there is no support for gtk2 over .netstandard / .net core. you have to migrate to gtksharp (= Gkt 3.2) first. |
Beta Was this translation helpful? Give feedback.
-
But then, how do you do it in maui? Isn't it full .net core? |
Beta Was this translation helpful? Give feedback.
-
.NET Framework implements .NET Standard. GTK2 projects are .NET Framework projects. |
Beta Was this translation helpful? Give feedback.
-
I do not understand this. But you run maui on linux over gtk, don't you? 😊 |
Beta Was this translation helpful? Give feedback.
-
Mono runs on Linux. Mono projects are .NET Framework projects. |
Beta Was this translation helpful? Give feedback.
-
TODO:
remark: |
Beta Was this translation helpful? Give feedback.
-
So, maui on linux runs on mono? Not .net core? Yes, I'm familiar with Mono and Gtk (and also gtk on win and macos). We use gtksharp to create this gui: https://www.plasticscm.com/gallery#linux and xamarin.mac for this one: https://www.plasticscm.com/gallery#macos. The thing is that we'd love to standardize in .net core and remove mono if possible. That's why I'm asking. On linux, the problem is that we run mono + gtksharp 2, so to move to .net core, we'd do a double jump: gtk3 and net core. Just porting to net core would be enough if we could stay in gtk2, at least for a while. |
Beta Was this translation helpful? Give feedback.
-
maui targets .net 6, and will run on .net 6 on linux. i have no idea if it will target .netstandard2 (=running on mono / .net framework too) |
Beta Was this translation helpful? Give feedback.
-
Ok, so no good way to test it today on linux without mono, I guess. |
Beta Was this translation helpful? Give feedback.
-
if Microsoft agrees to use https://github.com/gtksharp/gtksharp , it could be fast to have a xamarin.forms-gtk based on gtksharp 3 / .netstandard2 for you, it could be a roadmap like this:
|
Beta Was this translation helpful? Give feedback.
-
Actually @lytico, I will propose not to use gtk at all since the basis is LGPL and hence not good for future one-executable scenarios due to Its viral nature during these cicumstances. Any opinions on this? Ohh I actually se now that gtk# it is GPL. That makes it totally useless for many scenarios and out of tune with. Net core MIT licensing. |
Beta Was this translation helpful? Give feedback.
-
License is GNU LIBRARY GENERAL PUBLIC LICENSE Version 2 Licencse of GtkSharp & gtk-sharp: I'm not a lawyer, but to my opinion it says in
so that one-executable scenarios are a legal usage. But if there are legal problems, I think it could be possible to add a sort of "classpath exception" concerning one-executable scenarios. The folowing people have to be asked for a license-addition or change, a lot of them are at microsoft now: https://github.com/mono/gtk-sharp/graphs/contributors |
Beta Was this translation helpful? Give feedback.
-
I think that it would be a good idea to port the Xamarin.Forms backend to that project. Actually, it was asked a while ago on the gtksharp/gtksharp project : GtkSharp/GtkSharp#72 As for the license, that's the first time I hear about the "Library General Public License". It seems that this is the old name of the "Lesser General Public License". That said, I'm not a lawyer, and I can't tell if that would cause any issue. I'm subscribing to this post though, because that's something I'm interested in. If Microsoft says it's OK and if there's a community group around it, I could be interested to be part of it. |
Beta Was this translation helpful? Give feedback.
-
FWIW, the license in GtkSharp/GtkSharp is just a copy of the mono/gtk-sharp license, so if that's not currently an issue, there's no reason it would be an issue to migrate |
Beta Was this translation helpful? Give feedback.
-
@lytico, that "Library" is interesting indeed! This is a variant of GPL I have not enountered. Me personally I think .NET Core licensing was made easy using MIT (later Apache also) which gives more liberties and requires less (provide source code) of the consumer. |
Beta Was this translation helpful? Give feedback.
-
Since the beginning of this year I'm working on a proof of concept for a GTK wrapper for C# (https://github.com/gircore/gir.core), which is quite different from GtkSharp. Perhaps it is worth thinking about the concept I choose in the context of MAUI, too. (Especially regarding the target of .NET 6)
Through the two layer design it is possible to provide a stable API surface, even if the lower level GTK-API changes and obsoletes methods: This means less maintanance in depending projects. There could be different implementations on top of the lower level, e.g. one explicitly designed for F#. The lower level of the API is more or less completely generated (except like 4 structs, because it misses the generator for structs). The higher API level is "hand crafted" to create an API which explicitly meets the need of C# devs and is not just an object oriented wrapper around some C functions. The higher level is very easy to extend and to maintain, because my main concern with Gtk# is the complexity which I think is not needed to a large amount. Currently my implementation is delibarately missing deep integration into the GObject-Typesystem, which results in a quite simple codebase. It is just making the GObject classes available to C#. But of course it is possible to integrate into the C# classes and its hierachy. It is very easy to add new libraries. I already made proof of concepts for:
There is a dedicated webpage for the supported libraries: http://gircore.tiede.org/docs/SupportedLibraries The code is by no means complete or production ready. The generator for the low level code as it is now, is to complex for what it does and needs to be fixed. The code works for me with fedora 32. For other linux distributions there could be problems with the "*.so" files which could have different names. There is an example app in which I test my code: https://github.com/gircore/gir.core/tree/develop/GtkApp Perhaps MAUI is a good chance to create a simple and nice Wrapper-API for GTK, which is simple to create, easy to maintain and provides a simple API to use. Perhaps it is even s.th. new. If my code helps to find a matching solution, I would be very glad. |
Beta Was this translation helpful? Give feedback.
-
first draft (compiling, but not working) of Gtk3 - GtkSharp-Version is here: https://github.com/lytico/maui/tree/lytico_gtksharp Missing: |
Beta Was this translation helpful? Give feedback.
-
It would be better to prepare for gtk4 support which is apparently getting released later this year, the fall to be more specific (iirc). It is also finally getting constraint layouts (you support native widgets, right?) and hardware acceleration using either OpenGL or Vulkan, depending on what's available. Of course this would require either making preview bindings to gtk4 or waiting for it to release and then make bindings... |
Beta Was this translation helpful? Give feedback.
-
GtkSharp plans to have support for GKT4 |
Beta Was this translation helpful? Give feedback.
-
@badcel I see that you use the GIR files to generate the code in an automated way, and then you improve the API on them to get something more comfortable for C# developers. Have you found out about trying to use typelib files instead? To save yourself the step of generating the code, and then trying to "fix" the API. It is in this way that the bindings for Python or Javascript work, in turn allowing the use of practically any existing library based on GObject. If you think that this is not possible, then I think that it should be more prudent to generate a tool that allows correcting the API of a library simply by establishing rules for it. This is how Vala works, a language quite similar to C# created by GNOME. |
Beta Was this translation helpful? Give feedback.
-
@nahuelwexd, yes I took a look into the phyton bindings. My assumption is that because both languages are interpreted and dynamically typed it is easy to use libgirepository to access the typelib and in this way the "so" file. But I did not verify how they did it exactly. I considered a wrapper around libgirepository but this wrapper must be fed with the names of the methods to call. So there must be some C# glue code which provides method names to the libgirepositoy wrapper. This is what I already create: Some method names to access the "so" file directly without libgirepository and libffi. As far as I understand there must always be code generated or alternatively the code must be interpreted dynamically during runtime to access libgirepository. As C# is a compiled language I assume that if there needs to be some glue code, it should be in the C# style via DLL imports and not via libgirepository. But perhaps I'm wrong with this assumption? Actually the generated low level bindings are quite similar to the typelib file, they serve the same goal: allow access to the "so" file with native types. On top of it I generate c# friendly APIs. I would like to generate these friendly APIs but think it is quite hard. There are dependencies between functions which are not visible, like:
(e.g. this is in WebKitGtk). I want to provide just one function to call and get the result. Another point is for example that from my point of view gtk forces multiple classes into one. E.g. the GtkImage could be a "StockImage" which loads pictures from the current iconset via a magic string or just an image which is loaded from the harddisk. To avoid the task of describing the dependencies I want to define the public API manually, at least for now. If this is done the "stablized" API could be generated. I don't want this issue to get a discussion about creating GTK bindings. If you or anyone else is interested in bringing GTK bindings to C# which are more like a C# user expects it or has an opinion on this, head over to gircore repository and lets continue further discussion: Perhaps we can decide if adjusted GTK bindings are worthwile for .NET users and MAUI. |
Beta Was this translation helpful? Give feedback.
-
Maui risks running into the same support issue here that Xamarin.Forms did. Stating that it is supported by the 'community' doesn't magically create a community to support it. Xamarin.Forms got stuck on GTK2 because supported by the 'community' actually meant not supported by anyone. |
Beta Was this translation helpful? Give feedback.
-
If Microsoft are serious about having Maui linux supported by the 'community' then Microsoft needs to do things to build that 'community'. How are you planning to attract and incentivise that 'community' Here are some ideas:
I would love to see Microsoft reach out and work with the linux community here. But just stating it's supported by the 'community' isn't enough. |
Beta Was this translation helpful? Give feedback.
-
Work on https://github.com/gtksharp/gtksharp is going on, but if I'm right, MAUI is still using GtkSharp 2. Is there a plan to integrate Gtk3? |
Beta Was this translation helpful? Give feedback.
-
MAUI hasn't any Gtk-Backend at the moment. |
Beta Was this translation helpful? Give feedback.
-
Summary
Use https://github.com/gtksharp/gtksharp instead of https://github.com/mono/gtk-sharp
API Changes
adopt System.Maui.Platform.GTK to work with Gtk3
Intended Use Case
current implementation of System.Maui.Platform.GTK is based on outdated gtk 2
https://github.com/gtksharp/gtksharp is a .netstandard library and uses Gtk 3.22
so System.Maui.Platform.GTK - Backends can be targeted to dotnetcore - apps
Beta Was this translation helpful? Give feedback.
All reactions