[gtk+/gtk-2-24] Move the module cache files below libdir



commit c8849046860a9b17fa943247d85ddadb29262b48
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 4 09:27:17 2013 -0400

    Move the module cache files below libdir
    
    These files contain architecture-dependent paths, and thus placing
    them into sysconfdir causes unnecessary hassle. Now the immodule cache
    file is looked for in libdir/gtk-2.0/2.10.0/immodules.cache.
    
    Belated backport of a change that was done in the run-up to 3.0.

 docs/reference/gtk/gtk-query-immodules-2.0.xml |    6 +
 docs/reference/gtk/running.sgml                |    9 +-
 gtk/gtkrc.c                                    |    2 +-
 gtk/queryimmodules.c                           |  118 ++++++++++++------------
 4 files changed, 70 insertions(+), 65 deletions(-)
---
diff --git a/docs/reference/gtk/gtk-query-immodules-2.0.xml b/docs/reference/gtk/gtk-query-immodules-2.0.xml
index 1db0d70..d16aca8 100644
--- a/docs/reference/gtk/gtk-query-immodules-2.0.xml
+++ b/docs/reference/gtk/gtk-query-immodules-2.0.xml
@@ -34,6 +34,12 @@ module path.
 If called with arguments, it looks for the specified modules. The arguments
 may be absolute or relative paths.
 </para>
+<para>
+Normally, the output of <command>gtk-query-immodules-2.0</command> is written
+to <filename><replaceable>libdir</replaceable>/gtk-2.0/2.10.0/immodules.cache</filename>, where GTK+ looks 
for it by default. If it is written to some other
+location, the environment variable <link 
linkend="GTK_IM_MODULE_FILE"><envar>GTK_IM_MODULE_FILE</envar></link>
+can be set to point GTK+ at the file.
+</para>
 </refsect1>
 
 <refsect1><title>Environment</title>
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index 11fa0d1..74720c1 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -274,11 +274,10 @@ additional environment variables.
 
   <para>
     Specifies the file listing the IM modules to load. This environment
-    variable overrides the <literal>im_module_file</literal> specified in 
-    the RC files, which in turn overrides the default value 
-    <filename><replaceable>sysconfdir</replaceable>/gtk-2.0/gtk.immodules</filename>
-    (<replaceable>sysconfdir</replaceable> is the sysconfdir specified when GTK+ was configured, 
-     usually <filename>/usr/local/etc</filename>.)
+    variable overrides the <literal>im_module_file</literal> specified in
+    the RC files, which in turn overrides the default value
+    <filename><replaceable>libdir</replaceable>/gtk-2.0/2.10.0/immodules.cache</filename>
+    (<replaceable>libdir</replaceable> has the same meaning here as explained for <envar>GTK_PATH</envar>).
   </para>
 </formalpara>
 
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 69b3cfe..f0677aa 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -450,7 +450,7 @@ gtk_rc_get_im_module_file (void)
       if (im_module_file)
        result = g_strdup (im_module_file);
       else
-       result = g_build_filename (GTK_SYSCONFDIR, "gtk-2.0", "gtk.immodules", NULL);
+        result = gtk_rc_make_default_dir ("immodules.cache");
     }
 
   return result;
diff --git a/gtk/queryimmodules.c b/gtk/queryimmodules.c
index 5369c7f..34923b3 100644
--- a/gtk/queryimmodules.c
+++ b/gtk/queryimmodules.c
@@ -1,7 +1,7 @@
 /* GTK+
  * querymodules.c:
  *
- * Copyright (C) 2000 Red Hat Software
+ * Copyright (C) 2000-2013 Red Hat Software
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -10,7 +10,7 @@
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the GNU
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
@@ -49,28 +49,28 @@ escape_string (const char *str)
   while (TRUE)
     {
       char c = *str++;
-      
+
       switch (c)
-       {
-       case '\0':
-         goto done;
-       case '\n':
-         g_string_append (result, "\\n");
-         break;
-       case '\"':
-         g_string_append (result, "\\\"");
-         break;
+        {
+        case '\0':
+          goto done;
+        case '\n':
+          g_string_append (result, "\\n");
+          break;
+        case '\"':
+          g_string_append (result, "\\\"");
+          break;
 #ifdef G_OS_WIN32
-               /* Replace backslashes in path with forward slashes, so that
-                * it reads in without problems.
-                */
-       case '\\':
-         g_string_append (result, "/");
-         break;
-#endif 
-       default:
-         g_string_append_c (result, c);
-       }
+                /* Replace backslashes in path with forward slashes, so that
+                 * it reads in without problems.
+                 */
+        case '\\':
+          g_string_append (result, "/");
+          break;
+#endif
+        default:
+          g_string_append_c (result, c);
+        }
     }
 
  done:
