Skip to content
Browse files

completion scrolling

  • Loading branch information...
1 parent 04344d5 commit 5c0d82416d25d456822b2fdaa5fff03517ed1fd8 @baverman committed Dec 21, 2010
Showing with 9 additions and 18 deletions.
  1. +5 −3 taburet/ui/completion.py
  2. +4 −15 taburet/ui/grid.py
View
8 taburet/ui/completion.py
@@ -69,7 +69,7 @@ def __init__(self, model):
self.tree = gtk.TreeView()
self.tree.set_headers_visible(False)
- self.tree.set_hover_selection(True)
+ #self.tree.set_hover_selection(True)
self.tree.append_column(gtk.TreeViewColumn())
self.tree_selection = self.tree.get_selection()
@@ -168,12 +168,14 @@ def select(self, is_next):
model, iter = self.tree_selection.get_selected()
if not iter:
self.tree_selection.select_path((0, ))
+ self.tree.scroll_to_cell((0, ))
else:
path = list(model.get_path(iter))
path[0] += 1 if is_next else -1
-
+ path = tuple(path)
if path[0] >= 0 and path[0] < len(model):
- self.tree_selection.select_path(tuple(path))
+ self.tree_selection.select_path(path)
+ self.tree.scroll_to_cell(path)
def on_selection_changed(self, selection):
if not self.block_selection and self.entry:
View
19 taburet/ui/grid.py
@@ -6,6 +6,7 @@
import glib
from . import idle, guard, guarded_by, debug
+from .completion import make_simple_completion
class BadValueException(Exception): pass
@@ -103,24 +104,12 @@ def match_func(completion, key, iter):
class AutocompleteColumn(GridColumn):
def __init__(self, name, choices, **kwargs):
GridColumn.__init__(self, name, **kwargs)
- self.model = gtk.ListStore(str)
-
- for v in choices:
- self.model.append((str(v),))
+ self.choices = choices
+ self.completion = make_simple_completion(choices)
def create_widget(self, *args):
w = super(AutocompleteColumn, self).create_widget(*args)
-
- completion = gtk.EntryCompletion()
- completion.set_model(self.model)
- completion.set_text_column(0)
- completion.set_match_func(match_func)
- completion.set_inline_completion(True)
- completion.set_inline_selection(True)
- completion.set_popup_set_width(False)
-
- w.set_completion(completion)
-
+ self.completion.attach_to_entry(w)
return w

0 comments on commit 5c0d824

Please sign in to comment.
Something went wrong with that request. Please try again.