From a7e25f2c73040bc9506816eb3dc42417b1fa1cda Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 2 Aug 2020 21:46:44 -0400 Subject: [PATCH 1/2] gtk-demo: Make search progress visible again Set a progress fraction, so that the pulsing progress in the search entry demo is actually visible. --- demos/gtk-demo/search_entry.c | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c index 8905e4359b..ff63a42fe6 100644 --- a/demos/gtk-demo/search_entry.c +++ b/demos/gtk-demo/search_entry.c @@ -54,6 +54,7 @@ finish_search (GtkButton *button) static gboolean start_search_feedback (gpointer data) { + gtk_entry_set_progress_fraction (GTK_ENTRY (data), 0.1); search_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 100, (GSourceFunc)search_progress, data, (GDestroyNotify)search_progress_done); From df85ef1754f89f9e3c3be35274ae180a16d9aaab Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 2 Aug 2020 21:53:59 -0400 Subject: [PATCH 2/2] gtk-demo: Fix cleanup of search entry demo We can't use the ::destroy signal anymore; use a weak ref instead, and make ensure the entry stays around long enough for us to finish the cleanup. Fixes: #3004 --- demos/gtk-demo/search_entry.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/demos/gtk-demo/search_entry.c b/demos/gtk-demo/search_entry.c index ff63a42fe6..7e2f1d8f76 100644 --- a/demos/gtk-demo/search_entry.c +++ b/demos/gtk-demo/search_entry.c @@ -37,6 +37,7 @@ static void search_progress_done (GtkEntry *entry) { gtk_entry_set_progress_fraction (entry, 0.0); + g_object_unref (entry); } static gboolean @@ -56,8 +57,9 @@ start_search_feedback (gpointer data) { gtk_entry_set_progress_fraction (GTK_ENTRY (data), 0.1); search_progress_id = g_timeout_add_full (G_PRIORITY_DEFAULT, 100, - (GSourceFunc)search_progress, data, + (GSourceFunc)search_progress, g_object_ref (data), (GDestroyNotify)search_progress_done); + return G_SOURCE_REMOVE; } @@ -163,7 +165,8 @@ activate_cb (GtkEntry *entry, } static void -search_entry_destroyed (GtkWidget *widget) +search_entry_destroyed (gpointer data, + GObject *widget) { if (finish_search_id != 0) { @@ -262,8 +265,8 @@ do_search_entry (GtkWidget *do_widget) gtk_window_set_display (GTK_WINDOW (window), gtk_widget_get_display (do_widget)); gtk_window_set_title (GTK_WINDOW (window), "Search Entry"); gtk_window_set_resizable (GTK_WINDOW (window), FALSE); - g_signal_connect (window, "destroy", - G_CALLBACK (search_entry_destroyed), &window); + + g_object_weak_ref (G_OBJECT (window), search_entry_destroyed, &window); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); gtk_widget_set_margin_start (vbox, 5);