Commit 569b5ffd authored by Cosimo Cecchi's avatar Cosimo Cecchi

appchooser: add a GCancellable to the search operation

So that we can cancel it when the dialog is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=651818
parent 06dbbad5
......@@ -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);
}
......
......@@ -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
......
......@@ -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,
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment