Add Thomas' patch for better closing behaviour and an improved dialog for exiting Terminator. Fixes LP #161121
This commit is contained in:
commit
eb5070ccc4
75
terminator
75
terminator
|
@ -275,7 +275,7 @@ class TerminatorTerm:
|
||||||
elif keyname == 'V':
|
elif keyname == 'V':
|
||||||
self.term.splitaxis (self, True)
|
self.term.splitaxis (self, True)
|
||||||
return (True)
|
return (True)
|
||||||
elif keyname == 'Q':
|
elif keyname == 'W':
|
||||||
self.term.closeterm (self)
|
self.term.closeterm (self)
|
||||||
return (True)
|
return (True)
|
||||||
|
|
||||||
|
@ -405,20 +405,40 @@ class Terminator:
|
||||||
self.window.fullscreen ()
|
self.window.fullscreen ()
|
||||||
self._fullscreen = not self._fullscreen
|
self._fullscreen = not self._fullscreen
|
||||||
|
|
||||||
def on_delete_event (self, widget, event, data=None):
|
def on_delete_event (self, window, event, data=None):
|
||||||
if len (self.term_list) == 1:
|
if len (self.term_list) == 1:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
dialog = gtk.Dialog ("Quit?", self.window, gtk.DIALOG_MODAL, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_QUIT, gtk.RESPONSE_ACCEPT))
|
# show dialog
|
||||||
label = gtk.Label ("Do you really want to quit?")
|
dialog = gtk.Dialog ("Close?", window, gtk.DIALOG_MODAL,
|
||||||
dialog.vbox.pack_start (label, True, True, 0)
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT))
|
||||||
label.show ()
|
dialog.set_has_separator (False)
|
||||||
|
dialog.set_resizable (False)
|
||||||
|
|
||||||
res = dialog.run ()
|
primairy = gtk.Label ('<big><b>Close all terminals?</b></big>')
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
primairy.set_use_markup (True)
|
||||||
return False
|
primairy.set_alignment (0, 0.5)
|
||||||
|
secundairy = gtk.Label (("This window has %s terminals open. " % len(self.term_list)) +
|
||||||
|
"Closing the window will also close all terminals.")
|
||||||
|
secundairy.set_line_wrap(True)
|
||||||
|
primairy.set_alignment (0, 0.5)
|
||||||
|
|
||||||
|
labels = gtk.VBox ()
|
||||||
|
labels.pack_start (primairy, False, False, 6)
|
||||||
|
labels.pack_start (secundairy, False, False, 6)
|
||||||
|
|
||||||
|
image = gtk.image_new_from_stock(gtk.STOCK_DIALOG_WARNING, gtk.ICON_SIZE_DIALOG)
|
||||||
|
image.set_alignment (0.5, 0)
|
||||||
|
|
||||||
|
box = gtk.HBox()
|
||||||
|
box.pack_start (image, False, False, 6)
|
||||||
|
box.pack_start (labels, False, False, 6)
|
||||||
|
dialog.vbox.pack_start (box, False, False, 12)
|
||||||
|
|
||||||
|
dialog.show_all ()
|
||||||
|
result = dialog.run ()
|
||||||
dialog.destroy ()
|
dialog.destroy ()
|
||||||
return True
|
return not (result == gtk.RESPONSE_ACCEPT)
|
||||||
|
|
||||||
def on_destroy_event (self, widget, data=None):
|
def on_destroy_event (self, widget, data=None):
|
||||||
gtk.main_quit ()
|
gtk.main_quit ()
|
||||||
|
@ -435,6 +455,10 @@ class Terminator:
|
||||||
if keyname == 'F':
|
if keyname == 'F':
|
||||||
self.toggle_fullscreen ()
|
self.toggle_fullscreen ()
|
||||||
return (True)
|
return (True)
|
||||||
|
if keyname == 'Q':
|
||||||
|
if not self.on_delete_event (window, gtk.gdk.Event (gtk.gdk.DELETE)):
|
||||||
|
self.on_destroy_event (window, gtk.gdk.Event (gtk.gdk.DESTROY))
|
||||||
|
|
||||||
|
|
||||||
def splitaxis (self, widget, vert=True):
|
def splitaxis (self, widget, vert=True):
|
||||||
term2 = TerminatorTerm (self, self.profile)
|
term2 = TerminatorTerm (self, self.profile)
|
||||||
|
@ -524,31 +548,18 @@ class Terminator:
|
||||||
print "Error: %s is not a child of %s"%(widget, parent)
|
print "Error: %s is not a child of %s"%(widget, parent)
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.closetermreq ():
|
self.term_list.remove (widget)
|
||||||
self.term_list.remove (widget)
|
grandparent.remove (parent)
|
||||||
grandparent.remove (parent)
|
sibling.reparent (grandparent)
|
||||||
sibling.reparent (grandparent)
|
widget.get_box ().destroy ()
|
||||||
widget.get_box ().destroy ()
|
parent.destroy ()
|
||||||
parent.destroy ()
|
|
||||||
|
|
||||||
for term in self.term_list:
|
for term in self.term_list:
|
||||||
if term.get_box () == sibling:
|
if term.get_box () == sibling:
|
||||||
term._vte.grab_focus ()
|
term._vte.grab_focus ()
|
||||||
break
|
break
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def closetermreq (self):
|
|
||||||
dialog = gtk.Dialog ("Close?", self.window, gtk.DIALOG_MODAL, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT))
|
|
||||||
label = gtk.Label ("Do you really want to close this terminal?")
|
|
||||||
dialog.vbox.pack_start (label, True, True, 0)
|
|
||||||
label.show ()
|
|
||||||
|
|
||||||
res = dialog.run ()
|
|
||||||
dialog.destroy ()
|
|
||||||
if res == gtk.RESPONSE_ACCEPT:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def go_next (self, term):
|
def go_next (self, term):
|
||||||
current = self.term_list.index (term)
|
current = self.term_list.index (term)
|
||||||
|
|
Loading…
Reference in New Issue