2
votes

I develop an application written with C++/wxWidgets that has an embedded .NET runtime for scripting and plugins.

I would like to use gtk# for a plugins GUI, however the GUI is unresponsive due to the gtk event loop not having been started (This is wxWidgets on windows, so it does not use gtk as a backend).

This can be solved by pumping the event loop during wxWidgets idle processing:

public void OnWxWidgetsIdle()
{
    while(Gtk.Application.EventsPending())
        Gtk.Application.RunIteration();
}

However this does not seem to trigger gtk# idle events, therefore GUI widgets that depend on idle events, such as the blinking cursor in a text box do not update properly.

Does anyone know how I can force the dispatch of gtk# idle events, or any other alternative solution to this problem?

Kind Regards,

Andrew Ward.

1

1 Answers

0
votes

Use an idle handler on the Mono side:

void Start ()
    {
    GLib.Idle.Add (new IdleHandler (OnIdleCreateThumbnail));
    }

bool OnIdleCreateThumbnail ()
    {
    Image img = GetNextImage ();

    // If no more images remain, stop the idle handler.
    if (img == null)
       return false; 

    CreateThumbnail (img, img.ToString () + ".thumbnail");

    // There are more images, invoke this routine again on the next Idle moment.
    return true;           
    }

References