Mercurial > geeqie
changeset 645:b50deb0f9968
Rename bar_exif_validate_text() to utf8_validate_or_convert() and move it to main.[ch].
author | zas_ |
---|---|
date | Mon, 12 May 2008 23:21:35 +0000 |
parents | d062f6b5711a |
children | 91dfc98f3ca1 |
files | src/bar_exif.c src/bar_exif.h src/main.c src/main.h src/pan-view.c |
diffstat | 5 files changed, 26 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/bar_exif.c Mon May 12 23:00:04 2008 +0000 +++ b/src/bar_exif.c Mon May 12 23:21:35 2008 +0000 @@ -141,25 +141,6 @@ EXIF_ADVCOL_COUNT }; -gchar *bar_exif_validate_text(gchar *text) -{ - gint len; - - if (!text) return NULL; - - len = strlen(text); - if (!g_utf8_validate(text, len, NULL)) - { - gchar *conv_text; - - conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); - g_free(text); - text = conv_text; - } - - return text; -} - static void bar_exif_sensitive(ExifBar *eb, gint enable) { gtk_widget_set_sensitive(eb->table, enable); @@ -209,7 +190,7 @@ continue; } text = exif_get_data_as_text(exif, ExifUIList[i].key); - text = bar_exif_validate_text(text); + text = utf8_validate_or_convert(text); if (ExifUIList[i].current == EXIF_UI_IFSET && (!text || !*text)) { @@ -243,7 +224,7 @@ list = list->prev; text = exif_get_data_as_text(exif, name); - text = bar_exif_validate_text(text); + text = utf8_validate_or_convert(text); buf = g_strconcat(name, ":", NULL); gtk_label_set_text(GTK_LABEL(eb->custom_name[i]), buf); @@ -287,11 +268,11 @@ tag_name = exif_item_get_tag_name(item); format = exif_item_get_format_name(item, TRUE); text = exif_item_get_data_as_text(item); - text = bar_exif_validate_text(text); + text = utf8_validate_or_convert(text); elements = g_strdup_printf("%d", exif_item_get_elements(item)); description = exif_item_get_description(item); if (!description) description = g_strdup(""); - description = bar_exif_validate_text(description); + description = utf8_validate_or_convert(description); gtk_list_store_append(store, &iter); gtk_list_store_set(store, &iter, EXIF_ADVCOL_ENABLED, bar_exif_row_enabled(tag_name),
--- a/src/bar_exif.h Mon May 12 23:00:04 2008 +0000 +++ b/src/bar_exif.h Mon May 12 23:21:35 2008 +0000 @@ -41,7 +41,5 @@ const gchar **bar_exif_key_list; const gint bar_exif_key_count; -gchar *bar_exif_validate_text(gchar *text); - #endif
--- a/src/main.c Mon May 12 23:00:04 2008 +0000 +++ b/src/main.c Mon May 12 23:21:35 2008 +0000 @@ -120,6 +120,25 @@ return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0); } +gchar *utf8_validate_or_convert(gchar *text) +{ + gint len; + + if (!text) return NULL; + + len = strlen(text); + if (!g_utf8_validate(text, len, NULL)) + { + gchar *conv_text; + + conv_text = g_convert(text, len, "UTF-8", "ISO-8859-1", NULL, NULL, NULL); + g_free(text); + text = conv_text; + } + + return text; +} + /* *-----------------------------------------------------------------------------
--- a/src/main.h Mon May 12 23:00:04 2008 +0000 +++ b/src/main.h Mon May 12 23:21:35 2008 +0000 @@ -130,6 +130,7 @@ gint window_maximized(GtkWidget *window); gdouble get_zoom_increment(void); +gchar *utf8_validate_or_convert(gchar *text); void help_window_show(const gchar *key);
--- a/src/pan-view.c Mon May 12 23:00:04 2008 +0000 +++ b/src/pan-view.c Mon May 12 23:21:35 2008 +0000 @@ -1448,7 +1448,7 @@ if (ExifUIList[i].current == EXIF_UI_OFF) continue; text = exif_get_data_as_text(exif, ExifUIList[i].key); - text = bar_exif_validate_text(text); + text = utf8_validate_or_convert(text); if (ExifUIList[i].current == EXIF_UI_IFSET && (!text || !*text)) { if (text) g_free(text); @@ -1474,7 +1474,7 @@ label = g_strdup_printf("%s:", name); text = exif_get_data_as_text(exif, name); - text = bar_exif_validate_text(text); + text = utf8_validate_or_convert(text); pan_text_alignment_add(ta, label, text); g_free(label); g_free(text);