[gtk+] appchooser: add a GCancellable to the search operation
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] appchooser: add a GCancellable to the search operation
- Date: Tue, 4 Oct 2011 15:34:26 +0000 (UTC)
commit 569b5ffd5bf687cbb37e17367f1d7ac7657eee2e
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Oct 3 11:47:09 2011 -0400
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
gtk/gtkappchooserdialog.c | 15 +++++++++++++--
gtk/gtkappchooseronline.c | 3 ++-
gtk/gtkappchooseronline.h | 2 ++
gtk/gtkappchooseronlinepk.c | 3 ++-
4 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkappchooserdialog.c b/gtk/gtkappchooserdialog.c
index 28c6bc0..ac1f0af 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 99454cd..633d6fb 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 a8316c1..457fb7b 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 4b6df0e..7bfc84d 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]