diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c index 28c6bc0a50..ac1f0afdd4 100644 --- a/gtk/gtkappchooserdialog.c +++ b/gtk/gtkappchooserdialog.c @@ -77,6 +77,7 @@ struct _GtkAppChooserDialogPrivate { GtkWidget *show_more_button; GtkAppChooserOnline *online; + GCancellable *online_cancellable; gboolean show_more_clicked; }; @@ -128,17 +129,19 @@ search_for_mimetype_ready_cb (GObject *source, _gtk_app_chooser_online_search_for_mimetype_finish (online, res, &error); - if (error != NULL) + if (error != NULL && + !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { show_error_dialog (_("Failed to look for applications online"), error->message, GTK_WINDOW (self)); - g_error_free (error); } else { gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->priv->app_chooser_widget)); } + g_clear_error (&error); + gdk_threads_leave (); } @@ -148,9 +151,11 @@ online_button_clicked_cb (GtkButton *b, { GtkAppChooserDialog *self = user_data; + self->priv->online_cancellable = g_cancellable_new (); _gtk_app_chooser_online_search_for_mimetype_async (self->priv->online, self->priv->content_type, GTK_WINDOW (self), + self->priv->online_cancellable, search_for_mimetype_ready_cb, self); } @@ -612,6 +617,12 @@ gtk_app_chooser_dialog_dispose (GObject *object) g_clear_object (&self->priv->gfile); g_clear_object (&self->priv->online); + if (self->priv->online_cancellable != NULL) + { + g_cancellable_cancel (self->priv->online_cancellable); + g_clear_object (&self->priv->online_cancellable); + } + G_OBJECT_CLASS (gtk_app_chooser_dialog_parent_class)->dispose (object); } diff --git a/gtk/gtkappchooseronline.c b/gtk/gtkappchooseronline.c index 99454cd5ee..633d6fba3a 100644 --- a/gtk/gtkappchooseronline.c +++ b/gtk/gtkappchooseronline.c @@ -77,6 +77,7 @@ void _gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self, const gchar *content_type, GtkWindow *parent, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -86,7 +87,7 @@ _gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self, iface = GTK_APP_CHOOSER_ONLINE_GET_IFACE (self); - (* iface->search_for_mimetype_async) (self, content_type, parent, callback, user_data); + (* iface->search_for_mimetype_async) (self, content_type, parent, cancellable, callback, user_data); } gboolean diff --git a/gtk/gtkappchooseronline.h b/gtk/gtkappchooseronline.h index a8316c1e1e..457fb7b4d6 100644 --- a/gtk/gtkappchooseronline.h +++ b/gtk/gtkappchooseronline.h @@ -46,6 +46,7 @@ struct _GtkAppChooserOnlineInterface { void (*search_for_mimetype_async) (GtkAppChooserOnline *self, const gchar *content_type, GtkWindow *parent, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); @@ -64,6 +65,7 @@ GtkAppChooserOnline * _gtk_app_chooser_online_get_default_finish (GObjec void _gtk_app_chooser_online_search_for_mimetype_async (GtkAppChooserOnline *self, const gchar *content_type, GtkWindow *parent, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); gboolean _gtk_app_chooser_online_search_for_mimetype_finish (GtkAppChooserOnline *self, diff --git a/gtk/gtkappchooseronlinepk.c b/gtk/gtkappchooseronlinepk.c index 4b6df0ec22..7bfc84de9c 100644 --- a/gtk/gtkappchooseronlinepk.c +++ b/gtk/gtkappchooseronlinepk.c @@ -124,6 +124,7 @@ static void pk_search_mime_async (GtkAppChooserOnline *obj, const gchar *content_type, GtkWindow *parent, + GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { @@ -152,7 +153,7 @@ pk_search_mime_async (GtkAppChooserOnline *obj, "hide-confirm-search"), G_DBUS_CALL_FLAGS_NONE, G_MAXINT, /* no timeout */ - NULL, + cancellable, install_mime_types_ready_cb, self); }