aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--elymas/lib/ffi/gtk.ey65
-rw-r--r--examples/working-shared/gtk.ey48
2 files changed, 113 insertions, 0 deletions
diff --git a/elymas/lib/ffi/gtk.ey b/elymas/lib/ffi/gtk.ey
new file mode 100644
index 0000000..c923ee4
--- /dev/null
+++ b/elymas/lib/ffi/gtk.ey
@@ -0,0 +1,65 @@
+# GTK+ support
+
+<
+ sys .so ":" via
+
+ "libgtk-3.so" :dlopen --
+ "libgdk-3.so" :dlopen --
+ "libatk-1.0.so" :dlopen --
+ "libgio-2.0.so" :dlopen --
+ "libpangocairo-1.0.so" :dlopen --
+ "libgdk_pixbuf-2.0.so" :dlopen --
+ "libcairo-gobject.so" :dlopen --
+ "libpango-1.0" :dlopen --
+ "libcairo.so" :dlopen --
+ "libgobject-2.0.so" :dlopen --
+ "libglib-2.0.so" :dlopen --
+
+ { _ "g_" -01 cat -1032 :resolveFunction -01 deffd }' "-->" deffd
+ { _ "gtk_" -01 cat -1032 :resolveFunction -01 deffd }' "->" deffd
+
+ # GC protection for callbacks
+ map ==references
+ { _ _ sys .asm .rawAddress txt .produce .u references =[] } /reference deffd
+
+ "si" "p" ->application_new
+ "p" "p" ->application_window_new
+
+ "pip" "i64" -->application_run
+ "p" "" -->application_quit
+ "p" "" -->object_unref
+ { -2103 "pp" "" :wrapCallback reference -0321 } "g_signal_connect_data" "pscppi" "" :resolveFunction ; /signal_connect_data deffd
+
+ "pp" "" ->container_add
+ "pi" "" ->container_set_border_width
+
+ "p" "" ->widget_show_all
+ "p" "" ->widget_destroy
+ "pi" "" ->widget_set_hexpand
+ "pi" "" ->widget_set_vexpand
+
+ "" "p" ->grid_new
+ "ppiiii" "" ->grid_attach
+
+ "pp" "p" ->scrolled_window_new
+
+ "ps" "" ->window_set_title
+ "pii" "" ->window_set_default_size
+
+ "i" "p" ->button_box_new
+ "s" "p" ->button_new_with_label
+
+ "" "p" ->text_view_new
+ "pi" "" ->text_view_set_editable
+ "pi" "" ->text_view_set_cursor_visible
+ "p" "p" ->text_view_get_buffer
+
+ { _ len } "gtk_text_buffer_set_text" "psi" "" :resolveFunction ; /text_buffer_set_text deffd
+
+ 0 ==:ORIENTATION_HORIZONTAL
+ 1 ==:ORIENTATION_VERTICAL
+
+ 2 ==:CONNECT_SWAPPED
+> /gtk ffi .defv
+
+# vim: syn=elymas
diff --git a/examples/working-shared/gtk.ey b/examples/working-shared/gtk.ey
new file mode 100644
index 0000000..08fc488
--- /dev/null
+++ b/examples/working-shared/gtk.ey
@@ -0,0 +1,48 @@
+"lib/ffi.ey" include
+"lib/ffi/gtk.ey" include
+
+{ γbutton_new_with_label } "β" deffd
+{ -2201 0 0 0 γsignal_connect_data } "<-" deffd
+
+ffi .gtk "γ" via
+"org.gtk.example" 0 γapplication_new ==app
+app "activate" {
+ app γapplication_window_new ==win
+ win "Window" γwindow_set_title
+ win 200 200 γwindow_set_default_size
+
+ γORIENTATION_HORIZONTAL γbutton_box_new ==box
+ win 10 γcontainer_set_border_width
+
+ γgrid_new ==grid
+ win grid γcontainer_add
+
+ βHello World!
+ { "Hello World!" dump } <-clicked
+ grid -01 0 0 1 1 γgrid_attach
+
+ βFinish
+ { win γwidget_destroy } <-clicked
+ grid -01 1 0 1 1 γgrid_attach
+
+ γtext_view_new ==txt
+ txt 0 γtext_view_set_editable
+ txt 0 γtext_view_set_cursor_visible
+ txt γtext_view_get_buffer
+ sys .file "φ" via "gtk.ey" φopen 65536 φread φclose
+ γtext_buffer_set_text
+
+ 0 0 γscrolled_window_new ==scroll
+ scroll txt γcontainer_add
+ scroll 1 γwidget_set_hexpand
+ scroll 1 γwidget_set_vexpand
+ grid scroll 0 1 2 1 γgrid_attach
+
+ win γwidget_show_all
+} 0 0 0 γsignal_connect_data
+app 0 "" γapplication_run
+app γobject_unref
+
+"Killing threads with fire" die
+
+# vim: syn=elymas