summaryrefslogtreecommitdiffstats
path: root/gtk/src/callbacks.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-09-30 16:48:38 +0000
committerjstebbins <[email protected]>2009-09-30 16:48:38 +0000
commit6dbae64adc847cee2923393393cc17eb982cd847 (patch)
tree4faa093b04b27bc4c04c3d7e970c2d5e73a0d0bf /gtk/src/callbacks.c
parent8e35653c79dbe97b5b512796e0d9abc9102762b2 (diff)
LinGui: fix Gtk-CRITICAL warning when logging invalid utf-8 characters
assume all log text is iso8859-1 and convert to utf-8 git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2857 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/callbacks.c')
-rw-r--r--gtk/src/callbacks.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 74db8030a..ca9ac86a4 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -2723,6 +2723,7 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
gint width, height;
gint x, y;
gboolean bottom = FALSE;
+ gchar *utf8_text;
textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "activity_view"));
buffer = gtk_text_view_get_buffer (textview);
@@ -2748,34 +2749,40 @@ ghb_log_cb(GIOChannel *source, GIOCondition cond, gpointer data)
bottom = TRUE;
}
gtk_text_buffer_get_end_iter(buffer, &iter);
- gtk_text_buffer_insert(buffer, &iter, text, -1);
- if (bottom)
+ utf8_text = g_convert_with_fallback(text, -1, "UTF-8", "ISO-8859-1",
+ "?", NULL, &length, NULL);
+ if (utf8_text != NULL)
{
- gtk_text_buffer_get_end_iter(buffer, &iter);
- mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
- gtk_text_view_scroll_mark_onscreen(textview, mark);
- gtk_text_buffer_delete_mark(buffer, mark);
- }
-#if defined(_WIN32)
- gsize one = 1;
- text[length-1] = '\r';
-#endif
- g_io_channel_write_chars (ud->activity_log, text,
- length, &outlength, NULL);
+ gtk_text_buffer_insert(buffer, &iter, utf8_text, -1);
+ if (bottom)
+ {
+ gtk_text_buffer_get_end_iter(buffer, &iter);
+ mark = gtk_text_buffer_create_mark(buffer, NULL, &iter, FALSE);
+ gtk_text_view_scroll_mark_onscreen(textview, mark);
+ gtk_text_buffer_delete_mark(buffer, mark);
+ }
#if defined(_WIN32)
- g_io_channel_write_chars (ud->activity_log, "\n",
- one, &one, NULL);
+ gsize one = 1;
+ utf8_text[length-1] = '\r';
#endif
- g_io_channel_flush(ud->activity_log, NULL);
- if (ud->job_activity_log)
- {
- g_io_channel_write_chars (ud->job_activity_log, text,
+ g_io_channel_write_chars (ud->activity_log, utf8_text,
length, &outlength, NULL);
#if defined(_WIN32)
g_io_channel_write_chars (ud->activity_log, "\n",
- one, &outlength, NULL);
+ one, &one, NULL);
#endif
- g_io_channel_flush(ud->job_activity_log, NULL);
+ g_io_channel_flush(ud->activity_log, NULL);
+ if (ud->job_activity_log)
+ {
+ g_io_channel_write_chars (ud->job_activity_log, utf8_text,
+ length, &outlength, NULL);
+#if defined(_WIN32)
+ g_io_channel_write_chars (ud->activity_log, "\n",
+ one, &outlength, NULL);
+#endif
+ g_io_channel_flush(ud->job_activity_log, NULL);
+ }
+ g_free(utf8_text);
}
}
if (text != NULL)