diff --git a/src/exm-application.c b/src/exm-application.c index b98cab31..508627bb 100644 --- a/src/exm-application.c +++ b/src/exm-application.c @@ -130,7 +130,7 @@ exm_application_open (GApplication *app, } uuid = g_uri_get_host (uri); - g_print ("Opening extension with UUID: '%s'\n", uuid); + g_info ("Opening extension with UUID: '%s'\n", uuid); gtk_widget_activate_action (GTK_WIDGET (window), "win.show-detail", "s", uuid); } diff --git a/src/exm-backtrace.c b/src/exm-backtrace.c index e185ea6c..dae52873 100644 --- a/src/exm-backtrace.c +++ b/src/exm-backtrace.c @@ -39,7 +39,7 @@ exm_backtrace_error_cb (void *data, const char *msg, int errnum) { - g_print ("Error (%d): %s\n", errnum, msg); + g_warning ("Error (%d): %s\n", errnum, msg); } static int diff --git a/src/exm-browse-page.blp b/src/exm-browse-page.blp index 15b9f08d..60d9a5a7 100644 --- a/src/exm-browse-page.blp +++ b/src/exm-browse-page.blp @@ -28,7 +28,7 @@ template $ExmBrowsePage : Gtk.Widget { Gtk.DropDown search_dropdown { model: StringList { // Translators: dropdown items for sorting search results - strings [_("Relevance"), _("Popularity"), _("Downloads"), _("Recent"), _("Name")] + strings [_("Relevance"), _("Downloads"), _("Recent"), _("Name")] }; } } diff --git a/src/exm-browse-page.c b/src/exm-browse-page.c index 4ea864ad..2462c2a0 100644 --- a/src/exm-browse-page.c +++ b/src/exm-browse-page.c @@ -49,6 +49,8 @@ struct _ExmBrowsePage int current_page; int max_pages; + GCancellable *cancellable; + // Template Widgets GtkSearchEntry *search_entry; GtkListBox *search_results; @@ -237,9 +239,13 @@ on_load_more_results (GtkButton *btn, ExmSearchSort sort; gtk_widget_set_sensitive (GTK_WIDGET (self->more_results_btn), FALSE); + // If we have a current operation, cancel it + g_cancellable_cancel (self->cancellable); + self->cancellable = g_cancellable_new (); + query = gtk_editable_get_text (GTK_EDITABLE (self->search_entry)); sort = (ExmSearchSort) gtk_drop_down_get_selected (self->search_dropdown); - exm_search_provider_query_async (self->search, query, ++self->current_page, sort, NULL, + exm_search_provider_query_async (self->search, query, ++self->current_page, sort, self->cancellable, (GAsyncReadyCallback) on_next_page_result, self); } @@ -256,7 +262,11 @@ search (ExmBrowsePage *self, if (self->search_results_model) g_clear_object (&self->search_results_model); - exm_search_provider_query_async (self->search, query, 1, sort, NULL, + // If we have a current operation, cancel it + g_cancellable_cancel (self->cancellable); + self->cancellable = g_cancellable_new (); + + exm_search_provider_query_async (self->search, query, 1, sort, self->cancellable, (GAsyncReadyCallback) on_first_page_result, self); } @@ -444,3 +454,4 @@ exm_browse_page_init (ExmBrowsePage *self) load_suggestions (self); } + diff --git a/src/web/exm-comment-provider.c b/src/web/exm-comment-provider.c index 70e645e5..7f4fd1b9 100644 --- a/src/web/exm-comment-provider.c +++ b/src/web/exm-comment-provider.c @@ -45,8 +45,6 @@ parse_comments (GBytes *bytes, data = g_bytes_get_data (bytes, &length); - // g_print ("%s\n", (gchar *)data); - parser = json_parser_new (); if (json_parser_load_from_data (parser, data, length, &error)) { diff --git a/src/web/exm-search-provider.c b/src/web/exm-search-provider.c index fc503748..b9a832de 100644 --- a/src/web/exm-search-provider.c +++ b/src/web/exm-search-provider.c @@ -120,7 +120,7 @@ parse_search_results (GBytes *bytes, g_assert (json_object_has_member (root_object, "numpages")); num_pages = json_object_get_int_member (root_object, "numpages"); - g_print ("Num Pages: %d\n", num_pages); + g_info ("Num Pages: %d\n", num_pages); JsonArray *array = json_object_get_array_member (root_object, "extensions"); GList *search_results = json_array_get_elements (array); @@ -159,8 +159,6 @@ get_sort_string (ExmSearchSort sort_type) return "created"; case EXM_SEARCH_SORT_NAME: return "name"; - case EXM_SEARCH_SORT_POPULARITY: - return "popularity"; case EXM_SEARCH_SORT_RELEVANCE: default: return "relevance"; @@ -205,6 +203,14 @@ exm_search_provider_query_finish (ExmSearchProvider *self, SearchRequestData *data; GListModel *list_model; + // Check whether the task has been cancelled and if so, return null + // This prevents a race condition in the search logic + GCancellable *cancellable = g_task_get_cancellable (G_TASK (result)); + if (g_cancellable_is_cancelled (cancellable)) { + return NULL; + } + + ret = exm_request_handler_request_finish (EXM_REQUEST_HANDLER (self), result, error); diff --git a/src/web/exm-search-provider.h b/src/web/exm-search-provider.h index 62178ea4..0c8aff9a 100644 --- a/src/web/exm-search-provider.h +++ b/src/web/exm-search-provider.h @@ -14,10 +14,9 @@ G_DECLARE_FINAL_TYPE (ExmSearchProvider, exm_search_provider, EXM, SEARCH_PROVID typedef enum { EXM_SEARCH_SORT_RELEVANCE = 0, - EXM_SEARCH_SORT_POPULARITY = 1, - EXM_SEARCH_SORT_DOWNLOADS = 2, - EXM_SEARCH_SORT_RECENT = 3, - EXM_SEARCH_SORT_NAME = 4 + EXM_SEARCH_SORT_DOWNLOADS = 1, + EXM_SEARCH_SORT_RECENT = 2, + EXM_SEARCH_SORT_NAME = 3 } ExmSearchSort; ExmSearchProvider *exm_search_provider_new (void);