GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Beginner's Question -lines not showing textview

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
anewguy



Joined: 05 May 2008
Posts: 2

PostPosted: Mon May 05, 2008 3:50 am    Post subject: Beginner's Question -lines not showing textview Reply with quote

I'm a beginner at all of this, and extremely rusty at C, so please bear with me. :wink:

I have a main function which does all the GTK stuff to define a window with 2 buttons and a scrolling window with a text view. These 3 areas are within a vbox. For ease in this question, call back function when button 1 is pressed in "B1", a separate C file from the main.c. B1 in turn calls other separate .C files, any of which may output a text status message to the text view. I have the widgets globally declared. If B1 or any of the other functions issues a message, it goes through a common C function to post it into the text view buffer.

The problem I am having is that nothing is displayed in the text view until the original call back function exits. How do I make these status messages show "real-time"?

I have tried showing the buffer, the scrolled window, the vbox and the window (even all together!) in the logging function but nothing shows.

Thanks for the input! :D
Back to top
Micah Carrick
Never Seen the Sunlight


Joined: 21 Sep 2005
Posts: 480
Location: Portland, OR USA

PostPosted: Mon May 05, 2008 7:27 pm    Post subject: Reply with quote

It's hard to say without looking at your code, however, I can give you a few pointers.

First, rather than declaring your widgets as globals (that could get quite "big") we often use a structure declared in main() and pass it to our callback functions as user_data. An example of using this method can be seen in Execute command into a GtkTextView (C and Libglade)

As for making sure the status bar is updated quickly, you might want to use this handy bit of code.

Code: (C)
1
while (gtk_events_pending ()) gtk_main_iteration();


This will allow your UI to catch up should you be in the middle of processing something. We use this quite often for things like status bar messages and progress bars. If you put that immediately after the code that adds text to the text view, it might solve your problem.
Back to top
anewguy



Joined: 05 May 2008
Posts: 2

PostPosted: Mon May 05, 2008 10:28 pm    Post subject: Reply with quote

Thanks, Micah!! The last statement did the trick for the immediate problem.

I'll have to think on the structure thing a bit - if call back function A1 in turn uses functions B1 through Z1, and all of them need to post a message, but the message is posted through a common routine, I thought the globals were easier than changing every function call to include the structure (unless it was made global, at which point it would be self-defeating, wouldn't it?).

I'm so rusty at C and this is my first experience with GTK (using in Ubuntu Linux to "talk" to CVS one-time use video and still digital cameras) to make a GUI.

Thanks again! Any suggestions are greatly appreciated by this old man! :)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP