[Libreoffice] Reusing the GLib mainloop from GTK/GNOME integration

Alberto Ruiz alberto.ruiz at codethink.co.uk
Wed Feb 9 04:16:12 PST 2011

Hi Michael,

On 08/02/11 21:17, Michael Meeks wrote:
> Wonderful :-) but why are you doing this as an extension ? :-) surely
> we should put this into the core code ? it should be rather easier to do
> that, and less problematic.
For now deploying it as an extension allows me to focus on the code, 
ultimately I'm planning to deploy in the same fashion than ogltrans.
Once the code is working properly I'll figure out what the best way to

>> My approach is creating a Synchronous Job that gets executed everytime
>> a document is opened[1][2].
> 	Hokay, no idea if that makes sense without reading the framework code
> personally ;-)

> Sooo ... we have gtk mainloop integration; but you need to get the
> locking right of course; if it is pure gtk code; you should use:
> 	as you hit your idle handler, and GDK_THREADS_LEAVE as you exit it.
> Hmm ! interestingly I get similar corruption opening the file-selector
> over the top of the shell - which might be related - fun. That would be
> my first port of call.

Just tried that:

Same thing, funnily enough a timeout_add gives no problems.

>> My question is, is there a safe manner or any recommended practice
>> while using the glib mainloop from OpenOffice if the GNOME/GTK
>> integration is in use?
> 	cf. above I guess. I didn't see any interesting code at the links you
> posted though so ... beyond taking the toolkit lock before using the
> toolkit, I am not sure :-) There are really two ways to do that - one is
> with the GDK_THREADS magic; the other is via
> vcl/inc/vcl/solarmutex.hxx's helper.

Well, I intend to create a DBus service, as long as I get to that point 
I'll see how it behaves (the g_idle_add was just a test to check if the 
glib mainloop was usable).

I'll keep reporting. Thanks a lot for the comments.


Alberto Ruiz, VP of Business Development, Codethink Ltd. - http://codethink.co.uk
Twitter: @acruiz LinkedIn: http://www.linkedin.com/in/acruiz
Office: +44 161 236 5575 - Cell: +44 790 812 1293

More information about the LibreOffice mailing list