mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 19:00:08 +00:00
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:
parent
8a487aca2c
commit
0b0f176ac4
@ -35,6 +35,12 @@ If called without arguments, it looks for modules in the
|
||||
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>gdk-pixbuf-queryloaders-3.0</command> is written
|
||||
to <filename><replaceable>libdir</replaceable>gtk-3.0/3.0.0/loaders.cache</filename>, where <application>gdk-pixbuf</application> looks for it by default. If it is written to some other
|
||||
location, the environment variable <link linkend="GDK_PIXBUF_MODULE_FILE"><envar>GDK_PIXBUF_MODULE_FILE</envar></link>
|
||||
can be set to point <application>gdk-pixbuf</application> at the file.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1><title>Environment</title>
|
||||
|
@ -16,12 +16,12 @@ a #GdkPixbufModuleFillVtableFunc function named
|
||||
|
||||
<para>
|
||||
In order to make format-checking work before actually loading the modules
|
||||
(which may require dlopening image libraries), modules export their
|
||||
(which may require dlopening image libraries), modules export their
|
||||
signatures (and other information) via the <function>fill_info</function>
|
||||
function. An external utility, <command>gdk-pixbuf-query-loaders</command>,
|
||||
uses this to create a text file containing a list of all available loaders and
|
||||
function. An external utility, <command>gdk-pixbuf-query-loaders-3.0</command>,
|
||||
uses this to create a text file containing a list of all available loaders and
|
||||
their signatures. This file is then read at runtime by &gdk-pixbuf; to obtain
|
||||
the list of available loaders and their signatures.
|
||||
the list of available loaders and their signatures.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -30,21 +30,21 @@ Modules may only implement a subset of the functionality available via
|
||||
<function>fill_vtable</function> function will simply not set the corresponding
|
||||
function pointers of the #GdkPixbufModule structure. If a module supports
|
||||
incremental loading (i.e. provides #begin_load, #stop_load and
|
||||
#load_increment), it doesn't have to implement #load, since &gdk-pixbuf; can
|
||||
supply a generic #load implementation wrapping the incremental loading.
|
||||
#load_increment), it doesn't have to implement #load, since &gdk-pixbuf; can
|
||||
supply a generic #load implementation wrapping the incremental loading.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Installing a module is a two-step process:
|
||||
<itemizedlist>
|
||||
<listitem><para>copy the module file(s) to the loader directory (normally
|
||||
<filename><replaceable>libdir</replaceable>/gtk-2.0/<replaceable>version</replaceable>/loaders</filename>,
|
||||
<filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders</filename>,
|
||||
unless overridden by the environment variable
|
||||
<envar>GDK_PIXBUF_MODULEDIR</envar>)
|
||||
<envar>GDK_PIXBUF_MODULEDIR</envar>)
|
||||
</para></listitem>
|
||||
<listitem><para>call <command>gdk-pixbuf-query-loaders</command> to update the
|
||||
<listitem><para>call <command>gdk-pixbuf-query-loaders-3.0</command> to update the
|
||||
module file (normally
|
||||
<filename><replaceable>sysconfdir</replaceable>/gtk-2.0/gdk-pixbuf.loaders</filename>,
|
||||
<filename><replaceable>libdir</replaceable>/gtk-3.0/<replaceable>version</replaceable>/loaders.cache</filename>,
|
||||
unless overridden by the environment variable
|
||||
<envar>GDK_PIXBUF_MODULE_FILE</envar>)
|
||||
</para></listitem>
|
||||
@ -52,11 +52,11 @@ unless overridden by the environment variable
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The &gdk-pixbuf; interfaces needed for implementing modules are contained in
|
||||
The &gdk-pixbuf; interfaces needed for implementing modules are contained in
|
||||
<filename>gdk-pixbuf-io.h</filename> (and
|
||||
<filename>gdk-pixbuf-animation.h</filename> if the module supports animations).
|
||||
They are not covered by the same stability guarantees as the regular
|
||||
&gdk-pixbuf; API. To underline this fact, they are protected by
|
||||
They are not covered by the same stability guarantees as the regular
|
||||
&gdk-pixbuf; API. To underline this fact, they are protected by
|
||||
<literal>#ifdef GDK_PIXBUF_ENABLE_BACKEND</literal>.
|
||||
</para>
|
||||
|
||||
@ -188,7 +188,7 @@ use the <function>gdk_pixbuf_format_*</function> functions.
|
||||
image format.
|
||||
@flags: a combination of #GdkPixbufFormatFlags.
|
||||
@disabled: a boolean determining whether the loader is disabled.
|
||||
@license: a string containing license information, typically set to
|
||||
@license: a string containing license information, typically set to
|
||||
shorthands like "GPL", "LGPL", etc.
|
||||
@Since: 2.2
|
||||
|
||||
@ -208,21 +208,21 @@ operations.
|
||||
<!-- ##### STRUCT GdkPixbufModulePattern ##### -->
|
||||
<para>
|
||||
The signature of a module is a set of prefixes. Prefixes are encoded as
|
||||
pairs of ordinary strings, where the second string, called the mask, if
|
||||
not %NULL, must be of the same length as the first one and may contain
|
||||
' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
|
||||
not matched, "don't-care"-bytes, zeros and non-zeros.
|
||||
Each prefix has an associated integer that describes the relevance of
|
||||
pairs of ordinary strings, where the second string, called the mask, if
|
||||
not %NULL, must be of the same length as the first one and may contain
|
||||
' ', '!', 'x', 'z', and 'n' to indicate bytes that must be matched,
|
||||
not matched, "don't-care"-bytes, zeros and non-zeros.
|
||||
Each prefix has an associated integer that describes the relevance of
|
||||
the prefix, with 0 meaning a mismatch and 100 a "perfect match".
|
||||
</para>
|
||||
<para>
|
||||
Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
|
||||
indicating an unanchored pattern that matches not only at the beginning,
|
||||
Starting with &gdk-pixbuf; 2.8, the first byte of the mask may be '*',
|
||||
indicating an unanchored pattern that matches not only at the beginning,
|
||||
but also in the middle. Versions prior to 2.8 will interpret the '*'
|
||||
like an 'x'.
|
||||
like an 'x'.
|
||||
</para>
|
||||
<para>
|
||||
The signature of a module is stored as an array of
|
||||
The signature of a module is stored as an array of
|
||||
#GdkPixbufModulePattern<!-- -->s. The array is terminated by a pattern
|
||||
where the @prefix is %NULL.
|
||||
</para>
|
||||
@ -234,7 +234,7 @@ GdkPixbufModulePattern *signature[] = {
|
||||
{ NULL, NULL, 0 }
|
||||
};
|
||||
</programlisting>
|
||||
The example matches e.g. "auud\0" with relevance 100, and "blau" with
|
||||
The example matches e.g. "auud\0" with relevance 100, and "blau" with
|
||||
relevance 90.</informalexample>
|
||||
|
||||
@prefix: the prefix for this pattern
|
||||
@ -245,8 +245,8 @@ relevance 90.</informalexample>
|
||||
|
||||
<!-- ##### USER_FUNCTION GdkPixbufModuleFillVtableFunc ##### -->
|
||||
<para>
|
||||
Defines the type of the function used to set the vtable of a
|
||||
#GdkPixbufModule when it is loaded.
|
||||
Defines the type of the function used to set the vtable of a
|
||||
#GdkPixbufModule when it is loaded.
|
||||
</para>
|
||||
|
||||
@module: a #GdkPixbufModule.
|
||||
@ -255,7 +255,7 @@ Defines the type of the function used to set the vtable of a
|
||||
|
||||
<!-- ##### USER_FUNCTION GdkPixbufModuleFillInfoFunc ##### -->
|
||||
<para>
|
||||
Defines the type of the function used to fill a
|
||||
Defines the type of the function used to fill a
|
||||
#GdkPixbufFormat structure with information about a module.
|
||||
</para>
|
||||
|
||||
@ -265,19 +265,19 @@ Defines the type of the function used to fill a
|
||||
|
||||
<!-- ##### USER_FUNCTION GdkPixbufModuleSizeFunc ##### -->
|
||||
<para>
|
||||
Defines the type of the function that gets called once the size
|
||||
Defines the type of the function that gets called once the size
|
||||
of the loaded image is known.
|
||||
</para>
|
||||
<para>
|
||||
The function is expected to set @width and @height to the desired
|
||||
size to which the image should be scaled. If a module has no efficient
|
||||
size to which the image should be scaled. If a module has no efficient
|
||||
way to achieve the desired scaling during the loading of the image, it may
|
||||
either ignore the size request, or only approximate it -- &gdk-pixbuf; will
|
||||
then perform the required scaling on the completely loaded image.
|
||||
then perform the required scaling on the completely loaded image.
|
||||
</para>
|
||||
<para>
|
||||
If the function sets @width or @height to zero, the module should interpret
|
||||
this as a hint that it will be closed soon and shouldn't allocate further
|
||||
this as a hint that it will be closed soon and shouldn't allocate further
|
||||
resources. This convention is used to implement gdk_pixbuf_get_file_info()
|
||||
efficiently.
|
||||
</para>
|
||||
@ -290,11 +290,11 @@ efficiently.
|
||||
|
||||
<!-- ##### USER_FUNCTION GdkPixbufModulePreparedFunc ##### -->
|
||||
<para>
|
||||
Defines the type of the function that gets called once the initial
|
||||
Defines the type of the function that gets called once the initial
|
||||
setup of @pixbuf is done.
|
||||
</para>
|
||||
<para>
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
"<link linkend="GdkPixbufLoader-area-prepared">area_prepared</link>"
|
||||
signal.
|
||||
</para>
|
||||
@ -311,7 +311,7 @@ Defines the type of the function that gets called every time a region
|
||||
of @pixbuf is updated.
|
||||
</para>
|
||||
<para>
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
#GdkPixbufLoader uses a function of this type to emit the
|
||||
"<link linkend="GdkPixbufLoader-area-updated">area_updated</link>"
|
||||
signal.
|
||||
</para>
|
||||
@ -327,14 +327,14 @@ signal.
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufModule ##### -->
|
||||
<para>
|
||||
A #GdkPixbufModule contains the necessary functions to load and save
|
||||
images in a certain file format.
|
||||
A #GdkPixbufModule contains the necessary functions to load and save
|
||||
images in a certain file format.
|
||||
</para>
|
||||
<para>
|
||||
A #GdkPixbufModule can be loaded dynamically from a #GModule.
|
||||
Each loadable module must contain a #GdkPixbufModuleFillVtableFunc function
|
||||
Each loadable module must contain a #GdkPixbufModuleFillVtableFunc function
|
||||
named <function>fill_vtable</function>, which will get called when the module
|
||||
is loaded and must set the function pointers of the #GdkPixbufModule.
|
||||
is loaded and must set the function pointers of the #GdkPixbufModule.
|
||||
</para>
|
||||
|
||||
@module_name: the name of the module, usually the same as the
|
||||
@ -353,8 +353,8 @@ is loaded and must set the function pointers of the #GdkPixbufModule.
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufAnimationClass ##### -->
|
||||
<para>
|
||||
Modules supporting animations must derive a type from
|
||||
#GdkPixbufAnimation, providing suitable implementations of the
|
||||
Modules supporting animations must derive a type from
|
||||
#GdkPixbufAnimation, providing suitable implementations of the
|
||||
virtual functions.
|
||||
</para>
|
||||
|
||||
@ -366,17 +366,17 @@ virtual functions.
|
||||
|
||||
<!-- ##### STRUCT GdkPixbufAnimationIterClass ##### -->
|
||||
<para>
|
||||
Modules supporting animations must derive a type from
|
||||
#GdkPixbufAnimationIter, providing suitable implementations of the
|
||||
Modules supporting animations must derive a type from
|
||||
#GdkPixbufAnimationIter, providing suitable implementations of the
|
||||
virtual functions.
|
||||
</para>
|
||||
|
||||
@parent_class: the parent class
|
||||
@get_delay_time: returns the time in milliseconds that the current frame
|
||||
@get_delay_time: returns the time in milliseconds that the current frame
|
||||
should be shown.
|
||||
@get_pixbuf: returns the current frame.
|
||||
@on_currently_loading_frame: returns whether the current frame of @iter is
|
||||
@on_currently_loading_frame: returns whether the current frame of @iter is
|
||||
being loaded.
|
||||
@advance: advances the iterator to @current_time, possibly changing the
|
||||
@advance: advances the iterator to @current_time, possibly changing the
|
||||
current frame.
|
||||
|
||||
|
@ -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-3.0</command> is written
|
||||
to <filename><replaceable>libdir</replaceable>gtk-3.0/3.0.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>
|
||||
|
@ -262,9 +262,8 @@ additional environment variables.
|
||||
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-3.0/gtk.immodules</filename>
|
||||
(<replaceable>sysconfdir</replaceable> is the sysconfdir specified when GTK+ was configured,
|
||||
usually <filename>/usr/local/etc</filename>.)
|
||||
<filename><replaceable>libdir</replaceable>/gtk-3.0/3.0.0/immodules.cache</filename>
|
||||
(<replaceable>libdir</replaceable> has the same meaning here as explained for <envar>GTK_PATH</envar>).
|
||||
</para>
|
||||
</formalpara>
|
||||
|
||||
|
@ -509,7 +509,7 @@ INCLUDES = \
|
||||
-I$(top_srcdir) -I$(top_builddir) \
|
||||
-I$(top_srcdir)/gdk-pixbuf \
|
||||
-I$(top_builddir)/gdk-pixbuf \
|
||||
-DGTK_SYSCONFDIR=\"$(sysconfdir)\" \
|
||||
-DGTK_LIBDIR=\"$(libdir)\" \
|
||||
-DGTK_VERSION=\"$(GTK_VERSION)\" \
|
||||
-DGTK_BINARY_VERSION=\"$(GTK_BINARY_VERSION)\" \
|
||||
-DGTK_PREFIX=\"$(prefix)\" \
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
* queryloaders.c:
|
||||
*
|
||||
* Copyright (C) 2002 The Free Software Foundation
|
||||
*
|
||||
*
|
||||
* Author: Matthias Clasen <maclas@gmx.de>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -13,7 +13,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
|
||||
@ -52,276 +52,276 @@
|
||||
static void
|
||||
print_escaped (const char *str)
|
||||
{
|
||||
gchar *tmp = g_strescape (str, "");
|
||||
g_printf ("\"%s\" ", tmp);
|
||||
g_free (tmp);
|
||||
gchar *tmp = g_strescape (str, "");
|
||||
g_printf ("\"%s\" ", tmp);
|
||||
g_free (tmp);
|
||||
}
|
||||
|
||||
static int
|
||||
loader_sanity_check (const char *path, GdkPixbufFormat *info, GdkPixbufModule *vtable)
|
||||
{
|
||||
const GdkPixbufModulePattern *pattern;
|
||||
const char *error = "";
|
||||
const GdkPixbufModulePattern *pattern;
|
||||
const char *error = "";
|
||||
|
||||
for (pattern = info->signature; pattern->prefix; pattern++)
|
||||
{
|
||||
int prefix_len = strlen (pattern->prefix);
|
||||
if (prefix_len == 0)
|
||||
{
|
||||
error = "empty pattern";
|
||||
for (pattern = info->signature; pattern->prefix; pattern++)
|
||||
{
|
||||
int prefix_len = strlen (pattern->prefix);
|
||||
if (prefix_len == 0)
|
||||
{
|
||||
error = "empty pattern";
|
||||
|
||||
goto error;
|
||||
}
|
||||
if (pattern->mask)
|
||||
{
|
||||
int mask_len = strlen (pattern->mask);
|
||||
if (mask_len != prefix_len)
|
||||
{
|
||||
error = "mask length mismatch";
|
||||
|
||||
goto error;
|
||||
}
|
||||
if (strspn (pattern->mask, " !xzn*") < mask_len)
|
||||
{
|
||||
error = "bad char in mask";
|
||||
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
if (pattern->mask)
|
||||
{
|
||||
int mask_len = strlen (pattern->mask);
|
||||
if (mask_len != prefix_len)
|
||||
{
|
||||
error = "mask length mismatch";
|
||||
|
||||
goto error;
|
||||
}
|
||||
if (strspn (pattern->mask, " !xzn*") < mask_len)
|
||||
{
|
||||
error = "bad char in mask";
|
||||
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!vtable->load && !vtable->begin_load && !vtable->load_animation)
|
||||
{
|
||||
error = "no load method implemented";
|
||||
if (!vtable->load && !vtable->begin_load && !vtable->load_animation)
|
||||
{
|
||||
error = "no load method implemented";
|
||||
|
||||
goto error;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (vtable->begin_load && (!vtable->stop_load || !vtable->load_increment))
|
||||
{
|
||||
error = "incremental loading support incomplete";
|
||||
if (vtable->begin_load && (!vtable->stop_load || !vtable->load_increment))
|
||||
{
|
||||
error = "incremental loading support incomplete";
|
||||
|
||||
goto error;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((info->flags & GDK_PIXBUF_FORMAT_WRITABLE) && !(vtable->save || vtable->save_to_callback))
|
||||
{
|
||||
error = "loader claims to support saving but doesn't implement save";
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 1;
|
||||
if ((info->flags & GDK_PIXBUF_FORMAT_WRITABLE) && !(vtable->save || vtable->save_to_callback))
|
||||
{
|
||||
error = "loader claims to support saving but doesn't implement save";
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
error:
|
||||
g_fprintf (stderr, "Loader sanity check failed for %s: %s\n",
|
||||
path, error);
|
||||
|
||||
return 0;
|
||||
g_fprintf (stderr, "Loader sanity check failed for %s: %s\n",
|
||||
path, error);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
write_loader_info (const char *path, GdkPixbufFormat *info)
|
||||
{
|
||||
const GdkPixbufModulePattern *pattern;
|
||||
char **mime;
|
||||
char **ext;
|
||||
const GdkPixbufModulePattern *pattern;
|
||||
char **mime;
|
||||
char **ext;
|
||||
|
||||
g_printf("\"%s\"\n", path);
|
||||
g_printf ("\"%s\" %u \"%s\" \"%s\" \"%s\"\n",
|
||||
info->name,
|
||||
g_printf("\"%s\"\n", path);
|
||||
g_printf ("\"%s\" %u \"%s\" \"%s\" \"%s\"\n",
|
||||
info->name,
|
||||
info->flags,
|
||||
info->domain ? info->domain : GETTEXT_PACKAGE,
|
||||
info->domain ? info->domain : GETTEXT_PACKAGE,
|
||||
info->description,
|
||||
info->license ? info->license : "");
|
||||
for (mime = info->mime_types; *mime; mime++) {
|
||||
g_printf ("\"%s\" ", *mime);
|
||||
}
|
||||
g_printf ("\"\"\n");
|
||||
for (ext = info->extensions; *ext; ext++) {
|
||||
g_printf ("\"%s\" ", *ext);
|
||||
}
|
||||
g_printf ("\"\"\n");
|
||||
for (pattern = info->signature; pattern->prefix; pattern++) {
|
||||
print_escaped (pattern->prefix);
|
||||
print_escaped (pattern->mask ? (const char *)pattern->mask : "");
|
||||
g_printf ("%d\n", pattern->relevance);
|
||||
}
|
||||
g_printf ("\n");
|
||||
for (mime = info->mime_types; *mime; mime++) {
|
||||
g_printf ("\"%s\" ", *mime);
|
||||
}
|
||||
g_printf ("\"\"\n");
|
||||
for (ext = info->extensions; *ext; ext++) {
|
||||
g_printf ("\"%s\" ", *ext);
|
||||
}
|
||||
g_printf ("\"\"\n");
|
||||
for (pattern = info->signature; pattern->prefix; pattern++) {
|
||||
print_escaped (pattern->prefix);
|
||||
print_escaped (pattern->mask ? (const char *)pattern->mask : "");
|
||||
g_printf ("%d\n", pattern->relevance);
|
||||
}
|
||||
g_printf ("\n");
|
||||
}
|
||||
|
||||
static void
|
||||
query_module (const char *dir, const char *file)
|
||||
{
|
||||
char *path;
|
||||
GModule *module;
|
||||
void (*fill_info) (GdkPixbufFormat *info);
|
||||
void (*fill_vtable) (GdkPixbufModule *module);
|
||||
gpointer fill_info_ptr;
|
||||
gpointer fill_vtable_ptr;
|
||||
char *path;
|
||||
GModule *module;
|
||||
void (*fill_info) (GdkPixbufFormat *info);
|
||||
void (*fill_vtable) (GdkPixbufModule *module);
|
||||
gpointer fill_info_ptr;
|
||||
gpointer fill_vtable_ptr;
|
||||
|
||||
if (g_path_is_absolute (file))
|
||||
path = g_strdup (file);
|
||||
else
|
||||
path = g_build_filename (dir, file, NULL);
|
||||
if (g_path_is_absolute (file))
|
||||
path = g_strdup (file);
|
||||
else
|
||||
path = g_build_filename (dir, file, NULL);
|
||||
|
||||
module = g_module_open (path, 0);
|
||||
if (module &&
|
||||
g_module_symbol (module, "fill_info", &fill_info_ptr) &&
|
||||
g_module_symbol (module, "fill_vtable", &fill_vtable_ptr)) {
|
||||
GdkPixbufFormat *info;
|
||||
GdkPixbufModule *vtable;
|
||||
|
||||
module = g_module_open (path, 0);
|
||||
if (module &&
|
||||
g_module_symbol (module, "fill_info", &fill_info_ptr) &&
|
||||
g_module_symbol (module, "fill_vtable", &fill_vtable_ptr)) {
|
||||
GdkPixbufFormat *info;
|
||||
GdkPixbufModule *vtable;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
/* Replace backslashes in path with forward slashes, so that
|
||||
* it reads in without problems.
|
||||
*/
|
||||
{
|
||||
char *p = path;
|
||||
while (*p) {
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
p++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
info = g_new0 (GdkPixbufFormat, 1);
|
||||
vtable = g_new0 (GdkPixbufModule, 1);
|
||||
/* Replace backslashes in path with forward slashes, so that
|
||||
* it reads in without problems.
|
||||
*/
|
||||
{
|
||||
char *p = path;
|
||||
while (*p) {
|
||||
if (*p == '\\')
|
||||
*p = '/';
|
||||
p++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
info = g_new0 (GdkPixbufFormat, 1);
|
||||
vtable = g_new0 (GdkPixbufModule, 1);
|
||||
|
||||
vtable->module = module;
|
||||
vtable->module = module;
|
||||
|
||||
fill_info = fill_info_ptr;
|
||||
fill_vtable = fill_vtable_ptr;
|
||||
fill_info = fill_info_ptr;
|
||||
fill_vtable = fill_vtable_ptr;
|
||||
|
||||
(*fill_info) (info);
|
||||
(*fill_vtable) (vtable);
|
||||
|
||||
if (loader_sanity_check (path, info, vtable))
|
||||
write_loader_info (path, info);
|
||||
|
||||
g_free (info);
|
||||
g_free (vtable);
|
||||
}
|
||||
else {
|
||||
if (module == NULL)
|
||||
g_fprintf (stderr, "g_module_open() failed for %s: %s\n", path,
|
||||
g_module_error());
|
||||
else
|
||||
g_fprintf (stderr, "Cannot load loader %s\n", path);
|
||||
}
|
||||
if (module)
|
||||
g_module_close (module);
|
||||
g_free (path);
|
||||
(*fill_info) (info);
|
||||
(*fill_vtable) (vtable);
|
||||
|
||||
if (loader_sanity_check (path, info, vtable))
|
||||
write_loader_info (path, info);
|
||||
|
||||
g_free (info);
|
||||
g_free (vtable);
|
||||
}
|
||||
else {
|
||||
if (module == NULL)
|
||||
g_fprintf (stderr, "g_module_open() failed for %s: %s\n", path,
|
||||
g_module_error());
|
||||
else
|
||||
g_fprintf (stderr, "Cannot load loader %s\n", path);
|
||||
}
|
||||
if (module)
|
||||
g_module_close (module);
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
gint i;
|
||||
gchar *prgname;
|
||||
gint i;
|
||||
gchar *prgname;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
gchar *libdir;
|
||||
gchar *runtime_prefix;
|
||||
gchar *slash;
|
||||
gchar *libdir;
|
||||
gchar *runtime_prefix;
|
||||
gchar *slash;
|
||||
|
||||
if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 &&
|
||||
G_IS_DIR_SEPARATOR (PIXBUF_LIBDIR[strlen (GTK_PREFIX)])) {
|
||||
/* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it
|
||||
* normally is. Replace that prefix in PIXBUF_LIBDIR
|
||||
* with the installation directory on this machine.
|
||||
* We assume this invokation of
|
||||
* gdk-pixbuf-query-loaders is run from either a "bin"
|
||||
* subdirectory of the installation directory, or in
|
||||
* the installation directory itself.
|
||||
*/
|
||||
wchar_t fn[1000];
|
||||
GetModuleFileNameW (NULL, fn, G_N_ELEMENTS (fn));
|
||||
runtime_prefix = g_utf16_to_utf8 (fn, -1, NULL, NULL, NULL);
|
||||
slash = strrchr (runtime_prefix, '\\');
|
||||
*slash = '\0';
|
||||
slash = strrchr (runtime_prefix, '\\');
|
||||
/* If running from some weird location, or from the
|
||||
* build directory (either in the .libs folder where
|
||||
* libtool places the real executable when using a
|
||||
* wrapper, or directly from the gdk-pixbuf folder),
|
||||
* use the compile-time libdir.
|
||||
*/
|
||||
if (slash == NULL ||
|
||||
g_ascii_strcasecmp (slash + 1, ".libs") == 0 ||
|
||||
g_ascii_strcasecmp (slash + 1, "gdk-pixbuf") == 0) {
|
||||
libdir = PIXBUF_LIBDIR;
|
||||
}
|
||||
else {
|
||||
if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
|
||||
*slash = '\0';
|
||||
}
|
||||
|
||||
libdir = g_strconcat (runtime_prefix,
|
||||
"/",
|
||||
PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
libdir = PIXBUF_LIBDIR;
|
||||
}
|
||||
if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 &&
|
||||
G_IS_DIR_SEPARATOR (PIXBUF_LIBDIR[strlen (GTK_PREFIX)])) {
|
||||
/* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it
|
||||
* normally is. Replace that prefix in PIXBUF_LIBDIR
|
||||
* with the installation directory on this machine.
|
||||
* We assume this invokation of
|
||||
* gdk-pixbuf-query-loaders is run from either a "bin"
|
||||
* subdirectory of the installation directory, or in
|
||||
* the installation directory itself.
|
||||
*/
|
||||
wchar_t fn[1000];
|
||||
GetModuleFileNameW (NULL, fn, G_N_ELEMENTS (fn));
|
||||
runtime_prefix = g_utf16_to_utf8 (fn, -1, NULL, NULL, NULL);
|
||||
slash = strrchr (runtime_prefix, '\\');
|
||||
*slash = '\0';
|
||||
slash = strrchr (runtime_prefix, '\\');
|
||||
/* If running from some weird location, or from the
|
||||
* build directory (either in the .libs folder where
|
||||
* libtool places the real executable when using a
|
||||
* wrapper, or directly from the gdk-pixbuf folder),
|
||||
* use the compile-time libdir.
|
||||
*/
|
||||
if (slash == NULL ||
|
||||
g_ascii_strcasecmp (slash + 1, ".libs") == 0 ||
|
||||
g_ascii_strcasecmp (slash + 1, "gdk-pixbuf") == 0) {
|
||||
libdir = PIXBUF_LIBDIR;
|
||||
}
|
||||
else {
|
||||
if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
|
||||
*slash = '\0';
|
||||
}
|
||||
|
||||
libdir = g_strconcat (runtime_prefix,
|
||||
"/",
|
||||
PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
libdir = PIXBUF_LIBDIR;
|
||||
}
|
||||
|
||||
#undef PIXBUF_LIBDIR
|
||||
#define PIXBUF_LIBDIR libdir
|
||||
|
||||
#endif
|
||||
prgname = g_get_prgname ();
|
||||
g_printf ("# GdkPixbuf Image Loader Modules file\n"
|
||||
"# Automatically generated file, do not edit\n"
|
||||
"# Created by %s from gtk+-%s\n"
|
||||
"#\n",
|
||||
(prgname ? prgname : "gdk-pixbuf-query-loaders-3.0"),
|
||||
GDK_PIXBUF_VERSION);
|
||||
|
||||
if (argc == 1) {
|
||||
prgname = g_get_prgname ();
|
||||
g_printf ("# GdkPixbuf Image Loader Modules file\n"
|
||||
"# Automatically generated file, do not edit\n"
|
||||
"# Created by %s from gtk+-%s\n"
|
||||
"#\n",
|
||||
(prgname ? prgname : "gdk-pixbuf-query-loaders-3.0"),
|
||||
GDK_PIXBUF_VERSION);
|
||||
|
||||
if (argc == 1) {
|
||||
#ifdef USE_GMODULE
|
||||
const char *path;
|
||||
GDir *dir;
|
||||
|
||||
path = g_getenv ("GDK_PIXBUF_MODULEDIR");
|
||||
const char *path;
|
||||
GDir *dir;
|
||||
|
||||
path = g_getenv ("GDK_PIXBUF_MODULEDIR");
|
||||
#ifdef G_OS_WIN32
|
||||
if (path != NULL && *path != '\0')
|
||||
path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
|
||||
if (path != NULL && *path != '\0')
|
||||
path = g_locale_to_utf8 (path, -1, NULL, NULL, NULL);
|
||||
#endif
|
||||
if (path == NULL || *path == '\0')
|
||||
path = PIXBUF_LIBDIR;
|
||||
if (path == NULL || *path == '\0')
|
||||
path = PIXBUF_LIBDIR;
|
||||
|
||||
g_printf ("# LoaderDir = %s\n#\n", path);
|
||||
g_printf ("# LoaderDir = %s\n#\n", path);
|
||||
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir) {
|
||||
const char *dent;
|
||||
dir = g_dir_open (path, 0, NULL);
|
||||
if (dir) {
|
||||
const char *dent;
|
||||
|
||||
while ((dent = g_dir_read_name (dir))) {
|
||||
gint len = strlen (dent);
|
||||
if (len > SOEXT_LEN &&
|
||||
strcmp (dent + len - SOEXT_LEN, SOEXT) == 0) {
|
||||
query_module (path, dent);
|
||||
}
|
||||
}
|
||||
g_dir_close (dir);
|
||||
}
|
||||
while ((dent = g_dir_read_name (dir))) {
|
||||
gint len = strlen (dent);
|
||||
if (len > SOEXT_LEN &&
|
||||
strcmp (dent + len - SOEXT_LEN, SOEXT) == 0) {
|
||||
query_module (path, dent);
|
||||
}
|
||||
}
|
||||
g_dir_close (dir);
|
||||
}
|
||||
#else
|
||||
g_printf ("# dynamic loading of modules not supported\n");
|
||||
g_printf ("# dynamic loading of modules not supported\n");
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
char *cwd = g_get_current_dir ();
|
||||
}
|
||||
else {
|
||||
char *cwd = g_get_current_dir ();
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
char *infilename = argv[i];
|
||||
for (i = 1; i < argc; i++) {
|
||||
char *infilename = argv[i];
|
||||
#ifdef G_OS_WIN32
|
||||
infilename = g_locale_to_utf8 (infilename,
|
||||
-1, NULL, NULL, NULL);
|
||||
infilename = g_locale_to_utf8 (infilename,
|
||||
-1, NULL, NULL, NULL);
|
||||
#endif
|
||||
query_module (cwd, infilename);
|
||||
}
|
||||
g_free (cwd);
|
||||
}
|
||||
query_module (cwd, infilename);
|
||||
}
|
||||
g_free (cwd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -450,9 +450,9 @@ gtk_rc_get_im_module_file (void)
|
||||
if (!result)
|
||||
{
|
||||
if (im_module_file)
|
||||
result = g_strdup (im_module_file);
|
||||
result = g_strdup (im_module_file);
|
||||
else
|
||||
result = g_build_filename (GTK_SYSCONFDIR, "gtk-3.0", "gtk.immodules", NULL);
|
||||
result = gtk_rc_make_default_dir ("immodules.cache");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user