Ticket #5492 enhancement closed fixed

Opened 15 months ago

Last modified 12 months ago

G(tk)Application support in gtk3reactor

Reported by: lucian Owned by: itamar
Priority: normal Milestone:
Component: core Keywords:
Cc: dobey Branch: branches/gtk-app-5492
Author: lucian Launchpad Bug:

Description

GLib has a GApplication class that handles things like application uniqueness and a few other things, and provides its own .run() method. GtkApplication inherits from it and also does Gtk-specific things.

After installing the gtk3reactor, if I call reactor.run() the UI does show up, but the GApplication's 'activate' event never fires. At glyph's suggestion I explicitly set the reactor's mainloop to that of the GApplication's and 'activate' fired as expected.

The reactor also doesn't stop when I close the window, even with the hack.

Attachments

play.py Download (0.5 KB) - added by lucian 15 months ago.
Example of hanging reactor.
play.2.py Download (0.7 KB) - added by lucian 15 months ago.
Example with Window and a twisted callback
tx_gapp.patch Download (1.6 KB) - added by lucian 15 months ago.
Patch to replicate the _run=app.run and installSignalHandlersFalse=False workarounds
tx_gapp2.patch Download (2.5 KB) - added by lucian 15 months ago.
Default back to installing signal handlers by default, at exarkun's suggestion. Add docs.
tx_gapp3.patch Download (4.6 KB) - added by lucian 15 months ago.
Remove a useless method, add tests.

Change History

1

Changed 15 months ago by itamar

  • cc dobey added

Could you provide a minimal example?

2

Changed 15 months ago by itamar

  • milestone set to Twisted-12.1

Changed 15 months ago by lucian

Example of hanging reactor.

3

Changed 15 months ago by lucian

Perhaps something like the reactor.registerWxApp would work?

 http://twistedmatrix.com/documents/current/core/howto/choosing-reactor.html#auto12

Changed 15 months ago by lucian

Example with Window and a twisted callback

4

Changed 15 months ago by lucian

The sedonc minimal example doesn't hang when I close the window. I believe it happened because of my usage of IRCClient in my app.

I was wrong, I should've written the minimal example before filing the ticket.

5

Changed 15 months ago by lucian

If I start the reactor with .run(installSignalHandlers=False), the app responds to SIGTERM and dies correctly, and also responds to SIGINT (incorrectly, because of a GTK/py-gi bug  https://bugzilla.gnome.org/show_bug.cgi?id=622084)

Changed 15 months ago by lucian

Patch to replicate the _run=app.run and installSignalHandlersFalse=False workarounds

Changed 15 months ago by lucian

Default back to installing signal handlers by default, at exarkun's suggestion. Add docs.

Changed 15 months ago by lucian

Remove a useless method, add tests.

6

Changed 15 months ago by lucian

  • keywords review added

7

Changed 14 months ago by itamar

If possible the tests should use #5547. If #5547 isn't ready and we want to release 12.1, we should at a minimum make sure we do the SIGCHLD cleanup stuff that ReactorBuilder does since these tests create a new reactor instance and run it.

8

Changed 14 months ago by itamarst

  • branch set to branches/gtk-app-5492
  • branch_author set to itamarst

(In [34040]) Branching to 'gtk-app-5492'

9

Changed 14 months ago by itamar

  • owner set to itamar
  • keywords review removed

I made some fixes in the branch, in particular matching coding standard a bit better, and moving the code to gireactor instead of _glibbase.

10

Changed 14 months ago by itamar

  • keywords review added
  • owner itamar deleted
  • branch_author changed from itamarst to lucian

OK, ready for final review assuming all tests are happy:

 http://buildbot.twistedmatrix.com/boxes-supported?branch=/branches/gtk-app-5492

11

Changed 12 months ago by therve

  • keywords review removed
  • owner set to itamar
  • I'm seeing test failures when using the gi and gtk3 reactor on the whole test suite. They got attached to random tests:
[ERROR]
Traceback (most recent call last):
  File "Twisted/trunk/twisted/internet/base.py", line 800, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "Twisted/trunk/twisted/internet/_glibbase.py", line 296, in stop
    posixbase.PosixReactorBase.stop(self)
  File "Twisted/trunk/twisted/internet/base.py", line 577, in stop
    "Can't stop reactor that isn't running.")
twisted.internet.error.ReactorNotRunning: Can't stop reactor that isn't running.

I think maybe overriding _run may not be enough?

  • choosing-reactor.xhtml has some tabs in it. It'd be nice to wrap lines to 80 chars too.

Do we have a gtk3 slave somewhere too?

12

Changed 12 months ago by itamar

  • milestone Twisted-12.1 deleted

So in theory I fixed it. But I can't test it since it's not possible to do this correctly on older versions of gobject introspection, AFAICT. Removing from 12.1 milestone, though, this isn't really necessary for basic gtk3 support; if we make it in then fine, but doesn't seem like it should be a blocker.

13

Changed 12 months ago by itamar

Next step: run tests on e.g. Ubuntu 12.04. I will upgrade my system from 11.10 real soon now, but feel free to run on your system and if it looks good it's mergeable in theory.

14

Changed 12 months ago by therve

Looks good, tests are passing for me now. I think we can merge it as it is. Maybe the last question I have is whether we should raise an error when registerGApplication is called after reactor.run or called a second time.

15

Changed 12 months ago by itamar

OK, I added those two things, will merge once buildbot is happy.

16

Changed 12 months ago by itamarst

  • status changed from new to closed
  • resolution set to fixed

(In [34391]) Merge gtk-app-5492: Add support for Gio.Application instance registration.

Fixes: #5492 Author: lucian, itamar Review: itamar, therve

Note: See TracTickets for help on using tickets.