[clutter/clutter-1.16] clutter-text: emitting ClutterText::insert-text before actual changes on the text
- From: Alejandro Piñeiro Iglesias <apinheiro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.16] clutter-text: emitting ClutterText::insert-text before actual changes on the text
- Date: Fri, 17 Jan 2014 12:11:43 +0000 (UTC)
commit 798f4ef321c980a22220cce49a0d744ee85172b6
Author: Alejandro Piñeiro <apinheiro igalia com>
Date: Thu Jan 16 18:04:22 2014 +0100
clutter-text: emitting ClutterText::insert-text before actual changes on the text
https://bugzilla.gnome.org/show_bug.cgi?id=722220
(cherry picked from commit cadbeceff0a729cdeafd84db237ed44ad782e820)
Signed-off-by: Alejandro Piñeiro <apinheiro igalia com>
clutter/clutter-text.c | 38 ++++++++++++++++++++++++++++++--------
1 files changed, 30 insertions(+), 8 deletions(-)
---
diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c
index abc5608..a749739 100644
--- a/clutter/clutter-text.c
+++ b/clutter/clutter-text.c
@@ -4249,7 +4249,6 @@ buffer_inserted_text (ClutterTextBuffer *buffer,
ClutterTextPrivate *priv;
gint new_position;
gint new_selection_bound;
- gsize n_bytes;
priv = self->priv;
if (priv->position >= 0 || priv->selection_bound >= 0)
@@ -4266,10 +4265,6 @@ buffer_inserted_text (ClutterTextBuffer *buffer,
clutter_text_set_positions (self, new_position, new_selection_bound);
}
- n_bytes = g_utf8_offset_to_pointer (chars, n_chars) - chars;
- g_signal_emit (self, text_signals[INSERT_TEXT], 0, chars,
- n_bytes, &position);
-
/* TODO: What are we supposed to with the out value of position? */
}
@@ -5886,6 +5881,33 @@ clutter_text_get_max_length (ClutterText *self)
return clutter_text_buffer_get_max_length (get_buffer (self));
}
+static void
+clutter_text_real_insert_text (ClutterText *self,
+ guint start_pos,
+ const gchar *chars,
+ guint n_chars)
+{
+ gsize n_bytes;
+
+ n_bytes = g_utf8_offset_to_pointer (chars, n_chars) - chars;
+
+ /*
+ * insert-text is emitted here instead of as part of a
+ * buffer_inserted_text() callback because that should be emitted
+ * before the buffer changes, while ClutterTextBuffer::deleted-text
+ * is emitter after. See BG#722220 for more info.
+ */
+ g_signal_emit (self, text_signals[INSERT_TEXT], 0, chars,
+ n_bytes, &start_pos);
+
+ /*
+ * The actual insertion from the buffer. This will end firing the
+ * following signal handlers: buffer_inserted_text(),
+ * buffer_notify_text(), buffer_notify_max_length()
+ */
+ clutter_text_buffer_insert_text (get_buffer (self), start_pos, chars, n_chars);
+}
+
/**
* clutter_text_insert_unichar:
* @self: a #ClutterText
@@ -5908,11 +5930,12 @@ clutter_text_insert_unichar (ClutterText *self,
new = g_string_new ("");
g_string_append_unichar (new, wc);
- clutter_text_buffer_insert_text (get_buffer (self), priv->position, new->str, 1);
+ clutter_text_real_insert_text (self, priv->position, new->str, 1);
g_string_free (new, TRUE);
}
+
/**
* clutter_text_insert_text:
* @self: a #ClutterText
@@ -5936,8 +5959,7 @@ clutter_text_insert_text (ClutterText *self,
g_return_if_fail (CLUTTER_IS_TEXT (self));
g_return_if_fail (text != NULL);
- clutter_text_buffer_insert_text (get_buffer (self), position, text,
- g_utf8_strlen (text, -1));
+ clutter_text_real_insert_text (self, position, text, g_utf8_strlen (text, -1));
}
static
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]