Re: Can someone please comment on this short program

On Thu, 2005-12-15 at 11:40 -0600, Federico Mena Quintero wrote:

> /* Get a filename from the file chooser and display it in a widget */
> char *filename_on_disk = gtk_file_chooser_get_filename (chooser);
> GError *error = NULL;
> char *utf8_filename = g_filename_to_utf8 (filename_on_disk, -1, NULL, NULL, &error);
> if (utf8_filename == NULL)
>     g_error ("Could not convert on-disk filename to UTF-8: %s", error->message);
> else
>     gtk_entry_set_text (entry, utf8_filename);

For display only I would use g_filename_display_name() or
g_filename_display_basename() instead, they don't fail but do a "best
effort" to get something at least. But if its an editable widget that is
not a good idea, as it may change the actual string.

 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a lounge-singing white trash cyborg with no name. She's a supernatural 
snooty doctor with only herself to blame. They fight crime! 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]