2009-04-21 Christian Hoff <christian_hoff@gmx.net>
* gtk/Widget.custom: Deglued implementation of StyleGetProperty. svn path=/trunk/gtk-sharp/; revision=132224
This commit is contained in:
parent
a63841988e
commit
37c1f46d17
4 changed files with 34 additions and 35 deletions
|
@ -1,3 +1,7 @@
|
|||
2009-04-21 Christian Hoff <christian_hoff@gmx.net>
|
||||
|
||||
* gtk/Widget.custom: Deglued implementation of StyleGetProperty.
|
||||
|
||||
2009-04-16 Christian Hoff <christian_hoff@gmx.net>
|
||||
|
||||
* glib/Value.cs: Support for additional fundamental GTypes. Invoke
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace GLib {
|
|||
Writable = 1 << 1,
|
||||
}
|
||||
|
||||
internal class ParamSpec {
|
||||
public class ParamSpec {
|
||||
|
||||
IntPtr handle;
|
||||
|
||||
|
|
|
@ -329,31 +329,39 @@ static void ClassInit (GLib.GType gtype, Type t)
|
|||
GLib.Marshaller.Free (signame);
|
||||
}
|
||||
|
||||
[DllImport("gtksharpglue-2")]
|
||||
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 ();
|
||||
IntPtr name = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
||||
bool success = gtksharp_widget_style_get_property (Handle, name, ref value);
|
||||
GLib.Marshaller.Free (name);
|
||||
|
||||
if(success) {
|
||||
object ret = value.Val;
|
||||
value.Dispose ();
|
||||
return ret;
|
||||
public object StyleGetProperty (string property_name)
|
||||
{
|
||||
GLib.Value value;
|
||||
try {
|
||||
value = StyleGetPropertyValue (property_name);
|
||||
} catch (ArgumentException) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
object ret = value.Val;
|
||||
value.Dispose ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal GLib.Value StyleGetPropertyValue (string property_name) {
|
||||
GLib.Value value = new GLib.Value ();
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
static extern IntPtr gtk_widget_class_find_style_property (IntPtr class_ptr, IntPtr property_name);
|
||||
|
||||
IntPtr name = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
||||
gtksharp_widget_style_get_property (Handle, name, ref value);
|
||||
GLib.Marshaller.Free (name);
|
||||
return value;
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
static extern IntPtr gtk_widget_style_get_property (IntPtr inst, IntPtr property_name, ref GLib.Value value);
|
||||
|
||||
internal GLib.Value StyleGetPropertyValue (string property_name)
|
||||
{
|
||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
||||
try {
|
||||
IntPtr pspec_ptr = gtk_widget_class_find_style_property (this.LookupGType ().ClassPtr, native_name);
|
||||
if (pspec_ptr == IntPtr.Zero)
|
||||
throw new ArgumentException (String.Format ("Cannot find style property \"{0}\"", property_name));
|
||||
|
||||
GLib.Value value = new GLib.Value ((new GLib.ParamSpec (pspec_ptr)).ValueType);
|
||||
gtk_widget_style_get_property (Handle, native_name, ref value);
|
||||
return value;
|
||||
} finally {
|
||||
GLib.Marshaller.Free (native_name);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("libgtk-win32-2.0-0.dll")]
|
||||
|
|
|
@ -40,7 +40,6 @@ 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);
|
||||
gboolean gtksharp_widget_style_get_property (GtkWidget *widget, const gchar* property, GValue *value);
|
||||
/* */
|
||||
|
||||
GdkRectangle*
|
||||
|
@ -170,15 +169,3 @@ gtksharp_widget_register_binding (GType gtype, const gchar *signame, guint key,
|
|||
GtkBindingSet *set = gtk_binding_set_by_class (klass);
|
||||
gtk_binding_entry_add_signal (set, key, mod, signame, 1, G_TYPE_LONG, data);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue