After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 597669 - Add convenience functions for retrieving object properties that have a fundamental C-type
Add convenience functions for retrieving object properties that have a fundam...
Status: RESOLVED DUPLICATE of bug 541569
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2009-10-07 11:13 UTC by Gabriel Schulhof
Modified: 2010-09-03 22:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch against master to add convenience functions. (7.82 KB, patch)
2009-10-07 11:33 UTC, Gabriel Schulhof
none Details | Review

Description Gabriel Schulhof 2009-10-07 11:13:57 UTC
About to attach a patch for adding functions such as: g_object_get_int, g_object_get_char, g_object_get_double, etc. IOW, any type such that the return value doesn't require special handling.
Comment 1 Gabriel Schulhof 2009-10-07 11:33:40 UTC
Created attachment 144950 [details] [review]
Patch against master to add convenience functions.

The motivation behind this patch is to allow various types of objects implementing a property with a given name and identical semantics to be treated identically. For example, in GTK, the followings all have a _get_active() API:

GtkToggleButton
GtkCellRendererToggle
GtkCheckMenuItem
GtkToggleToolButton
GtkToggleAction

Unfortunately, if due to design changes a projects moves from one widget to another, all old_widget_get_active calls have to be sed-ed to new_widget_get_active calls. This is fine for upstream, but a downstream project does not have this luxury without introducing an enormous delta.

The solution is to use these convenience functions, making those portions of the code widget-independent. A change such as this has a chance of making it upstream.

My personal plight: Porting Pidgin to Maemo 5, replacing GtkCheckButton widgets with HildonCheckButton widgets.
Comment 2 Matthias Clasen 2009-10-07 13:10:26 UTC
I don't think this is a very strong argument for adding gobject api.
You can just use g_object_get...
Comment 3 Gabriel Schulhof 2009-10-07 13:21:17 UTC
The problem with g_object_get is that it cannot be nested. All the *_get_active functions I listed return a boolean, which makes them very convenient for nesting. In fact, all the calls to gtk accessors could be replaced with these convenience functions, making all applications slightly less dependent on gtk and/or specific gtk widgets.

For another example, look at gconf:

gconf_client_get_bool, gconf_client_get_int, etc. Extremely convenient.
Comment 4 Gabriel Schulhof 2009-10-07 13:45:30 UTC
For slightly related reference:
http://mail.gnome.org/archives/gtk-devel-list/2009-April/msg00150.html

Especially:
http://mail.gnome.org/archives/gtk-devel-list/2009-April/msg00152.html
(The remark about int get_x())

What that thread misses is the potential for nesting simple function calls like this. This is the feature that in turn could drive widget-choice-independence.
Comment 5 Matthias Clasen 2010-09-03 22:19:10 UTC

*** This bug has been marked as a duplicate of bug 541569 ***