From e6979f31de210eafd3dc0fe272e7af2a1a850dd7 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 28 Sep 2001 18:23:14 +0000 Subject: [PATCH] 2001-09-28 Mike Kestner * glib/Object.cs (GetProperty): New, gets props from the raw obj. (SetProperty): New, for setting props on the raw obj. * glib/Value.cs (type ctor): New needed for get accessors. *gtk/Window.cs (AllowGrow): Uncommented and filled out. (AllowShrink): Uncommented and filled out. (DestroyWithParent): Uncommented and filled out. (Modal): Uncommented and filled out. (Resizable): Added. All the bool Props work now. svn path=/trunk/gtk-sharp/; revision=1030 --- ChangeLog | 11 ++++++++ glib/Object.cs | 42 ++++++++++++++++++++++++----- glib/Value.cs | 13 +++++++++ gtk/Window.cs | 71 ++++++++++++++++++++++++++++++++++++++------------ 4 files changed, 115 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0218ca58..13715d0cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-09-28 Mike Kestner + + * glib/Object.cs (GetProperty): New, gets props from the raw obj. + (SetProperty): New, for setting props on the raw obj. + * glib/Value.cs (type ctor): New needed for get accessors. + *gtk/Window.cs (AllowGrow): Uncommented and filled out. + (AllowShrink): Uncommented and filled out. + (DestroyWithParent): Uncommented and filled out. + (Modal): Uncommented and filled out. + (Resizable): Added. All the bool Props work now. + 2001-09-28 Mike Kestner * glib/Value.cs (~Value): New destructor to release g_malloc'd space. diff --git a/glib/Object.cs b/glib/Object.cs index af153bcf4..d5deb2c15 100644 --- a/glib/Object.cs +++ b/glib/Object.cs @@ -121,6 +121,42 @@ namespace GLib { Data [key] = val; } + /// + /// GetProperty Method + /// + /// + /// + /// Accesses a raw Object Property. + /// + + [DllImport("gobject-1.3.dll")] + static extern void g_object_get_property (IntPtr obj, + String name, + IntPtr val); + + public void GetProperty (String name, Value val) + { + g_object_get_property (RawObject, name, val.MarshalAs); + } + + /// + /// SetProperty Method + /// + /// + /// + /// Changes the value of a raw Object Property. + /// + + [DllImport("gobject-1.3.dll")] + static extern void g_object_set_property (IntPtr obj, + String name, + IntPtr val); + + public void SetProperty (String name, Value val) + { + g_object_set_property (RawObject, name, val.MarshalAs); + } + /* [DllImport("gtk-1.3.dll")] static extern void g_object_set_data_full ( @@ -179,12 +215,6 @@ void g_object_set_qdata_full (GObject *object, GDestroyNotify destroy); gpointer g_object_steal_qdata (GObject *object, GQuark quark); -void g_object_set_property (GObject *object, - const gchar *property_name, - const GValue *value); -void g_object_get_property (GObject *object, - const gchar *property_name, - GValue *value); void g_object_watch_closure (GObject *object, GClosure *closure); void g_object_run_dispose (GObject *object); diff --git a/glib/Value.cs b/glib/Value.cs index 34829c664..bc5303b58 100755 --- a/glib/Value.cs +++ b/glib/Value.cs @@ -52,6 +52,19 @@ namespace GLib { _val = g_malloc0 (5 * IntPtr.Size); } + /// + /// Value Constructor + /// + /// + /// + /// Creates an initialized Value of the specified type. + /// + + public Value (TypeFundamentals type) : this () + { + Init (type); + } + /// /// Value Constructor /// diff --git a/gtk/Window.cs b/gtk/Window.cs index f2f00a681..bb81e3675 100755 --- a/gtk/Window.cs +++ b/gtk/Window.cs @@ -61,7 +61,6 @@ namespace Gtk { this.Title = title; } -/* /// /// AllowGrow Property /// @@ -73,11 +72,14 @@ namespace Gtk { public bool AllowGrow { get { - Value val = GetProp ("allow-grow"); - return (val != 0); + Value val = new Value ( + TypeFundamentals.TypeBoolean); + GetProperty ("allow-grow", val); + return ((bool) val); } set { - SetProp ("allow-grow", new GValue (value)); + Value val = new Value (value); + SetProperty ("allow-grow", val); } } @@ -92,14 +94,18 @@ namespace Gtk { public bool AllowShrink { get { - GValue val = GetProp ("allow-shrink"); - return (val != 0); + Value val = new Value ( + TypeFundamentals.TypeBoolean); + GetProperty ("allow-shrink", val); + return ((bool) val); } set { - SetProp ("allow-shrink", new GValue (value)); + Value val = new Value (value); + SetProperty ("allow-shrink", val); } } +/* /// /// DefaultSize Property /// @@ -117,6 +123,7 @@ namespace Gtk { SetProp ("default-size", new GValue (value)); } } +*/ /// /// DestroyWithParent Property @@ -129,16 +136,19 @@ namespace Gtk { public bool DestroyWithParent { get { - GValue val = GetProp ("allow-grow"); - return (val != 0); + Value val = new Value ( + TypeFundamentals.TypeBoolean); + GetProperty ("destroy-with-parent", val); + return ((bool) val); } set { - SetProp ("allow-grow", new GValue (value)); + Value val = new Value (value); + SetProperty ("destroy-with-parent", val); } } /// - /// IsModal Property + /// Modal Property /// /// /// @@ -148,16 +158,19 @@ namespace Gtk { /// is closed. /// - public bool IsModal { + public bool Modal { get { - GValue val = GetProp ("allow-grow"); - return (val != 0); + Value val = new Value ( + TypeFundamentals.TypeBoolean); + GetProperty ("modal", val); + return ((bool) val); } set { - SetProp ("allow-grow", new GValue (value)); + Value val = new Value (value); + SetProperty ("modal", val); } } -*/ + /// /// Position Property /// @@ -178,6 +191,28 @@ namespace Gtk { } } + /// + /// Resizable Property + /// + /// + /// + /// Indicates if the Height and Width of the Window can be + /// altered by the user. + /// + + public bool Resizable { + get { + Value val = new Value ( + TypeFundamentals.TypeBoolean); + GetProperty ("resizable", val); + return ((bool) val); + } + set { + Value val = new Value (value); + SetProperty ("resizable", val); + } + } + /// /// Title Property /// @@ -194,6 +229,10 @@ namespace Gtk { set { g_object_set (RawObject, "title", Marshal.StringToHGlobalAnsi (value), new IntPtr (0)); +/* FIXME: When the String value setting problem is solved. + Value val = new Value (value); + SetProperty ("title", val); +*/ } } }