Subject: [PATCH v3 39/47] gnu: Add go-github-com-mattn-go-gtk.

From: Raghav Gururajan <[email-masked]>
Date: Wed, 9 Jun 2021 13:00:14 -0400

* gnu/packages/golang.scm (go-github-com-mattn-go-gtk): New variable.
---
 gnu/packages/golang.scm | 135 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 135 insertions(+)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index d9a2f40285..691a5fed00 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -58,6 +58,7 @@
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages mp3)
@@ -72,6 +73,140 @@
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1))
 
+(define-public go-github-com-mattn-go-gtk
+  (let ((commit "af2e013261f57706ec683a61f85e8759a3faf6be")
+        (revision "1134"))
+    (package
+      (name "go-github-com-mattn-go-gtk")
+      (version (git-version "0.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri
+          (git-reference
+           (url "https://github.com/mattn/go-gtk")
+           (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "1zcvxz45iinamxnpvwf5ij9f6dk62bdbjg1vaggvyz79z5y9llk2"))))
+      (build-system go-build-system)
+      (arguments
+       `(#:unpack-path "github.com/mattn/go-gtk"
+         #:phases
+         (modify-phases %standard-phases
+           (replace 'build
+             (lambda* (#:key source system outputs search-paths build-flags unpack-path inputs #:allow-other-keys)
+               (for-each
+                (lambda (directory)
+                  ((assoc-ref %standard-phases 'build)
+                   #:source source
+                   #:system system
+                   #:outputs outputs
+                   #:search-paths search-paths
+                   #:build-flags build-flags
+                   #:unpack-path unpack-path
+                   #:inputs inputs
+                   #:import-path directory))
+                (list
+                 "github.com/mattn/go-gtk/gdk"
+                 "github.com/mattn/go-gtk/gdkpixbuf"
+                 "github.com/mattn/go-gtk/gio"
+                 "github.com/mattn/go-gtk/glib"
+                 "github.com/mattn/go-gtk/gtk"
+                 "github.com/mattn/go-gtk/gtkgl"
+                 "github.com/mattn/go-gtk/gtksourceview"
+                 "github.com/mattn/go-gtk/gtkspell"
+                 "github.com/mattn/go-gtk/pango"
+                 "github.com/mattn/go-gtk/tools/gogtkinfo"
+                 "github.com/mattn/go-gtk/tools/make_inline_pixbuf"))
+               #t))
+           (add-before 'check 'pre-check
+             (lambda _
+               ;; Tests require a running X server.
+               (system "Xvfb :1 +extension GLX &")
+               (setenv "DISPLAY" ":1")
+               ;; Tests write to $HOME.
+               (setenv "HOME" (getcwd))
+               ;; Tests look for $XDG_RUNTIME_DIR.
+               (setenv "XDG_RUNTIME_DIR" (getcwd))
+               ;; For missing '/etc/machine-id'.
+               (setenv "DBUS_FATAL_WARNINGS" "0")
+               #t))
+           (replace 'check
+             (lambda* (#:key source system outputs search-paths tests? unpack-path inputs #:allow-other-keys)
+               (for-each
+                (lambda (directory)
+                  ((assoc-ref %standard-phases 'check)
+                   #:source source
+                   #:system system
+                   #:outputs outputs
+                   #:search-paths search-paths
+                   #:tests? tests?
+                   #:unpack-path unpack-path
+                   #:inputs inputs
+                   #:import-path directory))
+                (list
+                 "github.com/mattn/go-gtk/gdk"
+                 "github.com/mattn/go-gtk/gdkpixbuf"
+                 "github.com/mattn/go-gtk/gio"
+                 "github.com/mattn/go-gtk/glib"
+                 "github.com/mattn/go-gtk/gtk"
+                 "github.com/mattn/go-gtk/gtkgl"
+                 "github.com/mattn/go-gtk/gtksourceview"
+                 "github.com/mattn/go-gtk/gtkspell"
+                 "github.com/mattn/go-gtk/pango"
+                 "github.com/mattn/go-gtk/tools/gogtkinfo"))
+               ;; ERROR: Println arg list ends with redundant newline.
+               ;;"github.com/mattn/go-gtk/tools/make_inline_pixbuf"))
+               #t))
+           (replace 'install
+             (lambda* (#:key source system outputs search-paths install-source? unpack-path inputs #:allow-other-keys)
+               (for-each
+                (lambda (directory)
+                  ((assoc-ref %standard-phases 'install)
+                   #:source source
+                   #:system system
+                   #:outputs outputs
+                   #:search-paths search-paths
+                   #:install-source? install-source?
+                   #:unpack-path unpack-path
+                   #:inputs inputs
+                   #:import-path directory))
+                (list
+                 "github.com/mattn/go-gtk/gdk"
+                 "github.com/mattn/go-gtk/gdkpixbuf"
+                 "github.com/mattn/go-gtk/gio"
+                 "github.com/mattn/go-gtk/glib"
+                 "github.com/mattn/go-gtk/gtk"
+                 "github.com/mattn/go-gtk/gtkgl"
+                 "github.com/mattn/go-gtk/gtksourceview"
+                 "github.com/mattn/go-gtk/gtkspell"
+                 "github.com/mattn/go-gtk/pango"
+                 "github.com/mattn/go-gtk/tools/gogtkinfo"
+                 "github.com/mattn/go-gtk/tools/make_inline_pixbuf"))
+               #t)))))
+      (native-inputs
+       `(("glib:bin" ,glib "bin")
+         ("go-github-com-stretchr-testify" ,go-github-com-stretchr-testify)
+         ("gtk+:bin" ,gtk+-2 "bin")
+         ("pkg-config" ,pkg-config)
+         ("xorg-server" ,xorg-server-for-tests)))
+      (inputs
+       `(("gdk-pixbuf" ,gdk-pixbuf+svg)
+         ("glib" ,glib)
+         ("gtk+" ,gtk+-2)
+         ("gtkgl" ,gtkglarea)
+         ("gtksourceview" ,gtksourceview-2)
+         ("gtkspell" ,gtkspell2)
+         ("pango" ,pango)))
+      (propagated-inputs
+       `(("go-github-com-mattn-go-pointer"
+          ,go-github-com-mattn-go-pointer)))
+      (home-page "https://github.com/mattn/go-gtk")
+      (synopsis "Go bindings for GTK")
+      (description "Go bindings for GTK.")
+      (license license:bsd-3))))
+
 (define-public go-github-com-jmshal-go-locale
   (let ((commit "eb00fb25cc61bca7a5331ae576ae4a3d5572a1e4")
         (revision "8"))
-- 
2.31.1