merge in full-window-term branch for terminal zooming feature. Fixes LP #229201

This commit is contained in:
Chris Jones 2008-05-30 13:26:35 +01:00
commit 0de2ba1561
3 changed files with 94 additions and 18 deletions

View File

@ -18,6 +18,8 @@ terminator 0.9:
* Drag & Drop support
* Many bug fixes and wider compatibility with GNOME Terminal
* Alpha transparency support when running in a composited window manager
* Support terminal zooming - now you can quickly hide all terminals apart
from one
terminator 0.8.1:
* Fixed ChangeLog

View File

@ -77,6 +77,9 @@ Move to \fBp\fRrevious terminal.
.B Ctrl+Shift+W
Close the current terminal.
.TP
.B Ctrl+Shift+Z
Toggle between showing all terminals and only showing the current one.
.TP
.B Ctrl+Shift+Q
Close the current window.
.TP

View File

@ -623,6 +623,9 @@ text/plain
elif keyname == 'Page_Up':
self.terminator.move_tab(self, 'left')
return (True)
elif keyname == 'Z':
self.terminator.toggle_zoom (self)
return (True)
mask = gtk.gdk.CONTROL_MASK
if (event.state & mask) == mask:
@ -723,25 +726,38 @@ text/plain
item = gtk.MenuItem ()
menu.append (item)
item = gtk.MenuItem (_("Split H_orizontally"))
item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, False))
menu.append (item)
item = gtk.MenuItem (_("Split V_ertically"))
item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, True))
menu.append (item)
item = gtk.MenuItem (_("Open _Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self))
menu.append (item)
if self.conf.extreme_tabs:
item = gtk.MenuItem (_("Open Top Level Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self, True))
if not self.terminator._zoomed:
item = gtk.MenuItem (_("Split H_orizontally"))
item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, False))
menu.append (item)
item = gtk.MenuItem (_("Split V_ertically"))
item.connect ("activate", lambda menu_item: self.terminator.splitaxis (self, True))
menu.append (item)
item = gtk.MenuItem (_("Open _Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self))
menu.append (item)
if self.conf.extreme_tabs:
item = gtk.MenuItem (_("Open Top Level Tab"))
item.connect ("activate", lambda menu_item: self.terminator.newtab (self, True))
menu.append (item)
item = gtk.MenuItem ()
menu.append (item)
item = gtk.MenuItem ()
menu.append (item)
if len (self.terminator.term_list) > 1:
if not self.terminator._zoomed:
item = gtk.MenuItem (_("_Zoom terminal"))
item.connect ("activate", lambda menu_item: self.terminator.toggle_zoom (self))
else:
item = gtk.MenuItem (_("_Unzoom terminal"))
item.connect ("activate", lambda menu_item: self.terminator.toggle_zoom (self))
menu.append (item)
item = gtk.MenuItem ()
menu.append (item)
item = gtk.ImageMenuItem (gtk.STOCK_CLOSE)
item.connect ("activate", lambda menu_item: self.terminator.closeterm (self))
@ -843,6 +859,7 @@ class Terminator:
self.profile = profile
self.command = command
self._zoomed = False
self._fullscreen = False
self.term_list = []
stores = []
@ -1155,6 +1172,11 @@ class Terminator:
return None
def newtab(self,widget, toplevel = False):
if self._zoomed:
# We don't want to add a new tab while we are zoomed in on a terminal
dbg ("newtab function called, but Terminator was in zoomed terminal mode.")
return
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd())
#only one term, we don't show the title
terminal._titlebox.hide()
@ -1235,6 +1257,11 @@ class Terminator:
def splitaxis (self, widget, vertical=True):
""" Split the provided widget on the horizontal or vertical axis. """
if self._zoomed:
# We don't want to split the terminal while we are in zoomed mode
dbg ("splitaxis function called, but Terminator was in zoomed mode.")
return
# create a new terminal and parent pane.
terminal = TerminatorTerm (self, self.profile, None, widget.get_cwd())
pos = vertical and "bottom" or "right"
@ -1288,7 +1315,8 @@ class Terminator:
else:
grandparent.remove (parent)
sibling.reparent (grandparent)
grandparent.resize_children()
if not self._zoomed:
grandparent.resize_children()
parent.destroy ()
if isinstance(sibling, TerminatorTerm) and isinstance(sibling.get_parent(), gtk.Notebook):
sibling._titlebox.hide()
@ -1334,6 +1362,11 @@ class Terminator:
return True
def closeterm (self, widget):
if self._zoomed:
# We are zoomed, pop back out to normal layout before closing
dbg ("closeterm function called while in zoomed mode. Restoring previous layout before closing.")
self.unzoom_term (widget)
if self.remove(widget):
widget.destroy ()
return True
@ -1480,6 +1513,44 @@ class Terminator:
for term in self.term_list:
term.reconfigure_vte ()
def toggle_zoom(self, widget):
if not self._zoomed:
self.zoom_term (widget)
else:
self.unzoom_term (widget)
def zoom_term (self, widget):
"""Proof of concept: Maximize to full window
an instance of TerminatorTerm.
"""
self.old_parent = widget.get_parent()
if isinstance(self.old_parent, gtk.Window):
return
if isinstance(self.old_parent, gtk.Notebook):
self.old_page = self.old_parent.get_current_page()
self.window_child = self.window.get_children()[0]
self.window.remove(self.window_child)
self.old_parent.remove(widget)
self.window.add(widget)
self._zoomed = True
def unzoom_term (self, widget):
"""Proof of concept: Go back to previous application
widget structure.
"""
if self._zoomed:
self.window.remove(widget)
self.window.add(self.window_child)
self.old_parent.add(widget)
if isinstance(self.old_parent, gtk.Notebook):
self.old_parent.set_current_page(self.old_page)
print "\nPARENT IS A NOTEBOOK\n"
self._zoomed = False
return
else:
return
if __name__ == '__main__':
def execute_cb (option, opt, value, parser):
assert value is None