You might have noticed that a lot of code in SWT/GTK has that odd /*int*/ comment after a long declaration.
long /*int*/ list
I turns out the comment is needed for backwards 32 bit support.
So in general you should put it in parameter declarations and in variable declarations:
Control  _getChildren (long /*int*/ parentHandle)
long /*int*/ list = OS.gtk_container_get_children (parentHandle);
This is especially important in OS.java which is used to generate C code.
As Eclipse developers, when troubleshooting Eclipse, it is sometimes important to figure out how parts of a U.I are constructed.
When troubleshooting Eclipse bugs, I sometimes ask if you are running eclipse on gtk2 or gtk3.
Usually I can tell visually if Eclipse is running on Gtk2 or Gtk3, but this changes depending on your system theme.
In the about section
As Alexander Kurtakov pointed out and described in Lar’s article ,
Help -> About -> Installation Details -> Configuration Tab.
Look for something like:
It’s usually somewhere near line 84 ish. But you can copy the text and search for it in your text editor.
Note, if this line is missing altogether, you’re (very most likely) running Eclipse on Gtk2.
See what version is on your system
You can find out which version of gtk is installed on your system by running pkg-config (you might need to install it first). This gives you an indication of which version of gtk eclipse might be using.
pkg-config --modversion gtk+-3.0
Force Eclipse to use either gtk2 / gtk3
You can force Eclipse to use a certain version of gtk:
Under gtk3, the entry in the about section should be present like: org.eclipse.swt.internal.gtk.version=3.14.12
This is actually by far the most visited blog entry on my blog (20k+ views)
I reference this page quite often, I made a short/memorable url for it: http://bit.ly/gtk2orgtk3
When developing SWT widgets, we need to test them on various GTK versions to ensure backwards compatibility.
There are some tricks and perks involved.
Get Gtk sources
Configure Eclipse to use the gtk you compiled
- Edit your run-configuration of the code snippet that you want to run.
- Navigate to “Environmental Variables”
- Click on “Add”, type in:
path: #your_compiled_gtk //e.g /home/lufimtse/src/gtk3_10/gtk/.libs
- Name your configuration (I reccomend appending gtk version, e.g “ControlExample (g3-10)”)
- It should look something like this:
- Now run the configuration and you should see your application rendered in gtk*.*.
You may note that it won’t have any styling:
- The lack of styling is due to the fact that there is no theaming.
Now sometimes you might want the compiled gtk to use your system theame to see impact of themes on looks.
To do so, do as above except run the configuration as following:
./configure --prefix=/usr --sysconfdir=/etc --enable-broadway-backend --enable-x11-backend --disable-wayland-backend
In the interest of comparison: (left native look, right bare look)
- Lastly, in your source code, you might want to verify that you’re running the compiled gtk and not your own. Use this line of code:
System.out.println("GTK Version: " + OS.gtk_major_version() + "." + OS.gtk_minor_version() + "." + OS.gtk_micro_version());
Making a gtk3 application in eclipse can be somewhat tricky as one has to fix dependencies.
Lemme show you how to do it: