Comment 19 for bug 107668

Revision history for this message
Martin Pitt (pitti) wrote :

Nicolas,

thanks for your initial work. First, some comments to the patch so far:

 - gtk_editable_get_chars() (just like all glib/gtk functions) already return a copy of the string, no need to copy it again. So you can simplify the loop like Mikele said.

   Just for some bikeshedding, I think that a for loop is a bit easier to read:

   for (p = text; *p; ++p)
       if (*p=='/') *p='_';

   But that's just a matter of style.

 - Right now it seems that the modified string is never actually written back to the input line? This should happen, so that the user sees the correction.
 - The loop should set a flag if it replaced any character. If so, then there should be a gtk_message_dialog which points out the error.
 - You need to g_free() the string you received from gtk_editable_get_chars() after having finished working with it.

Happy hacking!