summaryrefslogtreecommitdiff
path: root/gtk/gtkentry.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-11-01 21:50:58 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-11-01 21:50:58 +0000
commita1fe2ac180bf3c16dd58145e356767fc097c6b70 (patch)
tree9b501544246cd9c8f780550291b5f32080843500 /gtk/gtkentry.c
parent2704ea2b581c4d601c43e9843fca9afe271fc3a7 (diff)
downloadgtk+-a1fe2ac180bf3c16dd58145e356767fc097c6b70.tar.gz
Add: - A ::retrieve_surrounding signal that asks the widget for context
Thu Nov 1 16:20:56 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkimcontext.[ch]: Add: - A ::retrieve_surrounding signal that asks the widget for context around the insertion point. - A ::delete_surrounding signal that asks the widget to delete context aroudn the insertion point. - gtk_im_context_set_context() for widgets to set context around the insertion point in response to ::retrieve_context. - gtk_im_context_get_context() for context to get context around the insertion point * gtkmarshal.list: Add BOOL:INT,INT * gtk/gtkimmulticontext.c: Proxy the get_surrounding() / set_surrounding() methods, and the ::retrieve_surrounding / ::delete_surrounding signals. * gtk/gtkentry.c gtk/gtktreeview.c: Hook up to the GtkIMContext::retrieve_surrounding / ::delete_surrounding signals.
Diffstat (limited to 'gtk/gtkentry.c')
-rw-r--r--gtk/gtkentry.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index e3a8804bdc..a9c21bebc3 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -232,11 +232,18 @@ static void gtk_entry_keymap_direction_changed (GdkKeymap *keymap,
GtkEntry *entry);
/* IM Context Callbacks
*/
-static void gtk_entry_commit_cb (GtkIMContext *context,
- const gchar *str,
- GtkEntry *entry);
-static void gtk_entry_preedit_changed_cb (GtkIMContext *context,
- GtkEntry *entry);
+static void gtk_entry_commit_cb (GtkIMContext *context,
+ const gchar *str,
+ GtkEntry *entry);
+static void gtk_entry_preedit_changed_cb (GtkIMContext *context,
+ GtkEntry *entry);
+static gboolean gtk_entry_retrieve_surrounding_cb (GtkIMContext *context,
+ GtkEntry *entry);
+static gboolean gtk_entry_delete_surrounding_cb (GtkIMContext *context,
+ gint offset,
+ gint n_chars,
+ GtkEntry *entry);
+
/* Internal routines
*/
static void gtk_entry_set_positions (GtkEntry *entry,
@@ -919,6 +926,10 @@ gtk_entry_init (GtkEntry *entry)
G_CALLBACK (gtk_entry_commit_cb), entry);
g_signal_connect (G_OBJECT (entry->im_context), "preedit_changed",
G_CALLBACK (gtk_entry_preedit_changed_cb), entry);
+ g_signal_connect (G_OBJECT (entry->im_context), "retrieve_surrounding",
+ G_CALLBACK (gtk_entry_retrieve_surrounding_cb), entry);
+ g_signal_connect (G_OBJECT (entry->im_context), "delete_surrounding",
+ G_CALLBACK (gtk_entry_delete_surrounding_cb), entry);
}
static void
@@ -2272,6 +2283,31 @@ gtk_entry_preedit_changed_cb (GtkIMContext *context,
gtk_entry_recompute (entry);
}
+static gboolean
+gtk_entry_retrieve_surrounding_cb (GtkIMContext *context,
+ GtkEntry *entry)
+{
+ gtk_im_context_set_surrounding (context,
+ entry->text,
+ entry->n_bytes,
+ g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text);
+
+ return TRUE;
+}
+
+static gboolean
+gtk_entry_delete_surrounding_cb (GtkIMContext *slave,
+ gint offset,
+ gint n_chars,
+ GtkEntry *entry)
+{
+ gtk_editable_delete_text (GTK_EDITABLE (entry),
+ entry->current_pos + offset,
+ entry->current_pos + offset + n_chars);
+
+ return TRUE;
+}
+
/* Internal functions
*/