Re: Object properties
- From: Russell Shaw <rjshaw netspace net au>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Object properties
- Date: Fri, 21 May 2004 16:37:38 +1000
Olexiy Avramchenko wrote:
Russell Shaw wrote:
Hi,
In a widget, should an object property of the widget be accessed
directly,
or with g_object_get()/set() ?
Hello, Russel
What do you mean on "directly" ? I see two possible cases:
1) The direct access to the specific field of widgets structure.
2) Use of widget's supported wrappers like 'gtk_*_[gs]et_*()'.
The first case is not good because:
* widget implementation may change in future and you'll have to modify
code;
* you have to support notification on changed property.
The only possible place for such things IMO is a widget implementation
code.
The second case:
+ code is little more readable;
+ code will work somewhat faster (no need in GObject code that makes
checks and calls [gs]et_property widgets methods);
+ wrappers are better documented ;), so its easier for others to learn
your code;
- wrappers support access to the single property only, when with
g_object_[gs]et you can change multiply properties at one call;
- wrappers sometime sound different from properties:
gtk_toggle_button_set_mode() modify "draw_indicator" property,
gtk_widget_show()/gtk_widget_hide() modify "visibility" property.
Olexiy
Hi Olexiy,
I mean just for widget implementation code. Ie:
static void
show_table(DBTab *tab)
{
gint n=tab->ncols; // direct access of a property
// that is normally accessed externally
// with g_object_get/set()
...
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]