diff --git a/ChangeLog b/ChangeLog index 564b4f00c..704ac6bc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-12-18 Mike Kestner + + * gconf/GConf/ChangeSet.cs : add internal Handle prop. + * gconf/GConf/Engine.cs : new class to expose the default gconf engine + perform changeset commits and reverses. + 2004-12-17 Mike Kestner * gtk/ListStore.custom : dispose a bunch of GLib.Values. diff --git a/doc/en/GConf/Engine.xml b/doc/en/GConf/Engine.xml new file mode 100644 index 000000000..87e65f6ac --- /dev/null +++ b/doc/en/GConf/Engine.xml @@ -0,0 +1,96 @@ + + + + gconf-sharp + [00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4] + 2.0.0.0 + neutral + + + Gtk# is thread aware, but not thread safe; See the Gtk# Thread Programming for details. + + Configuration Engine class. + + + + System.Object + + + + System.IDisposable + + + + + + + Method + + System.Void + + + + Finalizes the engine. + + + + + + Method + + System.Void + + + + Releases the native engine ref. + + + + + + Method + + System.Void + + + + + + + Commits a change set to the engine. + a + a indicated if successfully committed items should be removed from the ChangeSet. + + + + + + Property + + GConf.Engine + + + + Gets the default configuration engine. + a + This is the engine to use for most application code. + + + + + Method + + GConf.ChangeSet + + + + + + Reverses the values for a ChangeSet. + a + a containing the keys/values reversed from non-default values. + + + + + diff --git a/gconf/GConf/ChangeSet.cs b/gconf/GConf/ChangeSet.cs index d188a8abe..b07386306 100644 --- a/gconf/GConf/ChangeSet.cs +++ b/gconf/GConf/ChangeSet.cs @@ -35,6 +35,12 @@ namespace GConf Raw = gconf_change_set_new (); } + internal ChangeSet (IntPtr raw) : base () + { + Initialize (); + Raw = raw; + } + ~ChangeSet () { Dispose (); @@ -52,6 +58,12 @@ namespace GConf } } + internal IntPtr Handle { + get { + return Raw; + } + } + [DllImport("gconf-2")] static extern void gconf_change_set_set (IntPtr cs, string key, IntPtr val); diff --git a/gconf/GConf/Engine.cs b/gconf/GConf/Engine.cs new file mode 100644 index 000000000..4beed418d --- /dev/null +++ b/gconf/GConf/Engine.cs @@ -0,0 +1,104 @@ +// Engine.cs - configureation engine wrapper +// +// Author: Mike Kestner +// +// Copyright (c) 2004 Novell, Inc. +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of version 2 of the Lesser GNU General +// Public License as published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. + + +namespace GConf +{ + using System; + using System.Runtime.InteropServices; + + public class Engine : IDisposable + { + IntPtr handle = IntPtr.Zero; + + [DllImport("gconf-2")] + static extern bool gconf_is_initialized (); + + [DllImport("gconf-2")] + static extern bool gconf_init (int argc, IntPtr argv, out IntPtr err); + + static Engine () + { + if (!gconf_is_initialized ()) { + IntPtr err; + gconf_init (0, IntPtr.Zero, out err); + if (err != IntPtr.Zero) + throw new GLib.GException (err); + } + } + + private Engine (IntPtr handle) + { + this.handle = handle; + } + + ~Engine () + { + Dispose (); + } + + [DllImport("gconf-2")] + static extern void gconf_engine_unref (IntPtr cs); + + public void Dispose () + { + if (handle != IntPtr.Zero) { + gconf_engine_unref (handle); + handle = IntPtr.Zero; + } + } + + [DllImport("gconf-2")] + static extern IntPtr gconf_engine_get_default (); + + static Engine default_engine; + public static Engine Default { + get { + if (default_engine == null) + default_engine = new Engine (gconf_engine_get_default ()); + + return default_engine; + } + } + + [DllImport("gconf-2")] + static extern bool gconf_engine_commit_change_set (IntPtr handle, IntPtr cs, bool remove, out IntPtr err); + + public void CommitChangeSet (ChangeSet cs, bool remove_committed) + { + IntPtr err_handle; + if (!gconf_engine_commit_change_set (handle, cs.Handle, remove_committed, out err_handle)) + throw new GLib.GException (err_handle); + } + + [DllImport("gconf-2")] + static extern IntPtr gconf_engine_reverse_change_set (IntPtr handle, IntPtr cs, out IntPtr err); + + public ChangeSet ReverseChangeSet (ChangeSet cs) + { + IntPtr err_handle; + ChangeSet result = new ChangeSet (gconf_engine_reverse_change_set (handle, cs.Handle, out err_handle)); + if (err_handle != IntPtr.Zero) + throw new GLib.GException (err_handle); + return result; + } + } +} + diff --git a/gconf/GConf/Makefile.am b/gconf/GConf/Makefile.am index 8d071dbcc..5a3cba1d6 100644 --- a/gconf/GConf/Makefile.am +++ b/gconf/GConf/Makefile.am @@ -25,6 +25,7 @@ sources = \ ClientBase.cs \ Client.cs \ ChangeSet.cs \ + Engine.cs \ _Entry.cs \ NoSuchKeyException.cs \ NotifyEventArgs.cs \