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-3.0/3.0.0/immodules.cache, and the
pixbuf loader cache is looked for in libdir/gtk-3.0/3.0.0/loaders.cache.
This commit is contained in:
Matthias Clasen
2010-05-17 21:30:46 -04:00
parent 8a487aca2c
commit 0b0f176ac4
9 changed files with 1480 additions and 1469 deletions

View File

@ -1,7 +1,7 @@
/* GTK+
* querymodules.c:
*
* Copyright (C) 2000 Red Hat Software
* Copyright (C) 2000-2010 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;
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);
}
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;
}