File geary-hide-gmail-main.patch of Package geary

From 1ecd6b65b2a01478fa849be5b90d2a4b5d0a9507 Mon Sep 17 00:00:00 2001
From: Gautier Pelloux-Prayer <gautier+git@damsy.net>
Date: Thu, 2 Mar 2017 12:35:39 +0100
Subject: [PATCH v2] Do not add non openable folders entry in sidemenu. Bug
 712902

---
 src/client/application/geary-controller.vala | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index b859fd80..d92ac9c0 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -1636,10 +1636,31 @@ public class GearyController : Geary.BaseObject {
         return null;
     }
     
+    private bool should_add_folder(Gee.List<Geary.Folder>? all, Geary.Folder folder) {
+        // if folder is openable, add it
+        if (folder.properties.is_openable != Geary.Trillian.FALSE)
+            return true;
+        else if (folder.properties.has_children == Geary.Trillian.FALSE)
+            return false;
+
+        // if folder contains children, we must ensure that there is at least one of the same type
+        Geary.SpecialFolderType type = folder.special_folder_type;
+        foreach (Geary.Folder other in all) {
+            if (other.special_folder_type == type && other.path.get_parent() == folder.path)
+                return true;
+        }
+
+        return false;
+    }
+
     private void on_folders_available_unavailable(Gee.List<Geary.Folder>? available,
         Gee.List<Geary.Folder>? unavailable) {
         if (available != null && available.size > 0) {
             foreach (Geary.Folder folder in available) {
+                if (!should_add_folder(available, folder)) {
+                    continue;
+                }
+
                 main_window.folder_list.add_folder(folder);
                 if (folder.account == current_account) {
                     if (!main_window.main_toolbar.copy_folder_menu.has_folder(folder))
-- 
2.11.0

openSUSE Build Service is sponsored by