diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/PYEngine.cc | 33 | ||||
-rw-r--r-- | src/PYEngine.h | 13 | ||||
-rw-r--r-- | src/PYPBopomofoEngine.cc | 21 | ||||
-rw-r--r-- | src/PYPBopomofoEngine.h | 7 | ||||
-rw-r--r-- | src/PYPPinyinEngine.cc | 21 | ||||
-rw-r--r-- | src/PYPPinyinEngine.h | 7 |
6 files changed, 47 insertions, 55 deletions
diff --git a/src/PYEngine.cc b/src/PYEngine.cc index 68260dd..fb32a0e 100644 --- a/src/PYEngine.cc +++ b/src/PYEngine.cc @@ -246,6 +246,39 @@ FUNCTION(cursor_up, cursorUp) FUNCTION(cursor_down, cursorDown) #undef FUNCTION +Engine::Engine (IBusEngine *engine) : m_engine (engine) +{ +#if IBUS_CHECK_VERSION (1, 5, 4) + m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM; +#endif +} + +gboolean +Engine::contentIsPassword() +{ +#if IBUS_CHECK_VERSION (1, 5, 4) + return IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose; +#else + return FALSE; +#endif +} + +void +Engine::focusOut (void) +{ +#if IBUS_CHECK_VERSION (1, 5, 4) + m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM; +#endif +} + +#if IBUS_CHECK_VERSION(1, 5, 4) +void +Engine::setContentType (guint purpose, guint hints) +{ + m_input_purpose = (IBusInputPurpose) purpose; +} +#endif + Engine::~Engine (void) { } diff --git a/src/PYEngine.h b/src/PYEngine.h index 0866146..702520c 100644 --- a/src/PYEngine.h +++ b/src/PYEngine.h @@ -37,15 +37,17 @@ GType ibus_pinyin_engine_get_type (void); class Engine { public: - Engine (IBusEngine *engine) : m_engine (engine) { } + Engine (IBusEngine *engine); virtual ~Engine (void); + gboolean contentIsPassword(); + // virtual functions virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0; virtual void focusIn (void) = 0; - virtual void focusOut (void) = 0; + virtual void focusOut (void); #if IBUS_CHECK_VERSION (1, 5, 4) - virtual void setContentType (guint purpose, guint hints) = 0; + virtual void setContentType (guint purpose, guint hints); #endif virtual void reset (void) = 0; virtual void enable (void) = 0; @@ -125,6 +127,11 @@ protected: protected: Pointer<IBusEngine> m_engine; // engine pointer + +#if IBUS_CHECK_VERSION (1, 5, 4) + IBusInputPurpose m_input_purpose; +#endif + }; }; diff --git a/src/PYPBopomofoEngine.cc b/src/PYPBopomofoEngine.cc index 9d2666f..75b8b57 100644 --- a/src/PYPBopomofoEngine.cc +++ b/src/PYPBopomofoEngine.cc @@ -40,10 +40,6 @@ LibPinyinBopomofoEngine::LibPinyinBopomofoEngine (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 LibPinyinBopomofoEditor (m_props, LibPinyinBopomofoConfig::instance ())); m_editors[MODE_PUNCT].reset (new PunctEditor (m_props, LibPinyinBopomofoConfig::instance ())); @@ -68,10 +64,8 @@ LibPinyinBopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint mod { gboolean retval = FALSE; -#if IBUS_CHECK_VERSION (1, 5, 4) - if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose) + if (contentIsPassword ()) return retval; -#endif /* check Shift or Ctrl + Release hotkey, * and then ignore other Release key event */ @@ -149,22 +143,11 @@ LibPinyinBopomofoEngine::focusIn (void) void LibPinyinBopomofoEngine::focusOut (void) { - -#if IBUS_CHECK_VERSION (1, 5, 4) - m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM; -#endif + Engine::focusOut (); reset (); } -#if IBUS_CHECK_VERSION(1, 5, 4) -void -LibPinyinBopomofoEngine::setContentType (guint purpose, guint hints) -{ - m_input_purpose = (IBusInputPurpose) purpose; -} -#endif - void LibPinyinBopomofoEngine::reset (void) { diff --git a/src/PYPBopomofoEngine.h b/src/PYPBopomofoEngine.h index 85d1ff6..fc64842 100644 --- a/src/PYPBopomofoEngine.h +++ b/src/PYPBopomofoEngine.h @@ -37,9 +37,6 @@ 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); @@ -63,10 +60,6 @@ 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/PYPPinyinEngine.cc b/src/PYPPinyinEngine.cc index d28dc6f..4406239 100644 --- a/src/PYPPinyinEngine.cc +++ b/src/PYPPinyinEngine.cc @@ -50,10 +50,6 @@ LibPinyinPinyinEngine::LibPinyinPinyinEngine (IBusEngine *engine) { gint i; -#if IBUS_CHECK_VERSION (1, 5, 4) - m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM; -#endif - m_double_pinyin = LibPinyinPinyinConfig::instance ().doublePinyin (); if (m_double_pinyin) @@ -104,10 +100,8 @@ LibPinyinPinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modif { gboolean retval = FALSE; -#if IBUS_CHECK_VERSION (1, 5, 4) - if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose) + if (contentIsPassword ()) return retval; -#endif /* check Shift or Ctrl + Release hotkey, * and then ignore other Release key event */ @@ -231,22 +225,11 @@ LibPinyinPinyinEngine::focusIn (void) void LibPinyinPinyinEngine::focusOut (void) { - -#if IBUS_CHECK_VERSION (1, 5, 4) - m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM; -#endif + Engine::focusOut (); reset (); } -#if IBUS_CHECK_VERSION(1, 5, 4) -void -LibPinyinPinyinEngine::setContentType (guint purpose, guint hints) -{ - m_input_purpose = (IBusInputPurpose) purpose; -} -#endif - void LibPinyinPinyinEngine::reset (void) { diff --git a/src/PYPPinyinEngine.h b/src/PYPPinyinEngine.h index 9954569..a7e0e12 100644 --- a/src/PYPPinyinEngine.h +++ b/src/PYPPinyinEngine.h @@ -35,9 +35,6 @@ 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,10 +56,6 @@ private: private: PinyinProperties m_props; -#if IBUS_CHECK_VERSION (1, 5, 4) - IBusInputPurpose m_input_purpose; -#endif - guint m_prev_pressed_key; enum { |