Do not show "Labels" folders entry in sidemenu if there are none. Bug 754802

This commit is contained in:
Gautier Pelloux-Prayer 2017-03-02 11:54:59 +01:00 committed by Michael James Gratton
parent acba774839
commit ff95fb819f
3 changed files with 23 additions and 8 deletions

View file

@ -20,14 +20,14 @@ public class FolderList.AccountBranch : Sidebar.Branch {
account.information.notify["nickname"].connect(on_nicknamed_changed);
graft(get_root(), user_folder_group);
entry_removed.connect(on_entry_removed);
entry_moved.connect(check_user_folders);
}
~AccountBranch() {
account.information.notify["nickname"].disconnect(on_nicknamed_changed);
entry_removed.disconnect(on_entry_removed);
entry_moved.disconnect(check_user_folders);
}
private void on_nicknamed_changed() {
@ -87,6 +87,10 @@ public class FolderList.AccountBranch : Sidebar.Branch {
} else if (folder.path.get_parent() == null) {
// Top-level folders get put in our special user folders group.
graft_point = user_folder_group;
if (!has_entry(user_folder_group)) {
graft(get_root(), user_folder_group);
}
} else {
Sidebar.Entry? entry = folder_entries.get(folder.path.get_parent());
if (entry != null)
@ -129,5 +133,16 @@ public class FolderList.AccountBranch : Sidebar.Branch {
FolderEntry? folder_entry = entry as FolderEntry;
if (folder_entry != null && folder_entries.has_key(folder_entry.folder.path))
folder_entries.unset(folder_entry.folder.path);
check_user_folders(entry);
}
private void check_user_folders(Sidebar.Entry entry) {
if (entry != user_folder_group) {
// remove "Labels" entry if there are no more user entries
if (has_entry(user_folder_group) && (get_child_count(user_folder_group) == 0)) {
prune(user_folder_group);
}
}
}
}

View file

@ -641,10 +641,10 @@ public class Sidebar.Tree : Gtk.TreeView {
private void on_branch_entry_removed(Sidebar.Branch branch, Sidebar.Entry entry) {
EntryWrapper? wrapper = get_wrapper(entry);
assert(wrapper != null);
assert(!(wrapper is RootWrapper));
disassociate_wrapper_and_signal(wrapper, false);
if (wrapper != null) {
assert(!(wrapper is RootWrapper));
disassociate_wrapper_and_signal(wrapper, false);
}
}
private void on_branch_entry_moved(Sidebar.Branch branch, Sidebar.Entry entry) {

View file

@ -466,8 +466,8 @@ public class Geary.AccountInformation : BaseObject {
/**
* Sets the path Geary will look for or create a special folder. This is
* only obeyed if the server doesn't tell Geary which folders are special.
* Only the DRAFTS, SENT, SPAM, and TRASH special folder types are valid to
* pass to this function.
* Only the DRAFTS, SENT, SPAM, TRASH and ARCHIVE special folder types are
* valid to pass to this function.
*/
public void set_special_folder_path(Geary.SpecialFolderType special, Geary.FolderPath? path) {
switch (special) {