[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

gdk_input_add looping



Hello all,
	I am having some trouble with gdk_input_add.  I am trying to watch a
log file, and whenever something is appended to it, read it in and insert it
into a text widget.  I am new to gtk and my C is pretty weak, but here is
what I am trying:
I open the file for reading and do the gdk_input_add on it when the program
starts:

	if((errlog[0] = open(logname, O_RDONLY)) == -1){
		printf("Error: can't open log %s\n", logname);
		exit(1);
	}
	errlog[1] = gdk_input_add(errlog[0], GDK_INPUT_READ,
(GdkInputFunction)read_log, errlog);

Then in read_log:

	readbytes = read(log_tag[0], buffer, MAXPIPE - 1);
	lseek(log_tag[0], 0, SEEK_END);
	gtk_text_freeze(GTK_TEXT (log->text));
	gtk_text_insert(GTK_TEXT (log->text), NULL, NULL, NULL, buffer,
strlen(buffer));
	gtk_text_thaw(GTK_TEXT (log->text));

This results in constant calling of read_log.  It does work (newly appended
text is read as it appears and put into the text widget), but %CPU goes to
99.9% for the app.  I know I am probably missing something simple. Can
someone tell me what it is?  Thanks in advance,
	broc
	



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]