GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 01, 2014 6:35 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Beginner's Question -lines not showing textview
PostPosted: Mon May 05, 2008 3:50 am 
Offline
Familiar Face

Joined: Mon May 05, 2008 3:38 am
Posts: 12
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 7:27 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
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:
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.

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 05, 2008 10:28 pm 
Offline
Familiar Face

Joined: Mon May 05, 2008 3:38 am
Posts: 12
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! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot], Google Adsense [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group