FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Strange behavior getting a property from a TextTag

 
Post new topic   Reply to topic     Forum Index -> gtkD
View previous topic :: View next topic  
Author Message
teales



Joined: 21 May 2007
Posts: 24
Location: Bangalore

PostPosted: Thu Jul 28, 2011 5:37 am    Post subject: Strange behavior getting a property from a TextTag Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Thu Jul 28, 2011 3:41 pm    Post subject: Reply with quote

You are missing null as the last param for g_object_get.

g_object_get accepts a vararg which should end with a null.
Back to top
View user's profile Send private message
teales



Joined: 21 May 2007
Posts: 24
Location: Bangalore

PostPosted: Fri Aug 05, 2011 12:00 am    Post subject: Reply with quote

Thanks Mike - I noticed that later. Once I had fixed it the warning messages, or at least the attribute name reported just got longer.
Back to top
View user's profile Send private message Send e-mail
Mike Wey



Joined: 07 May 2007
Posts: 428

PostPosted: Sat Aug 06, 2011 6:33 am    Post subject: Reply with quote

What are the error messages you are getting now?
Back to top
View user's profile Send private message
teales



Joined: 21 May 2007
Posts: 24
Location: Bangalore

PostPosted: Sun Aug 28, 2011 4:27 am    Post subject: Reply with quote

Sorry Mike,

I had missed the terminating null in one case, so your answer was spot on.

For any interested parties, I had done this in the first place because I did not know how to recover the 'foreground-gdk' property for a TextTag. The GTK documentation says this property is of type GdkColor, and I could not figure out what kind of gobject.Value to use. The answer is along the lines:

Value v = new Value();
v.init(Type.fromName("GdkColor"));
textTag.getProperty ("foreground-gdk", v);
GdkColor* p = cast(GdkColor*) v.getBoxed();

It's always easy when you know how ;=)

Steve
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> gtkD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group