GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Dec 21, 2014 9:34 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Dynamic GUI with GtkBuilder?
PostPosted: Sat May 31, 2008 11:42 am 
Offline
GTK+ Geek

Joined: Wed May 28, 2008 5:49 pm
Posts: 66
How can I go about having a GUI that can be changed within the program (with preferences and such) and one that uses GtkBuilder for it's interface design? I can't quite wrap my head around how would I be able to change the values properly / make sure they're saved after in the .xml...


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 31, 2008 7:43 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
You don't actually change the XML file from within the program. What you do, is you apply any properties that change based on user preferences when you initialize your application.

How you save users' preferences depends on the application. Many use XML files in the home dir, many use GConf (most large applications for Gnome use GConf).

For example, let's say your application is created in Glade and you're using GtkBuilder to load that interface. You have a preferences for the visibility of the toolbar. Your function which loads the interface might do:

1. GtkBuilder creates interface.
2. Get reference to the toolbar widget using gtk_builder_get_object ()
3. Get the user's preference from GConf using gconf_client_get_bool ()
4. Pass the toolbar widget and the return value from gconf_client_get_bool () to gtk_widget_set_visible().
5. Destroy the GtkBuilder object.
6. Show the application window.

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


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 31, 2008 8:21 pm 
Offline
GTK+ Geek

Joined: Wed May 28, 2008 5:49 pm
Posts: 66
Alright, sounds good. However my application will need to run on Windows there - is there any general way you can recommend about saving/loading settings on there?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 31, 2008 9:12 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
You could use the Windows registry, GKeyFile parser (like .ini files) or GMarkup (xml) to store your configuration values. GKeyFile might be the easiest.

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


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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