Replace the get_top_window with the much quicker builtin get_toplevel widget call

This commit is contained in:
Stephen Boddy 2011-02-23 22:35:10 +01:00
parent b3bee59c9d
commit 05520fd5a7
4 changed files with 9 additions and 17 deletions

View File

@ -12,7 +12,7 @@ from factory import Factory
from container import Container from container import Container
from editablelabel import EditableLabel from editablelabel import EditableLabel
from translation import _ from translation import _
from util import err, dbg, get_top_window, enumerate_descendants from util import err, dbg, enumerate_descendants
class Notebook(Container, gtk.Notebook): class Notebook(Container, gtk.Notebook):
"""Class implementing a gtk.Notebook container""" """Class implementing a gtk.Notebook container"""
@ -173,7 +173,7 @@ class Notebook(Container, gtk.Notebook):
def newtab(self, debugtab=False, widget=None, cwd=None): def newtab(self, debugtab=False, widget=None, cwd=None):
"""Add a new tab, optionally supplying a child widget""" """Add a new tab, optionally supplying a child widget"""
maker = Factory() maker = Factory()
top_window = get_top_window(self) top_window = self.get_toplevel()
if not widget: if not widget:
widget = maker.make('Terminal') widget = maker.make('Terminal')

View File

@ -7,7 +7,7 @@ variants"""
import gobject import gobject
import gtk import gtk
from util import dbg, err, get_top_window from util import dbg, err
from terminator import Terminator from terminator import Terminator
from factory import Factory from factory import Factory
from container import Container from container import Container
@ -86,7 +86,7 @@ class Paned(Container):
raise ValueError('Paned widgets can only have two children') raise ValueError('Paned widgets can only have two children')
if maker.isinstance(widget, 'Terminal'): if maker.isinstance(widget, 'Terminal'):
top_window = get_top_window(self) top_window = self.get_toplevel()
signals = {'close-term': self.wrapcloseterm, signals = {'close-term': self.wrapcloseterm,
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,
'split-vert': self.split_vert, 'split-vert': self.split_vert,

View File

@ -15,7 +15,7 @@ import pango
import subprocess import subprocess
import urllib import urllib
from util import dbg, err, gerr, get_top_window from util import dbg, err, gerr
import util import util
from config import Config from config import Config
from cwd import get_default_cwd from cwd import get_default_cwd
@ -960,7 +960,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def ensure_visible_and_focussed(self): def ensure_visible_and_focussed(self):
"""Make sure that we're visible and focussed""" """Make sure that we're visible and focussed"""
window = util.get_top_window(self) window = self.get_toplevel()
topchild = window.get_child() topchild = window.get_child()
maker = Factory() maker = Factory()
@ -1005,7 +1005,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
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']: if self.vte.window and self.config['geometry_hinting']:
window = util.get_top_window(self) window = self.get_toplevel()
window.set_rough_geometry_hints() window.set_rough_geometry_hints()
def on_vte_notify_enter(self, term, event): def on_vte_notify_enter(self, term, event):
@ -1078,7 +1078,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
"""Determine if we are a zoomed terminal""" """Determine if we are a zoomed terminal"""
prop = None prop = None
parent = self.get_parent() parent = self.get_parent()
window = get_top_window(self) window = self.get_toplevel()
try: try:
prop = window.get_property('term-zoomed') prop = window.get_property('term-zoomed')
@ -1312,7 +1312,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def on_beep(self, widget): def on_beep(self, widget):
"""Set the urgency hint for our window""" """Set the urgency hint for our window"""
if self.config['urgent_bell'] == True: if self.config['urgent_bell'] == True:
window = util.get_top_window(self) window = self.get_toplevel()
window.set_urgency_hint(True) window.set_urgency_hint(True)
if self.config['icon_bell'] == True: if self.config['icon_bell'] == True:
self.titlebar.icon_bell() self.titlebar.icon_bell()

View File

@ -89,14 +89,6 @@ def has_ancestor(widget, wtype):
return(True) return(True)
return(False) return(False)
def get_top_window(widget):
"""Return the Window instance a widget belongs to"""
parent = widget.get_parent()
while parent:
widget = parent
parent = widget.get_parent()
return(widget)
def path_lookup(command): def path_lookup(command):
'''Find a command in our path''' '''Find a command in our path'''
if os.path.isabs(command): if os.path.isabs(command):