Port geometry hinting from trunk to epic-refactor. HEY THEO.

This commit is contained in:
Chris Jones 2010-01-20 23:36:11 +00:00
parent 021f5cef98
commit a10babeb5d
2 changed files with 43 additions and 4 deletions

View File

@ -859,6 +859,9 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def on_vte_size_allocate(self, widget, allocation): def on_vte_size_allocate(self, widget, allocation):
self.titlebar.update_terminal_size(self.vte.get_column_count(), self.titlebar.update_terminal_size(self.vte.get_column_count(),
self.vte.get_row_count()) self.vte.get_row_count())
if self.vte.window and self.config['geometry_hinting']:
window = util.get_top_window(self)
window.set_rough_geometry_hints()
def on_vte_notify_enter(self, term, event): def on_vte_notify_enter(self, term, event):
"""Handle the mouse entering this terminal""" """Handle the mouse entering this terminal"""
@ -1084,6 +1087,14 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
height = self.vte.get_char_height() height = self.vte.get_char_height()
return((col * width, row * height)) return((col * width, row * height))
def get_font_size(self):
"""Return the width/height of our font"""
return((self.vte.get_char_width(), self.vte.get_char_height()))
def get_size(self):
"""Return the column/rows of the terminal"""
return((self.vte.get_column_count(), self.vte.get_row_count()))
# There now begins a great list of keyboard event handlers # There now begins a great list of keyboard event handlers
# FIXME: Probably a bunch of these are wrong. TEST! # FIXME: Probably a bunch of these are wrong. TEST!
def key_zoom_in(self): def key_zoom_in(self):

View File

@ -333,16 +333,44 @@ class Window(Container, gtk.Window):
if maker.isinstance(child, 'Container'): if maker.isinstance(child, 'Container'):
terminals.update(child.get_visible_terminals()) terminals.update(child.get_visible_terminals())
elif maker.isnstance(child, 'Terminal'): elif maker.isinstance(child, 'Terminal'):
# This branch is only possible if we started out as a Notebook. We
# wouldn't have been called if there was really only one Terminal
# child.
terminals[child] = child.get_allocation() terminals[child] = child.get_allocation()
else: else:
err('Unknown child type %s' % type(child)) err('Unknown child type %s' % type(child))
return(terminals) return(terminals)
def set_rough_geometry_hints(self):
"""Walk all the terminals along the top and left edges to fake up how
many columns/rows we sort of have"""
terminals = self.get_visible_terminals()
column_sum = 0
row_sum = 0
for terminal in terminals:
rect = terminal.get_allocation()
if rect.x == 0:
cols, rows = terminal.get_size()
row_sum = row_sum + rows
if rect.y == 0:
cols, rows = terminal.get_size()
column_sum = column_sum + cols
# FIXME: I don't think we should just use whatever font size info is on
# the last terminal we inspected. Looking up the default profile font
# size and calculating its character sizes would be rather expensive
# though.
font_width, font_height = terminal.get_font_size()
total_font_width = font_width * column_sum
total_font_height = font_height * row_sum
win_width, win_height = self.get_size()
extra_width = win_width - total_font_width
extra_height = win_height - total_font_height
self.set_geometry_hints(self, -1, -1, -1, -1, extra_width,
extra_height, font_width, font_height, -1.0, -1.0)
class WindowTitle(object): class WindowTitle(object):
"""Class to handle the setting of the window title""" """Class to handle the setting of the window title"""