Trapping the Pharo window close event

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
kmo
Reply | Threaded
Open this post in threaded view
|

Trapping the Pharo window close event

kmo
How do you get rid of that "Quit Pharo without saving message" that comes up when you try to close the Pharo window? I want to just let the user exit without any message or perhaps replace the message with one of my own.

Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Peter Uhnak
The closing is intercepted in

PasteUpMorph>>windowEvent:

from where this is called
WorldState>>quitSession
| save |
save := self confirm: 'Save changes before quitting?' translated orCancel: [ ^ self ].
save 
ifTrue: [Smalltalk snapshot: true andQuit: true] 
ifFalse: [Smalltalk snapshot: false andQuit: true]

So you can change the method for example to

WorldState>>quitSession
Smalltalk snapshot: true andQuit: true

(or snapshot: false if you don't want to save)

Or you can close it by clicking on world menu and selecting "Save and quit".

Peter


On Thu, Apr 14, 2016 at 7:57 PM, kmo <[hidden email]> wrote:
How do you get rid of that "Quit Pharo without saving message" that comes up
when you try to close the Pharo window? I want to just let the user exit
without any message or perhaps replace the message with one of my own.





--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


kmo
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kmo
Many thanks for that helpful and amazingly fast answer!
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

stepharo
In reply to this post by Peter Uhnak
I did not really get it. Now I have the impression that changing the method definition shows that Pharo does not
offer the correct possibility.
Am I correct?

Stef

Le 14/4/16 20:58, Peter Uhnák a écrit :
The closing is intercepted in

PasteUpMorph>>windowEvent:

from where this is called
WorldState>>quitSession
| save |
save := self confirm: 'Save changes before quitting?' translated orCancel: [ ^ self ].
save 
ifTrue: [Smalltalk snapshot: true andQuit: true] 
ifFalse: [Smalltalk snapshot: false andQuit: true]

So you can change the method for example to

WorldState>>quitSession
Smalltalk snapshot: true andQuit: true

(or snapshot: false if you don't want to save)

Or you can close it by clicking on world menu and selecting "Save and quit".

Peter


On Thu, Apr 14, 2016 at 7:57 PM, kmo <[hidden email]> wrote:
How do you get rid of that "Quit Pharo without saving message" that comes up
when you try to close the Pharo window? I want to just let the user exit
without any message or perhaps replace the message with one of my own.





--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.



Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Peter Uhnak
I did not really get it. Now I have the impression that changing the method definition shows that Pharo does not
offer the correct possibility.
Am I correct?

I disagree. Closing the window should not decide on it's own whether the session should be saved. Asking the user is the right thing.

The ideal thing would be to not ask if nothing has happened... but that's impossible, this is a live system, not a text editor.

Peter
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Esteban A. Maringolo
Maybe he refers to the option to abort the close request programmatically in an event based approach.

Something like that UI close event is handled and triggers a "QuitSmalltalkRequested" event (or announcement) with a boolean value holder as argument, if no one handling such event/announcement vetoed the request, then it continues to normal shutdown.

Dolphin Smalltalk uses that approach, see SessionManager >> queryEndSession at [1]

Regards,

Esteban A. Maringolo

2016-04-15 18:06 GMT-03:00 Peter Uhnák <[hidden email]>:
I did not really get it. Now I have the impression that changing the method definition shows that Pharo does not
offer the correct possibility.
Am I correct?

I disagree. Closing the window should not decide on it's own whether the session should be saved. Asking the user is the right thing.

The ideal thing would be to not ask if nothing has happened... but that's impossible, this is a live system, not a text editor.

Peter

kmo
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kmo
As a developer you need to be able to control the program shut down. That is a given.

I think I was expecting something like the Dolphin approach but it doesn't exist in pharo. Having to overwrite an existing method is not elegant but it works.

A similar issue exists with Growl notifications - I have a post on this as well.
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Peter Uhnak
What's Doplin's approach?

Also adding a configuration option for this situation is rather trivial.

On Sat, Apr 16, 2016 at 9:42 AM, kmo <[hidden email]> wrote:
As a developer you need to be able to control the program shut down. That is
a given.

I think I was expecting something like the Dolphin approach but it doesn't
exist in pharo. Having to overwrite an existing method is not elegant but it
works.

A similar issue exists with Growl notifications - I have a post on this as
well.



--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890279.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


kmo
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kmo
The Dolphin approach was described by Estaban earlier in this thread. I've never used Dolphin myself so cannot expand on it.
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Peter Uhnak
Ah, right, that certainly sounds interesting. :)

Pharo is yours, so you can add it. :)
We already have a SystemAnnouncer so maybe it would be quite easy to add… it might be a nice exercise to get a bit more familiar with the system.

