Skip to content

Commit

Permalink
Patch for regression of select_keys option on table sources. (bochecha)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaio committed Nov 30, 2012
1 parent d1b8d13 commit 52ec65d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
14 changes: 6 additions & 8 deletions engine/table.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -84,18 +84,13 @@ def __init__ (self, config, phrase_table_index,valid_input_chars, max_key_length
self._cursor = [0,0] self._cursor = [0,0]
# self._candidates: hold candidates selected from database [[now],[pre]] # self._candidates: hold candidates selected from database [[now],[pre]]
self._candidates = [[],[]] self._candidates = [[],[]]
# __page_size: lookup table page size
__page_size = self._config.get_value (
self._config_section,
"LookupTablePageSize",
self.db.get_page_size())
# __orientation: lookup table orientation # __orientation: lookup table orientation
__orientation = self._config.get_value ( __orientation = self._config.get_value (
self._config_section, self._config_section,
"LookupTableOrientation", "LookupTableOrientation",
self.db.get_orientation()) self.db.get_orientation())
# self._lookup_table: lookup table # self._lookup_table: lookup table
self._lookup_table = ibus.LookupTable (__page_size) self._lookup_table = ibus.LookupTable ()
self._lookup_table.set_orientation (__orientation) self._lookup_table.set_orientation (__orientation)
# self._py_mode: whether in pinyin mode # self._py_mode: whether in pinyin mode
self._py_mode = False self._py_mode = False
Expand All @@ -120,6 +115,11 @@ def __init__ (self, config, phrase_table_index,valid_input_chars, max_key_length
# self._select_keys: a list of chars for select keys # self._select_keys: a list of chars for select keys
self.init_select_keys() self.init_select_keys()


# __page_size: lookup table page size
# this is computed from the select_keys, so should be done after it
__page_size = self.db.get_page_size()
self._lookup_table.set_page_size(__page_size)

def init_select_keys(self): def init_select_keys(self):
# __select_keys: lookup table select keys/labels # __select_keys: lookup table select keys/labels
__select_keys = self._config.get_value ( __select_keys = self._config.get_value (
Expand Down Expand Up @@ -1718,8 +1718,6 @@ def config_value_changed_cb (self, config, section, name, value):
self._full_width_punct[0] = value self._full_width_punct[0] = value
elif name == u'LookupTableOrientation': elif name == u'LookupTableOrientation':
self._editor._lookup_table.set_orientation (value) self._editor._lookup_table.set_orientation (value)
elif name == u'LookupTablePageSize':
self._editor._lookup_table.set_page_size (value)
elif name == u'LookupTableSelectKeys': elif name == u'LookupTableSelectKeys':
self._editor.set_select_keys (value) self._editor.set_select_keys (value)
elif name == u'OneChar': elif name == u'OneChar':
Expand Down
10 changes: 1 addition & 9 deletions engine/tabsqlitedb.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(self, name = 'table.db', user_db = None, filename = None ):
# 'commit_keys':'space', # 'commit_keys':'space',
# 'forward_keys':'Return', # 'forward_keys':'Return',
'select_keys':'1,2,3,4,5,6,7,8,9,0', 'select_keys':'1,2,3,4,5,6,7,8,9,0',
'page_size':'6',
'page_up_keys':'Page_Up,minus', 'page_up_keys':'Page_Up,minus',
'page_down_keys':'Page_Down,equal', 'page_down_keys':'Page_Down,equal',
'status_prompt':'', 'status_prompt':'',
Expand Down Expand Up @@ -272,14 +271,7 @@ def get_chinese_mode (self):
return -1 return -1


def get_page_size (self): def get_page_size (self):
try: return len(self.get_select_keys().split(','))
__page_size = int( self.get_ime_property ('page_size') )
if __page_size:
return __page_size
else:
return len(__select_keys.split(','))
except:
return 6


def get_select_keys (self): def get_select_keys (self):
ret = None ret = None
Expand Down

2 comments on commit 52ec65d

@mozbugbox
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the "LookupTablePageSize" option removed here? I kept seeing people asking ways to set the page size because of lower screen resolution or bigger font.

For myself, the default page size of 10 for most Chinese input table is just too big.

"LookupTablePageSize" should be able to override table default page size.

@kaio
Copy link
Owner Author

@kaio kaio commented on 52ec65d May 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a removal of the feature, but reproduced in a different way.

The page size is not controlled by the LookupTablePageSize option, but the number of items listed in SELECT_KEYS in the table source. Because the select_keys implied the page size already, keeping 2 data will make confusion.

Please sign in to comment.