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

Commit

Permalink
completion scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
baverman committed Dec 21, 2010
1 parent 04344d5 commit 5c0d824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
8 changes: 5 additions & 3 deletions taburet/ui/completion.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down
19 changes: 4 additions & 15 deletions taburet/ui/grid.py
Expand Up @@ -6,6 +6,7 @@
import glib

from . import idle, guard, guarded_by, debug
from .completion import make_simple_completion

class BadValueException(Exception): pass

Expand Down Expand Up @@ -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


Expand Down

0 comments on commit 5c0d824

Please sign in to comment.