diff mbox series

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

Message ID 86k0e4827w.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. 9, 2022, 3:54 p.m. UTC
I've clean the code.

Comments

M Feb. 9, 2022, 8:33 p.m. UTC | #1
users guix
usertags 53648 reviewed-looks-good
thanks

Zhu Zihao schreef op wo 09-02-2022 om 23:54 [+0800]:
> +                  (("¥¥$¥¥{CMAKE_INSTALL_LIBDIR¥¥}")
> +                   (string-append output "/lib"))))

Aside from the file encoding issue of the patch file (which the
committer might be in a better position to figure out), LGTM
(although I didn't personally test it.)

Greetings,
Maxime.
diff mbox series

Patch

From 49f3d7e4f8a07f546c49a894867c8c633dd58309 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..514c94ef2e 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
+           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