~ubuntu-branches/ubuntu/saucy/geary/saucy-updates

« back to all changes in this revision

Viewing changes to src/client/composer/contact-list-store.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-10-10 17:40:37 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20131010174037-5p5o4dlsoewek2kg
Tags: 0.4.0-0ubuntu1
New stable version

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
    public enum Column {
12
12
        CONTACT_OBJECT,
13
13
        CONTACT_MARKUP_NAME,
14
 
        LAST_KEY;
 
14
        PRIOR_KEYS;
15
15
        
16
16
        public static Type[] get_types() {
17
17
            return {
18
18
                typeof (Geary.Contact), // CONTACT_OBJECT
19
19
                typeof (string),        // CONTACT_MARKUP_NAME
20
 
                typeof (string)         // LAST_KEY
 
20
                typeof (Gee.HashSet)    // PRIOR_KEYS
21
21
            };
22
22
        }
23
23
    }
59
59
    // Highlighted result should be Markup.escaped for presentation to the user
60
60
    public void set_highlighted_result(Gtk.TreeIter iter, string highlighted_result,
61
61
        string current_address_key) {
62
 
        // get the last key for this row for comparison
63
 
        GLib.Value last_key_value;
64
 
        get_value(iter, Column.LAST_KEY, out last_key_value);
65
 
        string? last_key = last_key_value.get_string();
 
62
        // get the previous keys for this row for comparison
 
63
        GLib.Value prior_keys_value;
 
64
        get_value(iter, Column.PRIOR_KEYS, out prior_keys_value);
 
65
        Gee.HashSet<string> prior_keys = (Gee.HashSet<string>) prior_keys_value.get_object();
66
66
        
67
67
        // Changing a row in the list store causes Gtk.EntryCompletion to re-evaluate
68
68
        // completion_match_func for that row. Thus we need to make sure the key has
69
69
        // actually changed before settings the highlighting--otherwise we will cause
70
70
        // an infinite loop.
71
 
        if (current_address_key != last_key) {
72
 
            set(iter,
73
 
                Column.CONTACT_MARKUP_NAME, highlighted_result,
74
 
                Column.LAST_KEY, current_address_key, -1);
 
71
        if (!(current_address_key in prior_keys)) {
 
72
            prior_keys.add(current_address_key);
 
73
            set(iter, Column.CONTACT_MARKUP_NAME, highlighted_result, -1);
75
74
        }
76
75
    }
77
76
    
85
84
        set(iter,
86
85
            Column.CONTACT_OBJECT, contact,
87
86
            Column.CONTACT_MARKUP_NAME, Markup.escape_text(full_address),
88
 
            Column.LAST_KEY, "");
 
87
            Column.PRIOR_KEYS, new Gee.HashSet<string>());
89
88
    }
90
89
    
91
90
    private void update_contact(Geary.Contact updated_contact) {