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 141157 - Request: GtkTextBuffer maximum length api
Request: GtkTextBuffer maximum length api
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: GtkTextView
2.4.x
Other Linux
: Normal enhancement
: Small API
Assigned To: makuchaku (Mayank)
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-04-26 16:59 UTC by Grant Gayed
Modified: 2018-02-10 03:21 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10


Attachments
"max-length" property for GtkTextBuffer (5.76 KB, patch)
2011-11-02 05:58 UTC, Swati Pardeshi
none Details | Review

Description Grant Gayed 2004-04-26 16:59:07 UTC
swt provides API Text.setTextLimit(int) which allows the user to set a limit on 
the number of characters that a Text can contain, beyond which it does not 
accept new characters.  This is not currently implemented in the gtk multiple-
line Text scenario because GtkTextBuffer does not provide something similar to 
gtk_entry_set_max_length(...) to do this for GtkTextViews.
Comment 1 Havoc Pennington 2007-03-01 15:48:14 UTC
It should be relatively simple to implement this by overriding the default behavior of the insert-text signal on GtkTextBuffer:

 http://developer.gnome.org/doc/API/2.0/gtk/GtkTextBuffer.html#GtkTextBuffer-insert-text

In an application, you could connect to the insert-text signal "before" (run before the default handler, using g_signal_connect not connect_after) then call g_signal_stop_emission_by_name() to keep the default handler from running if the buffer is already too large
http://developer.gnome.org/doc/API/2.0/gobject/gobject-Signals.html#g-signal-stop-emission-by-name

a set_max_length might be a nice API addition anyway but in the meantime you could do something like this as a workaround.
Comment 2 makuchaku (Mayank) 2007-03-05 09:39:46 UTC
Assigning to self as I'm trying to implement this API
Comment 3 Swati Pardeshi 2011-11-02 05:58:54 UTC
Created attachment 200479 [details] [review]
"max-length" property for GtkTextBuffer

I have been working on implementing "max-length" property for GtkTextBuffer. Attached is a proposed patch which implements "max-length" similar to GtkEntryBuffer. Request review.
Comment 4 Matthias Clasen 2018-02-10 03:21:23 UTC
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and
still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue
for it.