www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Strange behavior with Linux GTK+ library

reply Steve Teale <steve.teale britseyeview.com> writes:
I've been trying to add some new methods to ObjectG.d in gtkD. As an example:

	public string getString(string propertyName)
	{
		// void g_object_get(gpointer object, gchar* firstPropertyName, ... )
		// gchar* is described as being a C style string

		char* csz;
		writefln("%s", propertyName);
		g_object_get(gObject, cast(char*) std.string.toStringz(propertyName), &csz);
 // try 1
		//g_object_get(gObject, cast(char*) "font\0".ptr, &csz);
  // try 2
		uint n;
		for (char* p = csz; *p; p++, n++) {}
		return csz[0..n].idup;
	}

When I use this in code to get a property from a GtkTextTag I get a warning
from Glib-GObject telling me there's no such property, and then the expected
result is returned. I've done this several different ways. It works, but with
different warning message string values, like:

font

(thost:9068): GLib-GObject-WARNING **: g_object_get_valist: object class
`GtkTextTag' has no property named `\xb8;\u001a	\u0003'
ArtBrush 12

font

(thost:8524): GLib-GObject-WARNING **: g_object_get_valist: object class
`GtkTextTag' has no property named `XO\xdc\u0008\u0003'
ArtBrush 12

This is with DMD2.054. Can anyone hazard a guess as to what's going on here?

Thanks
Steve
Jul 28 2011
next sibling parent Kagamin <spam here.lot> writes:
Steve Teale Wrote:

 I've been trying to add some new methods to ObjectG.d in gtkD. As an example:
How it works without adding new methods to GObject?
Jul 28 2011
prev sibling parent Kagamin <spam here.lot> writes:
http://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-get
Jul 28 2011