[gedit-list] Default signal hander for insert-text signal



Hi All,
I want to figure out what's the default signal hander for insert-text signal in the source code of gedit. I found that in file "gedit/gedit-document.c" function "insert_text_cb". There is some comments in the insert_text_cb.
<snip>
2806 static void
2807 insert_text_cb (GeditDocument *doc,
2808                 GtkTextIter   *pos,
2809                 const gchar   *text,
2810                 gint           length)
2811 {
2812         GtkTextIter start;
2813         GtkTextIter end;
2814
2815         gedit_debug (DEBUG_DOCUMENT);
2816
2817         start = end = *pos;
2818
2819         /*
2820          * pos is invalidated when
2821 * insertion occurs (because the buffer contents change), but the 2822 * default signal handler revalidates it to point to the end of the
2823          * inserted text
2824          */
2825         gtk_text_iter_backward_chars (&start,
2826                                       g_utf8_strlen (text, length));
2827
2828         to_search_region_range (doc, &start, &end);
2829 }
</snip>
In the comment, "the default signal handler revalidates it to point to the end of the inserted", also where is the content of "text" come from?

I also check out the file in gtk/gtktextbuffer.c
function gtk_text_buffer_real_insert_text
<snip>
279   /**
 280    * GtkTextBuffer::insert-text:
 281    * @textbuffer: the object which received the signal
 282    * @location: position to insert @text in @textbuffer
 283    * @text: the UTF-8 text to be inserted
 284    * @len: length of the inserted text in bytes
 285    *
286 * The ::insert-text signal is emitted to insert text in a #GtkTextBuffer.
 287    * Insertion actually occurs in the default handler.
 288    *
289 * Note that if your handler runs before the default handler it must not
 290    * invalidate the @location iter (or has to revalidate it).
291 * The default signal handler revalidates it to point to the end of the
 292    * inserted text.
 293    *
 294    * See also:
 295    * gtk_text_buffer_insert(),
 296    * gtk_text_buffer_insert_range().
 297    */
 298   signals[INSERT_TEXT] =
 299     g_signal_new (I_("insert-text"),
 300                   G_OBJECT_CLASS_TYPE (object_class),
 301                   G_SIGNAL_RUN_LAST,
 302                   G_STRUCT_OFFSET (GtkTextBufferClass, insert_text),
 303                   NULL, NULL,
 304                   _gtk_marshal_VOID__BOXED_STRING_INT,
 305                   G_TYPE_NONE,
 306                   3,
 307                   GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
 308                   G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
 309                   G_TYPE_INT);
</snip>

Could someone shed me some lights on where is the default signal handler for insert-text signal defined?

Best Wishes,
Yaohui Hu



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]