correctly stdin input for text info dialog (Fixes bug #336736).

2006-07-27  Lucas Rocha  <lucasr@gnome.org>

	* src/text.c (zenity_text_handle_stdin): correctly stdin input for
	text info dialog (Fixes bug #336736).
This commit is contained in:
Lucas Rocha 2006-07-28 04:18:58 +00:00 committed by Lucas Almeida Rocha
parent 8af67dea6c
commit e46814b46a
2 changed files with 29 additions and 31 deletions

View File

@ -1,3 +1,8 @@
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/text.c (zenity_text_handle_stdin): correctly stdin input for
text info dialog (Fixes bug #336736).
2006-07-27 Lucas Rocha <lucasr@gnome.org> 2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/entry.c (zenity_entry): entry activation makes dialog * src/entry.c (zenity_entry): entry activation makes dialog

View File

@ -43,50 +43,43 @@ zenity_text_handle_stdin (GIOChannel *channel,
buffer = GTK_TEXT_BUFFER (data); buffer = GTK_TEXT_BUFFER (data);
if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) {
GError *error = NULL; GError *error = NULL;
gint status;
while (channel->is_readable != TRUE) while (channel->is_readable != TRUE)
; ;
do { do {
gint status; status = g_io_channel_read_chars (channel, buf, 1024, &len, &error);
do { while (gtk_events_pending ())
status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); gtk_main_iteration ();
while (gtk_events_pending ()) } while (status == G_IO_STATUS_AGAIN);
gtk_main_iteration ();
} while (status == G_IO_STATUS_AGAIN); if (status != G_IO_STATUS_NORMAL) {
if (error) {
if (status != G_IO_STATUS_NORMAL) { g_warning ("zenity_text_handle_stdin () : %s", error->message);
if (error) { g_error_free (error);
g_warning ("zenity_text_handle_stdin () : %s", error->message); error = NULL;
g_error_free (error);
error = NULL;
}
continue;
} }
return FALSE;
}
if (len > 0) { if (len > 0) {
GtkTextIter end; GtkTextIter end;
gchar *utftext; gchar *utftext;
gsize localelen; gsize localelen;
gsize utflen; gsize utflen;
gtk_text_buffer_get_end_iter (buffer, &end); gtk_text_buffer_get_end_iter (buffer, &end);
utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL);
gtk_text_buffer_insert (buffer, &end, utftext, utflen); gtk_text_buffer_insert (buffer, &end, utftext, utflen);
g_free (utftext); g_free (utftext);
} }
} while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
} }
if (condition != G_IO_IN) {
g_io_channel_shutdown (channel, TRUE, NULL);
return FALSE;
}
return TRUE; return TRUE;
} }