mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
path spinner demo: Don't crash
This commit is contained in:
parent
d3f9b3e28a
commit
9a6aac0459
@ -286,6 +286,12 @@ progress_timeout (gpointer data)
|
|||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
unset_timeout (gpointer data)
|
||||||
|
{
|
||||||
|
g_source_remove (GPOINTER_TO_UINT (data));
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
do_path_spinner (GtkWidget *do_widget)
|
do_path_spinner (GtkWidget *do_widget)
|
||||||
{
|
{
|
||||||
@ -295,6 +301,7 @@ do_path_spinner (GtkWidget *do_widget)
|
|||||||
{
|
{
|
||||||
GtkWidget *picture;
|
GtkWidget *picture;
|
||||||
GdkPaintable *paintable;
|
GdkPaintable *paintable;
|
||||||
|
guint timeout_id;
|
||||||
|
|
||||||
window = gtk_window_new ();
|
window = gtk_window_new ();
|
||||||
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
gtk_window_set_resizable (GTK_WINDOW (window), TRUE);
|
||||||
@ -308,7 +315,9 @@ do_path_spinner (GtkWidget *do_widget)
|
|||||||
g_object_unref (paintable);
|
g_object_unref (paintable);
|
||||||
|
|
||||||
gtk_widget_add_tick_callback (picture, tick_cb, paintable, NULL);
|
gtk_widget_add_tick_callback (picture, tick_cb, paintable, NULL);
|
||||||
g_timeout_add (100, progress_timeout, paintable);
|
timeout_id = g_timeout_add (100, progress_timeout, paintable);
|
||||||
|
|
||||||
|
g_object_set_data_full (G_OBJECT (picture), "timeout", GUINT_TO_POINTER (timeout_id), unset_timeout);
|
||||||
|
|
||||||
gtk_window_set_child (GTK_WINDOW (window), picture);
|
gtk_window_set_child (GTK_WINDOW (window), picture);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user