Modal Primary Editor Windows

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Modal Primary Editor Windows

Steve Youngs
Hi
Is there an easy way to re-use the standard primary editor windows
modally? e.g. EditPerson, EditEvent.
To compound the problem I want to do this from an existing modal dialog.

The best I've come up with so far is:

     # some function in the modal dialog class
     def _func(self):
       # create editor window
       editor = EditPerson(dbstate, uistate, track, person)

       # make it modal and wait for it to be destroyed
       editor.window.set_modal(True)
       editor.window.connect('destroy', Gtk.main_quit)
       Gtk.main()

       # follow on operations that use person
       # may include other EditPerson, EditEvent, ... windows

It seems to work, but it just feels wrong.

I had considered using the EditPerson callback and performing the follow
on operations inside the callback. I'm concerned about the user
experience if several EditX windows appear on the screen simultaneously.

Thanks
Steve


_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Modal Primary Editor Windows

prculley
Your method might work to set the Editor window modal.  However be aware that having multiple modal windows active at one time will confuse Gtk and has created problems in the past.  The problems may even vary with the version of Gtk.

If your original tool class inherits from ManagedWindow and you use its modal=True parameter you should not have to do anything special to have the Editor windows modal; the ManagedWindow code handles this for you (see gramps/gui/managedwindow.py).  And the class handles the multiple modal thing for you by temporarily making the parent non-modal while the Editor child is active.

Paul C.

On Fri, Jan 3, 2020 at 4:41 PM Steve Youngs <[hidden email]> wrote:
Hi
Is there an easy way to re-use the standard primary editor windows
modally? e.g. EditPerson, EditEvent.
To compound the problem I want to do this from an existing modal dialog.

The best I've come up with so far is:

     # some function in the modal dialog class
     def _func(self):
       # create editor window
       editor = EditPerson(dbstate, uistate, track, person)

       # make it modal and wait for it to be destroyed
       editor.window.set_modal(True)
       editor.window.connect('destroy', Gtk.main_quit)
       Gtk.main()

       # follow on operations that use person
       # may include other EditPerson, EditEvent, ... windows

It seems to work, but it just feels wrong.

I had considered using the EditPerson callback and performing the follow
on operations inside the callback. I'm concerned about the user
experience if several EditX windows appear on the screen simultaneously.

Thanks
Steve


_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel


_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel
Reply | Threaded
Open this post in threaded view
|

Re: Modal Primary Editor Windows

Steve Youngs

Hi Paul,

Thanks for that information. I had not spotted that the Editor window would be modal if the parent (ManagedWindow) window was modal.

I just managed to achieve what I wanted using callbacks - chaining them together to run multiple Editor windows, sequentially. This has the advantage of keeping the Editor windows modeless, allowing you can interact with the remainder of gramps, and the disadvantage of making the code more complex.

Steve

On 04/01/2020 15:49, Paul Culley wrote:
Your method might work to set the Editor window modal.  However be aware that having multiple modal windows active at one time will confuse Gtk and has created problems in the past.  The problems may even vary with the version of Gtk.

If your original tool class inherits from ManagedWindow and you use its modal=True parameter you should not have to do anything special to have the Editor windows modal; the ManagedWindow code handles this for you (see gramps/gui/managedwindow.py).  And the class handles the multiple modal thing for you by temporarily making the parent non-modal while the Editor child is active.

Paul C.

On Fri, Jan 3, 2020 at 4:41 PM Steve Youngs [hidden email] wrote:
Hi
Is there an easy way to re-use the standard primary editor windows
modally? e.g. EditPerson, EditEvent.
To compound the problem I want to do this from an existing modal dialog.

The best I've come up with so far is:

     # some function in the modal dialog class
     def _func(self):
       # create editor window
       editor = EditPerson(dbstate, uistate, track, person)

       # make it modal and wait for it to be destroyed
       editor.window.set_modal(True)
       editor.window.connect('destroy', Gtk.main_quit)
       Gtk.main()

       # follow on operations that use person
       # may include other EditPerson, EditEvent, ... windows

It seems to work, but it just feels wrong.

I had considered using the EditPerson callback and performing the follow
on operations inside the callback. I'm concerned about the user
experience if several EditX windows appear on the screen simultaneously.

Thanks
Steve


_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel


_______________________________________________
Gramps-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gramps-devel