Contacts Browser Example

Contacts Browser Example — Explanation of how to create a scrolling window listing contacts in alphabetical order.

Introduction

This is a fully functional reference application for implementing scrolling contact browsers using the EBookClientCursor. With the cursor, the following features are possible.

  • Display contacts in a configurable sort order

    Sort by any EContactField which conforms to G_TYPE_STRING, this can be checked with e_contact_field_type()

  • Minimal memory constraints

    Only load into memory the contacts which are currently visible in the list

  • Filter search results on the fly

    Set new search expressions generated with EBookQuery on the fly. Refresh the contact list at the current position without losing the current cursor position.

  • Display the the user's alphabet

    Using interesting features from ICU libraries allow us to display the user's alphabet, and implement features such as jumping to a given letter in the user's alphabet.

The actual example code is built into the 'example' subdirectory of the Evolution Data Server sources. In order to run the example, just launch the program and give it a path to a directory full of vcards, bearing the .vcf filename extention.

Contact Browser

Below is an example of the contact browser code itself, the example program is broken down into a couple of object classes which are also listed below.

1

The alphabetic navigator

This is a simple class which implements a vertical scroller and displays various letters according to the currently active alphabet. The actual interaction with EBookClientCursor is done in the main contact browser and this class is simply configured with the active alphabet.

1

The search entry

The search entry is placed at the top of the contacts browser, this class simply implements a drop down box choosing the appropriate search expression which should be used to filter the contacts in the browser display window.

1

The contact slot

This is a very simple class who's only purpose is to display contact related data, each entry in the list is a 'slot'

1

Creating addressbooks and loading vcards

This is the messy part of the example, here we take care of creating a custom addressbook and populating it with the contacts found in the directory given to the example.

1