- //
- // FIXME: this doesn't work when we paste a string which is going to be
- // truncated
- if (text_length == text_max_length)
+
+ const int text_length = gtk_entry_get_text_length(entry);
+
+ // We can't use new_text_length as it is in bytes while we want to count
+ // characters (in first approximation, anyhow...).
+ if ( text_length + g_utf8_strlen(new_text, -1) > text_max_length )