GtkSharp / GtkSharp

.NET wrapper for Gtk and other related libraries
Other
887 stars 98 forks source link

Fixed StyleContext.GetProperty #286

Closed zii-dmg closed 1 year ago

zii-dmg commented 2 years ago

Fixes #285 but not every property type is working ("padding" is crashing very often). Added test section to samples.

lytico commented 1 year ago

it crashes on unkown properties, eg. "Font" System.Exception: Unknown type PangoFontDescription at GLib.Value.ToBoxed() in /home/data/Work/Programming/contrib/GtkSharp/Source/Libs/GLibSharp/Value.cs:line 439

lytico commented 1 year ago

anyway, this is maybe a follow up issue

zii-dmg commented 1 year ago
  1. For unknown properties StyleContext.GetProperty not fill GLib.Value and nothing is throwing exceptions (GLib.Value.Val returns null).
  2. StyleContext.GetProperty (gtk_style_context_get_property) should return only style properties according to docs, but it returns value of simple properties as well.
  3. Property "Font" is not exists, so GLib.Value.Val returns null, no exceptions.
  4. Property "font" is exists, GLib.Value.Val can't find type "Pango.FontDescription" in already loaded .NET assemblies, so throws exception for unknown .NET type.
  5. You can preload .NET "PangoSharp.dll" assembly by using something from it in code.
  6. There is algorithm to load assemblies when searching for .NET types, but it uses old assembly names from gtksharp 2 like "pango-sharp", so this assembly will never be found.
  7. Later I will submit fix for searching algorithm, so "PangoSharp.dll" will be loaded when searching.
zii-dmg commented 1 year ago

Submitted #385