Merge Christoph Holtermann's 'PR-dont-close-gnucash-on-pycons-close' into maint.

This commit is contained in:
John Ralls
2019-04-20 12:47:12 -07:00
2 changed files with 12 additions and 5 deletions

View File

@@ -75,6 +75,10 @@ class Console (cons.Console):
""" Button press event """
return self.refresh()
def quit_event (self, widget, event):
""" Event handler for closing of console window """
return self.quit()
def refresh (self):
""" Refresh drawing """
for fig in self.figures:
@@ -82,6 +86,12 @@ class Console (cons.Console):
canvas.draw()
return False
def quit (self):
""" quit """
self.write("\nHave a nice day !\n")
return super(Console, self).quit()
# Change this to "if True:" to switch on a python console at gnucash
# startup:
@@ -92,10 +102,8 @@ if False:
window.set_position(Gtk.WindowPosition.CENTER)
window.set_default_size(800,600)
window.set_border_width(0)
# Hm. Gtk.main_quit will kill gnucash without closing the file
# properly. That's kinda bad.
window.connect('destroy-event', Gtk.main_quit)
window.connect('delete-event', Gtk.main_quit)
window.connect('destroy-event', console.quit_event)
window.connect('delete-event', console.quit_event)
window.add (console)
window.show_all()
console.grab_focus()

View File

@@ -434,7 +434,6 @@ class Console (Gtk.ScrolledWindow):
def quit(self):
""" Quit console """
Gtk.main_quit()
self.history_save()
try:
os.close (self.piperead)