Commit 88667aba authored by Aron Xu's avatar Aron Xu

Imported Upstream version 1.6.92

parent c1685be3
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
m4_define([ibus_released], [1]) m4_define([ibus_released], [1])
m4_define([ibus_major_version], [1]) m4_define([ibus_major_version], [1])
m4_define([ibus_minor_version], [6]) m4_define([ibus_minor_version], [6])
m4_define([ibus_micro_version], [91]) m4_define([ibus_micro_version], [92])
m4_define(ibus_maybe_datestamp, m4_define(ibus_maybe_datestamp,
m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
...@@ -54,7 +54,7 @@ AC_PROG_SED ...@@ -54,7 +54,7 @@ AC_PROG_SED
# check ibus # check ibus
PKG_CHECK_MODULES(IBUS, [ PKG_CHECK_MODULES(IBUS, [
ibus-1.0 >= 1.3.99 ibus-1.0 >= 1.4.0
]) ])
# check sqlite # check sqlite
......
...@@ -26,6 +26,14 @@ ...@@ -26,6 +26,14 @@
#include "lua-plugin.h" #include "lua-plugin.h"
#if LUA_VERSION_NUM >= 502
/* ugly hack for lua 5.2 */
#define lua_objlen lua_rawlen
#endif
static const luaL_Reg lualibs[] = { static const luaL_Reg lualibs[] = {
{"", luaopen_base}, {"", luaopen_base},
{LUA_TABLIBNAME, luaopen_table}, {LUA_TABLIBNAME, luaopen_table},
......
...@@ -25,6 +25,15 @@ ...@@ -25,6 +25,15 @@
#include "lua-plugin.h" #include "lua-plugin.h"
#if LUA_VERSION_NUM >= 502
/* ugly hack for lua 5.2 */
#define lua_open luaL_newstate
#define lua_objlen lua_rawlen
#endif
#define IBUS_ENGINE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginPrivate)) #define IBUS_ENGINE_PLUGIN_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), IBUS_TYPE_ENGINE_PLUGIN, IBusEnginePluginPrivate))
struct _IBusEnginePluginPrivate{ struct _IBusEnginePluginPrivate{
......
...@@ -30,7 +30,6 @@ import sys ...@@ -30,7 +30,6 @@ import sys
from gi.repository import GLib from gi.repository import GLib
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import IBus from gi.repository import IBus
from xdg import BaseDirectory
import config import config
from dicttreeview import DictionaryTreeView from dicttreeview import DictionaryTreeView
...@@ -373,7 +372,7 @@ class PreferencesDialog: ...@@ -373,7 +372,7 @@ class PreferencesDialog:
def __edit_lua_cb(self, widget): def __edit_lua_cb(self, widget):
import shutil import shutil
path = os.path.join(BaseDirectory.xdg_config_home, "ibus", "libpinyin") path = os.path.join(GLib.get_user_config_dir(), "ibus", "libpinyin")
os.path.exists(path) or os.makedirs(path) os.path.exists(path) or os.makedirs(path)
path = os.path.join(path, "user.lua") path = os.path.join(path, "user.lua")
if not os.path.exists(path): if not os.path.exists(path):
......
...@@ -67,6 +67,12 @@ static gboolean ibus_pinyin_engine_process_key_event ...@@ -67,6 +67,12 @@ static gboolean ibus_pinyin_engine_process_key_event
guint modifiers); guint modifiers);
static void ibus_pinyin_engine_focus_in (IBusEngine *engine); static void ibus_pinyin_engine_focus_in (IBusEngine *engine);
static void ibus_pinyin_engine_focus_out (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_reset (IBusEngine *engine);
static void ibus_pinyin_engine_enable (IBusEngine *engine); static void ibus_pinyin_engine_enable (IBusEngine *engine);
static void ibus_pinyin_engine_disable (IBusEngine *engine); static void ibus_pinyin_engine_disable (IBusEngine *engine);
...@@ -123,6 +129,10 @@ ibus_pinyin_engine_class_init (IBusPinyinEngineClass *klass) ...@@ -123,6 +129,10 @@ ibus_pinyin_engine_class_init (IBusPinyinEngineClass *klass)
engine_class->focus_in = ibus_pinyin_engine_focus_in; engine_class->focus_in = ibus_pinyin_engine_focus_in;
engine_class->focus_out = ibus_pinyin_engine_focus_out; 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_up = ibus_pinyin_engine_page_up;
engine_class->page_down = ibus_pinyin_engine_page_down; engine_class->page_down = ibus_pinyin_engine_page_down;
...@@ -189,6 +199,17 @@ ibus_pinyin_engine_process_key_event (IBusEngine *engine, ...@@ -189,6 +199,17 @@ ibus_pinyin_engine_process_key_event (IBusEngine *engine,
return pinyin->engine->processKeyEvent (keyval, keycode, modifiers); 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 static void
ibus_pinyin_engine_property_activate (IBusEngine *engine, ibus_pinyin_engine_property_activate (IBusEngine *engine,
const gchar *prop_name, const gchar *prop_name,
......
...@@ -44,6 +44,9 @@ public: ...@@ -44,6 +44,9 @@ public:
virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0; virtual gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers) = 0;
virtual void focusIn (void) = 0; virtual void focusIn (void) = 0;
virtual void focusOut (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 reset (void) = 0;
virtual void enable (void) = 0; virtual void enable (void) = 0;
virtual void disable (void) = 0; virtual void disable (void) = 0;
......
...@@ -40,6 +40,10 @@ LibPinyinBopomofoEngine::LibPinyinBopomofoEngine (IBusEngine *engine) ...@@ -40,6 +40,10 @@ LibPinyinBopomofoEngine::LibPinyinBopomofoEngine (IBusEngine *engine)
{ {
gint i; gint i;
#if IBUS_CHECK_VERSION (1, 5, 4)
m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
#endif
/* create editors */ /* create editors */
m_editors[MODE_INIT].reset (new LibPinyinBopomofoEditor (m_props, LibPinyinBopomofoConfig::instance ())); m_editors[MODE_INIT].reset (new LibPinyinBopomofoEditor (m_props, LibPinyinBopomofoConfig::instance ()));
m_editors[MODE_PUNCT].reset (new PunctEditor (m_props, LibPinyinBopomofoConfig::instance ())); m_editors[MODE_PUNCT].reset (new PunctEditor (m_props, LibPinyinBopomofoConfig::instance ()));
...@@ -64,6 +68,11 @@ LibPinyinBopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint mod ...@@ -64,6 +68,11 @@ LibPinyinBopomofoEngine::processKeyEvent (guint keyval, guint keycode, guint mod
{ {
gboolean retval = FALSE; gboolean retval = FALSE;
#if IBUS_CHECK_VERSION (1, 5, 4)
if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose)
return retval;
#endif
/* check Shift or Ctrl + Release hotkey, /* check Shift or Ctrl + Release hotkey,
* and then ignore other Release key event */ * and then ignore other Release key event */
if (modifiers & IBUS_RELEASE_MASK) { if (modifiers & IBUS_RELEASE_MASK) {
...@@ -140,9 +149,22 @@ LibPinyinBopomofoEngine::focusIn (void) ...@@ -140,9 +149,22 @@ LibPinyinBopomofoEngine::focusIn (void)
void void
LibPinyinBopomofoEngine::focusOut (void) LibPinyinBopomofoEngine::focusOut (void)
{ {
#if IBUS_CHECK_VERSION (1, 5, 4)
m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
#endif
reset (); reset ();
} }
#if IBUS_CHECK_VERSION(1, 5, 4)
void
LibPinyinBopomofoEngine::setContentType (guint purpose, guint hints)
{
m_input_purpose = (IBusInputPurpose) purpose;
}
#endif
void void
LibPinyinBopomofoEngine::reset (void) LibPinyinBopomofoEngine::reset (void)
{ {
......
...@@ -37,6 +37,9 @@ public: ...@@ -37,6 +37,9 @@ public:
gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
void focusIn (void); void focusIn (void);
void focusOut (void); void focusOut (void);
#if IBUS_CHECK_VERSION (1, 5, 4)
void setContentType (guint purpose, guint hints);
#endif
void reset (void); void reset (void);
void enable (void); void enable (void);
void disable (void); void disable (void);
...@@ -60,6 +63,10 @@ private: ...@@ -60,6 +63,10 @@ private:
private: private:
PinyinProperties m_props; PinyinProperties m_props;
#if IBUS_CHECK_VERSION (1, 5, 4)
IBusInputPurpose m_input_purpose;
#endif
guint m_prev_pressed_key; guint m_prev_pressed_key;
enum { enum {
......
...@@ -50,6 +50,10 @@ LibPinyinPinyinEngine::LibPinyinPinyinEngine (IBusEngine *engine) ...@@ -50,6 +50,10 @@ LibPinyinPinyinEngine::LibPinyinPinyinEngine (IBusEngine *engine)
{ {
gint i; gint i;
#if IBUS_CHECK_VERSION (1, 5, 4)
m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
#endif
m_double_pinyin = LibPinyinPinyinConfig::instance ().doublePinyin (); m_double_pinyin = LibPinyinPinyinConfig::instance ().doublePinyin ();
if (m_double_pinyin) if (m_double_pinyin)
...@@ -100,6 +104,11 @@ LibPinyinPinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modif ...@@ -100,6 +104,11 @@ LibPinyinPinyinEngine::processKeyEvent (guint keyval, guint keycode, guint modif
{ {
gboolean retval = FALSE; gboolean retval = FALSE;
#if IBUS_CHECK_VERSION (1, 5, 4)
if (IBUS_INPUT_PURPOSE_PASSWORD == m_input_purpose)
return retval;
#endif
/* check Shift or Ctrl + Release hotkey, /* check Shift or Ctrl + Release hotkey,
* and then ignore other Release key event */ * and then ignore other Release key event */
if (modifiers & IBUS_RELEASE_MASK) { if (modifiers & IBUS_RELEASE_MASK) {
...@@ -222,9 +231,22 @@ LibPinyinPinyinEngine::focusIn (void) ...@@ -222,9 +231,22 @@ LibPinyinPinyinEngine::focusIn (void)
void void
LibPinyinPinyinEngine::focusOut (void) LibPinyinPinyinEngine::focusOut (void)
{ {
#if IBUS_CHECK_VERSION (1, 5, 4)
m_input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
#endif
reset (); reset ();
} }
#if IBUS_CHECK_VERSION(1, 5, 4)
void
LibPinyinPinyinEngine::setContentType (guint purpose, guint hints)
{
m_input_purpose = (IBusInputPurpose) purpose;
}
#endif
void void
LibPinyinPinyinEngine::reset (void) LibPinyinPinyinEngine::reset (void)
{ {
......
...@@ -35,6 +35,9 @@ public: ...@@ -35,6 +35,9 @@ public:
gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers); gboolean processKeyEvent (guint keyval, guint keycode, guint modifiers);
void focusIn (void); void focusIn (void);
void focusOut (void); void focusOut (void);
#if IBUS_CHECK_VERSION (1, 5, 4)
void setContentType (guint purpose, guint hints);
#endif
void reset (void); void reset (void);
void enable (void); void enable (void);
void disable (void); void disable (void);
...@@ -56,6 +59,10 @@ private: ...@@ -56,6 +59,10 @@ private:
private: private:
PinyinProperties m_props; PinyinProperties m_props;
#if IBUS_CHECK_VERSION (1, 5, 4)
IBusInputPurpose m_input_purpose;
#endif
guint m_prev_pressed_key; guint m_prev_pressed_key;
enum { enum {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
namespace PY { namespace PY {
#define _(text) (dgettext (GETTEXT_PACKAGE, text)) #define _(text) (dgettext (GETTEXT_PACKAGE, text))
#define N_(text) text
PinyinProperties::PinyinProperties (Config & config) PinyinProperties::PinyinProperties (Config & config)
: m_config (config), : m_config (config),
...@@ -33,7 +34,7 @@ PinyinProperties::PinyinProperties (Config & config) ...@@ -33,7 +34,7 @@ PinyinProperties::PinyinProperties (Config & config)
m_mode_full (m_config.initFull ()), m_mode_full (m_config.initFull ()),
m_mode_full_punct (m_config.initFullPunct ()), m_mode_full_punct (m_config.initFullPunct ()),
m_mode_simp (m_config.initSimpChinese ()), m_mode_simp (m_config.initSimpChinese ()),
m_prop_chinese ("mode.chinese", m_prop_chinese ("InputMode",
PROP_TYPE_NORMAL, PROP_TYPE_NORMAL,
StaticText (m_mode_chinese ? StaticText (m_mode_chinese ?
_("Chinese") : _("Chinese") :
...@@ -83,6 +84,11 @@ PinyinProperties::PinyinProperties (Config & config) ...@@ -83,6 +84,11 @@ PinyinProperties::PinyinProperties (Config & config)
"ibus-setup", "ibus-setup",
StaticText (_("Preferences"))) StaticText (_("Preferences")))
{ {
if (m_mode_chinese)
m_prop_chinese.setSymbol(N_("中"));
else
m_prop_chinese.setSymbol(N_("英"));
m_props.append (m_prop_chinese); m_props.append (m_prop_chinese);
m_props.append (m_prop_full); m_props.append (m_prop_full);
m_props.append (m_prop_full_punct); m_props.append (m_prop_full_punct);
...@@ -98,6 +104,12 @@ PinyinProperties::toggleModeChinese (void) ...@@ -98,6 +104,12 @@ PinyinProperties::toggleModeChinese (void)
m_prop_chinese.setLabel (m_mode_chinese ? m_prop_chinese.setLabel (m_mode_chinese ?
_("Chinese") : _("Chinese") :
_("English")); _("English"));
if (m_mode_chinese)
m_prop_chinese.setSymbol(N_("中"));
else
m_prop_chinese.setSymbol(N_("英"));
m_prop_chinese.setIcon (m_mode_chinese ? m_prop_chinese.setIcon (m_mode_chinese ?
PKGDATADIR"/icons/chinese.svg" : PKGDATADIR"/icons/chinese.svg" :
PKGDATADIR"/icons/english.svg"); PKGDATADIR"/icons/english.svg");
......
...@@ -55,6 +55,16 @@ public: ...@@ -55,6 +55,16 @@ public:
ibus_property_set_icon (get<IBusProperty> (), icon); ibus_property_set_icon (get<IBusProperty> (), icon);
} }
void setSymbol (IBusText *text)
{
ibus_property_set_symbol (get<IBusProperty> (), text);
}
void setSymbol (const gchar *text)
{
setSymbol (Text (text));
}
void setSensitive (gboolean sensitive) void setSensitive (gboolean sensitive)
{ {
ibus_property_set_sensitive (get<IBusProperty> (), sensitive); ibus_property_set_sensitive (get<IBusProperty> (), sensitive);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment