From a5fddd5b417a3aff4e4f1771a45763c280df0823 Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 20 Jan 2005 10:33:27 +0000 Subject: action.c: convert locale strings to UTF-8 before displaying it. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@24 ee746299-78ed-0310-b773-934348b2243d --- src/action.c | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/action.c b/src/action.c index 4c97f73a..430de479 100644 --- a/src/action.c +++ b/src/action.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2004 Hiroyuki Yamamoto & The Sylpheed Claws Team + * Copyright (C) 1999-2005 Hiroyuki Yamamoto & The Sylpheed Claws Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1006,7 +1006,8 @@ static void update_io_dialog(Children *children) textbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); gtk_text_buffer_get_start_iter(textbuf, &start_iter); gtk_text_buffer_get_end_iter(textbuf, &end_iter); - iter = start_iter; + gtk_text_buffer_delete(textbuf, &start_iter, &end_iter); + gtk_text_buffer_get_start_iter(textbuf, &iter); for (cur = children->list; cur; cur = cur->next) { child_info = (ChildInfo *)cur->data; @@ -1184,7 +1185,7 @@ static void catch_input(gpointer data, gint source, GdkInputCondition cond) static void catch_output(gpointer data, gint source, GdkInputCondition cond) { ChildInfo *child_info = (ChildInfo *)data; - gint c, i; + gint c; gchar buf[BUFFSIZE]; debug_print("Catching grand child's output.\n"); @@ -1202,10 +1203,22 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond) gtk_text_buffer_get_iter_at_mark(textbuf, &iter2, mark); while (TRUE) { + gsize bytes_read = 0, bytes_written = 0; + gchar *ret_str; + c = read(source, buf, sizeof(buf) - 1); if (c == 0) break; - gtk_text_buffer_insert(textbuf, &iter2, buf, c); + + ret_str = g_locale_to_utf8 + (buf, c, &bytes_read, &bytes_written, NULL); + if (ret_str && bytes_written > 0) { + gtk_text_buffer_insert + (textbuf, &iter2, ret_str, + bytes_written); + g_free(ret_str); + } else + gtk_text_buffer_insert(textbuf, &iter2, buf, c); } if (child_info->children->is_selection) { @@ -1215,10 +1228,22 @@ static void catch_output(gpointer data, gint source, GdkInputCondition cond) } } else { c = read(source, buf, sizeof(buf) - 1); - for (i = 0; i < c; i++) - g_string_append_c(child_info->output, buf[i]); - if (c > 0) + if (c > 0) { + gsize bytes_read = 0, bytes_written = 0; + gchar *ret_str; + + ret_str = g_locale_to_utf8 + (buf, c, &bytes_read, &bytes_written, NULL); + if (ret_str && bytes_written > 0) { + g_string_append_len + (child_info->output, ret_str, + bytes_written); + g_free(ret_str); + } else + g_string_append_len(child_info->output, buf, c); + child_info->new_out = TRUE; + } } if (c == 0) { if (source == child_info->chld_out) { -- cgit v1.2.3