In the earlier post I was exploring Standard Widget Toolkit. I have created simple application to see how SWT works. In this post I want to show couple of reasons, why SWT cannot be easily migrated from GTK+ 2.x to GTK 3.x .
Let’s approach this issue step by step.
What is GTK + ?
As I have found out from GTK+ Project website (http://www.gtk.org/) ” GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off tools to complete application suites.” GTK+ supports most widely used programming languages, thus making it one of the main tools in User Interface development.
How GTK+ is connected with SWT ?
As I have found out, GTK+ library is widely used in SWT.
How to build SWT with GTK+ 2.x ?
I have pulled SWT source code using tutorial from here and built it using following commands:
export JAVA_HOME=/usr/lib/jvm/java ./git/eclipse.platform.swt/bundles/org.eclipse.swt/bin/library sudo ./build.sh
Everything built just fine. However, problems started when I tried to built it with GTK+ 3.x.
How to build SWT with GTK+ 3.x ?
To be able to build SWT with GTK+ 3.x I have uncommented line
#define GDK_DISABLE_DEPRECATED
in:
./git/eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/os.h
After doing it, I tried to built again. Unfortunately this time built was not succesful.
Here is the sample of the output:
Building SWT/GTK+ for linux x86 gcc -O -Wall -DSWT_VERSION=4230 -DLINUX -DGTK -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -fPIC `pkg-config --cflags gtk+-2.0` -c os.c os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS__1gdk_1bitmap_1create_1from_1data’: os.c:4930:2: warning: implicit declaration of function ‘gdk_bitmap_create_from_data’ [-Wimplicit-function-declaration] os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS__1gdk_1color_1white’: os.c:5078:2: warning: implicit declaration of function ‘gdk_color_white’ [-Wimplicit-function-declaration] os.c: In function ‘Java_org_eclipse_swt_internal_gtk_OS__1gdk_1draw_1drawable’: os.c:5273:2: warning: implicit declaration of function ‘gdk_draw_drawable’ [-Wimplicit-function-declaration] ........
Why SWT cannot be built with GTK+ 3.x ?
After small research I have found out that some of the methods of GTK library that SWT uses are deprecated.
Complete guide on what need to be change to migrate from GTK+ 2.x to GTK+ 3.x can be found here .
Most depreciation are already resolved, except ones that are supposed to use Cairo graphics library for drawing. Next couple of months, I will be working on implementing Cairo library into SWT instead of deprecated gdk methods, so it could be successfully migrated to GTK+3.x.
More about Cairo in my next posts…
Check out more posts on “SWT migration From GTK+ 2 to GTK+ 3″
Tagged: Cairo graphics, Cairo library, GDK, gdk depricated, GTK+2. GTK, Gtk+3, how to build SWT, red hat, Standard Widget Tooklit, SWT, SWT migration to GTK 3