[recipes/recipe-link: 2/8] Defer link activation to an idle
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [recipes/recipe-link: 2/8] Defer link activation to an idle
- Date: Fri, 30 Dec 2016 12:17:57 +0000 (UTC)
commit 720e37eeedc97ca7531df0d8105a6648edb940ae
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Dec 29 11:17:57 2016 -0500
Defer link activation to an idle
This avoids a crash in GTK+ that will be fixed with 3.22.6.
src/gr-details-page.c | 32 ++++++++++++++++++++++++++------
1 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/src/gr-details-page.c b/src/gr-details-page.c
index 844eec8..5df7160 100644
--- a/src/gr-details-page.c
+++ b/src/gr-details-page.c
@@ -150,6 +150,8 @@ struct _GrDetailsPage
GtkWidget *error_revealer;
guint save_timeout;
+
+ char *uri;
};
G_DEFINE_TYPE (GrDetailsPage, gr_details_page, GTK_TYPE_BOX)
@@ -497,6 +499,7 @@ details_page_finalize (GObject *object)
g_clear_object (&self->printer);
g_clear_object (&self->exporter);
g_clear_pointer (&self->cooking, g_hash_table_unref);
+ g_clear_pointer (&self->uri, g_free);
if (self->save_timeout) {
g_source_remove (self->save_timeout);
@@ -583,10 +586,14 @@ schedule_save (GtkTextBuffer *buffer, GrDetailsPage *page)
}
static gboolean
-activate_link (GtkLabel *label,
- const char *uri,
- GrDetailsPage *page)
+activate_uri_at_idle (gpointer data)
{
+ GrDetailsPage *page = data;
+ g_autofree char *uri = NULL;
+
+ uri = page->uri;
+ page->uri = NULL;
+
if (g_str_has_prefix (uri, "recipe:")) {
GrRecipeStore *store;
const char *id;
@@ -600,17 +607,30 @@ activate_link (GtkLabel *label,
GtkWidget *window;
window = gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_APPLICATION_WINDOW);
- gr_window_edit_recipe (GR_WINDOW (window), recipe);
+ gr_window_show_recipe (GR_WINDOW (window), recipe);
}
else {
gtk_label_set_label (GTK_LABEL (page->error_label),
_("Could not find this recipe."));
gtk_revealer_set_reveal_child (GTK_REVEALER (page->error_revealer), TRUE);
}
- return TRUE;
}
- return FALSE;
+ return G_SOURCE_REMOVE;
+}
+
+static gboolean
+activate_link (GtkLabel *label,
+ const char *uri,
+ GrDetailsPage *page)
+{
+ g_free (page->uri);
+ page->uri = g_strdup (uri);
+
+ // FIXME: We can avoid the idle with GTK+ 3.22.6 or newer
+ g_idle_add (activate_uri_at_idle, page);
+
+ return TRUE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]