 M:: gtk-ui-backend (open-window) ( world -- )
     GTK_WINDOW_TOPLEVEL gtk_window_new :> win
     gtk_im_multicontext_new :> im
-    
+
     win im <window-handle> world handle<<
 
     world win register-window

! Copyright (C) 2010 Anton Gorenko, Philipp Brüschweiler.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien.accessors alien.c-types alien.data
alien.strings arrays assocs classes.struct command-line
destructors gdk.ffi gdk.gl.ffi glib.ffi gobject.ffi gtk.ffi
gtk.gl.ffi io.backend io.backend.unix.multiplexers
io.encodings.utf8 io.thread kernel libc literals locals math
math.bitwise math.order math.vectors namespaces sequences
strings system threads ui ui.backend ui.clipboards ui.commands
ui.event-loop ui.gadgets ui.gadgets.editors ui.gadgets.menus
ui.gadgets.private ui.gadgets.worlds ui.gestures
ui.pixel-formats ui.pixel-formats.private ui.private ;
IN: ui.backend.gtk

SINGLETON: gtk-ui-backend

TUPLE: handle ;
TUPLE: window-handle < handle window fullscreen? im-context im-menu ;

: <window-handle> ( window im-context -- window-handle )
    window-handle new

    nip [ f gtk_im_context_set_client_window ]
    [ g_object_unref ] bi ;

:: configure-im ( win im -- )
    im win gtk_widget_get_window gtk_im_context_set_client_window
    im f gtk_im_context_set_use_preedit
    
    im "commit" [ on-commit yield ]
    GtkIMContext:commit win connect-signal-with-data
