summaryrefslogtreecommitdiff
blob: b7be95d9c89fd6aa0298311417f7611fe078997c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
From f1accaa9a18bd4a1c7234b40e16ad9889c25a461 Mon Sep 17 00:00:00 2001
From: Peng Wu <alexepico@gmail.com>
Date: Wed, 6 Nov 2013 13:16:14 +0800
Subject: [PATCH] support setContentType method

---
 src/PYBopomofoEngine.cc | 22 ++++++++++++++++++++++
 src/PYBopomofoEngine.h  |  7 +++++++
 src/PYEngine.cc         | 21 +++++++++++++++++++++
 src/PYEngine.h          |  3 +++
 src/PYPinyinEngine.cc   | 22 ++++++++++++++++++++++
 src/PYPinyinEngine.h    |  7 +++++++
 6 files changed, 82 insertions(+)

diff --git a/src/PYBopomofoEngine.cc b/src/PYBopomofoEngine.cc
index 581c4cf..4dfbc2c 100644
--- a/src/PYBopomofoEngine.cc
+++ b/src/PYBopomofoEngine.cc
@@ -42,6 +42,10 @@ BopomofoEngine::BopomofoEngine (IBusEngine *engine)
 {
     gint i;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
+#endif
+
     /* create editors */
     m_editors[MODE_INIT].reset (new BopomofoEditor (m_props, BopomofoConfig::instance ()));
     m_editors[MODE_PUNCT].reset (new PunctEditor (m_props, BopomofoConfig::instance ()));
@@ -72,6 +76,11 @@ BopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
 {
     gboolean retval = FALSE;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose)
+        return retval;
+#endif
+
     /* check Shift + Release hotkey,
      * and then ignore other Release key event */
     if (modifiers & IBUS_RELEASE_MASK) {
@@ -139,9 +148,22 @@ BopomofoEngine::focusIn (void)
 void
 BopomofoEngine::focusOut (void)
 {
+
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
+#endif
+
     reset ();
 }
 
+#if IBUS_CHECK_VERSION(1, 5, 4)
+void
+BopomofoEngine::setContentType (guint purpose, guint hints)
+{
+    m_input_purpose = (IBusInputPurpose) purpose;
+}
+#endif
+
 void
 BopomofoEngine::reset (void)
 {
diff --git a/src/PYBopomofoEngine.h b/src/PYBopomofoEngine.h
index ce41ce8..14b6780 100644
--- a/src/PYBopomofoEngine.h
+++ b/src/PYBopomofoEngine.h
@@ -36,6 +36,9 @@ public:
     gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
     void focusIn (void);
     void focusOut (void);
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    void setContentType (guint purpose, guint hints);
+#endif
     void reset (void);
     void enable (void);
     void disable (void);
@@ -59,6 +62,10 @@ private:
 private:
     PinyinProperties m_props;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    IBusInputPurpose m_input_purpose;
+#endif
+
     guint    m_prev_pressed_key;
 
     enum {
diff --git a/src/PYEngine.cc b/src/PYEngine.cc
index d9fa04a..da047b2 100644
--- a/src/PYEngine.cc
+++ b/src/PYEngine.cc
@@ -67,6 +67,12 @@ static gboolean ibus_pinyin_engine_process_key_event
                                                  guint                   modifiers);
 static void     ibus_pinyin_engine_focus_in     (IBusEngine             *engine);
 static void     ibus_pinyin_engine_focus_out    (IBusEngine             *engine);
+#if IBUS_CHECK_VERSION (1, 5, 4)
+static void     ibus_pinyin_engine_set_content_type
+                                                (IBusEngine     *engine,
+                                                 guint           purpose,
+                                                 guint           hints);
+#endif
 static void     ibus_pinyin_engine_reset        (IBusEngine             *engine);
 static void     ibus_pinyin_engine_enable       (IBusEngine             *engine);
 static void     ibus_pinyin_engine_disable      (IBusEngine             *engine);
@@ -123,6 +129,10 @@ ibus_pinyin_engine_class_init (IBusPinyinEngineClass *klass)
     engine_class->focus_in = ibus_pinyin_engine_focus_in;
     engine_class->focus_out = ibus_pinyin_engine_focus_out;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    engine_class->set_content_type = ibus_pinyin_engine_set_content_type;
+#endif
+
     engine_class->page_up = ibus_pinyin_engine_page_up;
     engine_class->page_down = ibus_pinyin_engine_page_down;
 
@@ -182,6 +192,17 @@ ibus_pinyin_engine_process_key_event (IBusEngine     *engine,
     return pinyin->engine->processKeyEvent (keyval, keycode, modifiers);
 }
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+static void
+ibus_pinyin_engine_set_content_type (IBusEngine     *engine,
+                                     guint purpose,
+                                     guint hints)
+{
+    IBusPinyinEngine *pinyin = (IBusPinyinEngine *) engine;
+    return pinyin->engine->setContentType (purpose, hints);
+}
+#endif
+
 static void
 ibus_pinyin_engine_property_activate (IBusEngine    *engine,
                                       const gchar   *prop_name,
diff --git a/src/PYEngine.h b/src/PYEngine.h
index b74e6e8..22e1b79 100644
--- a/src/PYEngine.h
+++ b/src/PYEngine.h
@@ -44,6 +44,9 @@ public:
     virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0;
     virtual void focusIn (void) = 0;
     virtual void focusOut (void) = 0;
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    virtual void setContentType (guint purpose, guint hints) = 0;
+#endif
     virtual void reset (void) = 0;
     virtual void enable (void) = 0;
     virtual void disable (void) = 0;
diff --git a/src/PYPinyinEngine.cc b/src/PYPinyinEngine.cc
index 7aea261..570187b 100644
--- a/src/PYPinyinEngine.cc
+++ b/src/PYPinyinEngine.cc
@@ -45,6 +45,10 @@ PinyinEngine::PinyinEngine (IBusEngine *engine)
 {
     gint i;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
+#endif
+
     if (PinyinConfig::instance ().doublePinyin ())
         m_editors[MODE_INIT].reset (new DoublePinyinEditor (m_props, PinyinConfig::instance ()));
     else
@@ -82,6 +86,11 @@ PinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modifiers)
 {
     gboolean retval = FALSE;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose)
+        return retval;
+#endif
+
     /* check Shift + Release hotkey,
      * and then ignore other Release key event */
     if (modifiers & IBUS_RELEASE_MASK) {
@@ -195,9 +204,22 @@ PinyinEngine::focusIn (void)
 void
 PinyinEngine::focusOut (void)
 {
+
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
+#endif
+
     reset ();
 }
 
+#if IBUS_CHECK_VERSION(1, 5, 4)
+void
+PinyinEngine::setContentType (guint purpose, guint hints)
+{
+    m_input_purpose = (IBusInputPurpose) purpose;
+}
+#endif
+
 void
 PinyinEngine::reset (void)
 {
diff --git a/src/PYPinyinEngine.h b/src/PYPinyinEngine.h
index fcce73e..de50269 100644
--- a/src/PYPinyinEngine.h
+++ b/src/PYPinyinEngine.h
@@ -35,6 +35,9 @@ public:
     gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
     void focusIn (void);
     void focusOut (void);
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    void setContentType (guint purpose, guint hints);
+#endif
     void reset (void);
     void enable (void);
     void disable (void);
@@ -58,6 +61,10 @@ private:
 private:
     PinyinProperties m_props;
 
+#if IBUS_CHECK_VERSION (1, 5, 4)
+    IBusInputPurpose m_input_purpose;
+#endif
+
     guint    m_prev_pressed_key;
 
     enum {
-- 
1.8.3.1