Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
completion: caontext manager to block entry change habdler
Browse files Browse the repository at this point in the history
  • Loading branch information
baverman committed Feb 18, 2011
1 parent c254928 commit 85676a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion taburet/ui/completion.py
Expand Up @@ -3,6 +3,8 @@
import gtk
from gtk.keysyms import Escape, Up, Down, Return, KP_Up, KP_Enter, KP_Down

from contextlib import contextmanager

def entry_changed(entry, completion_ref):
completion = completion_ref()

Expand Down Expand Up @@ -216,4 +218,12 @@ def on_key_event(self, popup, event):

def on_button_event(self, popup, event):
self.hide()
return True
return True

@contextmanager
def block(self, entry):
entry.handler_block_by_func(entry_changed)
try:
yield
finally:
entry.handler_unblock_by_func(entry_changed)
3 changes: 3 additions & 0 deletions taburet/ui/grid.py
Expand Up @@ -47,6 +47,9 @@ def _set_value(self, entry, row):

@guard('changing')
def set_dirty_value(self, entry, row):
self._set_dirty_value(entry, row)

def _set_dirty_value(self, entry, row):
entry.set_text(row[self.name])

def update_row_value(self, dirty_row, row):
Expand Down

0 comments on commit 85676a7

Please sign in to comment.