From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: [PATCH] gtk+: Support GUIX_GTK{2,3}_PATH variables. Date: Thu, 03 Dec 2015 08:52:51 +0100 Message-ID: <877fkwotnw.fsf@elephly.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45052) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4OhM-0001yr-Ef for guix-devel@gnu.org; Thu, 03 Dec 2015 02:53:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4OhH-0000kE-Lo for guix-devel@gnu.org; Thu, 03 Dec 2015 02:53:04 -0500 Received: from sender163-mail.zoho.com ([74.201.84.163]:25254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4OhH-0000k6-DF for guix-devel@gnu.org; Thu, 03 Dec 2015 02:52:59 -0500 In-Reply-To: 87bncx54nh.fsf@elephly.net List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Guix, a couple of months ago we discussed how to make IBus and GTK themes work across different GTK versions. See: http://lists.gnu.org/archive/html/guix-devel/2015-09/msg00617.html To summarise, GTK itself only supports path environment variables that are recognised by *all* versions of GTK, such as GTK_EXE_PREFIX or GTK_PATH. This is a problem as modules built for GTK3 cannot be loaded by GTK2 (and vice versa). This can result in segfaults or other nasty effects that are hard to debug. The attached patches modify our gtk packages such that they apply patches against the GTK sources to enable support for two new environment variables: * GUIX_GTK2_PATH, which is honoured exclusively by gtk+ 2.x, and * GUIX_GTK3_PATH, which is only honoured by gtk+ 3.x Directories specified in these variables are searched first when GTK looks for modules, such as input method modules provided by IBus. A user would just set both of these variables such: export GUIX_GTK2_PATH=$HOME/.guix-profile/lib/gtk-2.0 export GUIX_GTK3_PATH=$HOME/.guix-profile/lib/gtk-3.0 With these variables set GTK2 will find the IBus input methods for GTK2 (and not those for GTK3), and vice versa. I rebuilt both GTKs in my profile, and rebuilt ibus, ibus-libpinyin, and xfce4-terminal and after removing some cached state (a problem which we’ll have to fix eventually) I could input Chinese characters on the terminal, indicating that the environment variables are in fact recognised. An additional patch to ibus-libpinyin was required because it previously only worked by accident as I had a package installed in my profile that also propagated gtk+. The third attached patch adds gtk-propagated inputs to ibus-libpinyin for the sole purpose of adding their girepository directories to the GI_TYPELIB_PATH with which we’re wrapping some executables. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-gnu-gtk-2-Add-patch-to-support-GUIX_GTK2_PATH.patch >From 87b0a54e92f51b885ea93ebc3e05c78fcfb94dcf Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 3 Dec 2015 08:30:04 +0100 Subject: [PATCH 1/3] gnu: gtk+-2: Add patch to support GUIX_GTK2_PATH. * gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH: New file. * gnu-system.am (dist_patch_DATA): Add it. * gnu/packages/gtk.scm (gtk+-2) [source]: Add patch. [native-search-paths]: Add search path for GUIX_GTK2_PATH. --- gnu-system.am | 1 + gnu/packages/gtk.scm | 9 ++++- .../patches/gtk2-respect-GUIX_GTK2_PATH.patch | 46 ++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch diff --git a/gnu-system.am b/gnu-system.am index 4e06853..677ade5 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -505,6 +505,7 @@ dist_patch_DATA = \ gnu/packages/patches/guile-present-coding.patch \ gnu/packages/patches/guile-relocatable.patch \ gnu/packages/patches/guile-rsvg-pkgconfig.patch \ + gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch \ gnu/packages/patches/gtkglext-disable-disable-deprecated.patch \ gnu/packages/patches/hop-bigloo-4.0b.patch \ gnu/packages/patches/hop-linker-flags.patch \ diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm index c0c0794..33feb2a 100644 --- a/gnu/packages/gtk.scm +++ b/gnu/packages/gtk.scm @@ -522,7 +522,8 @@ is part of the GNOME accessibility project.") name "-" version ".tar.xz")) (sha256 (base32 - "0mj6xn40py9r9lvzg633fal81xfwfm89d9mvz7jk4lmwk0g49imj")))) + "0mj6xn40py9r9lvzg633fal81xfwfm89d9mvz7jk4lmwk0g49imj")) + (patches (list (search-patch "gtk2-respect-GUIX_GTK2_PATH.patch"))))) (build-system gnu-build-system) (outputs '("out" "doc")) (propagated-inputs @@ -557,7 +558,11 @@ is part of the GNOME accessibility project.") ;; FIXME: re-enable tests requiring an X server (substitute* "gtk/Makefile.in" (("SUBDIRS = theme-bits . tests") "SUBDIRS = theme-bits ."))) - %standard-phases))) + %standard-phases))) + (native-search-paths + (list (search-path-specification + (variable "GUIX_GTK2_PATH") + (files '("lib/gtk-2.0"))))) (synopsis "Cross-platform toolkit for creating graphical user interfaces") (description "GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating diff --git a/gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch b/gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch new file mode 100644 index 0000000..93a8ddc --- /dev/null +++ b/gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch @@ -0,0 +1,46 @@ +This patch makes GTK+ look for additional modules in a list of directories +specified by the environment variable "GUIX_GTK2_PATH". This can be used +instead of "GTK_PATH" to make GTK+ find modules that are incompatible with +other major versions of GTK+. + +--- a/gtk/gtkmodules.c 2014-09-29 22:02:17.000000000 +0200 ++++ b/gtk/gtkmodules.c 2015-12-02 18:41:53.306396938 +0100 +@@ -55,6 +55,7 @@ + get_module_path (void) + { + const gchar *module_path_env; ++ const gchar *module_guix_gtk2_path_env; + const gchar *exe_prefix; + const gchar *home_dir; + gchar *home_gtk_dir = NULL; +@@ -70,6 +71,7 @@ + home_gtk_dir = g_build_filename (home_dir, ".gtk-2.0", NULL); + + module_path_env = g_getenv ("GTK_PATH"); ++ module_guix_gtk2_path_env = g_getenv ("GUIX_GTK2_PATH"); + exe_prefix = g_getenv ("GTK_EXE_PREFIX"); + + if (exe_prefix) +@@ -77,9 +79,21 @@ + else + default_dir = g_build_filename (GTK_LIBDIR, "gtk-2.0", NULL); + +- if (module_path_env && home_gtk_dir) ++ if (module_guix_gtk2_path_env && module_path_env && home_gtk_dir) ++ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, ++ module_guix_gtk2_path_env, module_path_env, home_gtk_dir, default_dir, NULL); ++ else if (module_guix_gtk2_path_env && home_gtk_dir) ++ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, ++ module_guix_gtk2_path_env, home_gtk_dir, default_dir, NULL); ++ else if (module_guix_gtk2_path_env && module_path_env) ++ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, ++ module_guix_gtk2_path_env, module_path_env, default_dir, NULL); ++ else if (module_path_env && home_gtk_dir) + module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, + module_path_env, home_gtk_dir, default_dir, NULL); ++ else if (module_guix_gtk2_path_env) ++ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, ++ module_guix_gtk2_path_env, default_dir, NULL); + else if (module_path_env) + module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S, + module_path_env, default_dir, NULL); -- 2.5.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0002-gnu-gtk-Add-patch-to-support-GUIX_GTK3_PATH.patch >From b8120ae8e21e234ffd0eb9f5de1d7809a0860c45 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 3 Dec 2015 08:32:06 +0100 Subject: [PATCH 2/3] gnu: gtk+: Add patch to support GUIX_GTK3_PATH. * gnu/packages/patches/gtk3-respect-GUIX_GTK3_PATH: New file. * gnu-system.am (dist_patch_DATA): Add it. * gnu/packages/gtk.scm (gtk+) [source]: Add patch. [native-search-paths]: Add search path for GUIX_GTK3_PATH. --- gnu-system.am | 1 + gnu/packages/gtk.scm | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gnu-system.am b/gnu-system.am index 677ade5..580bd66 100644 --- a/gnu-system.am +++ b/gnu-system.am @@ -506,6 +506,7 @@ dist_patch_DATA = \ gnu/packages/patches/guile-relocatable.patch \ gnu/packages/patches/guile-rsvg-pkgconfig.patch \ gnu/packages/patches/gtk2-respect-GUIX_GTK2_PATH.patch \ + gnu/packages/patches/gtk3-respect-GUIX_GTK3_PATH.patch \ gnu/packages/patches/gtkglext-disable-disable-deprecated.patch \ gnu/packages/patches/hop-bigloo-4.0b.patch \ gnu/packages/patches/hop-linker-flags.patch \ diff --git a/gnu/packages/gtk.scm b/gnu/packages/gtk.scm index 33feb2a..a4dd2d4 100644 --- a/gnu/packages/gtk.scm +++ b/gnu/packages/gtk.scm @@ -583,7 +583,8 @@ application suites.") name "-" version ".tar.xz")) (sha256 (base32 - "0lp1hn0qydxx03bianzzr0a4maqzsvylrkzr7c3p0050qihwbgjx")))) + "0lp1hn0qydxx03bianzzr0a4maqzsvylrkzr7c3p0050qihwbgjx")) + (patches (list (search-patch "gtk3-respect-GUIX_GTK3_PATH.patch"))))) (propagated-inputs `(("at-spi2-atk" ,at-spi2-atk) ("atk" ,atk) @@ -642,7 +643,11 @@ application suites.") (loaders.cache (find-files librsvg "^loaders\\.cache$"))) (wrap-program prog `("GDK_PIXBUF_MODULE_FILE" = ,loaders.cache)))) - %standard-phases)))))) + %standard-phases)))) + (native-search-paths + (list (search-path-specification + (variable "GUIX_GTK3_PATH") + (files '("lib/gtk-3.0"))))))) ;;; ;;; Guile bindings. -- 2.5.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0003-gnu-ibus-libpinyin-Include-more-directories-in-GI_TY.patch >From 2088ec24d2a69962310028d9cb686043fbde988d Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Thu, 3 Dec 2015 08:49:30 +0100 Subject: [PATCH 3/3] gnu: ibus-libpinyin: Include more directories in GI_TYPELIB_PATH. * gnu/packages/ibus.scm (ibus-libpinyin)[inputs]: Add "gdk-pixbuf", "at-spi2-atk", "atk", "pango". [arguments]: Add the new inputs' girepository-1.0 directories to the GI_TYPELIB_PATH. --- gnu/packages/ibus.scm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gnu/packages/ibus.scm b/gnu/packages/ibus.scm index 770d7ff..bec7964 100644 --- a/gnu/packages/ibus.scm +++ b/gnu/packages/ibus.scm @@ -135,6 +135,16 @@ may also simplify input method development.") "/lib/girepository-1.0"))) `("GI_TYPELIB_PATH" ":" prefix (,(string-append (assoc-ref inputs "ibus") + "/lib/girepository-1.0") + ,(string-append (assoc-ref inputs "gtk+") + "/lib/girepository-1.0") + ,(string-append (assoc-ref inputs "pango") + "/lib/girepository-1.0") + ,(string-append (assoc-ref inputs "gdk-pixbuf") + "/lib/girepository-1.0") + ,(string-append (assoc-ref inputs "at-spi2-atk") + "/lib/girepository-1.0") + ,(string-append (assoc-ref inputs "atk") "/lib/girepository-1.0")))) #t)))))) (inputs @@ -144,7 +154,14 @@ may also simplify input method development.") ("sqlite" ,sqlite) ("python" ,python-2) ("pyxdg" ,python2-pyxdg) - ("gtk+" ,gtk+))) + ("gtk+" ,gtk+) + + ;; These are propagated by gtk+, but we need them to add the + ;; girepository directories to the GI_TYPELIB_PATH. + ("gdk-pixbuf" ,gdk-pixbuf) + ("at-spi2-atk" ,at-spi2-atk) + ("atk" ,atk) + ("pango" ,pango))) (native-inputs `(("pkg-config" ,pkg-config) ("intltool" ,intltool) -- 2.5.0 --=-=-= Content-Type: text/plain ~~ Ricardo --=-=-=--