Re: misc. properties



jacob berkman <jacob ximian com> writes: 
> so i'm running into the same issue with GtkTextView; here's a quick
> patch.

Creates the issue that the text view may not have a buffer yet, or the
buffer may change - probably OK, I just want this code to create only
one buffer:
 
  view = gtk_text_view_new ();
  buffer = gtk_text_buffer_new ();
  gtk_text_view_set_buffer (view, buffer);

I'm not sure what it does now, but I want the view to create its
implicit buffer lazily enough that it doesn't get created in that
case.

> as an aside - is there an easier way to get all the text from a text
> buffer?  initializing the iters etc. seems like a PITA for such a common
> thing as getting all the text,  especially since _set_text() doesn't
> take an iter - _insert_text() does.

The get_text() interface is a bit screwed up. Making it worse is the
inconsistency with the text_iter functions for doing the same
thing. I think we get to live with it at this point though.

The least-typing way to get text is:

 GtkTextIter start, end;
 gtk_text_buffer_get_bounds (buffer, &start, &end);
 text = gtk_text_iter_get_text (&start, &end);

You're probably right that gtk_text_buffer_get_text() should take no
args and return all the text in the buffer.

And the iter/buffer variants shouldn't exist, we should just have one.

> and it is also a little confusing why GtkTextView doesn't implement
> GtkEditable.

Because GtkEditable includes several signals/vfuncs such as
insert_text as part of its interface, which are impossible to
implement with the proper semantics on GtkTextView. (There was much
discussion of simply making GtkText a wrapper of GtkTextView, and the
signal issue prevented it.)

> i haven't been following the TextView development, but these are my
> first thoughts when porting from GtkText to GtkTextView (is there a doc
> for this?)

There are reasonable API docs for much of text view, including an
overview section, but nothing on porting specifically.

Havoc



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