[evolution-data-server] M!31 - EWebDAVDiscoverContent: Select implicitly the single item



commit 8712460c3dd2ad39d8f88c8414fd8d4b0aa4c4d3
Author: Дилян Палаузов <git-dpa aegee org>
Date:   Fri Jul 26 15:32:55 2019 +0000

    M!31 - EWebDAVDiscoverContent: Select implicitly the single item
    
    When the EWebDAVDiscoverContent finds a single item, select it
    implicitly, so that the user does not have to choose manually
    one out of one items.
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/merge_requests/31

 src/libedataserverui/e-webdav-discover-widget.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/src/libedataserverui/e-webdav-discover-widget.c b/src/libedataserverui/e-webdav-discover-widget.c
index 1c5facfbd..857f1d6fa 100644
--- a/src/libedataserverui/e-webdav-discover-widget.c
+++ b/src/libedataserverui/e-webdav-discover-widget.c
@@ -454,6 +454,7 @@ e_webdav_discover_content_fill_discovered_sources (GtkTreeView *tree_view,
        GtkTreeModel *model;
        GtkTreeIter iter;
        GSList *link;
+       guint num_displayed_items = 0;
 
        /* It's okay to pass NULL here */
        if (!tree_view)
@@ -477,6 +478,7 @@ e_webdav_discover_content_fill_discovered_sources (GtkTreeView *tree_view,
                    (source->supports & E_WEBDAV_DISCOVER_SUPPORTS_SUBSCRIBED_ICALENDAR) != 0)
                        continue;
 
+               num_displayed_items++;
                if (source->color && *source->color) {
                        gint rr, gg, bb;
 
@@ -542,6 +544,13 @@ e_webdav_discover_content_fill_discovered_sources (GtkTreeView *tree_view,
                g_free (colorstr);
                g_string_free (supports, TRUE);
        }
+
+       /* If there is only one item, select it */
+       if (num_displayed_items == 1) {
+               GtkTreeSelection *tree_selection = gtk_tree_view_get_selection (tree_view);
+
+               gtk_tree_selection_select_iter (tree_selection, &iter);
+       }
 }
 
 static void


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