From 91753258892c4a1fbf7ed43ff793a00ac0f77cf6 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 1 Jun 2019 10:22:23 +0200 Subject: [PATCH 4/4] textview editor example...BOOM. --- README | 7 ++++++ test/editor.scm | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 test/editor.scm diff --git a/README b/README index cb31e1e..0c2682b 100644 --- a/README +++ b/README @@ -27,3 +27,10 @@ Try: guix environment --ad-hoc -l guix.scm guile guile-gi test/example-1.scm guile-gi test/browser.scm + +Or, create and run in a development environment + + guix environment -l guix.scm + ./bootstrap && ./configure && make + tools/uninstalled-env tools/guile-gi test/browser.scm + tools/uninstalled-env tools/guile-gi test/editor.scm diff --git a/test/editor.scm b/test/editor.scm new file mode 100644 index 0000000..5294943 --- /dev/null +++ b/test/editor.scm @@ -0,0 +1,58 @@ +;; Copyright (C) 2019 Michael L. Gran +;; Copyright (C) 2019 Jan (janneke) Nieuwenhuizen + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +(use-modules (gi)) + +(typelib-load "Gio" "2.0") +(typelib-load "Gtk" "3.0") +(typelib-load "GLib" "2.0") +(typelib-load "WebKit2" "4.0") + +(define (print-goodbye widget data) + (display "Goodbye World\n")) + +(define (key-press widget event) + (display "key\n") + (format "key: ~s\n" event) + #f) + +(define (activate app user-data) + (let ((window (cast (ApplicationWindow-new app) )) + (vbox (cast (VBox-new 0 0) )) + (editor (cast (TextView-new) )) + (button-box (cast (ButtonBox-new 0) )) + (button (Button-new-with-label "Quit"))) + (send window (set-title "Window")) + (send window (set-default-size 200 200)) + (send window (show-all)) + (send window (add vbox)) + (send vbox (add editor)) + (send vbox (add button-box)) + (connect button (clicked print-goodbye #f)) + (connect button (clicked (lambda x + (send window (destroy))) + #f)) + ;; disable this and we are `fine' + (connect editor (key-press-event key-press #f)) ;; BOOM + (send editor (grab-focus)) + (send button-box (add button)) + (send window (show-all)))) + +(define (main) + (let ((app (Application-new "org.gtk.example" 0))) + (connect app (activate activate #f)) + (send app (run (length (command-line)) (command-line))))) + +(main) -- 2.21.0