[geary] Do not show "Labels" folders entry in sidemenu if there are none. Bug 754802
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Do not show "Labels" folders entry in sidemenu if there are none. Bug 754802
- Date: Tue, 9 Jan 2018 09:25:54 +0000 (UTC)
commit ff95fb819f72e7199824b7292ce5de54cc69ae7e
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date: Thu Mar 2 11:54:59 2017 +0100
Do not show "Labels" folders entry in sidemenu if there are none. Bug 754802
.../folder-list/folder-list-account-branch.vala | 19 +++++++++++++++++--
src/client/sidebar/sidebar-tree.vala | 8 ++++----
src/engine/api/geary-account-information.vala | 4 ++--
3 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/client/folder-list/folder-list-account-branch.vala
b/src/client/folder-list/folder-list-account-branch.vala
index 465e9a5..877fb85 100644
--- a/src/client/folder-list/folder-list-account-branch.vala
+++ b/src/client/folder-list/folder-list-account-branch.vala
@@ -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);
+ }
+ }
}
}
diff --git a/src/client/sidebar/sidebar-tree.vala b/src/client/sidebar/sidebar-tree.vala
index 7136f2f..e5c5ac7 100644
--- a/src/client/sidebar/sidebar-tree.vala
+++ b/src/client/sidebar/sidebar-tree.vala
@@ -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) {
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index c2a34b3..0b0ce5e 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]