Peter

On Sat, Apr 16, 2016 at 11:01 AM, kmo <[hidden email]> wrote:
The Dolphin approach was described by Estaban earlier in this thread. I've
never used Dolphin myself so cannot expand on it.



--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890281.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


kmo
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kmo

Pharo is yours, so you can add it. :)

Yes, but I don't want to add it. I expect it to be there out of the box. I think it's quite enough work for me to add my own code on window close. I don't want to have to write the framework for doing it as well.
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Damien Pollet-2
On 16 April 2016 at 11:33, kmo <[hidden email]> wrote:
/Pharo is yours, so you can add it. :)/

Yes, but I don't want to add it. I expect it to be there out of the box.

If you expect a perfect system out of the box, you will never get it.
 
think it's quite enough work for me to add my own code on window close. I
don't want to have to write the framework for doing it as well.

Point is, it's not by design if the feature you're asking for is absent out of the box; nobody in Pharo decided you should HAVE to implement it yourself. I think everyone agrees that the platform should provide that feature, however everyone is focused on different issues, and you seem to be the first one for whom it's an itch worth scratching. It's open-source, so the system is yours too and it's the responsibility of everyone to improve it.

If you really need the feature but don't want to implement it yourself, you could sponsor someone via the Pharo association or the consortium.
kmo
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kmo
Well, my reply was rather tongue-in-cheek. I was mocking my own laziness and the laziness of developers like me. But really I have no problem in doing these things for myself. And I hope that soon I will be in a position to contribute to pharo myself.

But overriding the close event is something any application developer is going to want to do. And every time you make a developer work harder than necessary to implement a basic feature you make the pharo platform less attractive. If you want more developers to use pharo you have to make basic things like this easy to do and easy to find out how to do.

I do think that deployment of applications gets very little attention in pharo - yet it's a major issue of you want to make pharo a widely-used application platform.

I'm not the only lazy developer, you know .
Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

John Pfersich
In reply to this post by Damien Pollet-2


On Apr 16, 2016, at 03:30, Damien Pollet <[hidden email]> wrote:

On 16 April 2016 at 11:33, kmo <[hidden email]> wrote:
/Pharo is yours, so you can add it. :)/

Yes, but I don't want to add it. I expect it to be there out of the box.

If you expect a perfect system out of the box, you will never get it.
 
think it's quite enough work for me to add my own code on window close. I
don't want to have to write the framework for doing it as well.

Point is, it's not by design if the feature you're asking for is absent out of the box; nobody in Pharo decided you should HAVE to implement it yourself. I think everyone agrees that the platform should provide that feature, however everyone is focused on different issues, and you seem to be the first one for whom it's an itch worth scratching. It's open-source, so the system is yours too and it's the responsibility of everyone to improve it.

If you really need the feature but don't want to implement it yourself, you could sponsor someone via the Pharo association or the consortium.

Or Bountysource or Bountysource Salt (https://salt.bountysource.com/teams/pharo).

Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

Nicolai Hess-3-2
In reply to this post by kmo


2016-04-14 19:57 GMT+02:00 kmo <[hidden email]>:
How do you get rid of that "Quit Pharo without saving message" that comes up
when you try to close the Pharo window? I want to just let the user exit
without any message or perhaps replace the message with one of my own.



Aboiut what are we talking ?
The "Quit Pharo without saving message" is something I only see on
the Windows platform.
And for getting rid of this message, you can set
EnableAltF4Quit=0
in Pharo.ini

The Other message that exists is
"Save changes before quitting"
when selecting the "Quit" menu in Pharos world menu.


 



--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

stepharo
In reply to this post by Peter Uhnak
My point is that it is a proof that a library is not good when it forces users to redefined core code.

Stef


Le 15/4/16 23:06, Peter Uhnák a écrit :
I did not really get it. Now I have the impression that changing the method definition shows that Pharo does not
offer the correct possibility.
Am I correct?

I disagree. Closing the window should not decide on it's own whether the session should be saved. Asking the user is the right thing.

The ideal thing would be to not ask if nothing has happened... but that's impossible, this is a live system, not a text editor.

Peter

Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

stepharo
In reply to this post by kmo


Le 16/4/16 11:33, kmo a écrit :
> /Pharo is yours, so you can add it. :)/
>
> Yes, but I don't want to add it. I expect it to be there out of the box.

So you believe either is modern slavery or magic auto generation :D
Seriously if you that need it are not ready to invest 30 min why me that
does not need it should do it?
Do you know what is free open-source software?

