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 322252 - GtkEntry: Truncate multi-line pastes
GtkEntry: Truncate multi-line pastes
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
2.8.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2005-11-23 16:55 UTC by Michael Natterer
Modified: 2005-12-19 19:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch implementing the truncate-multiline property (3.75 KB, patch)
2005-11-23 16:56 UTC, Michael Natterer
none Details | Review
Updated patch addressing the mentioned issues in GtkEntry (5.14 KB, patch)
2005-12-19 15:07 UTC, Michael Natterer
committed Details | Review

Description Michael Natterer 2005-11-23 16:55:21 UTC
Attached patch was extracted from maemo-gtk and made configurable.
It adds a boolean "truncate-multiline" property which, when TRUE
truncates pasted text to the first line.

This is useful esp. in filename entries, where one often happens
to paste the terminating newline with filenames copied from the
terminal window or editor.
Comment 1 Michael Natterer 2005-11-23 16:56:06 UTC
Created attachment 55155 [details] [review]
Patch implementing the truncate-multiline property
Comment 2 Michael Natterer 2005-11-23 17:03:01 UTC
Actually, I think this property should be enabled by default in GTK's own
filename entries and in treeview cells.
Comment 3 Tim Janik 2005-12-02 12:41:11 UTC
i think this should go into CVS, however i'd like to get matthias or owen's
opinion on it as well.
Comment 4 Matthias Clasen 2005-12-02 13:00:51 UTC
Should use strchr() instead of manually looking for '\n', but is just looking
for '\n' good enough ? What about possible '\r's in the text ?

If the use case is really only trailing newlines, though, it might be easier to
just always trim a trailing newline, and not worry about a property to turn this
on or off. 

Does the trim-trailing-newline idea also apply to DND ?
Comment 5 Michael Natterer 2005-12-07 15:27:49 UTC
Yes, I think that property should be applied to DND too.
Comment 6 Tim Janik 2005-12-12 10:55:45 UTC
matthias, what you suggest will work for entries used to enter filenames
(because filenames can't properly contain \n.* as far as i'm aware). but for
other types of entries, being able to enter/edit multi line text may be
intended, so we couldn't simply disable this feature.
i.e. i think we'll have to introduce a property here that needs to default to
FALSE to maintain compatibility with the current entry functionality.
Comment 7 Matthias Clasen 2005-12-12 18:16:25 UTC
Well, technically, the only bytes not allowed in filenames are '\0' and '/'. I
don't think trimming trailing newlines (not internal newlines) will affect the
ability to enter multiline text in entries (to the extent that thats possible at
all currently), but I don't feel very strong about adding a property.
Comment 8 Tim Janik 2005-12-14 14:24:38 UTC
ok, after some talking to matthias on irc, we came up with:
- the patch should treat \r (CR) equally to \n (LF)
- entries used for filenames should default to truncate-multiline=TRUE
- truncation should be applied to DND as well
Comment 9 Michael Natterer 2005-12-19 15:07:01 UTC
Created attachment 56162 [details] [review]
Updated patch addressing the mentioned issues in GtkEntry
Comment 10 Matthias Clasen 2005-12-19 17:24:15 UTC
Looks good to commit. 
Do you want to turn it on for the file chooser entry ?
Comment 11 Michael Natterer 2005-12-19 19:05:19 UTC
Fixed in CVS:

2005-12-19  Michael Natterer  <mitch@imendio.com>

	* gtk/gtkentry.c: implement boolean property "truncate-multiline"
	which, when enabled, truncates multi-line pastes or drops to their
	first line. Fixes bug #322252.

	* gtk/gtkfilechooserentry.c (gtk_file_chooser_entry_init): enable
	truncate-multiline here.