mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-11 19:30:10 +00:00
GtkImageMenuItem: move public members to private structure
This commit is contained in:
parent
ad3b5941ab
commit
47e824a5e4
@ -33,6 +33,18 @@
|
||||
typedef struct _GtkComposeTable GtkComposeTable;
|
||||
typedef struct _GtkComposeTableCompact GtkComposeTableCompact;
|
||||
|
||||
struct _GtkIMContextSimplePriv
|
||||
{
|
||||
GSList *tables;
|
||||
|
||||
guint compose_buffer[GTK_MAX_COMPOSE_LEN + 1];
|
||||
gunichar tentative_match;
|
||||
gint tentative_match_len;
|
||||
|
||||
guint in_hex_sequence : 1;
|
||||
guint modifiers_dropped : 1;
|
||||
};
|
||||
|
||||
struct _GtkComposeTable
|
||||
{
|
||||
const guint16 *data;
|
||||
@ -106,24 +118,30 @@ gtk_im_context_simple_class_init (GtkIMContextSimpleClass *class)
|
||||
im_context_class->reset = gtk_im_context_simple_reset;
|
||||
im_context_class->get_preedit_string = gtk_im_context_simple_get_preedit_string;
|
||||
gobject_class->finalize = gtk_im_context_simple_finalize;
|
||||
|
||||
g_type_class_add_private (class, sizeof (GtkIMContextSimplePriv));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_simple_init (GtkIMContextSimple *im_context_simple)
|
||||
{
|
||||
{
|
||||
im_context_simple->priv = G_TYPE_INSTANCE_GET_PRIVATE (im_context_simple,
|
||||
GTK_TYPE_IM_CONTEXT_SIMPLE,
|
||||
GtkIMContextSimplePriv);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_simple_finalize (GObject *obj)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj);
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
|
||||
if (context_simple->tables)
|
||||
if (priv->tables)
|
||||
{
|
||||
g_slist_foreach (context_simple->tables, (GFunc)g_free, NULL);
|
||||
g_slist_free (context_simple->tables);
|
||||
g_slist_foreach (priv->tables, (GFunc)g_free, NULL);
|
||||
g_slist_free (priv->tables);
|
||||
|
||||
context_simple->tables = NULL;
|
||||
priv->tables = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj);
|
||||
@ -146,21 +164,21 @@ static void
|
||||
gtk_im_context_simple_commit_char (GtkIMContext *context,
|
||||
gunichar ch)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
gchar buf[10];
|
||||
gint len;
|
||||
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
|
||||
g_return_if_fail (g_unichar_validate (ch));
|
||||
|
||||
|
||||
len = g_unichar_to_utf8 (ch, buf);
|
||||
buf[len] = '\0';
|
||||
|
||||
if (context_simple->tentative_match || context_simple->in_hex_sequence)
|
||||
if (priv->tentative_match || priv->in_hex_sequence)
|
||||
{
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->tentative_match_len = 0;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
priv->tentative_match_len = 0;
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
}
|
||||
@ -207,6 +225,7 @@ check_table (GtkIMContextSimple *context_simple,
|
||||
const GtkComposeTable *table,
|
||||
gint n_compose)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
gint row_stride = table->max_seq_len + 2;
|
||||
guint16 *seq;
|
||||
|
||||
@ -216,7 +235,7 @@ check_table (GtkIMContextSimple *context_simple,
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq = bsearch (context_simple->compose_buffer,
|
||||
seq = bsearch (priv->compose_buffer,
|
||||
table->data, table->n_seqs,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
@ -231,7 +250,7 @@ check_table (GtkIMContextSimple *context_simple,
|
||||
while (seq > table->data)
|
||||
{
|
||||
prev_seq = seq - row_stride;
|
||||
if (compare_seq (context_simple->compose_buffer, prev_seq) != 0)
|
||||
if (compare_seq (priv->compose_buffer, prev_seq) != 0)
|
||||
break;
|
||||
seq = prev_seq;
|
||||
}
|
||||
@ -250,10 +269,10 @@ check_table (GtkIMContextSimple *context_simple,
|
||||
next_seq = seq + row_stride;
|
||||
if (next_seq < table->data + row_stride * table->n_seqs)
|
||||
{
|
||||
if (compare_seq (context_simple->compose_buffer, next_seq) == 0)
|
||||
if (compare_seq (priv->compose_buffer, next_seq) == 0)
|
||||
{
|
||||
context_simple->tentative_match = value;
|
||||
context_simple->tentative_match_len = n_compose;
|
||||
priv->tentative_match = value;
|
||||
priv->tentative_match_len = n_compose;
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
@ -262,7 +281,7 @@ check_table (GtkIMContextSimple *context_simple,
|
||||
}
|
||||
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -294,12 +313,13 @@ static gboolean
|
||||
check_win32_special_cases (GtkIMContextSimple *context_simple,
|
||||
gint n_compose)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
if (n_compose == 2 &&
|
||||
context_simple->compose_buffer[1] == GDK_space)
|
||||
priv->compose_buffer[1] == GDK_space)
|
||||
{
|
||||
gunichar value = 0;
|
||||
|
||||
switch (context_simple->compose_buffer[0])
|
||||
switch (priv->compose_buffer[0])
|
||||
{
|
||||
case GDK_dead_acute:
|
||||
value = 0x00B4; break;
|
||||
@ -309,7 +329,7 @@ check_win32_special_cases (GtkIMContextSimple *context_simple,
|
||||
if (value > 0)
|
||||
{
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("win32: U+%04X\n", value));
|
||||
return TRUE;
|
||||
@ -323,12 +343,14 @@ check_win32_special_case_after_compact_match (GtkIMContextSimple *context_sim
|
||||
gint n_compose,
|
||||
guint value)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
|
||||
/* On Windows user expectation is that typing two dead accents will input
|
||||
* two corresponding spacing accents.
|
||||
*/
|
||||
if (n_compose == 2 &&
|
||||
context_simple->compose_buffer[0] == context_simple->compose_buffer[1] &&
|
||||
IS_DEAD_KEY (context_simple->compose_buffer[0]))
|
||||
priv->compose_buffer[0] == priv->compose_buffer[1] &&
|
||||
IS_DEAD_KEY (priv->compose_buffer[0]))
|
||||
{
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
|
||||
GTK_NOTE (MISC, g_print ("win32: U+%04X ", value));
|
||||
@ -342,6 +364,7 @@ check_compact_table (GtkIMContextSimple *context_simple,
|
||||
const GtkComposeTableCompact *table,
|
||||
gint n_compose)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
gint row_stride;
|
||||
guint16 *seq_index;
|
||||
guint16 *seq;
|
||||
@ -352,8 +375,8 @@ check_compact_table (GtkIMContextSimple *context_simple,
|
||||
* will overrun val if key is longer than val. */
|
||||
if (n_compose > table->max_seq_len)
|
||||
return FALSE;
|
||||
|
||||
seq_index = bsearch (context_simple->compose_buffer,
|
||||
|
||||
seq_index = bsearch (priv->compose_buffer,
|
||||
table->data, table->n_index_size,
|
||||
sizeof (guint16) * table->n_index_stride,
|
||||
compare_seq_index);
|
||||
@ -379,7 +402,7 @@ check_compact_table (GtkIMContextSimple *context_simple,
|
||||
|
||||
if (seq_index[i+1] - seq_index[i] > 0)
|
||||
{
|
||||
seq = bsearch (context_simple->compose_buffer + 1,
|
||||
seq = bsearch (priv->compose_buffer + 1,
|
||||
table->data + seq_index[i], (seq_index[i+1] - seq_index[i]) / row_stride,
|
||||
sizeof (guint16) * row_stride,
|
||||
compare_seq);
|
||||
@ -414,7 +437,7 @@ check_compact_table (GtkIMContextSimple *context_simple,
|
||||
#ifdef G_OS_WIN32
|
||||
check_win32_special_case_after_compact_match (context_simple, n_compose, value);
|
||||
#endif
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("U+%04X\n", value));
|
||||
return TRUE;
|
||||
@ -496,6 +519,7 @@ check_algorithmically (GtkIMContextSimple *context_simple,
|
||||
gint n_compose)
|
||||
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
gint i;
|
||||
gunichar combination_buffer[GTK_MAX_COMPOSE_LEN];
|
||||
gchar *combination_utf8, *nfc;
|
||||
@ -503,19 +527,19 @@ check_algorithmically (GtkIMContextSimple *context_simple,
|
||||
if (n_compose >= GTK_MAX_COMPOSE_LEN)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < n_compose && IS_DEAD_KEY (context_simple->compose_buffer[i]); i++)
|
||||
for (i = 0; i < n_compose && IS_DEAD_KEY (priv->compose_buffer[i]); i++)
|
||||
;
|
||||
if (i == n_compose)
|
||||
return TRUE;
|
||||
|
||||
if (i > 0 && i == n_compose - 1)
|
||||
{
|
||||
combination_buffer[0] = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
|
||||
combination_buffer[0] = gdk_keyval_to_unicode (priv->compose_buffer[i]);
|
||||
combination_buffer[n_compose] = 0;
|
||||
i--;
|
||||
while (i >= 0)
|
||||
{
|
||||
switch (context_simple->compose_buffer[i])
|
||||
switch (priv->compose_buffer[i])
|
||||
{
|
||||
#define CASE(keysym, unicode) \
|
||||
case GDK_dead_##keysym: combination_buffer[i+1] = unicode; break
|
||||
@ -552,7 +576,7 @@ check_algorithmically (GtkIMContextSimple *context_simple,
|
||||
/* CASE (psili, 0x343); */
|
||||
#undef CASE
|
||||
default:
|
||||
combination_buffer[i+1] = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
|
||||
combination_buffer[i+1] = gdk_keyval_to_unicode (priv->compose_buffer[i]);
|
||||
}
|
||||
i--;
|
||||
}
|
||||
@ -569,7 +593,7 @@ check_algorithmically (GtkIMContextSimple *context_simple,
|
||||
|
||||
value = g_utf8_get_char (nfc);
|
||||
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
g_free (combination_utf8);
|
||||
g_free (nfc);
|
||||
@ -602,6 +626,7 @@ static gboolean
|
||||
check_hex (GtkIMContextSimple *context_simple,
|
||||
gint n_compose)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
/* See if this is a hex sequence, return TRUE if so */
|
||||
gint i;
|
||||
GString *str;
|
||||
@ -609,8 +634,8 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
gchar *nptr = NULL;
|
||||
gchar buf[7];
|
||||
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->tentative_match_len = 0;
|
||||
priv->tentative_match = 0;
|
||||
priv->tentative_match_len = 0;
|
||||
|
||||
str = g_string_new (NULL);
|
||||
|
||||
@ -619,7 +644,7 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
{
|
||||
gunichar ch;
|
||||
|
||||
ch = gdk_keyval_to_unicode (context_simple->compose_buffer[i]);
|
||||
ch = gdk_keyval_to_unicode (priv->compose_buffer[i]);
|
||||
|
||||
if (ch == 0)
|
||||
return FALSE;
|
||||
@ -649,8 +674,8 @@ check_hex (GtkIMContextSimple *context_simple,
|
||||
|
||||
if (g_unichar_validate (n))
|
||||
{
|
||||
context_simple->tentative_match = n;
|
||||
context_simple->tentative_match_len = n_compose;
|
||||
priv->tentative_match = n;
|
||||
priv->tentative_match_len = n_compose;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -686,6 +711,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
gint n_compose,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
GtkIMContext *context;
|
||||
gunichar ch;
|
||||
|
||||
@ -694,18 +720,18 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
/* No compose sequences found, check first if we have a partial
|
||||
* match pending.
|
||||
*/
|
||||
if (context_simple->tentative_match)
|
||||
if (priv->tentative_match)
|
||||
{
|
||||
gint len = context_simple->tentative_match_len;
|
||||
gint len = priv->tentative_match_len;
|
||||
int i;
|
||||
|
||||
gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
for (i=0; i < n_compose - len - 1; i++)
|
||||
{
|
||||
GdkEvent *tmp_event = gdk_event_copy ((GdkEvent *)event);
|
||||
tmp_event->key.keyval = context_simple->compose_buffer[len + i];
|
||||
tmp_event->key.keyval = priv->compose_buffer[len + i];
|
||||
|
||||
gtk_im_context_filter_keypress (context, (GdkEventKey *)tmp_event);
|
||||
gdk_event_free (tmp_event);
|
||||
@ -715,7 +741,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
|
||||
}
|
||||
else
|
||||
{
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
if (n_compose > 1) /* Invalid sequence */
|
||||
{
|
||||
beep_window (event->window);
|
||||
@ -790,6 +816,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
GdkEventKey *event)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
GSList *tmp_list;
|
||||
int n_compose = 0;
|
||||
gboolean have_hex_mods;
|
||||
@ -800,34 +827,34 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
guint hex_keyval;
|
||||
int i;
|
||||
|
||||
while (context_simple->compose_buffer[n_compose] != 0)
|
||||
while (priv->compose_buffer[n_compose] != 0)
|
||||
n_compose++;
|
||||
|
||||
if (event->type == GDK_KEY_RELEASE)
|
||||
{
|
||||
if (context_simple->in_hex_sequence &&
|
||||
if (priv->in_hex_sequence &&
|
||||
(event->keyval == GDK_Control_L || event->keyval == GDK_Control_R ||
|
||||
event->keyval == GDK_Shift_L || event->keyval == GDK_Shift_R))
|
||||
{
|
||||
if (context_simple->tentative_match &&
|
||||
g_unichar_validate (context_simple->tentative_match))
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
}
|
||||
else if (n_compose == 0)
|
||||
{
|
||||
context_simple->modifiers_dropped = TRUE;
|
||||
priv->modifiers_dropped = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid hex sequence */
|
||||
beep_window (event->window);
|
||||
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->tentative_match = 0;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
@ -844,7 +871,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
if (event->keyval == gtk_compose_ignore[i])
|
||||
return FALSE;
|
||||
|
||||
if (context_simple->in_hex_sequence && context_simple->modifiers_dropped)
|
||||
if (priv->in_hex_sequence && priv->modifiers_dropped)
|
||||
have_hex_mods = TRUE;
|
||||
else
|
||||
have_hex_mods = (event->state & (HEX_MOD_MASK)) == HEX_MOD_MASK;
|
||||
@ -866,13 +893,13 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
* ISO_Level3_Switch.
|
||||
*/
|
||||
if (!have_hex_mods ||
|
||||
(n_compose > 0 && !context_simple->in_hex_sequence) ||
|
||||
(n_compose == 0 && !context_simple->in_hex_sequence && !is_hex_start) ||
|
||||
(context_simple->in_hex_sequence && !hex_keyval &&
|
||||
(n_compose > 0 && !priv->in_hex_sequence) ||
|
||||
(n_compose == 0 && !priv->in_hex_sequence && !is_hex_start) ||
|
||||
(priv->in_hex_sequence && !hex_keyval &&
|
||||
!is_hex_start && !is_hex_end && !is_escape && !is_backspace))
|
||||
{
|
||||
if (event->state & (GDK_MOD1_MASK | GDK_CONTROL_MASK) ||
|
||||
(context_simple->in_hex_sequence && context_simple->modifiers_dropped &&
|
||||
(priv->in_hex_sequence && priv->modifiers_dropped &&
|
||||
(event->keyval == GDK_Return ||
|
||||
event->keyval == GDK_ISO_Enter ||
|
||||
event->keyval == GDK_KP_Enter)))
|
||||
@ -882,35 +909,35 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
|
||||
/* Handle backspace */
|
||||
if (context_simple->in_hex_sequence && have_hex_mods && is_backspace)
|
||||
if (priv->in_hex_sequence && have_hex_mods && is_backspace)
|
||||
{
|
||||
if (n_compose > 0)
|
||||
{
|
||||
n_compose--;
|
||||
context_simple->compose_buffer[n_compose] = 0;
|
||||
priv->compose_buffer[n_compose] = 0;
|
||||
check_hex (context_simple, n_compose);
|
||||
}
|
||||
else
|
||||
{
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
if (!context_simple->in_hex_sequence)
|
||||
if (!priv->in_hex_sequence)
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Check for hex sequence restart */
|
||||
if (context_simple->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
if (priv->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
{
|
||||
if (context_simple->tentative_match &&
|
||||
g_unichar_validate (context_simple->tentative_match))
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -918,19 +945,19 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
if (n_compose > 0)
|
||||
beep_window (event->window);
|
||||
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->tentative_match = 0;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for hex sequence start */
|
||||
if (!context_simple->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
if (!priv->in_hex_sequence && have_hex_mods && is_hex_start)
|
||||
{
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
context_simple->in_hex_sequence = TRUE;
|
||||
context_simple->modifiers_dropped = FALSE;
|
||||
context_simple->tentative_match = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
priv->in_hex_sequence = TRUE;
|
||||
priv->modifiers_dropped = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-start");
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
@ -939,10 +966,10 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
|
||||
/* Then, check for compose sequences */
|
||||
if (context_simple->in_hex_sequence)
|
||||
if (priv->in_hex_sequence)
|
||||
{
|
||||
if (hex_keyval)
|
||||
context_simple->compose_buffer[n_compose++] = hex_keyval;
|
||||
priv->compose_buffer[n_compose++] = hex_keyval;
|
||||
else if (is_escape)
|
||||
{
|
||||
gtk_im_context_simple_reset (context);
|
||||
@ -958,11 +985,11 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
}
|
||||
else
|
||||
context_simple->compose_buffer[n_compose++] = event->keyval;
|
||||
priv->compose_buffer[n_compose++] = event->keyval;
|
||||
|
||||
context_simple->compose_buffer[n_compose] = 0;
|
||||
priv->compose_buffer[n_compose] = 0;
|
||||
|
||||
if (context_simple->in_hex_sequence)
|
||||
if (priv->in_hex_sequence)
|
||||
{
|
||||
/* If the modifiers are still held down, consider the sequence again */
|
||||
if (have_hex_mods)
|
||||
@ -970,20 +997,20 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
/* space or return ends the sequence, and we eat the key */
|
||||
if (n_compose > 0 && is_hex_end)
|
||||
{
|
||||
if (context_simple->tentative_match &&
|
||||
g_unichar_validate (context_simple->tentative_match))
|
||||
if (priv->tentative_match &&
|
||||
g_unichar_validate (priv->tentative_match))
|
||||
{
|
||||
gtk_im_context_simple_commit_char (context, context_simple->tentative_match);
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
gtk_im_context_simple_commit_char (context, priv->tentative_match);
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid hex sequence */
|
||||
beep_window (event->window);
|
||||
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->tentative_match = 0;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->compose_buffer[0] = 0;
|
||||
}
|
||||
}
|
||||
else if (!check_hex (context_simple, n_compose))
|
||||
@ -991,7 +1018,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
|
||||
if (!context_simple->in_hex_sequence)
|
||||
if (!priv->in_hex_sequence)
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
|
||||
return TRUE;
|
||||
@ -999,7 +1026,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_list = context_simple->tables;
|
||||
tmp_list = priv->tables;
|
||||
while (tmp_list)
|
||||
{
|
||||
if (check_table (context_simple, tmp_list->data, n_compose))
|
||||
@ -1011,12 +1038,12 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context,
|
||||
g_print ("[ ");
|
||||
for (i = 0; i < n_compose; i++)
|
||||
{
|
||||
const gchar *keyval_name = gdk_keyval_name (context_simple->compose_buffer[i]);
|
||||
const gchar *keyval_name = gdk_keyval_name (priv->compose_buffer[i]);
|
||||
|
||||
if (keyval_name != NULL)
|
||||
g_print ("%s ", keyval_name);
|
||||
else
|
||||
g_print ("%04x ", context_simple->compose_buffer[i]);
|
||||
g_print ("%04x ", priv->compose_buffer[i]);
|
||||
}
|
||||
g_print ("] ");
|
||||
});
|
||||
@ -1041,14 +1068,15 @@ static void
|
||||
gtk_im_context_simple_reset (GtkIMContext *context)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
|
||||
context_simple->compose_buffer[0] = 0;
|
||||
priv->compose_buffer[0] = 0;
|
||||
|
||||
if (context_simple->tentative_match || context_simple->in_hex_sequence)
|
||||
if (priv->tentative_match || priv->in_hex_sequence)
|
||||
{
|
||||
context_simple->in_hex_sequence = FALSE;
|
||||
context_simple->tentative_match = 0;
|
||||
context_simple->tentative_match_len = 0;
|
||||
priv->in_hex_sequence = FALSE;
|
||||
priv->tentative_match = 0;
|
||||
priv->tentative_match_len = 0;
|
||||
g_signal_emit_by_name (context_simple, "preedit-changed");
|
||||
g_signal_emit_by_name (context_simple, "preedit-end");
|
||||
}
|
||||
@ -1060,29 +1088,29 @@ gtk_im_context_simple_get_preedit_string (GtkIMContext *context,
|
||||
PangoAttrList **attrs,
|
||||
gint *cursor_pos)
|
||||
{
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
char outbuf[37]; /* up to 6 hex digits */
|
||||
int len = 0;
|
||||
|
||||
GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context);
|
||||
|
||||
if (context_simple->in_hex_sequence)
|
||||
if (priv->in_hex_sequence)
|
||||
{
|
||||
int hexchars = 0;
|
||||
|
||||
outbuf[0] = 'u';
|
||||
len = 1;
|
||||
|
||||
while (context_simple->compose_buffer[hexchars] != 0)
|
||||
while (priv->compose_buffer[hexchars] != 0)
|
||||
{
|
||||
len += g_unichar_to_utf8 (gdk_keyval_to_unicode (context_simple->compose_buffer[hexchars]),
|
||||
len += g_unichar_to_utf8 (gdk_keyval_to_unicode (priv->compose_buffer[hexchars]),
|
||||
outbuf + len);
|
||||
++hexchars;
|
||||
}
|
||||
|
||||
g_assert (len < 25);
|
||||
}
|
||||
else if (context_simple->tentative_match)
|
||||
len = g_unichar_to_utf8 (context_simple->tentative_match, outbuf);
|
||||
else if (priv->tentative_match)
|
||||
len = g_unichar_to_utf8 (priv->tentative_match, outbuf);
|
||||
|
||||
outbuf[len] = '\0';
|
||||
|
||||
@ -1130,6 +1158,7 @@ gtk_im_context_simple_add_table (GtkIMContextSimple *context_simple,
|
||||
gint max_seq_len,
|
||||
gint n_seqs)
|
||||
{
|
||||
GtkIMContextSimplePriv *priv = context_simple->priv;
|
||||
GtkComposeTable *table;
|
||||
|
||||
g_return_if_fail (GTK_IS_IM_CONTEXT_SIMPLE (context_simple));
|
||||
@ -1141,5 +1170,5 @@ gtk_im_context_simple_add_table (GtkIMContextSimple *context_simple,
|
||||
table->max_seq_len = max_seq_len;
|
||||
table->n_seqs = n_seqs;
|
||||
|
||||
context_simple->tables = g_slist_prepend (context_simple->tables, table);
|
||||
priv->tables = g_slist_prepend (priv->tables, table);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef struct _GtkIMContextSimple GtkIMContextSimple;
|
||||
typedef struct _GtkIMContextSimplePriv GtkIMContextSimplePriv;
|
||||
typedef struct _GtkIMContextSimpleClass GtkIMContextSimpleClass;
|
||||
|
||||
#define GTK_MAX_COMPOSE_LEN 7
|
||||
@ -47,14 +48,8 @@ struct _GtkIMContextSimple
|
||||
{
|
||||
GtkIMContext object;
|
||||
|
||||
GSList *GSEAL (tables);
|
||||
|
||||
guint GSEAL (compose_buffer[GTK_MAX_COMPOSE_LEN + 1]);
|
||||
gunichar GSEAL (tentative_match);
|
||||
gint GSEAL (tentative_match_len);
|
||||
|
||||
guint GSEAL (in_hex_sequence) : 1;
|
||||
guint GSEAL (modifiers_dropped) : 1;
|
||||
/* <private> */
|
||||
GtkIMContextSimplePriv *priv;
|
||||
};
|
||||
|
||||
struct _GtkIMContextSimpleClass
|
||||
|
Loading…
Reference in New Issue
Block a user