diff mbox series

[bug#53648] gnu: fcitx5-gtk: Add GTK 4 support.

Message ID 865yplz3mx.fsf@163.com
State Accepted
Headers show
Series [bug#53648] gnu: fcitx5-gtk: Add GTK 4 support. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Zhu Zihao Feb. 11, 2022, 5:42 p.m. UTC
You can test it with

# No immodule cache needed for GTK4
./pre-inst-env guix shell fcitx5-gtk:gtk4 celluloid
GUIX_GTK4_PATH=$GUIX_ENVIRONMENT/lib/gtk-4.0 celluloid

Comments

Ludovic Courtès Feb. 14, 2022, 1:36 p.m. UTC | #1
Hi,

Zhu Zihao <all_but_last@163.com> skribis:

>>From 0c23e8cbbfe8f0548b29176831a4358d41820159 Mon Sep 17 00:00:00 2001
> From: Zhu Zihao <all_but_last@163.com>
> Date: Mon, 31 Jan 2022 14:51:30 +0800
> Subject: [PATCH 1/2] gnu: fcitx5-gtk: Add GTK 4 support.
>
> * gnu/packages/fcitx5.scm (fcitx5-gtk)[arguments]:
> <configure-flags>: Enable GTK 4 IM module.
> <phases>: In 'patch-install-prefix', patch the install prefix of GTK 4 IM
> module.
> [inputs]: Add GTK 4.
> [outputs]: Add 'gtk4'.

[...]

>>From 429e4569a03af76a7fbd2b56726f35a1b38bc0b9 Mon Sep 17 00:00:00 2001
> From: Zhu Zihao <all_but_last@163.com>
> Date: Mon, 7 Feb 2022 13:55:26 +0800
> Subject: [PATCH 2/2] gnu: fcitx5-gtk: Split IM module output for different
>  version of GTK.
>
> * gnu/packages/fcitx5.scm (fcitx5-gtk)[arguments]: Use G-Expression.
>
> <phases>: Split input method module into different outputs for GTK2, GTK3 and GTK4.
>
> Now default output only provides GLib client of Fcitx5.
>
> [inputs]: Use label-less style inputs.
> [outputs]: Add new "gtk3" output.
>
> [synopsis]: Fix typo.
> [description]: Describe the functionality of each output.

Applied!

However, I wonder if this should not be split into several packages,
rather than several outputs.  The main reason is that merely building
fcitx5-gtk now requires pulling all three GTK+ versions, and GTK4 has a
lot more dependencies, some of which may be unavailable on platforms
other than x86_64.

WDYT?

Thanks,
Ludo’.
Zhu Zihao Feb. 16, 2022, 1:25 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:
> Applied!
>
> However, I wonder if this should not be split into several packages,
> rather than several outputs.  The main reason is that merely building
> fcitx5-gtk now requires pulling all three GTK+ versions, and GTK4 has a
> lot more dependencies, some of which may be unavailable on platforms
> other than x86_64.
>
> WDYT?
>
> Thanks,
> Ludo’.

Fcitx5-gtk doesn't provide option to build only GTK4 module(GLib client
must build), it may requires heavily patch work.
diff mbox series

Patch

From 429e4569a03af76a7fbd2b56726f35a1b38bc0b9 Mon Sep 17 00:00:00 2001
From: Zhu Zihao <all_but_last@163.com>
Date: Mon, 7 Feb 2022 13:55:26 +0800
Subject: [PATCH 2/2] gnu: fcitx5-gtk: Split IM module output for different
 version of GTK.

* gnu/packages/fcitx5.scm (fcitx5-gtk)[arguments]: Use G-Expression.

<phases>: Split input method module into different outputs for GTK2, GTK3 and GTK4.

Now default output only provides GLib client of Fcitx5.

[inputs]: Use label-less style inputs.
[outputs]: Add new "gtk3" output.

[synopsis]: Fix typo.
[description]: Describe the functionality of each output.
---
 gnu/packages/fcitx5.scm | 87 +++++++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 37 deletions(-)

diff --git a/gnu/packages/fcitx5.scm b/gnu/packages/fcitx5.scm
index 123418cd4f..9e1ccdd3eb 100644
--- a/gnu/packages/fcitx5.scm
+++ b/gnu/packages/fcitx5.scm
@@ -1,5 +1,5 @@ 
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020 Zhu Zihao <all_but_last@163.com>
+;;; Copyright © 2020, 2022 Zhu Zihao <all_but_last@163.com>
 ;;; Copyright © 2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -20,6 +20,7 @@ 
 (define-module (gnu packages fcitx5)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix gexp)
   #:use-module (guix git-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
@@ -196,48 +197,60 @@  (define-public fcitx5-gtk
         (base32 "07ip4sxf3q895pp7mivv2bdwcmqjnwrmv9pg99jk73cw9bgyq00n"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:tests? #f                      ;No test
-       #:configure-flags
-       (list (string-append "-DGOBJECT_INTROSPECTION_GIRDIR="
-                            %output "/share/gir-1.0")
-             (string-append "-DGOBJECT_INTROSPECTION_TYPELIBDIR="
-                            %output "/lib/girepository-1.0"))
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'patch-install-prefix
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out"))
-                   (gtk2 (assoc-ref outputs "gtk2"))
-                   (gtk4 (assoc-ref outputs "gtk4")))
-               ;; Install GTK+ 2 input method module to its own output.
-               (substitute* "gtk2/CMakeLists.txt"
-                 (("\\$\\{CMAKE_INSTALL_LIBDIR\\}")
-                  (string-append gtk2 "/lib")))
+     (list
+      #:tests? #f                       ;No test
+      #:configure-flags
+      #~(list (string-append "-DGOBJECT_INTROSPECTION_GIRDIR="
+                             #$output "/share/gir-1.0")
+              (string-append "-DGOBJECT_INTROSPECTION_TYPELIBDIR="
+                             #$output "/lib/girepository-1.0"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'patch-install-prefix
+            (lambda _
+              ;; Take care of different versions of GTK because this package
+              ;; provides IM module for GTK application to use input method.
+              (define (split-immodule gtk-version output)
+                (substitute* (string-append gtk-version "/CMakeLists.txt")
+                  (("\\$\\{CMAKE_INSTALL_LIBDIR\\}")
+                   (string-append output "/lib"))))
 
-               ;; Install for GTK 4.
-               (substitute* "gtk4/CMakeLists.txt"
-                 (("\\$\\{CMAKE_INSTALL_LIBDIR\\}")
-                  (string-append gtk4 "/lib")))))))))
+              (let ((gtk2 #$output:gtk2)
+                    (gtk3 #$output:gtk3)
+                    (gtk4 #$output:gtk4))
+                (for-each split-immodule
+                          '("gtk2" "gtk3" "gtk4")
+                          (list gtk2 gtk3 gtk4))))))))
     (inputs
-     `(("fcitx5" ,fcitx5)
-       ("fmt" ,fmt)
-       ("libxkbcommon" ,libxkbcommon)
-       ("gobject-introspection" ,gobject-introspection)
-       ("gtk2" ,gtk+-2)
-       ("gtk3" ,gtk+)
-       ("gtk4" ,gtk)
-       ("glib" ,glib)
-       ("libx11" ,libx11)
-       ("gettext" ,gettext-minimal)))
+     (list fcitx5
+           fmt
+           libx11
+           libxkbcommon
+           gettext-minimal
+           gobject-introspection
+           gtk+-2
+           gtk+
+           gtk
+           glib))
     (native-inputs
      (list extra-cmake-modules pkg-config
            `(,glib "bin")))           ;for glib-genmarshal
-    ;; TODO: Add "lib" output to reduce the closure size of "gtk2".
-    (outputs '("out" "gtk2" "gtk4"))
+    (outputs '("out" "gtk2" "gtk3" "gtk4"))
     (home-page "https://github.com/fcitx/fcitx5-gtk")
-    (synopsis "Glib based D-Bus client and GTK IM module for Fcitx 5")
-    (description "Fcitx5-gtk provides a Glib based D-Bus client and IM module
-for GTK+2/GTK+3 application.")
+    (synopsis "GLib-based D-Bus client and GTK IM module for Fcitx 5")
+    (description "Fcitx5-gtk provides the following functionality in the
+corresponding output:
+
+@table @code
+@item out
+GLib-based D-Bus client of Fcitx5.
+@item gtk2
+IM module for GTK+2 applications.
+@item gtk3
+IM module for GTK+3 applications.
+@item gtk4
+IM module for GTK4 applications.
+@end table")
     (license license:lgpl2.1+)))
 
 (define-public fcitx5-qt
-- 
2.34.0