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 663798 - Add AbstractFieldDetails.value_type
Add AbstractFieldDetails.value_type
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2011-11-10 18:01 UTC by Travis Reitter
Modified: 2011-11-10 22:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add AbstractFieldDetails.value_type (4.56 KB, patch)
2011-11-10 19:07 UTC, Travis Reitter
reviewed Details | Review

Description Travis Reitter 2011-11-10 18:01:11 UTC
This would let us (and our clients) treat our AFD-derived classes in a more generic way. The my search branch for bug #646808 made this usefulness obvious (and I'm cherry-picking it for this bug to get it merged before that branch).

For example, one could handle all AFD-derived classes without needing to switch between their specific types as in:

if (FOLKS_IS_ABSTRACT_FIELD_DETAILS (fd))
{
  GType value_type = folks_abstract_field_details_get_value_type
(FOLKS_ABSTRACT_FIELD_DETAILS (fd));
  if (value_type == G_TYPE_STRING)
    handle_afd_str (fd);
  else if (value_type == FOLKS_TYPE_POSTAL_ADDRESS)
    handle_afd_postal_address (fd);
  else
    ...
}

This is particularly useful for the first case; most AFD-derived types have value_type G_TYPE_STRING, so this saves a bit of repetitive code. It also helps future-proof the code a bit (since it's possible we'll add more AFD<string> classes in the future.
Comment 1 Travis Reitter 2011-11-10 19:07:51 UTC
Created attachment 201174 [details] [review]
Add AbstractFieldDetails.value_type

Patch from branch:

http://cgit.collabora.com/git/user/treitter/folks.git/log/?h=bgo663798-add-afd-get-value-type
Comment 2 Raul Gutierrez Segales 2011-11-10 19:24:38 UTC
Review of attachment 201174 [details] [review]:

Looks good to me.
Comment 3 Travis Reitter 2011-11-10 22:07:06 UTC
commit 0719b657cacd96edfc2a7159c3228b5fc3e7969f
Author: Travis Reitter <travis.reitter@collabora.co.uk>
Date:   Thu Nov 3 14:05:45 2011 -0700

    Add AbstractFieldDetails.value_type.
    
    This allows generic handling of collections of derived objects of
    mixed concrete classes.
    
    Helps: bgo#663798 - Add AbstractFieldDetails.value_type

 NEWS                                    |    2 +
 folks/abstract-field-details.vala       |   14 ++++++++++
 tests/folks/abstract-field-details.vala |   44 +++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+), 0 deletions(-)