From f89698d3b3e70c2b07ddaa74fb3e1603d2e76f54 Mon Sep 17 00:00:00 2001 From: Aaron Bockover Date: Tue, 24 Apr 2007 19:40:27 +0000 Subject: [PATCH] 2007-04-24 Aaron Bockover * gtk/Widget.custom (StyleGetProperty): return null if gtksharp_widget_style_get_property returns FALSE (property doesn't exist) [Fixes #81445] * gtk/glue/widget.c (gtksharp_widget_style_get_property): check return of gtk_widget_class_find_style_property for NULL; function now returns TRUE if spec is not NULL, FALSE otherwise svn path=/trunk/gtk-sharp/; revision=76217 --- ChangeLog | 10 ++++++++++ gtk/Widget.custom | 17 ++++++++++------- gtk/glue/widget.c | 7 +++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1531ca405..08ef141ff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-04-24 Aaron Bockover + + * gtk/Widget.custom (StyleGetProperty): return null if + gtksharp_widget_style_get_property returns FALSE (property + doesn't exist) [Fixes #81445] + + * gtk/glue/widget.c (gtksharp_widget_style_get_property): check + return of gtk_widget_class_find_style_property for NULL; function now + returns TRUE if spec is not NULL, FALSE otherwise + 2007-04-23 Brad Taylor * gtk/TreePath.custom: Override Equals and compare based upon the diff --git a/gtk/Widget.custom b/gtk/Widget.custom index 6eef23b68..3aaa2370d 100644 --- a/gtk/Widget.custom +++ b/gtk/Widget.custom @@ -317,18 +317,21 @@ static void ClassInit (GLib.GType gtype, Type t) } [DllImport("gtksharpglue-2")] -static extern void gtksharp_widget_style_get_property (IntPtr widget, IntPtr property, ref GLib.Value value); +static extern bool gtksharp_widget_style_get_property (IntPtr widget, IntPtr property, ref GLib.Value value); public object StyleGetProperty (string property_name) { GLib.Value value = new GLib.Value (); - object ret; - IntPtr name = GLib.Marshaller.StringToPtrGStrdup (property_name); - gtksharp_widget_style_get_property (Handle, name, ref value); + bool success = gtksharp_widget_style_get_property (Handle, name, ref value); GLib.Marshaller.Free (name); - ret = value.Val; - value.Dispose (); - return ret; + + if(success) { + object ret = value.Val; + value.Dispose (); + return ret; + } + + return null; } internal GLib.Value StyleGetPropertyValue (string property_name) { diff --git a/gtk/glue/widget.c b/gtk/glue/widget.c index a686f7350..40cf2b789 100644 --- a/gtk/glue/widget.c +++ b/gtk/glue/widget.c @@ -40,7 +40,7 @@ void gtksharp_gtk_widget_set_flags (GtkWidget *widget, int flags); int gtksharp_gtk_widget_style_get_int (GtkWidget *widget, const char *name); void gtksharp_widget_add_binding_signal (GType gtype, const char *sig_name, GCallback cb); void gtksharp_widget_register_binding (GType gtype, const char *sig_name, guint key, int mod, gpointer data); -void gtksharp_widget_style_get_property (GtkWidget *widget, const gchar* property, GValue *value); +gboolean gtksharp_widget_style_get_property (GtkWidget *widget, const gchar* property, GValue *value); /* */ GdkRectangle* @@ -171,11 +171,14 @@ gtksharp_widget_register_binding (GType gtype, const gchar *signame, guint key, gtk_binding_entry_add_signal (set, key, mod, signame, 1, G_TYPE_LONG, data); } -void +gboolean gtksharp_widget_style_get_property (GtkWidget *widget, const gchar* property, GValue *value) { GParamSpec *spec = gtk_widget_class_find_style_property (GTK_WIDGET_GET_CLASS (widget), property); + if (spec == NULL) + return FALSE; g_value_init (value, spec->value_type); gtk_widget_style_get_property (widget, property, value); + return TRUE; }