LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-29-2008, 04:32 PM   #1
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Rep: Reputation: 33
GTK Lists


I've written a little app using GTK+ 2.0. In it is a tree with a list store. I can add data to it and clear it, but I can't dynamically add data to it, it always waits until the process is finished before it updates. Here's the function which is called every time something needs to be added:
Code:
void add_entry(char *nm, int size, char*perms)	//GtkWidget *list, const gchar *str)
{
	GtkTreeIter             iter;
	gtk_list_store_append (the_store, &iter);
	gtk_list_store_set (the_store, &iter,
				COL_NAME, nm,
				COL_SIZE, size,
				COL_PERMS, perms,
				-1);
}
I don't even need to call this any more? (not sure if I really should (it's from when I did the whole thing at once))
Code:
gtk_tree_view_set_model(GTK_TREE_VIEW (the_view), GTK_TREE_MODEL (the_store));
 
Old 03-03-2008, 10:28 AM   #2
ararus
Member
 
Registered: Mar 2008
Location: UK
Distribution: Slackware
Posts: 56

Rep: Reputation: 15
For efficiency reasons, Gtk doesn't update anything on screen until control returns from your program back to gtk. If you want to force an update, you can add a gtk_main_iteration() at the end of the add_entry function. As the name suggests, this will make a pass through gtk's main loop, which will update whatever needs to be updated.

Last edited by ararus; 03-03-2008 at 10:29 AM.
 
Old 04-26-2008, 09:05 AM   #3
rubadub
Member
 
Registered: Jun 2004
Posts: 233

Original Poster
Rep: Reputation: 33
mmm, it's taken a while to get back to this project but thanks that does the trick!

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


Reply

Tags
gtk+, list


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK+ programs on Windows without having to install GTK+, GLib, etc Nylex Programming 2 02-19-2006 01:33 PM
Freerock uninstall stole GTK looking for up-to-date pango, atk, gtk, glib and xft tgz Oholiab Slackware 8 09-18-2005 11:57 AM
GTK source install doesn't give gtk-config Feebles Linux - Software 4 06-15-2005 12:51 PM
cant find gtk-config file or gtk-devel to install happychappy Linux - Software 2 02-16-2005 12:46 AM
compiling gaim/ gtk error (two versions of gtk) webazoid Linux - Software 0 07-06-2004 06:05 PM


All times are GMT -5. The time now is 09:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration