[evolution/gnome-3-38] I#1127 - EWebDAVBrowserPage: Offer 'Browse' for WebDAV sources only



commit e030f27b047ebfe8e5761faab6418368e86097e8
Author: Milan Crha <mcrha redhat com>
Date:   Thu Oct 1 17:16:10 2020 +0200

    I#1127 - EWebDAVBrowserPage: Offer 'Browse' for WebDAV sources only
    
    Closes https://gitlab.gnome.org/GNOME/evolution/-/issues/1127

 .../accounts-window/e-webdav-browser-page.c        | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/src/modules/accounts-window/e-webdav-browser-page.c 
b/src/modules/accounts-window/e-webdav-browser-page.c
index ade9008d5f..157d7d3972 100644
--- a/src/modules/accounts-window/e-webdav-browser-page.c
+++ b/src/modules/accounts-window/e-webdav-browser-page.c
@@ -68,7 +68,7 @@ webdav_browser_page_selection_changed_cb (EAccountsWindow *accounts_window,
                                          gpointer user_data)
 {
        EWebDAVBrowserPage *page = user_data;
-       gboolean has_path = FALSE;
+       gboolean can_use = FALSE;
 
        g_return_if_fail (E_IS_ACCOUNTS_WINDOW (accounts_window));
        g_return_if_fail (E_IS_WEBDAV_BROWSER_PAGE (page));
@@ -78,12 +78,30 @@ webdav_browser_page_selection_changed_cb (EAccountsWindow *accounts_window,
 
                path = e_source_webdav_dup_resource_path (e_source_get_extension (source, 
E_SOURCE_EXTENSION_WEBDAV_BACKEND));
 
-               has_path = path && *path;
+               can_use = path && *path;
 
                g_free (path);
        }
 
-       gtk_widget_set_sensitive (page->browse_button, has_path);
+       if (source && can_use) {
+               ESourceBackend *backend_extension = NULL;
+
+               if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK))
+                       backend_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK);
+               else if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR))
+                       backend_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR);
+               else if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST))
+                       backend_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_TASK_LIST);
+               else if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST))
+                       backend_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MEMO_LIST);
+
+               can_use = backend_extension && (
+                       g_strcmp0 (e_source_backend_get_backend_name (backend_extension), "caldav") == 0 ||
+                       g_strcmp0 (e_source_backend_get_backend_name (backend_extension), "carddav") == 0 ||
+                       g_strcmp0 (e_source_backend_get_backend_name (backend_extension), "webdav-notes") == 
0);
+       }
+
+       gtk_widget_set_sensitive (page->browse_button, can_use);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]