The last thing you need to add is the GtkRequisition structure so add a Structure to the Window and call it GtkRequisition, with two properties: Width As Int32 and Height As Int32.
Looking at the code you can see that it is looping through all the controls on the Window and updating any that are RectControls to use the size reported back from the gtk_widget_get_preferred_size Declare call. These parameters use the GtkRequisition structure which you will create in a moment. This method takes a reference to the control and then has two parameters that contain size information. This method has a Declare that calls gtk_widget_get_preferred_size in the libgtk-3 library. Control(iter) IsA RectControl Thenĭim rc As RectControl = RectControl(Window1. Gtk_widget_get_preferred_size(widget, minSize, naturalSize)įor iter As Integer = 0 To Window1. (widget As Integer, ByRef minSize As GtkRequisition, ByRef naturalSize As GtkRequisition)ĭim minSize, naturalSize As GtkRequisition Private Shared Sub RealizeCallback(widget As Integer, data As Ptr)ĭeclare Sub gtk_widget_get_preferred_size Lib "libgtk-3" _ Apple Books has lots of ways to help you find Computing & Internet books youll love.
Here is the code, which you can put on the Open event of a PushButton that has been added to a Window: Browse, buy and download Computing & Internet books from Apple Books. You will typically do that on the Open event of the control.
To start you first have to ask the Window Manager to let you know when the control has been "realized" (made available) so that you can request its default size. This information is provided by GTK+ in conjunction with the Window Manager. The problem on Linux is that you have different themes that dictate how much padding should go into a control, and the much larger default font size.Ī solution to this problem is to use Linux APs to get the default control size.
On Windows and macOS this almost never changes, so thankfully a 22 pixel high PushButton would look just fine on macOS, as it does on Windows. The main challenge of being a native Linux app is trying to normalize the UI experience across different platforms (yes, even different Linux distros).Īs each platform has their own native default control sizes and such, your app will most likely need to be adjusted accordingly. With the many different Window Managers and themes on Linux, and personal preferences, you can be assured that your UI will look different from one Linux user to the next.