modGtk3 for Xojo

Linux has always been kind of an odd duck when it comes to Xojo.  If you create Linux applications with the IDE running in Linux the default sizes for controls is 26 which is different than MacOS or Windows since their default control height is 22.  See the initial screenshot:  the controls in Linux just don’t look right at the default Mac/Win control height.

The standard answer for many years was to subclass your controls and modify the height of the controls in Linux.  This was okay but it hard to make your UI look good on all three target platforms.

Xojo 2017 R2 changed the drawing system it uses.  The switch to GTK3 made it possible to modify the CSS of your application theoretically making it possible to make all platforms look and behave the same.

Just because you can modify the CSS means it’s a trivial task.  Several long time Xojo community members Jim McKay and Jürg Otter stepped up to the plate and put in the time to figure it out.  The result is at https://bitbucket.org/pidog/modgtk3/src/master/.

In this screenshot you can see that everything looks as you’d expect.

Implementing this in your own project is simple.  Download the BitBucket repository, open the project in Xojo and copy the GTK3 folder into  your own project.  Then in the App.Open event put these three lines in:

modGTK3.initGtkEntryFix
modGTK3.initGtkWidgetHeightFix
modGTK3.InitGlobalGTK3Style

That’s it.  Voila!  Now your app looks better in Linux and there’s no need to subclass your controls.  I realize this isn’t magic but it sure seems like it.

Become a Part of the Community

If you’ve been working with REALbasic for more than 6 months I guarantee that you know how to do something in RB that someone else needs help with.  I frequent the RB forums and for the most part I’m too late in answering a question – that’s how good the community is.  I’ll add comments when and where it makes sense, but for the most part, a majority of the questions are answered by less than 30 people even though there are tens of thousands of people registered.

REALbasic is easy-to-use and it doesn’t take a lot of development knowledge to make applications but, at one point in time, all of us were beginners with REALbasic.  When we had questions we turned to the NUG list or to the REALbasic forums and asked (you searched first, right?) the ‘experts’.

So what are you giving back to the community?  In past nine months or so I’ve been creating little example projects based on the questions on the RB Forums and put them into the The Association of REALbasic Professionals (ARBP) source code repository (free registration required).  Here are few of the highlights:

  • Making a listbox popup menu
  • Multi-line listbox
  • Popup menu with icon example
  • Printing using the Graphics Object along with companion articles for printing with On-Target Reports and RS Report.
  • Stylegrid auto-height rows
  • SQLizing text (automatic formatting of a string so you can use it in an SQL string)
  • Calculator application

None of these projects are outstanding and they could certainly be done better but they are contributions to the community and someone might find them useful.  In fact, people are.  People have downloaded the hundreds of example projects and tutorials a lot.

The REALbasic community needs your experience and your input.  The first thing you can do is participate in the discussions on the RB forums.  Give advice and share your source code when you can.  There are tons of questions that get partial answers and you just might know how to help them.

Secondly, create some example projects demonstrating some very small technique.  Put them on your own website and link them to RBGarage or put them on ARBP.

Thirdly, think about giving something back to the community.  Hopfully you’ve gotten something from the REALbasic community and you can give something back.  Just because you think you’re not a ‘professional’ doesn’t mean you don’t have valuable insights and knowledge. Together we can come up with some amazing examples and help each other out.