[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sylpheed
Subject:    [sylpheed:23861] Minor action.c fixes
From:       Alfons Hoogervorst <alfons () proteus ! demon ! nl>
Date:       2005-01-19 23:14:53
Message-ID: 20050120001453.79a4866b.alfons () proteus ! demon ! nl
[Download RAW message or body]

Lo Hiro,

This patch to actions fixes a code conversion problem I found with 
src/action.c: data returned over a pipe should be converted to UTF-8 before 
inserted in a GtkTextBuffer.

And the other one hunk fixes the output as how Melvin it initially coded for 
GTK 1.

Martin Schaaf should have another UTF-8 patch for action.c.

Bye.

-- 
Ecuación algebraico sin solución posible,
a menos de poseer profundos conocimientos
en matemática - Revueltas (Ocho Por Radio)


["gtk2-fixes.action.patch" (text/plain)]

Thu Jan 20 00:02:49 CET 2005  alfons_hoogervorst@gmail_com
  * action fixes
  * clear initial Running: text when action finished
  * output sent over pipe maybe UTF-8
--- sylpheed-old/trunk/src/action.c	2005-01-20 00:07:31.000000000 +0100
+++ sylpheed-new/trunk/src/action.c	2005-01-20 00:00:59.000000000 +0100
@@ -1006,6 +1006,8 @@
 		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);
+		gtk_text_buffer_delete(textbuf, &start_iter, &end_iter);
+		gtk_text_buffer_get_start_iter(textbuf, &start_iter);
 		iter = start_iter;
 
 		for (cur = children->list; cur; cur = cur->next) {
@@ -1205,7 +1207,18 @@
 			c = read(source, buf, sizeof(buf) - 1);
 			if (c == 0)
 				break;
-			gtk_text_buffer_insert(textbuf, &iter2, buf, c);
+ 			else {
+ 				gssize by_read = 0, by_written = 0;
+ 				gchar *ret_str = g_locale_to_utf8(buf, c, &by_read,
+ 								  &by_written, NULL);
+ 								  
+ 				if (ret_str && by_written) {
+ 					gtk_text_buffer_insert(textbuf, &iter2, 
+ 							       ret_str, by_written);
+ 					g_free(ret_str);
+ 				} else
+ 					gtk_text_buffer_insert(textbuf, &iter2, buf, c);
+ 			}				
 		}
 
 		if (child_info->children->is_selection) {
@@ -1215,8 +1228,20 @@
 		}
 	} 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) {
+			gssize by_read = 0, by_written = 0;
+			gchar *ret_str = g_locale_to_utf8(buf, c, &by_read,
+							  &by_written, NULL);
+							  
+			if (ret_str && by_written) {
+				g_string_append_len(child_info->output,
+						    ret_str, by_written);
+				g_free(ret_str);						    
+			} else
+				g_string_append_len(child_info->output, buf, c);
+		}
+		
 		if (c > 0)
 			child_info->new_out = TRUE;
 	}




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic