diff --git a/taburet/ui/completion.py b/taburet/ui/completion.py index ed9308e..f7f3ca7 100644 --- a/taburet/ui/completion.py +++ b/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: diff --git a/taburet/ui/grid.py b/taburet/ui/grid.py index bea6fd7..29fd2ce 100644 --- a/taburet/ui/grid.py +++ b/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