Web lists-archives.com

GTK2_PATH and GTK3_PATH




Hi,

I’m using GuixSD[1], a variant of the GNU system which does not follow
the FHS in order to provide declarative system configuration and
functional package management.  As the functional package manager
installs each package into its own directory under “/gnu/store”, the
GTK+ libraries are obviously not installed in the same global tree as
input method modules or themes.

When a user installs, say, an IBus input method into their profile at
“~/.guix-profile” they have no good way to tell the GTK libraries
(somewhere in “/gnu/store/...-gtk.../lib”) about the location of these
modules.  As a user may have applications of which some use GTK+ 2 and
others use GTK+ 3, the usual GTK+ environment variables cannot be used
to direct a particular version of GTK+ to load compatible modules from a
given path.

The documentation at [2] explicitly warns about setting GTK_PATH or
GTK_IM_MODULE_PATH system-wide, as both GTK+ 2.x and GTK+ 3.x will
respect these variables.

This is why I would like to propose two patches, one against GTK+ 2.x
and the other against GTK+ 3.x, introducing the environment variables
GTK2_PATH and GTK3_PATH, which allow users to specify additional search
paths that are only respected by one major version of GTK+ (and not the
other).

I packaged IBus and the libpinyin input method module for Guix and could
only make it work in all applications after patching both major versions
of GTK+ to respect these additional environment variables.[3][4]

We intend to use a slightly modified version of the attached patches for
Guix (prefixing the variable names with “GUIX_”), but we think it would
be best to see if upstream would be okay with these patches, or if there
are better ways we haven’t thought of.

The patches are inlined below.

~~ Ricardo

____
[1]: https://www.gnu.org/software/guix/
[2]: https://developer.gnome.org/gtk3/stable/gtk-running.html
[2]: http://lists.gnu.org/archive/html/guix-devel/2015-09/msg00306.html
[3]: http://lists.gnu.org/archive/html/guix-devel/2015-12/msg00046.html

This patch makes GTK+ look for additional modules in a list of directories
specified by the environment variable "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_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_gtk2_path_env = g_getenv ("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_gtk2_path_env && module_path_env && home_gtk_dir)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_gtk2_path_env, module_path_env, home_gtk_dir, default_dir, NULL);
+  else if (module_gtk2_path_env && home_gtk_dir)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_gtk2_path_env, home_gtk_dir, default_dir, NULL);
+  else if (module_gtk2_path_env && module_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_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_gtk2_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_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);
This patch makes GTK+ look for additional modules in a list of directories
specified by the environment variable "GTK3_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	2015-09-20 20:09:05.060590217 +0200
+++ b/gtk/gtkmodules.c	2015-09-20 20:10:33.423124833 +0200
@@ -52,6 +52,7 @@
 get_module_path (void)
 {
   const gchar *module_path_env;
+  const gchar *module_gtk3_path_env;
   const gchar *exe_prefix;
   gchar *module_path;
   gchar *default_dir;
@@ -61,6 +62,7 @@
     return result;
 
   module_path_env = g_getenv ("GTK_PATH");
+  module_gtk3_path_env = g_getenv ("GTK3_PATH");
   exe_prefix = g_getenv ("GTK_EXE_PREFIX");
 
   if (exe_prefix)
@@ -68,7 +70,13 @@
   else
     default_dir = g_build_filename (_gtk_get_libdir (), "gtk-3.0", NULL);
 
-  if (module_path_env)
+  if (module_gtk3_path_env && module_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_gtk3_path_env, module_path_env, default_dir, NULL);
+  else if (module_gtk3_path_env)
+    module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+				module_gtk3_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);
   else
_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list