forked from AuroraMiddleware/gtk
Merge branch 'wip/jtojnar/compose-consistent-system' into 'main'
Improve composetable inclusions See merge request GNOME/gtk!5150
This commit is contained in:
commit
ae7bf4dcf7
@ -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__ */
|
||||
|
@ -46,8 +46,9 @@
|
||||
* `GtkIMContextSimple` reads compose sequences from the first of the
|
||||
* following files that is found: ~/.config/gtk-4.0/Compose, ~/.XCompose,
|
||||
* /usr/share/X11/locale/$locale/Compose (for locales that have a nontrivial
|
||||
* Compose file). The syntax of these files is described in the Compose(5)
|
||||
* manual page.
|
||||
* Compose file). A subset of the file syntax described in the Compose(5)
|
||||
* manual page is supported. Additionally, `include "%L"` loads GTK’s built-in
|
||||
* table of compose sequences rather than the locale-specific one from X11.
|
||||
*
|
||||
* If none of these files is found, `GtkIMContextSimple` uses a built-in table
|
||||
* of compose sequences that is derived from the X11 Compose files.
|
||||
@ -180,20 +181,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 +308,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