From David Aggeler via bug 3468:

Escape filenames in the welcome screen with g_markup_escape_text().


From me:

Add a binary prefix for gigabytes. Add a comment explaining why we're
using binary prefixes instead of IEC.

svn path=/trunk/; revision=28453
This commit is contained in:
Gerald Combs 2009-05-22 23:09:31 +00:00
parent f7f2a08def
commit 42ad8213bb
1 changed files with 22 additions and 10 deletions

View File

@ -408,6 +408,7 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
GtkWidget *w;
GtkWidget *eb;
GString *str;
gchar *str_escaped;
const unsigned int max = 60;
int err;
struct stat stat_buf;
@ -425,15 +426,26 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label)
g_string_insert(str, 20, " ... ");
}
/* add file size */
/* escape the possibly shortened filename before adding pango language */
str_escaped=g_markup_escape_text(str->str, -1);
g_string_free(str, TRUE);
str=g_string_new(str_escaped);
g_free(str_escaped);
/*
* Add file size. We use binary prefixes instead of IEC because that's what
* most OSes use.
*/
err = ws_stat(filename, &stat_buf);
if(err == 0) {
if (stat_buf.st_size/1024/1024 > 10) {
g_string_append_printf(str, " %" G_GINT64_MODIFIER "dMB", (gint64) (stat_buf.st_size/1024/1024));
if (stat_buf.st_size/1024/1024/1024 > 10) {
g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d GB)", (gint64) (stat_buf.st_size/1024/1024/1024));
} else if (stat_buf.st_size/1024/1024 > 10) {
g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d MB)", (gint64) (stat_buf.st_size/1024/1024));
} else if (stat_buf.st_size/1024 > 10) {
g_string_append_printf(str, " %" G_GINT64_MODIFIER "dKB", (gint64) (stat_buf.st_size/1024));
g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d KB)", (gint64) (stat_buf.st_size/1024));
} else {
g_string_append_printf(str, " %" G_GINT64_MODIFIER "d Bytes", (gint64) (stat_buf.st_size));
g_string_append_printf(str, " (%" G_GINT64_MODIFIER "d Bytes)", (gint64) (stat_buf.st_size));
}
} else {
g_string_append(str, " [not found]");