1 # -*- coding: utf-8 -*-
6 from ibus
import interface
7 from languagebar
import LanguageBarWindow
8 from candidatewindow
import CandidateWindow
10 class Panel (gobject
.GObject
):
11 def __init__ (self
, proxy
):
12 gobject
.GObject
.__init
__ (self
)
14 self
._language
_bar
= LanguageBarWindow ()
15 self
._candidate
_panel
= CandidateWindow ()
16 self
._candidate
_panel
.connect ("cursor-up", lambda x
: self
._proxy
.CursorUp ())
17 self
._candidate
_panel
.connect ("cursor-down", lambda x
: self
._proxy
.CursorDown ())
19 def set_cursor_location (self
, x
, y
, w
, h
):
20 self
._candidate
_panel
.move (x
+ w
, y
+ h
)
22 def set_preedit_string (self
, text
, attrs
, cursor_pos
):
23 self
._candidate
_panel
.set_preedit_string (text
, attrs
, cursor_pos
)
25 def show_preedit_string (self
):
26 self
._candidate
_panel
.show_preedit_string ()
28 def hide_preedit_string (self
):
29 self
._candidate
_panel
.hide_preedit_string ()
31 def set_aux_string (self
, text
, attrs
):
32 self
._candidate
_panel
.set_aux_string (text
, attrs
)
34 def show_aux_string (self
):
35 self
._candidate
_panel
.show_aux_string ()
37 def hide_aux_string (self
):
38 self
._candidate
_panel
.hide_aux_string ()
40 def update_lookup_table (self
, lookup_table
):
41 self
._candidate
_panel
.set_lookup_table (lookup_table
)
43 def show_candidate_window (self
):
44 self
._candidate
_panel
.show ()
46 def hide_candidate_window (self
):
47 self
._candidate
_panel
.hide ()
49 def show_language_bar (self
):
50 selk
._language
_bar
.show ()
52 def hide_language_bar (self
):
53 selk
._language
_bar
.hide ()
55 class PanelProxy (interface
.IPanel
):
56 def __init__ (self
, dbusconn
, object_path
):
57 interface
.IPanel
.__init
__ (self
, dbusconn
, object_path
)
58 self
._dbusconn
= dbusconn
59 self
._panel
= Panel (self
)
61 def SetCursorLocation (self
, x
, y
, w
, h
):
62 self
._panel
.set_cursor_location (x
, y
, w
, h
)
64 def SetPreeditString (self
, text
, attrs
, cursor_pos
):
65 attrs
= ibus
.attr_list_from_dbus_value (attrs
)
66 self
._panel
.set_preedit_string (text
, atrrs
, cursor_pos
)
68 def ShowPreeditString (self
):
69 self
._panel
.show_preedit_string ()
71 def HidePreeditString (self
):
72 self
._panel
.hide_preedit_string ()
74 def SetAuxString (self
, text
, attrs
):
75 attrs
= ibus
.attr_list_from_dbus_value (attrs
)
76 self
._panel
.set_aux_string (text
, attrs
)
78 def ShowAuxString (self
):
79 self
._panel
.show_aux_string ()
81 def HideAuxString (self
):
82 self
._panel
.hide_aux_string ()
84 def UpdateLookupTable (self
, lookup_table
):
85 lookup_table
= ibus
.lookup_table_from_dbus_value (lookup_table
)
86 self
._panel
.update_lookup_table (lookup_table
)
88 def ShowCandidateWindow (self
):
89 self
._panel
.show_candidate_window ()
91 def HideCandidateWindow (self
):
92 self
._panel
.hide_candidate_window ()
94 def ShowLanguageBar (self
):
95 self
._panel
.show_language_bar ()
97 def HideLanguageBar (self
):
98 self
._panel
.hide_language_bar ()
101 self
._pabel
.destroy ()