Re: Is this design feasible in GTK?



On Mon, 10 Nov 2003 04:38:09 -0000
<chenjun1 egr msu edu> wrote:

One windows contains a button and a text entry( or any other widget
display text).
The user clicks a button, then a function is called. During that
function is executed, it will dump out process informations to the
Text Entries ? I mean the text entry keeps updating when the function
is running.

        If you are reading the information from a
file, it is easy enough: 
        
        <pseudo code>
        read_line_from_file ()
        gtk_entry_set_text (GTK_ENTRY (text_entry), line);
        while (g_main_context_iteration(NULL, FALSE));
        </pseudo code>

        if you are waiting of a socket, or a fifo, or the like, I would do the
following:

        <pseudo code>
        while (1) {
                select (n, socket_fd_set, NULL, NULL, timeout)
                if (socket_ready_to_read) {
                        read_from_socket ()
                        gtk_entry_set_text (GTK_ENTRY (text_entry), line);
                }
                if (socket_closed)
                        break;
                while (g_main_context_iteration (NULL, FALSE));
        }
        </pseudo code>

        of course, what other users have suggested (using a textview instead of
an entry) is also a good idea.




-- 
Mitko Haralanov
mitko pathscale com
http://www.pathscale.com

==========================================
91. Well, it's doing _something_.....

        --Top 100 things you don't want the sysadmin to say



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