@@ -89,7 +89,7 @@ static gboolean
 query_module (const char *dir, const char *name)
 {
   void          (*list)   (const GtkIMContextInfo ***contexts,
-                          guint                    *n_contexts);
+                           guint                    *n_contexts);
   void          (*init)   (GTypeModule              *type_module);
   void          (*exit)   (void);
   GtkIMContext *(*create) (const gchar             *context_id);
@@ -107,7 +107,7 @@ query_module (const char *dir, const char *name)
     path = g_strdup (name);
   else
     path = g_build_filename (dir, name, NULL);
-  
+
   module = g_module_open (path, 0);
 
   if (!module)
@@ -115,7 +115,7 @@ query_module (const char *dir, const char *name)
       g_fprintf (stderr, "Cannot load module %s: %s\n", path, g_module_error());
       error = TRUE;
     }
-         
+
   if (module &&
       g_module_symbol (module, "im_module_list", &list_ptr) &&
       g_module_symbol (module, "im_module_init", &init_ptr) &&
@@ -137,20 +137,20 @@ query_module (const char *dir, const char *name)
       (*list) (&contexts, &n_contexts);
 
       for (i=0; i<n_contexts; i++)
-       {
-         print_escaped (contexts[i]->context_id);
-         print_escaped (contexts[i]->context_name);
-         print_escaped (contexts[i]->domain);
-         print_escaped (contexts[i]->domain_dirname);
-         print_escaped (contexts[i]->default_locales);
-         fputs ("\n", stdout);
-       }
+        {
+          print_escaped (contexts[i]->context_id);
+          print_escaped (contexts[i]->context_name);
+          print_escaped (contexts[i]->domain);
+          print_escaped (contexts[i]->domain_dirname);
+          print_escaped (contexts[i]->default_locales);
+          fputs ("\n", stdout);
+        }
       fputs ("\n", stdout);
     }
   else
     {
       g_fprintf (stderr, "%s does not export GTK+ IM module API: %s\n", path,
-                g_module_error ());
+                 g_module_error ());
       error = TRUE;
     }
 
@@ -159,7 +159,7 @@ query_module (const char *dir, const char *name)
     g_module_close (module);
 
   return error;
-}                     
+}
 
 int main (int argc, char **argv)
 {
@@ -169,14 +169,14 @@ int main (int argc, char **argv)
   gboolean error = FALSE;
 
   g_printf ("# GTK+ Input Method Modules file\n"
-           "# Automatically generated file, do not edit\n"
-           "# Created by %s from gtk+-%d.%d.%d\n"
-           "#\n",
-           argv[0],
-           GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
+            "# Automatically generated file, do not edit\n"
+            "# Created by %s from gtk+-%d.%d.%d\n"
+            "#\n",
+            argv[0],
+            GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
 
 
-  if (argc == 1)               /* No arguments given */
+  if (argc == 1)                /* No arguments given */
     {
       char **dirs;
       int i;
@@ -189,22 +189,22 @@ int main (int argc, char **argv)
       dirs = pango_split_file_list (path);
       dirs_done = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
 
-      for (i=0; dirs[i]; i++)
+      for (i = 0; dirs[i]; i++)
         if (!g_hash_table_lookup (dirs_done, dirs[i]))
           {
-           GDir *dir = g_dir_open (dirs[i], 0, NULL);
-           if (dir)
-             {
-               const char *dent;
-
-               while ((dent = g_dir_read_name (dir)))
-                 {
-                   if (g_str_has_suffix (dent, SOEXT))
-                     error |= query_module (dirs[i], dent);
-                 }
-               
-               g_dir_close (dir);
-             }
+            GDir *dir = g_dir_open (dirs[i], 0, NULL);
+            if (dir)
+              {
+                const char *dent;
+
+                while ((dent = g_dir_read_name (dir)))
+                  {
+                    if (g_str_has_suffix (dent, SOEXT))
+                      error |= query_module (dirs[i], dent);
+                  }
+
+                g_dir_close (dir);
+              }
 
             g_hash_table_insert (dirs_done, dirs[i], GUINT_TO_POINTER (TRUE));
           }
@@ -214,12 +214,12 @@ int main (int argc, char **argv)
   else
     {
       cwd = g_get_current_dir ();
-      
-      for (i=1; i<argc; i++)
-       error |= query_module (cwd, argv[i]);
+
+      for (i = 1; i < argc; i++)
+        error |= query_module (cwd, argv[i]);
 
       g_free (cwd);
     }
-  
+
   return error ? 1 : 0;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]