From f1ffa56b7ec078f0270eb6bba7a23faa11999db7 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 31 May 2019 00:54:18 +0200 Subject: [PATCH 1/4] webkit browser example. * test/browser.scm: New file. --- test/Makefile.am | 8 ++++++-- test/browser.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 test/browser.scm diff --git a/test/Makefile.am b/test/Makefile.am index 5fae67d..e87bf99 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -46,5 +46,9 @@ AM_SCM_LOG_FLAGS = --no-auto-compile -L $(abs_top_srcdir)/src -L $(abs_top_srcdi EXTRA_DIST = \ $(TESTS) \ lib.scm \ - automake-test-lib.scm \ - example-1.scm + automake-test-lib.scm + +exampledir = $(datadir)/doc/guile-gi +dist_example_DATA = \ + example-1.scm \ + browser.scm diff --git a/test/browser.scm b/test/browser.scm new file mode 100644 index 0000000..d262e53 --- /dev/null +++ b/test/browser.scm @@ -0,0 +1,52 @@ +;; 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-hello widget data) + (display "Hello World\n")) + +(define (activate app user-data) + (let ((window (cast (ApplicationWindow-new app) )) + (vbox (cast (VBox-new 0 0) )) + (browser (cast (WebView-new) )) + (button-box (cast (ButtonBox-new 0) )) + (button (Button-new-with-label "Hello World"))) + (send window (set-title "Window")) + (send window (set-default-size 200 200)) + (send window (show-all)) + (send window (add vbox)) + (send vbox (add browser)) + (send vbox (add button-box)) + + (connect button (clicked print-hello #f)) + (connect button (clicked (lambda x + (send window (destroy))) + #f)) + (send browser (load-uri "http://gnu.org/s/mes")) + (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