mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 21:51:08 +00:00
composetable: Support non-FHS paths for Compose tables
On platforms like NixOS, the libX11 installation prefix may differ from /usr/share, breaking the hardcoded placeholders. Let’s re-use the X11 path definition from imcontextsimple.
This commit is contained in:
parent
4bb79decf3
commit
94a096ec4c
@ -284,6 +284,20 @@ fail:
|
||||
static void parser_parse_file (GtkComposeParser *parser,
|
||||
const char *path);
|
||||
|
||||
char *
|
||||
gtk_compose_table_get_x11_compose_file_dir (void)
|
||||
{
|
||||
char * compose_file_dir;
|
||||
|
||||
#if defined (X11_DATA_PREFIX)
|
||||
compose_file_dir = g_strdup (X11_DATA_PREFIX "/share/X11/locale");
|
||||
#else
|
||||
compose_file_dir = g_build_filename (_gtk_get_datadir (), "X11", "locale", NULL);
|
||||
#endif
|
||||
|
||||
return compose_file_dir;
|
||||
}
|
||||
|
||||
/* Substitute %H, %L and %S */
|
||||
static char *
|
||||
handle_substitutions (const char *start,
|
||||
@ -305,6 +319,9 @@ handle_substitutions (const char *start,
|
||||
}
|
||||
else
|
||||
{
|
||||
char *x11_compose_file_dir;
|
||||
char *path;
|
||||
|
||||
switch (p[1])
|
||||
{
|
||||
case 'H':
|
||||
@ -313,11 +330,17 @@ handle_substitutions (const char *start,
|
||||
break;
|
||||
case 'L':
|
||||
p++;
|
||||
g_string_append_printf (s, "/usr/share/X11/locale/%s/Compose", locale_name);
|
||||
x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
|
||||
path = g_build_filename (x11_compose_file_dir, locale_name, "Compose", NULL);
|
||||
g_string_append (s, path);
|
||||
g_free (path);
|
||||
g_free (x11_compose_file_dir);
|
||||
break;
|
||||
case 'S':
|
||||
p++;
|
||||
g_string_append (s, "/usr/share/X11/locale");
|
||||
x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
|
||||
g_string_append (s, x11_compose_file_dir);
|
||||
g_free (x11_compose_file_dir);
|
||||
break;
|
||||
default: ;
|
||||
/* do nothing, next iteration handles p[1] */
|
||||
|
@ -93,6 +93,8 @@ guint32 gtk_compose_table_data_hash (const guint16 *data,
|
||||
int max_seq_len,
|
||||
int n_seqs);
|
||||
|
||||
char * gtk_compose_table_get_x11_compose_file_dir (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_COMPOSETABLE_H__ */
|
||||
|
@ -180,20 +180,6 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)
|
||||
init_compose_table_async (NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static char *
|
||||
get_x11_compose_file_dir (void)
|
||||
{
|
||||
char * compose_file_dir;
|
||||
|
||||
#if defined (X11_DATA_PREFIX)
|
||||
compose_file_dir = g_strdup (X11_DATA_PREFIX "/share/X11/locale");
|
||||
#else
|
||||
compose_file_dir = g_build_filename (_gtk_get_datadir (), "X11", "locale", NULL);
|
||||
#endif
|
||||
|
||||
return compose_file_dir;
|
||||
}
|
||||
|
||||
static int
|
||||
gtk_compose_table_find (gconstpointer data1,
|
||||
gconstpointer data2)
|
||||
@ -321,7 +307,7 @@ gtk_im_context_simple_init_compose_table (void)
|
||||
{
|
||||
if (g_ascii_strncasecmp (*lang, *sys_lang, strlen (*sys_lang)) == 0)
|
||||
{
|
||||
char *x11_compose_file_dir = get_x11_compose_file_dir ();
|
||||
char *x11_compose_file_dir = gtk_compose_table_get_x11_compose_file_dir ();
|
||||
path = g_build_filename (x11_compose_file_dir, *lang, "Compose", NULL);
|
||||
g_free (x11_compose_file_dir);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user