After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 727908 - Various GtkTextView improvements (doc, unit tests)
Various GtkTextView improvements (doc, unit tests)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
3.12.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-04-09 17:25 UTC by Sébastien Wilmet
Modified: 2014-04-13 21:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests textiter: test word boundaries (4.62 KB, patch)
2014-04-09 17:27 UTC, Sébastien Wilmet
committed Details | Review
doc: improve documentation of gtk_text_iter_inside_word() (1.95 KB, patch)
2014-04-09 17:27 UTC, Sébastien Wilmet
committed Details | Review
textview: inline a function (1.81 KB, patch)
2014-04-09 17:27 UTC, Sébastien Wilmet
committed Details | Review
GtkTextView: use GSlice to allocate GtkTextLineSegment's (9.22 KB, patch)
2014-04-11 19:53 UTC, Sébastien Wilmet
committed Details | Review

Description Sébastien Wilmet 2014-04-09 17:25:55 UTC
Various GtkTextView improvements, see the attached patches.
Comment 1 Sébastien Wilmet 2014-04-09 17:27:39 UTC
Created attachment 273922 [details] [review]
tests textiter: test word boundaries

- As the tests show, some of the functions have a strange and
inconsistent behavior for corner cases.

- Rename test_full_buffer() -> test_search_full_buffer() because
textiter.c is used for other GtkTextIter unit tests.
Comment 2 Sébastien Wilmet 2014-04-09 17:27:43 UTC
Created attachment 273923 [details] [review]
doc: improve documentation of gtk_text_iter_inside_word()

There is a possible confusion with the sentence:
"@iter is inside a natural-language word"

The iter should be viewed here as the pointed character (i.e. on the
right of the iter), not as a position between two characters.

Instead of improving the documentation, another solution would have been
to change the implementation so it is interpreted as an iter position
inside a word, i.e. between two characters that are part of a
natural-language word. But maybe some applications rely on the current
implementation.
Comment 3 Sébastien Wilmet 2014-04-09 17:27:47 UTC
Created attachment 273924 [details] [review]
textview: inline a function

gtk_text_view_move_cursor_internal() was exactly the same as
gtk_text_view_move_cursor(), and was called only in the latter function.
Comment 4 Sébastien Wilmet 2014-04-11 19:53:27 UTC
Created attachment 274130 [details] [review]
GtkTextView: use GSlice to allocate GtkTextLineSegment's

Use GSlice to allocate all types of segments:
- char
- toggle
- mark
- pixbuf
- child widget

Char segments are a bit more complicated because the length of the text
is determined at run time and stored in the 'byte_count' field. If the
text is long, GSlice will call the system malloc() anyway, so it's
better to always use GSlice for GtkTextLineSegment.

Toggle segments are also freed in gtktextbtree.c, hence the function
_gtk_toggle_segment_free() (for a later commit it would be nice to
rename those functions with the _gtk_text prefix).
Comment 5 Matthias Clasen 2014-04-13 21:08:56 UTC
Attachment 273922 [details] pushed as 704a178 - tests textiter: test word boundaries
Attachment 273923 [details] pushed as 22ce03f - doc: improve documentation of gtk_text_iter_inside_word()
Attachment 273924 [details] pushed as d69d57a - textview: inline a function
Attachment 274130 [details] pushed as 983a03d - GtkTextView: use GSlice to allocate GtkTextLineSegment's