[totem/wip/hadess/search-entry-focus] grilo: Keep focus on search entry after validation



commit 4fd7a94a43a2879c71d72b44010e2840e7cdb7f8
Author: Gabor Karsay <gabor karsay gmx at>
Date:   Thu Oct 24 18:58:26 2019 +0200

    grilo: Keep focus on search entry after validation
    
    Don't make the search entry insensitive while the search is ongoing,
    instead cancel the ongoing operation if a new search is started.
    
    Closes: #188
    Helps: #113

 meson.build       |  2 +-
 src/totem-grilo.c | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/meson.build b/meson.build
index 6aa31bc98..af8aa7953 100644
--- a/meson.build
+++ b/meson.build
@@ -123,7 +123,7 @@ endif
 
 add_project_arguments(common_flags, language: 'c')
 
-glib_req_version = '>= 2.35.0'
+glib_req_version = '>= 2.56.0'
 gtk_req_version = '>= 3.22.0'
 gst_req_version = '>= 1.6.0'
 grilo_req_version = '>= 0.3.0'
diff --git a/src/totem-grilo.c b/src/totem-grilo.c
index 0f9396c19..a41a69f17 100644
--- a/src/totem-grilo.c
+++ b/src/totem-grilo.c
@@ -813,12 +813,18 @@ search_cb (GrlSource    *source,
 
        self = TOTEM_GRILO (user_data);
 
-       if (error != NULL &&
-           g_error_matches (error,
-                            GRL_CORE_ERROR,
-                            GRL_CORE_ERROR_OPERATION_CANCELLED) == FALSE) {
-               window = totem_object_get_main_window (self->priv->totem);
-               totem_interface_error (_("Search Error"), error->message, window);
+       if (error != NULL) {
+               if (g_error_matches (error,
+                                    GRL_CORE_ERROR,
+                                    GRL_CORE_ERROR_OPERATION_CANCELLED)) {
+                       g_application_unmark_busy (g_application_get_default ());
+                       /* Don't zero out self->priv->search_id to avoid a race
+                        * condition with next search. Don't update thumbnails. */
+                       return;
+               } else {
+                       window = totem_object_get_main_window (self->priv->totem);
+                       totem_interface_error (_("Search Error"), error->message, window);
+               }
        }
 
        if (media != NULL) {
@@ -840,7 +846,6 @@ search_cb (GrlSource    *source,
        if (remaining == 0) {
                g_application_unmark_busy (g_application_get_default ());
                self->priv->search_id = 0;
-               gtk_widget_set_sensitive (self->priv->search_entry, TRUE);
                update_search_thumbnails (self);
        }
 }
@@ -877,7 +882,6 @@ search_more (TotemGrilo *self)
 
        search_options = get_search_options (self);
 
-       gtk_widget_set_sensitive (self->priv->search_entry, FALSE);
        self->priv->search_page++;
        self->priv->search_remaining = PAGE_SIZE;
 
@@ -911,9 +915,10 @@ search (TotemGrilo  *self,
        GrlSource   *source,
        const gchar *text)
 {
+       g_clear_handle_id (&self->priv->search_id, grl_operation_cancel);
+
        gtk_tree_store_clear (GTK_TREE_STORE (self->priv->search_results_model));
 //     g_hash_table_remove_all (self->priv->cache_thumbnails);
-       gtk_widget_set_sensitive (self->priv->search_entry, FALSE);
        self->priv->search_source = source;
        g_free (self->priv->search_text);
        self->priv->search_text = g_strdup (text);


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