gtk-ui-backend


Vocabulary
ui.backend.gtk

Definition
IN: ui.backend.gtk

SINGLETON: gtk-ui-backend


Methods
USING: accessors gtk.ffi kernel ui.backend ui.backend.gtk
ui.event-loop ui.private ;

M: gtk-ui-backend (close-window)
window>> [ gtk_widget_destroy ] [ unregister-window ] bi
event-loop? [ gtk_main_quit ] unless ;


USING: accessors gobject.ffi ui.backend.gtk ui.pixel-formats ;

M: gtk-ui-backend (free-pixel-format) handle>> g_object_unref ;


USING: accessors ui.backend ui.backend.gtk ;

M: gtk-ui-backend (fullscreen?) handle>> fullscreen?>> ;


USING: accessors gdk.ffi gtk.ffi kernel ui.backend
ui.backend.gtk ;

M: gtk-ui-backend (grab-input)
window>>
[ gtk_grab_add ] [ GDK_BLANK_CURSOR set-cursor ] bi ;


USING: gdk.gl.ffi kernel ui.backend.gtk ui.pixel-formats ;

M: gtk-ui-backend (make-pixel-format)
nip >gl-config-attribs-int-array gdk_gl_config_new ;


USING: accessors alien.strings gtk.ffi io.encodings.utf8 kernel
locals sequences ui.backend ui.backend.gtk ui.private ;

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 win world
[ window-loc>> auto-position ]
[ dim>> first2 gtk_window_set_default_size ] 2bi
win "factor" "Factor" [ utf8 string>alien ] bi@
gtk_window_set_wmclass world configure-gl
win gtk_widget_realize
win world window-controls>> configure-window-controls
win im configure-im win connect-user-input-signals
win connect-win-state-signals win gtk_widget_show_all ;


USING: accessors alien.data gdk.gl.ffi
gobject-introspection.standard-types kernel ui.backend.gtk
ui.pixel-formats ;

M: gtk-ui-backend (pixel-format-attribute)
[ handle>> ] [ >gl-config-attribs ] bi*
{ gint } [ gdk_gl_config_get_attrib drop ]
with-out-parameters ;


USING: accessors gtk.ffi kernel ui.backend ui.backend.gtk ;

M: gtk-ui-backend (set-fullscreen)
[ handle>> ] dip [ >>fullscreen? ] keep [ window>> ] dip
[ gtk_window_fullscreen ] [ gtk_window_unfullscreen ] if ;


USING: accessors gdk.ffi gtk.ffi kernel ui.backend
ui.backend.gtk ;

M: gtk-ui-backend (ungrab-input)
window>> [ gtk_grab_remove ] [ GDK_LEFT_PTR set-cursor ] bi
;


USING: alien.c-types alien.data destructors
gobject-introspection.standard-types gtk.ffi gtk.gl.ffi
ui.backend ui.backend.gtk ui.backend.gtk.io ui.private ;

M: gtk-ui-backend (with-ui)
[
0 gint <ref> f void* <ref> gtk_init 0 gint <ref>
f void* <ref> gtk_gl_init
load-icon init-clipboard start-ui
[ [ [ gtk_main ] with-timer ] with-event-loop ]
with-destructors
] ui-running ;


USING: gdk.ffi ui ui.backend.gtk ;

M: gtk-ui-backend beep gdk_beep ;


USING: accessors gtk.ffi ui.backend ui.backend.gtk ;

M: gtk-ui-backend raise-window*
handle>> window>> gtk_window_present ;


USING: accessors gtk.ffi kernel sequences ui ui.backend.gtk ;

M: gtk-ui-backend resize-window
[ handle>> window>> ] [ first2 ] bi* gtk_window_resize ;


USING: accessors alien.strings gtk.ffi io.encodings.utf8 kernel
ui.backend ui.backend.gtk ;

M: gtk-ui-backend set-title
swap [ handle>> window>> ] [ utf8 string>alien ] bi*
gtk_window_set_title ;


USING: alien.strings destructors gtk.ffi io.encodings.utf8
kernel locals ui ui.backend.gtk ;

M:: gtk-ui-backend system-alert ( caption text -- )
[
f GTK_DIALOG_MODAL GTK_MESSAGE_WARNING GTK_BUTTONS_OK
caption utf8 string>alien f gtk_message_dialog_new
&gtk_widget_destroy [
text utf8 string>alien
f gtk_message_dialog_format_secondary_text
] [ gtk_dialog_run drop ] bi
] with-destructors ;


USING: environment kernel ui.backend ui.backend.gtk ;

M: gtk-ui-backend ui-backend-available?
"DISPLAY" os-env >boolean ;