> I think it's quite enough work for me to add my own code on window close. I
> don't want to have to write the framework for doing it as well.
>
>
>
> --
> View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890283.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

stepharo
In reply to this post by kmo


Le 16/4/16 12:18, kmo a écrit :
> Well, my reply was rather tongue-in-cheek. I was mocking my own laziness and
> the laziness of developers like me. But really I have no problem in doing
> these things for myself. And I hope that soon I will be in a position to
> contribute to pharo myself.

But you are :)
30 min a week is enough :)
>
> But overriding the close event is something any application developer is
> going to want to do. And every time you make a developer work harder than
> necessary to implement a basic feature you make the pharo platform less
> attractive. If you want more developers to use pharo you have to make basic
> things like this easy to do and easy to find out how to do.
We know that.
Now I will not give the HUGE list of the things we are working on and
that default
developers are in need:
     - good file library
     - good list widget
     - FFI
     - decent texteditor
     - a compiler :)
     - ...

>
> I do think that deployment of applications gets very little attention in
> pharo - yet it's a major issue of you want to make pharo a widely-used
> application platform.
Indeed. We started to push that when damien worked on the launcher and
we should continue.


>
> I'm not the only lazy developer, you know .
>
>
>
> --
> View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890285.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kilon.alios
In reply to this post by kmo
Just for the record I am in agreement as I think most of us are about this.

But....

I think as a community must make one thing clear

Pharo is environment meant to be hacked. Its not always to do so but similarly to Squeak, the goal here is to give developers and environment that they can design and modify themselves with ease. At least a lot more than other languages and this is where Pharo really excels.

In the end Pharo does not tries to be the most popular thing out there, it tries to fill a gap that others dont or cant. Sure we want to make Pharo popular but making something that is a ready made solution is not our top priority.  Making something modifiable and direct so much more.

I think its our responsibility to make this clear to newcomers.

Or else people will wonder, why not use python, ruby or whatelse which comes with sophisticated IDEs far more lazy friendly than Pharo.

Pharo is definetly  , by nature, lazy coder friendly. Its for coders that like to design their own workflow.

On Sat, Apr 16, 2016 at 1:51 PM kmo <[hidden email]> wrote:
Well, my reply was rather tongue-in-cheek. I was mocking my own laziness and
the laziness of developers like me. But really I have no problem in doing
these things for myself. And I hope that soon I will be in a position to
contribute to pharo myself.

But overriding the close event is something any application developer is
going to want to do. And every time you make a developer work harder than
necessary to implement a basic feature you make the pharo platform less
attractive. If you want more developers to use pharo you have to make basic
things like this easy to do and easy to find out how to do.

I do think that deployment of applications gets very little attention in
pharo - yet it's a major issue of you want to make pharo a widely-used
application platform.

I'm not the only lazy developer, you know .



--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890285.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: Trapping the Pharo window close event

kilon.alios
sorry meant to say Pharo is not lazy coder friendly by nature.

On Fri, Apr 22, 2016 at 10:03 AM Dimitris Chloupis <[hidden email]> wrote:
Just for the record I am in agreement as I think most of us are about this.

But....

I think as a community must make one thing clear

Pharo is environment meant to be hacked. Its not always to do so but similarly to Squeak, the goal here is to give developers and environment that they can design and modify themselves with ease. At least a lot more than other languages and this is where Pharo really excels.

In the end Pharo does not tries to be the most popular thing out there, it tries to fill a gap that others dont or cant. Sure we want to make Pharo popular but making something that is a ready made solution is not our top priority.  Making something modifiable and direct so much more.

I think its our responsibility to make this clear to newcomers.

Or else people will wonder, why not use python, ruby or whatelse which comes with sophisticated IDEs far more lazy friendly than Pharo.

Pharo is definetly  , by nature, lazy coder friendly. Its for coders that like to design their own workflow.

On Sat, Apr 16, 2016 at 1:51 PM kmo <[hidden email]> wrote:
Well, my reply was rather tongue-in-cheek. I was mocking my own laziness and
the laziness of developers like me. But really I have no problem in doing
these things for myself. And I hope that soon I will be in a position to
contribute to pharo myself.

But overriding the close event is something any application developer is
going to want to do. And every time you make a developer work harder than
necessary to implement a basic feature you make the pharo platform less
attractive. If you want more developers to use pharo you have to make basic
things like this easy to do and easy to find out how to do.

I do think that deployment of applications gets very little attention in
pharo - yet it's a major issue of you want to make pharo a widely-used
application platform.

I'm not the only lazy developer, you know .



--
View this message in context: http://forum.world.st/Trapping-the-Pharo-window-close-event-tp4890079p4890285.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.