Implement geometry hinting for useful resizing
This commit is contained in:
parent
d2ccdafaba
commit
6103d83829
|
@ -328,6 +328,47 @@ class Terminator:
|
||||||
if hidden or self.conf.hidden:
|
if hidden or self.conf.hidden:
|
||||||
self.window.iconify()
|
self.window.iconify()
|
||||||
|
|
||||||
|
def on_term_resized(self):
|
||||||
|
win_total_width, win_total_height = self.window.get_size ()
|
||||||
|
dbg ('Resized window is %dx%d' % (win_total_width, win_total_height))
|
||||||
|
|
||||||
|
# FIXME: find first terminal
|
||||||
|
firstidx = 0
|
||||||
|
|
||||||
|
# Walk terminals across top edge to sum column geometries
|
||||||
|
prev = -1
|
||||||
|
column_sum = 0
|
||||||
|
width_extra = 0
|
||||||
|
walker = firstidx
|
||||||
|
while (walker != None):
|
||||||
|
term = self.term_list[walker]
|
||||||
|
font_width, font_height, columns, rows = term.get_size_details ()
|
||||||
|
column_sum += columns
|
||||||
|
dbg ('Geometry hints (term %d) column += %d characters' % (walker, columns))
|
||||||
|
prev = walker
|
||||||
|
walker = self._select_right (walker)
|
||||||
|
|
||||||
|
# Walk terminals down left edge to sum row geometries
|
||||||
|
prev = -1
|
||||||
|
row_sum = 0
|
||||||
|
height_extra = 0
|
||||||
|
walker = firstidx
|
||||||
|
while (walker != None):
|
||||||
|
term = self.term_list[walker]
|
||||||
|
font_width, font_height, columns, rows = term.get_size_details ()
|
||||||
|
row_sum += rows
|
||||||
|
dbg ('Geometry hints (term %d) row += %d characters' % (walker, rows))
|
||||||
|
prev = walker
|
||||||
|
walker = self._select_down (walker)
|
||||||
|
|
||||||
|
# adjust...
|
||||||
|
width_extra = win_total_width - (column_sum * font_width)
|
||||||
|
height_extra = win_total_height - (row_sum * font_height)
|
||||||
|
|
||||||
|
dbg ('Geometry hints based on font size: %dx%d, columns: %d, rows: %d, extra width: %d, extra height: %d' % (font_width, font_height, column_sum, row_sum, width_extra, height_extra))
|
||||||
|
|
||||||
|
self.window.set_geometry_hints(self.window, -1, -1, -1, -1, width_extra, height_extra, font_width, font_height, -1.0, -1.0)
|
||||||
|
|
||||||
def set_handle_size (self, size):
|
def set_handle_size (self, size):
|
||||||
if size in xrange (0,6):
|
if size in xrange (0,6):
|
||||||
gtk.rc_parse_string("""
|
gtk.rc_parse_string("""
|
||||||
|
@ -947,6 +988,12 @@ class Terminator:
|
||||||
term._vte.grab_focus ()
|
term._vte.grab_focus ()
|
||||||
|
|
||||||
def _select_direction (self, term, matcher):
|
def _select_direction (self, term, matcher):
|
||||||
|
'''Return index of terminal in given direction'''
|
||||||
|
# Handle either TerminatorTerm or int index
|
||||||
|
if type(term) == int:
|
||||||
|
current = term
|
||||||
|
term = self.term_list[current]
|
||||||
|
else:
|
||||||
current = self.term_list.index (term)
|
current = self.term_list.index (term)
|
||||||
current_geo = term.get_geometry ()
|
current_geo = term.get_geometry ()
|
||||||
best_index = None
|
best_index = None
|
||||||
|
|
|
@ -406,7 +406,10 @@ class TerminatorTerm (gtk.VBox):
|
||||||
dbg ('Resize window triggered on %s: %dx%d' % (widget, width, height))
|
dbg ('Resize window triggered on %s: %dx%d' % (widget, width, height))
|
||||||
|
|
||||||
def on_vte_size_allocate(self, widget, allocation):
|
def on_vte_size_allocate(self, widget, allocation):
|
||||||
|
dbg ('Terminal resized to %dx%d' % (self._vte.get_column_count (), self._vte.get_row_count ()))
|
||||||
self._titlebox.set_terminal_size (self._vte.get_column_count (), self._vte.get_row_count ())
|
self._titlebox.set_terminal_size (self._vte.get_column_count (), self._vte.get_row_count ())
|
||||||
|
if self._vte.window != None:
|
||||||
|
self.terminator.on_term_resized ()
|
||||||
|
|
||||||
def get_pixbuf(self, maxsize= None):
|
def get_pixbuf(self, maxsize= None):
|
||||||
pixmap = self.get_snapshot()
|
pixmap = self.get_snapshot()
|
||||||
|
@ -897,6 +900,14 @@ text/plain
|
||||||
self._titlebox.update ()
|
self._titlebox.update ()
|
||||||
self._vte.queue_draw ()
|
self._vte.queue_draw ()
|
||||||
|
|
||||||
|
def get_size_details(self):
|
||||||
|
font_width = self._vte.get_char_width ()
|
||||||
|
font_height = self._vte.get_char_height ()
|
||||||
|
columns = self._vte.get_column_count ()
|
||||||
|
rows = self._vte.get_row_count ()
|
||||||
|
|
||||||
|
return (font_width, font_height, columns, rows)
|
||||||
|
|
||||||
def on_composited_changed (self, widget):
|
def on_composited_changed (self, widget):
|
||||||
self.reconfigure_vte ()
|
self.reconfigure_vte ()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue