Getting ready for GTK+ 3.0 - upgrading deprecated calls

14 views
Skip to first unread message

Neil Hodgson

unread,
Apr 30, 2011, 9:53:59 AM4/30/11
to scite-interest, scintilla-interest
Ubuntu 11.04 was recently released which makes it easier to
experiment with GTK+ 3.0. Over the next couple of days, I will upload
code to make Scintilla and SciTE work on GTK+ 3.0.

There are still some open issues. I don't think GTK+ 3.0 is ready
for widespread adoption yet but some are problems with Scintilla or
SciTE.

The first set of changes fixes almost all of the deprecated calls
in SciTE but avoids fixes that need to be conditional on which version
of GTK+ is used. It works on older versions of GTK+ back to 2.8 but
was mainly developed on 2.22 and 3.0.

The menu code was heavily rewritten to use GtkMenu, GtkMenuItem and
so on instead of the old GtkItemFactory API. It does not use the
'Action' API which could have allowed users to customize menus and
toolbars more easily but would have required more work. Removed the
menubar.detachable property as I didn't want to reimplement it and I
doubt anyone uses it. Otherwise menu behaviour appears identical to
me.

Toolbars were also rewritten although that was simpler. There are a
couple of visible changes: toolbar buttons don't shade as much when
hovered over and there is now an overflow menu on the right if there
are too many toolbar buttons for the window width.

There were other minor changes for window sizing (it is no longer
possible to make SciTE very small), the application icon, and
GTK_OBJECT was replaced with G_OBJECT. Hg holds all the changes in
change sets 3462 to 3467.

There are 3 remaining deprecation warnings on 2.22 which are from
drawing the divider between the two panes while moving it. These use a
special drawing mode that drew over all the subwindows which does not
appear possible with Cairo. I don't know how to fix this yet so on
GTK+ 3.0, you can't see where the split is while moving it.

GTK+ 3.0 on Ubuntu 11.04 draws with an ugly theme and doesn't link
up to the unified menu bar so displays menus inside its window. Many
warning messages appear at start-up complaining about menus:
(SciTE:8106): Gtk-WARNING **: Failed to load type module: (null)
`menu_proxy_module_load': bin/SciTE: undefined symbol: menu_proxy_module_load

To install GTK+ 3.0 development libraries on Ubuntu 11.04 use:
sudo apt-get install libgtk-3-dev

Neil

Neil Hodgson

unread,
May 1, 2011, 6:50:46 AM5/1/11
to scintilla-interest
The modifications needed to make Scintilla work on GTK+ 3.0 are now
available from Hg.

The code has been tested on GTK+ 2.8, 2.22, and 3.0.

Drawing surfaces are initialised on 3.0 differently to 2.x when
using Cairo. That is, there are now 3 initialisation paths: GDK
(original), GdkDrawable+Cairo (recent 2.x) and Cairo. This is because
3.0 changes to a new drawing callback 'draw' which provides a cairo_t*
and not the GdkDrawable* provided by the 2.x 'expose-event'. The
Scintilla type SurfaceID is a cairo_t on 3.0 and a GdkDrawable on 2.x.

The 'draw' callback, unlike 'expose-event' does not provide any
easy way to find out what parts of the window really need to be
redrawn - the 'damaged' region. Scintilla depends on this information
to optimize drawing. The actual drawing will be clipped away by the
context object (cairo_t) but Scintilla does work to prepare for the
drawing and can often just update the line that has changed. There is
probably a way to retrieve the damaged region from the cairo_t but I
haven't found it yet.

The palette code has been disabled as GTK+ 3 does not appear to
have any support for paletted displays which are quite unusual now.

The Bait test program works and looks like this:
http://scintilla.org/bait3.png. Notice how the scroll bars don't go
right into the corner. I don't know why this is and at one point
changed the code to include the corner in both scrollbars but this
problem does not occur in SciTE so I removed that tweak. The
scrollbars also look rather old, from some time around 1997.
The Bait source code, slightly modified for GTK+ 3 can be
downloaded from http://scintilla.org/bait.tgz

The changes for GTK+ 3.0 are in Hg change sets 3627 to 3640.

SciTE modified for GTK+ 3 should appear in a day or so.

I'm happy to release the GTK+ 3 support in an unoptimized and
perhaps buggy form as experimental code since it allows downstream
projects to start to move towards supporting GTK+ 3. I'm more worried
that the many changes have introduced bugs on 2.x, so please watch out
for any regressions.

Neil

Lex Trotman

unread,
May 1, 2011, 7:31:58 AM5/1/11
to scintilla...@googlegroups.com
> drawing and can often just update the line that has changed. There is
> probably a way to retrieve the damaged region from the cairo_t but I
> haven't found it yet.
>

Hi Neil,

My understanding from talking to some people experimenting with GTK3
(not from personal knowledge) is that the clip region of the cairo
context is set to the damage region, so you could get that by
cairo_copy_clip_rectangle_list or cairo_clip_extents for a single
bounding box.

Might be worth a try.

Cheers
Lex

Neil Hodgson

unread,
May 2, 2011, 2:55:44 AM5/2/11
to scintilla...@googlegroups.com
Lex Trotman:

> My understanding from talking to some people experimenting with GTK3
> (not from personal knowledge) is that the clip region of the cairo
> context is set to the damage region, so you could get that by
> cairo_copy_clip_rectangle_list or cairo_clip_extents for a single
> bounding box.

That works.

Neil

Neil Hodgson

unread,
May 2, 2011, 3:13:51 AM5/2/11
to scite-interest, scintilla-interest
The modifications needed to make SciTE work on GTK+ 3.0 are now
available from Hg.

The code has been tested on GTK+ 2.8, 2.22, and 3.0.

The changes for GTK+ 3.0 are in Hg change sets 3468 to 3480.

There is an issue with scroll bars first noticed in the Bait demo.
When a scrollbar overlaps the resizing widget in the corner of the
application window, it is shrunk back by the size of its arrow button
to avoid the overlap.

The divider between the panes can not be seen while it is moving.
Since it appears difficult to draw over all the windows, this may be
changed to live resizing like on Windows. This was tried in the early
days of SciTE on GTK+ and was too slow then but it may be OK now.

Neil

Reply all
Reply to author
Forward
0 new messages