~ubuntu-branches/ubuntu/saucy/geary/saucy-proposed

« back to all changes in this revision

Viewing changes to src/client/folder-list/folder-list-account-branch.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-04-10 10:57:25 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20130410105725-f532n2cfre2sq6mf
Tags: 0.3.1-0ubuntu1
* New upstream bugfix version:
  - Reduced CPU and memory footprint
  - Account dialog bugs fixed
  - Stability improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
            new ThemedIcon("folder-open"), new ThemedIcon("folder"));
21
21
        user_folder_group = new SpecialGrouping(2, "",
22
22
            IconFactory.instance.get_custom_icon("tags", IconFactory.ICON_SIDEBAR));
23
 
        folder_entries = new Gee.HashMap<Geary.FolderPath, FolderEntry>();
 
23
        folder_entries = new Gee.HashMap<Geary.FolderPath, FolderEntry>(
 
24
            Geary.Hashable.hash_func, Geary.Equalable.equal_func);
24
25
        
25
26
        account.information.notify["nickname"].connect(on_nicknamed_changed);
26
27
        
77
78
    }
78
79
    
79
80
    public void add_folder(Geary.Folder folder) {
 
81
        Sidebar.Entry? graft_point = null;
80
82
        FolderEntry folder_entry = new FolderEntry(folder);
81
83
        Geary.SpecialFolderType special_folder_type = folder.get_special_folder_type();
82
84
        if (special_folder_type != Geary.SpecialFolderType.NONE) {
86
88
                case Geary.SpecialFolderType.FLAGGED:
87
89
                case Geary.SpecialFolderType.IMPORTANT:
88
90
                case Geary.SpecialFolderType.ALL_MAIL:
89
 
                    graft(get_root(), folder_entry);
 
91
                    graft_point = get_root();
90
92
                break;
91
93
                
92
94
                // Others go in the "More" grouping.
93
95
                default:
94
 
                    graft(uncommon_special_group, folder_entry);
 
96
                    graft_point = uncommon_special_group;
95
97
                break;
96
98
            }
97
99
        } else if (folder.get_path().get_parent() == null) {
98
100
            // Top-level folders get put in our special user folders group.
99
 
            graft(user_folder_group, folder_entry);
 
101
            graft_point = user_folder_group;
100
102
        } else {
101
103
            Sidebar.Entry? entry = folder_entries.get(folder.get_path().get_parent());
102
 
            if (entry == null) {
103
 
                debug("Could not add folder %s of type %s to folder list", folder.to_string(),
104
 
                    special_folder_type.to_string());
105
 
                return;
106
 
            }
107
 
            graft(entry, folder_entry);
 
104
            if (entry != null)
 
105
                graft_point = entry;
108
106
        }
109
107
        
110
 
        folder_entries.set(folder.get_path(), folder_entry);
 
108
        // Due to how we enumerate folders on the server, it's unfortunately
 
109
        // possible now to have two folders that we'd put in the same place in
 
110
        // our tree.  In that case, we just ignore the second folder for now.
 
111
        // See #6616.
 
112
        if (graft_point != null) {
 
113
            Sidebar.Entry? twin = find_first_child(graft_point, (e) => {
 
114
                return e.get_sidebar_name() == folder_entry.get_sidebar_name();
 
115
            });
 
116
            if (twin != null)
 
117
                graft_point = null;
 
118
        }
 
119
 
 
120
        if (graft_point != null) {
 
121
            graft(graft_point, folder_entry);
 
122
            folder_entries.set(folder.get_path(), folder_entry);
 
123
        } else {
 
124
            debug("Could not add folder %s of type %s to folder list", folder.to_string(),
 
125
                special_folder_type.to_string());
 
126
        }
111
127
    }
112
128
    
113
129
    public void remove_folder(Geary.Folder folder) {