Add header for sources.
[ibus.git] / ibusdaemon / lookuptable.py
blob3be493d2f86163c95c75b2053a85dff58aaef9b2
1 # vim:set noet ts=4:
3 # ibus - The Input Bus
5 # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the
19 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 # Boston, MA 02111-1307 USA
22 import dbus
24 class Candidates (list):
25 SIGNATURE = "a(saau)"
26 def to_dbus_value (self):
27 value = dbus.Array (signature = "(saau)")
28 for text, attrs in self:
29 value.append ((text, attrs.to_dbus_value ()), "(s%s)" % attrs.SIGNATURE)
31 def from_dbus_value (self):
32 pass
34 class LookupTable:
35 SIGNATURE = "(ibia(saau))"
37 def __init__ (self, page_size = 5):
38 self._page_size = page_size
39 self._cursor_visible = False
40 self._cursor_pos = 0
41 self._candidates = []
43 def set_page_size (self, page_size):
44 self._page_size = page_size
46 def get_page_size (self):
47 return self._page_size
49 def show_cursor (self):
50 self._cursor_visible = True
52 def hide_cursor (self):
53 self._cursor_visible = False
55 def is_cursor_visible (self):
56 return self._cursor_visible
58 def get_current_page_start (self):
59 return (self._cursor_pos / self._page_size) * self._page_size
61 def set_cursor_pos (self, pos):
62 self._current_pos = pos
64 def get_cursor_pos (self):
65 return self._current_pos
67 def get_cursor_pos_in_current_page (self):
68 return self._current_pos % self._page_size
70 def page_up (self):
71 pass
73 def page_down (self):
74 pass
76 def cursor_up (self):
77 pass
79 def cursor_down (self):
80 pass
82 def clear (self):
83 self._candidates = []
85 def append_candidate (self, candidate, attrs = None):
86 self._candidates.append ((candidates, attrs))
88 def get_candidate (self, index):
89 return self._candidates[index]
91 def to_dbus_struct (self):
92 pass
94 def from_dbus_struct (self, value)
95 pass