Re: Problems with Properties and Notify Signal Parts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2005-07-29 at 17:27 +1000, Richard Cole wrote:

> Well you see somewhere in glib the property "font_size" is helpfully 
> changed to "font-size". (The underscore turned into a dash). I guess so 
> that if one's code says:
> 
>   view.set_property("font-size", 10)
> 
> Then rather than a warning about a non-existent property one will get 
> what one intended: a change to the font size [1].
> 
> However this helpfull modification to property names isn't being 
> performed for signal details. At least not in: glib-2.6.5 as packaged by 
> debian. So what happens is the property name is being changed to 
> font-size and the signal being emitted is "notify::font-size", but the 
> modification to the signal name from "notify::font_size" to 
> "notify::font-size" is not being performed.
> 
> My guess is that this situation should be fixed so that underscores are 
> changed to hyphens in each of: property names, signal names, and signal 
> details. At the moment it seems to be missing on signal details. But 
> that is a bit of guess.

Yes, this is a common problem people have when using ::notify.

GTK+ considers - and _ to be equivalent in signal and property 
names; the reason for this is so that they can be used as identifiers
both in languages that use '_' in identifiers (most languages) and
languages that use '-' (scheme, lisp, mostly).

The '-' is what is used internally, so when GTK+ sees a signal
or property name, it converts '_' to '-'.

In notify::prop-foo, the signal system doesn't actually know
that "prop-foo" is a property name. It's just an arbitrary
"detail" string. So, it can't do the conversion.

For this reason, I would recommend *always* using '-' in both signal
names and property names.

> I think it would also be helpfull to put a note about signal names and 
> this kind of hidden conversion that goes on behind the scenes into the 
> description part of
> 
>   file:///usr/share/doc/libgtk2.0-doc/gobject/gobject-Signals.html
> 
> i.e. from whereever that file is being generated.

The GObject docs can be found online at:

 http://developer.gnome.org/doc/API/2.0/gobject/

They are built as part of the GTK+ distribution. Contributions are
always appreciated. (Suggestions for the documentation go in bugzilla.)

Regards,
						Owen

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux