[Gtk-sharp-list] GConf replacement

Martin Willemoes Hansen mwh@sysrq.dk
27 Apr 2003 18:50:03 +0200


Sounds very nifty, I for one could use it. Hope you will distribute your
class library.

On Sat, 2003-04-26 at 11:15, Pablo Baena wrote:
> Hi! I told you some time ago that I was avoiding gconf because of a
> few issues. Well, I finished some prototype of what I'm doing to
> replace gconf# in my project.
> 
> The nifty thing works this way. First you define an interface like
> this:
> 
> 
> 	interface IMySettings 
> 	{
> 		[GeSettings.Property ("GnoMencoder", 
> 				      "/dev/cdroms/cdrom0", 
> 				      "DVD Device")]
> 		string DVDDevice 
> 		{
> 			get; 
> 			set;
> 		}
> 	}
> The arguments of the attribute are: name of the app, default value and
> description, respectively.
> 
> Then you pass the interface to a magic machine like this:
> 
> 
> IMySettings mySettings = (IMySettings) 
> 	GeSettings.Builder.Build (typeof(IMySettings));
> Et voilá, you'll have a mySettings.DVDDevice to use as any other
> property, only that any changes to it will be recorded in a XML file
> on your home directory for future sessions, and all get operations
> will retrieve that setting from said XML file (without you having to
> know _anything_ about XML).
> 
> With this we avoided all the steps we had to make with gconf#, that
> were:
> 
> * create a GConf schema (learn how to make one)
> * run gconf-schemagen over it to create the class
> * have root priviledges to install the schema
> 
> And there is more! With another class I created (it is apart so one
> doesn't have to depend on gtk# for other uses), one can do this:
> 
> 
> 
> 	interface IMySettings 
> 	{
> 		[GeSettings.Property ("GnoMencoder", 
> 				      "/dev/cdroms/cdrom0", 
> 				      "DVD Device",
> 				      WidgetName="dvddevice_entry")]
> 		string DVDDevice 
> 		{
> 			get; 
> 			set;
> 		}
> 	}
> And, with this function:
> 
> 
> IMySettings mySettings = (IMySettings) 
> 	GeSettings.GladeBuilder.Build (typeof(IMySettings), gxml);
> we'll have the property associated with the widget on the glade
> resource, which will update the value on the Changed events and
> display the value on Realized.
> 
> The classes are in a very very alpha state yet, and aren't optimized
> in any way, so I didn't released them to the public. Anyway, the
> quality is poor because they're 'inside use only' and it serves its
> purpose for what I'm doing. If there is enough interest on making them
> available independently, I can do the work. It only supports storing
> string settings by now, doesn't monitor the settings for external
> changes as GConf does and only supports Entry widgets, but that can
> change, and I can do it without adding anything complicated to the
> API.
> 
> Do you think I should make it releasable?
> 
> Cheers!
> 
> PS: I hate to reinvent the wheel, but I just don't like gconf. It is
> good at what it does, but complicates something that should be MUCH
> easier.
> 
> -- 
> Pablo Baena <pbaena@uol.com.ar>
-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh@sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net	
--------------------------------------------------------