GtkSharp / GtkSharp

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

Custom widget - CSS name #340

Closed klasyc closed 1 year ago

klasyc commented 2 years ago

Hello,

I created a custom component by inheriting a Label widget. I would like to change its CSS name in order to distinguish it from a regular label widget - in other words in CSS file I would like to write myCustomWidget.myClass { ... } instead of label.myClass { ... }. This should be done by calling gtk_widget_class_set_css_name(), but I cannot find any corresponding function in GtkSharp API. Am I missing something or is it a shortcomming of GtkSharp?

Off-topic question: when I was reading the source code, I noticed that e.g. Gtk.Widget class is declared as partial, but I cannot find where the rest of class is defined... When displaying the class in Visual Studio, it takes the full class definition from the compiled library and that class has many extra functions compared to the source code. Where do these extra functions come from?

lytico commented 2 years ago

Off-topic question: ... Where do these extra functions come from?

the extra functions are generated by the programs in Source/Tools/Tools.sln this tools take the source definitions of the libs-directories (eg. https://github.com/GtkSharp/GtkSharp/blob/develop/Source/Libs/GtkSharp/GtkSharp-api.xml) and generate code. this generated code is written into the generated-directory of the respective library, eg. in case of GtkSharp in Source/Libs/GtkSharp/Generated. so, checkout GtkSharp, then call build (.sh or .ps1), which in turn compiles the tools, and execute them to generated the code.

gtk_widget_class_set_css_name

seems that it is missing. it's declared as shared in https://github.com/GtkSharp/GtkSharp/blob/develop/Source/Libs/GtkSharp/GtkSharp-api.xml, so maybe that's the problem. I have no idea why it's not generated.