[gnome-contacts] Show initial letter



commit 4dcdd93f0a0546ee87fae0df8792c692e9eaf158
Author: Alexander Larsson <alexl redhat com>
Date:   Tue May 24 11:07:21 2011 +0200

    Show initial letter
    
    There is still some bugs in the is_first tracking that need
    to be fixed.

 src/contacts-app.vala   |   16 +++++++++++++++-
 src/contacts-store.vala |    8 ++++++++
 2 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 861adec..c7f92e1 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -42,6 +42,20 @@ public class Contacts.App : Window {
     var column = new TreeViewColumn ();
     column.set_spacing (10);
 
+    var text = new CellRendererText ();
+    column.pack_start (text, true);
+    text.set ("weight", Pango.Weight.BOLD);
+    column.set_cell_data_func (text, (column, cell, model, iter) => {
+	Contact contact;
+
+	model.get (iter, 0, out contact);
+
+	string letter = "";
+	if (contacts_store.is_first (iter))
+	  letter = contact.display_name.get_char ().totitle ().to_string ();
+	cell.set ("text", letter);
+      });
+
     var icon = new CellRendererPixbuf ();
     column.pack_start (icon, false);
     column.set_cell_data_func (icon, (column, cell, model, iter) => {
@@ -52,7 +66,7 @@ public class Contacts.App : Window {
 	cell.set ("pixbuf", contact.avatar);
       });
 
-    var text = new CellRendererText ();
+    text = new CellRendererText ();
     column.pack_start (text, true);
     text.set ("weight", Pango.Weight.BOLD);
     column.set_cell_data_func (text, (column, cell, model, iter) => {
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index caa1433..6336f76 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -59,6 +59,14 @@ public class Contacts.Store  {
 		return contact.contains_strings (filter_values);
 	}
 
+	public bool is_first (TreeIter iter) {
+		ContactData *data;
+		list_store.get (iter, 1, out data);
+		if (data != null)
+			return data->is_first;
+		return false;
+	}
+
 	private ContactData? get_previous (ContactData data) {
 		ContactData *previous = null;
 		TreeIter iter = data.iter;



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