« first day (967 days earlier)      last day (411 days later) » 

2:06 PM
Hopefully this is a simple question, but I am not sure what would be the most clever way to approach it. I am using g_spawn_async() to spawn a python process from my C code and I change the cursor to a spinner because it takes a couple of seconds for the plot to appear. The problem is, I am not sure of how I can get the spinner to go back to the default cursor after the plot appears.
It's an asynchronous, so non-blocking, spawn. Also, the cursor is initialized to the GdkDisplay of the dialog where the button click happens to spawn the process, and even that seems a bit clunky to me. Can it be tied to an event instead?
The spinner start is done by:
// Get the display from the edit transition dialog
GtkWidget *transition_dialog = GTK_WIDGET(gtk_builder_get_object(csdata->builder, "transition_dialog"));
GdkDisplay *display = gtk_widget_get_display(transition_dialog);

// Initialize cursor
GdkCursor *cursor;
cursor = gdk_cursor_new_from_name(display, "wait"); // Set to spinner

// Set the cursor for the window
gdk_window_set_cursor(gtk_widget_get_window(transition_dialog), cursor);

// Free cursor
g_object_unref(cursor);
I was thinking along the lines of g_idle_add(), but I don't think I can tie that to a g_spawn() since it needs a GSourceFunc.
Also, just throwing in a timed pause will mess with the gtk main loop, and is also a clunky solution.
 
2:32 PM
Does it have to be gdk_window_set_cursor()? Are there other options?
 
2:49 PM
Is there any way to know when the plot appears?
When I do things like this, I check for values fed back from the Python process. How this is done is difficult to know, as I don't know how the rest of your app works. Checking for a simple print() can do the trick.
 
 
2 hours later…
4:25 PM
That's actually a good idea, and I have done something similar with updating a progress bar using a print from a python script.
 

« first day (967 days earlier)      last day (411 days later) »