GNOME Bugzilla – Bug 322252
GtkEntry: Truncate multi-line pastes
Last modified: 2005-12-19 19:05:19 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.
Created attachment 55155 [details] [review] Patch implementing the truncate-multiline property
Actually, I think this property should be enabled by default in GTK's own filename entries and in treeview cells.
i think this should go into CVS, however i'd like to get matthias or owen's opinion on it as well.
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 ?
Yes, I think that property should be applied to DND too.
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.
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.
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
Created attachment 56162 [details] [review] Updated patch addressing the mentioned issues in GtkEntry
Looks good to commit. Do you want to turn it on for the file chooser entry ?
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.