Skip to content

[NOTES] Gtk Bindings Development

Maciej Łoziński edited this page Jan 3, 2020 · 22 revisions

GTK Bindings Development

Development of Linux backend for Red's Graphical User Interface, using version 3 of Gtk+ library.

Official repo's GTK branch is now a default development branch for GTK implementation. It moved from @rcqls' development branches, which are no longer a reference point.

Compilation (32-bit Linux)

(see rcqls/docker-red-gtk Dockerfile or reds project page for quick installation notes about red/GTK requirements)

  1. Install 32-bit dependencies: at-spi2-core, libgtk-3-bin
  2. Download code: git clone -b GTK
  3. Download REBOL: wget && tar xzvf rebol-core-278-4-3.tar.gz && cp releases/rebol-core/rebol red/
  4. cd red
  5. Edit environment/console/CLI/, and add Needs: View line inside Red [] block.
  6. Compile: echo 'Rebol[] do/args %red.r "-r %environment/console/CLI/"' | rebol +q -s
  7. Test: ./console tests/react.test should open a window with red/green/blue sliders that change color in a box next to them and color of text below them. More tests can be found in tests and tests/gtk3 folders. You can also run console in interactive mode: ./console and enter the line: view [button "hello"].

Developer notes

For GTK, use official GTK docs. Instead of using GTK3's recommended CSS-like API, we try to use deprecated low-level API, used also by SWT library

There is not much documentation available. You must rely on official View documentation and View code – modules/view folder in Red's sources. GTK implementation sits in modules/view/backends/gtk3, with most important files: gui.reds, gtk.reds, events.reds and handlers.reds.


Notes for experimental camera stuff

Last red binary and include preliminary camera stuff that require some further dependencies.

Let us notice that, from now, only one camera is detected at the device /dev/video0.

  • Inside .bah_profile (or equivalent):
export GST_V4L2_USE_LIBV4L2=1
  • gstreamer installation (Ubuntu example)
apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good 
  • optional installation (for further development)
apt-get install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-pulseaudio
  • in case plugin gtksink is not already installed in standard plugins above:
apt-get install gstreamer1.0-gtk3
  • for detection of webcam
apt-get install  libgudev-1.0-0
  • preliminary test to apply to check if gstreamer stuff is working properly
gst-launch-1.0 v4l2src ! videoconvert ! gtksink 

which launchs a camera viewer. Normally if this test passes camera is supposed to work inside red.

  • If you test red/tests/, debug mode needs to be deactivated (issue nothing related to camera).

Known problems

  • Some floating point arithmetic give strange results on GTK branch and a specific LOCALE. For example load "0.00000152" returns 0.0 or 5 / 2.0 returns 2,5.0.

There is a workaround for LOCALE bug. Just use "C" locale, like this: LC_ALL=C path/to/console-view

Clone this wiki locally
You can’t perform that action at this time.