1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// LOG
gboolean FonctionUpdateLog(GIOChannel *source,GIOCondition condition, gpointer data)
{
gchar * msg;
GError *pErr = NULL;
gsize len;
GIOStatus status;
gchar * sBuffer;
GtkTextIter iStart, iEnd;
GtkTextBuffer *pTextBuffer;
Window_Printer *TabPrinter;
TabPrinter = (Window_Printer *) data;
while(gtk_events_pending())
gtk_main_iteration();
g_assert (condition == G_IO_IN);
status = g_io_channel_read_line (source, &msg, &len, NULL, &pErr);
switch (status)
{
case G_IO_STATUS_NORMAL:
/* Recuperation du buffer */
g_file_get_contents("./IHM/test", &sBuffer, NULL, NULL);
pTextBuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(TabPrinter->pTextViewLog));
/* Suppression des données du buffer */
gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
gtk_text_buffer_get_end_iter(pTextBuffer, &iEnd);
gtk_text_buffer_delete(pTextBuffer, &iStart, &iEnd);
/* Affichage du fichier */
gtk_text_buffer_get_start_iter(pTextBuffer, &iStart);
gtk_text_buffer_insert(pTextBuffer, &iStart, sBuffer, -1);
g_free(sBuffer);
g_debug ("data Read = '%s'", msg);
g_free (msg);
break;
case G_IO_STATUS_ERROR:
g_assert (pErr != NULL);
g_error ("%s", pErr->message);
break;
case G_IO_STATUS_EOF:
g_debug ("End of file detected");
break;
case G_IO_STATUS_AGAIN:
g_debug ("iResource is busy, we'll try again");
break;
default:
g_assert_not_reached ();
}
Return TRUE;
} |
Partager