Re: gtk_text_buffer_delete_interactive



On Mon, Sep 10, 2001 at 05:59:27PM -0400, Havoc Pennington wrote:
> vishnu pobox com writes:
> > Can i add a "delete-range-interactive" signal that mirrors
> > the "delete-range" signal?
> > 
> > If i can insert my code before "delete-range-interactive"
> > then i can adjust the tags & iterators to do the right thing.
> 
> It should be possible to simply adjust the iterators in a signal
> handler connected to delete_range. The deletion occurs in the
> delete_range default handler which runs after your signal handlers.

Yes, i know, but that won't work because the iterators passed
into delete_range are already adjusted to respect the editable
attribute.

If you connect a signal handler like this:

  g_signal_connect (cx->text, "delete-range",
		    G_CALLBACK (_text_delete_range), cx);

static void
_text_delete_range (GtkTextBuffer *buffer,
		    GtkTextIter   *start,
		    GtkTextIter   *end,
		    AppTranscript *tx)
{
  gchar *text = gtk_text_iter_get_text (start, end);
  g_print ("d[%s]\n", text);
  // text is memory leak, oops
}

You will see that this handler isn't even called for the
example in my initial message (cursor directly before the
editable=false range and delete is pressed).  The code
inside gtk_text_buffer_delete_interactive has already
decided that the event should not be processed further.

In contrast, if i can insert code *before* gkt_t_b_d_i then
i'm sure i can adjust things to the desired behavior.

Again, no new APIs are needed and i'm happy to do the patch.

Please comment.




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