port Terminal to use Signalman

This commit is contained in:
Chris Jones 2010-01-18 19:48:24 +00:00
parent f17fab0610
commit 7d08d790e2
3 changed files with 17 additions and 25 deletions

View File

@ -33,8 +33,11 @@ class Signalman(object):
def remove_signal(self, widget, signal): def remove_signal(self, widget, signal):
"""Remove a signal handler""" """Remove a signal handler"""
if not self.cnxids.has_key(widget):
dbg('%s is not registered' % widget)
return
if not self.cnxids[widget].has_key(signal): if not self.cnxids[widget].has_key(signal):
err('%s not registered for %s' % (signal, type(widget))) dbg('%s not registered for %s' % (signal, type(widget)))
return return
dbg('removing %s::%s' % (type(widget), signal)) dbg('removing %s::%s' % (type(widget), signal))
widget.disconnect(self.cnxids[widget][signal]) widget.disconnect(self.cnxids[widget][signal])

View File

@ -22,6 +22,7 @@ from titlebar import Titlebar
from terminal_popup_menu import TerminalPopupMenu from terminal_popup_menu import TerminalPopupMenu
from searchbar import Searchbar from searchbar import Searchbar
from translation import _ from translation import _
from signalman import Signalman
import plugin import plugin
try: try:
@ -97,8 +98,7 @@ class Terminal(gtk.VBox):
self.connect('focus-in', self.terminator.focus_changed) self.connect('focus-in', self.terminator.focus_changed)
self.matches = {} self.matches = {}
# FIXME: Port cnxids to using Signalman self.cnxids = Signalman()
self.cnxids = {}
self.config = Config() self.config = Config()
@ -267,9 +267,9 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
self.vte.connect('drag-data-received', self.vte.connect('drag-data-received',
self.on_drag_data_received, self) self.on_drag_data_received, self)
# FIXME: Shouldn't this be in configure()?
if self.config['copy_on_selection']: if self.config['copy_on_selection']:
self.cnxids['copy_on_selection'] = self.vte.connect( self.cnxids.new(self.vte, 'selection-changed',
'selection-changed',
lambda widget: self.vte.copy_clipboard()) lambda widget: self.vte.copy_clipboard())
if self.composite_support: if self.composite_support:
@ -286,7 +286,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
self.vte.connect('enter_notify_event', self.vte.connect('enter_notify_event',
self.on_vte_notify_enter) self.on_vte_notify_enter)
self.cnxids['conf'] = self.vte.connect_after('realize', self.reconfigure) self.cnxids.new(self.vte, 'realize', self.reconfigure)
def create_popup_group_menu(self, widget, event = None): def create_popup_group_menu(self, widget, event = None):
"""Pop up a menu for the group widget""" """Pop up a menu for the group widget"""
@ -461,21 +461,15 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def reconfigure(self, widget=None): def reconfigure(self, widget=None):
"""Reconfigure our settings""" """Reconfigure our settings"""
dbg('Terminal::reconfigure') dbg('Terminal::reconfigure')
if self.cnxids.has_key('conf'): self.cnxids.remove_signal(self.vte, 'realize')
self.vte.disconnect(self.cnxids['conf'])
del(self.cnxids['conf'])
# Handle child command exiting # Handle child command exiting
if self.cnxids.has_key('child-exited'): self.cnxids.remove_signal(self.vte, 'child-exited')
dbg('Terminal::reconfigure: Dropping child-exited handler')
self.vte.disconnect(self.cnxids['child-exited'])
del(self.cnxids['child-exited'])
if self.config['exit_action'] == 'restart': if self.config['exit_action'] == 'restart':
self.cnxids['child-exited'] = self.vte.connect('child-exited', self.cnxids.new(self.vte, 'child-exited', self.spawn_child)
self.spawn_child)
elif self.config['exit_action'] in ('close', 'left'): elif self.config['exit_action'] in ('close', 'left'):
self.cnxids['child-exited'] = self.vte.connect('child-exited', self.cnxids.new(self.vte, 'child-exited',
lambda x: self.emit('close-term')) lambda x: self.emit('close-term'))
self.vte.set_emulation(self.config['emulation']) self.vte.set_emulation(self.config['emulation'])
@ -568,9 +562,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
if self.config['force_no_bell'] == True: if self.config['force_no_bell'] == True:
self.vte.set_audible_bell(False) self.vte.set_audible_bell(False)
self.vte.set_visible_bell(False) self.vte.set_visible_bell(False)
if self.cnxids.has_key('urgent_bell'): self.cnxids.remove_signal(self.vte, 'urgent_bell')
self.vte.disconnect(self.cnxids['urgent_bell'])
del(self.cnxids['urgent_bell'])
else: else:
self.vte.set_audible_bell(self.config['audible_bell']) self.vte.set_audible_bell(self.config['audible_bell'])
self.vte.set_visible_bell(self.config['visible_bell']) self.vte.set_visible_bell(self.config['visible_bell'])
@ -578,9 +570,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
# FIXME: Hook up a signal handler here # FIXME: Hook up a signal handler here
pass pass
else: else:
if self.cnxids.has_key('urgent_bell'): self.cnxids.remove_signal(self.vte, 'urgent_bell')
self.vte.disconnect(self.cnxids['urgent_bell'])
del(self.cnxids['urgent_bell'])
self.vte.set_scrollback_lines(self.config['scrollback_lines']) self.vte.set_scrollback_lines(self.config['scrollback_lines'])
self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke']) self.vte.set_scroll_on_keystroke(self.config['scroll_on_keystroke'])
@ -893,8 +883,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
def zoom_scale(self, widget, allocation, old_data): def zoom_scale(self, widget, allocation, old_data):
"""Scale our font correctly based on how big we are not vs before""" """Scale our font correctly based on how big we are not vs before"""
self.disconnect(self.cnxids['zoom']) self.cnxids.remove_signal(self, 'zoom')
del(self.cnxids['zoom'])
new_columns = self.vte.get_column_count() new_columns = self.vte.get_column_count()
new_rows = self.vte.get_row_count() new_rows = self.vte.get_row_count()

View File

@ -295,7 +295,7 @@ class Window(Container, gtk.Window):
self.set_property('term_zoomed', True) self.set_property('term_zoomed', True)
if font_scale: if font_scale:
widget.cnxids['zoom'] = widget.connect('size-allocate', widget.cnxids.new(widget, 'size-allocate',
widget.zoom_scale, self.zoom_data) widget.zoom_scale, self.zoom_data)
widget.grab_focus() widget.grab_focus()