[gtk/preedit-selection-fix: 2/8] immulticontext: Implement [gs]et_surrounding_with_selection
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/preedit-selection-fix: 2/8] immulticontext: Implement [gs]et_surrounding_with_selection
- Date: Thu, 4 Mar 2021 20:18:55 +0000 (UTC)
commit 97db959305cd30450dfa1dca713ee7477b792fa4
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Mar 4 15:14:52 2021 -0500
immulticontext: Implement [gs]et_surrounding_with_selection
This is the recommended api, going forward.
gtk/gtkimmulticontext.c | 48 ++++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkimmulticontext.c b/gtk/gtkimmulticontext.c
index 75a70c3f0d..5775a42880 100644
--- a/gtk/gtkimmulticontext.c
+++ b/gtk/gtkimmulticontext.c
@@ -74,13 +74,17 @@ static void gtk_im_multicontext_set_cursor_location (GtkIMContext
GdkRectangle *area);
static void gtk_im_multicontext_set_use_preedit (GtkIMContext *context,
gboolean use_preedit);
-static gboolean gtk_im_multicontext_get_surrounding (GtkIMContext *context,
- char **text,
- int *cursor_index);
-static void gtk_im_multicontext_set_surrounding (GtkIMContext *context,
- const char *text,
- int len,
- int cursor_index);
+static gboolean gtk_im_multicontext_get_surrounding_with_selection
+ (GtkIMContext *context,
+ char **text,
+ int *cursor_index,
+ int *anchor_index);
+static void gtk_im_multicontext_set_surrounding_with_selection
+ (GtkIMContext *context,
+ const char *text,
+ int len,
+ int cursor_index,
+ int anchor_index);
static void gtk_im_multicontext_preedit_start_cb (GtkIMContext *delegate,
GtkIMMulticontext *multicontext);
@@ -118,8 +122,8 @@ gtk_im_multicontext_class_init (GtkIMMulticontextClass *class)
im_context_class->reset = gtk_im_multicontext_reset;
im_context_class->set_cursor_location = gtk_im_multicontext_set_cursor_location;
im_context_class->set_use_preedit = gtk_im_multicontext_set_use_preedit;
- im_context_class->set_surrounding = gtk_im_multicontext_set_surrounding;
- im_context_class->get_surrounding = gtk_im_multicontext_get_surrounding;
+ im_context_class->set_surrounding_with_selection = gtk_im_multicontext_set_surrounding_with_selection;
+ im_context_class->get_surrounding_with_selection = gtk_im_multicontext_get_surrounding_with_selection;
gobject_class->finalize = gtk_im_multicontext_finalize;
}
@@ -460,37 +464,41 @@ gtk_im_multicontext_set_use_preedit (GtkIMContext *context,
}
static gboolean
-gtk_im_multicontext_get_surrounding (GtkIMContext *context,
- char **text,
- int *cursor_index)
+gtk_im_multicontext_get_surrounding_with_selection (GtkIMContext *context,
+ char **text,
+ int *cursor_index,
+ int *anchor_index)
{
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
GtkIMContext *delegate = gtk_im_multicontext_get_delegate (multicontext);
if (delegate)
- return gtk_im_context_get_surrounding (delegate, text, cursor_index);
+ return gtk_im_context_get_surrounding_with_selection (delegate, text, cursor_index, anchor_index);
else
{
if (text)
- *text = NULL;
+ *text = NULL;
if (cursor_index)
- *cursor_index = 0;
+ *cursor_index = 0;
+ if (anchor_index)
+ *anchor_index = 0;
return FALSE;
}
}
static void
-gtk_im_multicontext_set_surrounding (GtkIMContext *context,
- const char *text,
- int len,
- int cursor_index)
+gtk_im_multicontext_set_surrounding_with_selection (GtkIMContext *context,
+ const char *text,
+ int len,
+ int cursor_index,
+ int anchor_index)
{
GtkIMMulticontext *multicontext = GTK_IM_MULTICONTEXT (context);
GtkIMContext *delegate = gtk_im_multicontext_get_delegate (multicontext);
if (delegate)
- gtk_im_context_set_surrounding (delegate, text, len, cursor_index);
+ gtk_im_context_set_surrounding_with_selection (delegate, text, len, cursor_index, anchor_index);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]