Update to 1.3.1-1.

This commit is contained in:
Daiki Ueno 2010-09-03 17:30:46 +09:00
parent 89e2ebd29f
commit 83f062206b
5 changed files with 59 additions and 254 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
ibus-m17n-1.3.0.tar.gz
/ibus-m17n-1.3.0.tar.gz
/ibus-m17n-1.3.1.tar.gz

View File

@ -1,153 +0,0 @@
diff --git a/src/engine.c b/src/engine.c
index dcfbe48..21fae67 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -254,12 +254,31 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
}
static void
+ibus_m17n_engine_update_preedit (IBusM17NEngine *m17n)
+{
+ IBusText *text;
+ gchar *buf;
+
+ buf = ibus_m17n_mtext_to_utf8 (m17n->context->preedit);
+ if (buf) {
+ text = ibus_text_new_from_static_string (buf);
+ ibus_text_append_attribute (text, IBUS_ATTR_TYPE_FOREGROUND, 0x00ffffff, 0, -1);
+ ibus_text_append_attribute (text, IBUS_ATTR_TYPE_BACKGROUND, 0x00000000, 0, -1);
+ ibus_engine_update_preedit_text ((IBusEngine *) m17n,
+ text,
+ m17n->context->cursor_pos,
+ mtext_len (m17n->context->preedit) > 0);
+ }
+}
+
+static void
ibus_m17n_engine_commit_string (IBusM17NEngine *m17n,
const gchar *string)
{
IBusText *text;
text = ibus_text_new_from_static_string (string);
ibus_engine_commit_text ((IBusEngine *)m17n, text);
+ ibus_m17n_engine_update_preedit (m17n);
}
MSymbol
@@ -503,14 +522,15 @@ ibus_m17n_engine_update_lookup_table (IBusM17NEngine *m17n)
if (mplist_key (group) == Mtext) {
MText *mt;
- gunichar *buf, *p;
+ gunichar *buf;
+ glong nchars, i;
mt = (MText *) mplist_value (group);
ibus_lookup_table_set_page_size (m17n->table, mtext_len (mt));
- buf = ibus_m17n_mtext_to_ucs4 (mt);
- for (p = buf + 1; *p != 0; p++) {
- ibus_lookup_table_append_candidate (m17n->table, ibus_text_new_from_unichar (*p));
+ buf = ibus_m17n_mtext_to_ucs4 (mt, &nchars);
+ for (i = 0; i < nchars; i++) {
+ ibus_lookup_table_append_candidate (m17n->table, ibus_text_new_from_unichar (buf[i]));
}
g_free (buf);
}
@@ -565,19 +585,7 @@ ibus_m17n_engine_callback (MInputContext *context,
ibus_engine_hide_preedit_text ((IBusEngine *)m17n);
}
else if (command == Minput_preedit_draw) {
- IBusText *text;
- gchar *buf;
-
- buf = ibus_m17n_mtext_to_utf8 (m17n->context->preedit);
- if (buf) {
- text = ibus_text_new_from_static_string (buf);
- ibus_text_append_attribute (text, IBUS_ATTR_TYPE_FOREGROUND, 0x00ffffff, 0, -1);
- ibus_text_append_attribute (text, IBUS_ATTR_TYPE_BACKGROUND, 0x00000000, 0, -1);
- ibus_engine_update_preedit_text ((IBusEngine *) m17n,
- text,
- m17n->context->cursor_pos,
- mtext_len (m17n->context->preedit) > 0);
- }
+ ibus_m17n_engine_update_preedit (m17n);
}
else if (command == Minput_preedit_done) {
ibus_engine_hide_preedit_text ((IBusEngine *)m17n);
diff --git a/src/m17nutil.c b/src/m17nutil.c
index 257f68e..dc2626e 100644
--- a/src/m17nutil.c
+++ b/src/m17nutil.c
@@ -5,7 +5,6 @@
#define N_(text) text
static MConverter *utf8_converter = NULL;
-static MConverter *utf32_converter = NULL;
static const gchar *keymap[] = {
"m17n:as:phonetic",
@@ -35,10 +34,6 @@ ibus_m17n_init (void)
if (utf8_converter == NULL) {
utf8_converter = mconv_buffer_converter (Mcoding_utf_8, NULL, 0);
}
-
- if (utf32_converter == NULL) {
- utf32_converter = mconv_buffer_converter (Mcoding_utf_32, NULL, 0);
- }
}
gchar *
@@ -64,25 +59,28 @@ ibus_m17n_mtext_to_utf8 (MText *text)
}
gunichar *
-ibus_m17n_mtext_to_ucs4 (MText *text)
+ibus_m17n_mtext_to_ucs4 (MText *text, glong *nchars)
{
- gint bufsize;
- gunichar *buf;
+ glong bufsize;
+ gchar *buf;
+ gunichar *ucs;
if (text == NULL)
return NULL;
- mconv_reset_converter (utf32_converter);
-
- bufsize = (mtext_len (text) + 2) * sizeof (gunichar);
- buf = (gunichar *) g_malloc (bufsize);
-
- mconv_rebind_buffer (utf32_converter, (gchar *)buf, bufsize);
- mconv_encode (utf32_converter, text);
+ mconv_reset_converter (utf8_converter);
- buf [utf32_converter->nchars] = 0;
+ bufsize = (mtext_len (text) + 1) * 6;
+ buf = (gchar *) g_malloc (bufsize);
- return buf;
+ mconv_rebind_buffer (utf8_converter, buf, bufsize);
+ if (mconv_encode (utf8_converter, text) < 0) {
+ g_free (buf);
+ return NULL;
+ }
+ ucs = g_utf8_to_ucs4_fast (buf, bufsize, nchars);
+ g_free (buf);
+ return ucs;
}
static IBusEngineDesc *
diff --git a/src/m17nutil.h b/src/m17nutil.h
index 82e7e59..707c5cc 100644
--- a/src/m17nutil.h
+++ b/src/m17nutil.h
@@ -9,5 +9,6 @@ void ibus_m17n_init (void);
GList *ibus_m17n_list_engines (void);
IBusComponent *ibus_m17n_get_component (void);
gchar *ibus_m17n_mtext_to_utf8 (MText *text);
-gunichar *ibus_m17n_mtext_to_ucs4 (MText *text);
+gunichar *ibus_m17n_mtext_to_ucs4 (MText *text,
+ glong *nchars);
#endif

View File

@ -1,98 +1,61 @@
diff --git a/src/engine.c b/src/engine.c
index e5bc115..7eac4f3 100644
index 260a806..abeeeef 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -17,6 +17,8 @@ struct _IBusM17NEngine {
IBusLookupTable *table;
IBusProperty *status_prop;
@@ -19,6 +19,8 @@ struct _IBusM17NEngine {
IBusProperty *setup_prop;
IBusPropList *prop_list;
gchar *config_section;
+ IBusProperty *show_iok_prop;
+ gchar *keymap_name;
};
struct _IBusM17NEngineClass {
@@ -134,6 +136,8 @@ ibus_m17n_engine_class_init (IBusM17NEngineClass *klass)
static void
ibus_m17n_engine_init (IBusM17NEngine *m17n)
{
+ IBusText *text;
+
m17n->status_prop = ibus_property_new ("status",
PROP_TYPE_NORMAL,
NULL,
@@ -145,9 +149,22 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
NULL);
g_object_ref_sink (m17n->status_prop);
@@ -218,10 +220,23 @@ ibus_m17n_engine_init (IBusM17NEngine *m17n)
NULL);
g_object_ref_sink (m17n->setup_prop);
+ text = ibus_text_new_from_string ("iok");
+ label = ibus_text_new_from_string ("iok");
+ m17n->show_iok_prop = ibus_property_new ("iok",
+ PROP_TYPE_NORMAL,
+ text,
+ "/usr/share/pixmaps/iok.xpm",
+ text,
+ TRUE,
+ FALSE,
+ 0,
+ NULL);
+ PROP_TYPE_NORMAL,
+ label,
+ "/usr/share/pixmaps/iok.xpm",
+ label,
+ TRUE,
+ FALSE,
+ 0,
+ NULL);
+ g_object_ref_sink (m17n->show_iok_prop);
+
m17n->prop_list = ibus_prop_list_new ();
g_object_ref_sink (m17n->prop_list);
ibus_prop_list_append (m17n->prop_list, m17n->status_prop);
ibus_prop_list_append (m17n->prop_list, m17n->setup_prop);
+ ibus_prop_list_append (m17n->prop_list, m17n->show_iok_prop);
m17n->table = ibus_lookup_table_new (9, 0, TRUE, TRUE);
g_object_ref_sink (m17n->table);
@@ -162,6 +179,7 @@ ibus_m17n_engine_constructor (GType type,
IBusM17NEngine *m17n;
MInputMethod *im;
const gchar *engine_name;
+ gchar **strv;
m17n = (IBusM17NEngine *) G_OBJECT_CLASS (parent_class)->constructor (type,
n_construct_params,
@@ -169,6 +187,15 @@ ibus_m17n_engine_constructor (GType type,
@@ -248,6 +263,7 @@ ibus_m17n_engine_constructor (GType type,
engine_name = ibus_engine_get_name ((IBusEngine *) m17n);
g_assert (engine_name);
+ m17n->keymap_name = g_strdup (engine_name);
+
+ strv = g_strsplit (engine_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
+
+ /* show iok icon for inscript */
+ if(strcmp (strv[2], "inscript") == 0 || strcmp (strv[2] , "inscript2") == 0)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
strv = g_strsplit (engine_name, ":", 3);
@@ -257,6 +273,10 @@ ibus_m17n_engine_constructor (GType type,
lang = strv[1];
name = strv[2];
+ /* show iok icon for inscript */
+ if(strcmp (name, "inscript") == 0 || strcmp (name , "inscript2") == 0)
+ ibus_property_set_visible (m17n->show_iok_prop, TRUE);
+
if (im_table == NULL) {
im_table = g_hash_table_new_full (g_str_hash,
@@ -181,12 +208,6 @@ ibus_m17n_engine_constructor (GType type,
if (im == NULL) {
gchar *lang;
gchar *name;
- gchar **strv;
-
- strv = g_strsplit (engine_name, ":", 3);
-
- g_assert (g_strv_length (strv) == 3);
- g_assert (g_strcmp0 (strv[0], "m17n") == 0);
lang = strv[1];
name = strv[2];
@@ -211,9 +232,9 @@ ibus_m17n_engine_constructor (GType type,
g_hash_table_insert (im_table, g_strdup (engine_name), im);
}
- g_strfreev (strv);
}
+ g_strfreev (strv);
if (im == NULL) {
g_warning ("Can not find m17n keymap %s", engine_name);
g_object_unref (m17n);
@@ -240,6 +261,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->status_prop = NULL;
g_str_equal,
@@ -369,6 +389,11 @@ ibus_m17n_engine_destroy (IBusM17NEngine *m17n)
m17n->setup_prop = NULL;
}
+ if (m17n->show_iok_prop) {
@ -103,35 +66,23 @@ index e5bc115..7eac4f3 100644
if (m17n->table) {
g_object_unref (m17n->table);
m17n->table = NULL;
@@ -405,6 +431,7 @@ ibus_m17n_engine_focus_in (IBusEngine *engine)
IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
ibus_engine_register_properties (engine, m17n->prop_list);
@@ -669,6 +694,19 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
LIBEXECDIR, engine_name);
g_spawn_command_line_async (setup, NULL);
g_free (setup);
+ } else if (g_strcmp0 (prop_name, "iok") == 0) {
+ gchar **strv;
+ gchar cmd[80];
+
ibus_m17n_engine_process_key (m17n, msymbol ("input-focus-in"));
parent_class->focus_in (engine);
@@ -490,6 +517,23 @@ ibus_m17n_engine_property_activate (IBusEngine *engine,
const gchar *prop_name,
guint prop_state)
{
+ gchar **strv;
+ gchar cmd[80];
+ strv = g_strsplit (m17n->keymap_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
+
+ IBusM17NEngine *m17n = (IBusM17NEngine *) engine;
+ sprintf (cmd, "/usr/bin/iok -n %s", strv[1]);
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d", m17n->keymap_name, prop_name, prop_state);
+ g_strfreev (strv);
+
+ if (g_strcmp0 (prop_name, "iok") != 0)
+ return;
+
+ strv = g_strsplit (m17n->keymap_name, ":", 3);
+ g_assert (g_strv_length (strv) == 3);
+ g_assert (g_strcmp0 (strv[0], "m17n") == 0);
+
+ sprintf (cmd, "/usr/bin/iok -n %s", strv[1]);
+ g_debug ("keymap name = %s,prop_name=%s, prop_state=%d", m17n->keymap_name, prop_name, prop_state);
+ g_strfreev (strv);
+
+ g_spawn_command_line_async(cmd, NULL);
+ g_spawn_command_line_async(cmd, NULL);
}
parent_class->property_activate (engine, prop_name, prop_state);
}

View File

@ -1,22 +1,22 @@
%define require_ibus_version 1.3.7
Name: ibus-m17n
Version: 1.3.0
Release: 4%{?dist}
Version: 1.3.1
Release: 1%{?dist}
Summary: The M17N engine for IBus platform
License: GPLv2+
Group: System Environment/Libraries
URL: http://code.google.com/p/ibus/
Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz
Patch0: ibus-m17n-HEAD.patch
Patch1: ibus-m17n-iok.patch
Patch0: ibus-m17n-iok.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: gettext-devel
BuildRequires: libtool
BuildRequires: pkgconfig
BuildRequires: m17n-lib-devel
BuildRequires: gtk2-devel
BuildRequires: ibus-devel >= %{require_ibus_version}
Requires: ibus >= %{require_ibus_version}
@ -30,7 +30,6 @@ the input table maps from m17n-db.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%build
%configure --disable-static
@ -51,9 +50,16 @@ rm -rf $RPM_BUILD_ROOT
%doc AUTHORS COPYING README
%{_datadir}/ibus-m17n
%{_libexecdir}/ibus-engine-m17n
%{_libexecdir}/ibus-setup-m17n
%{_datadir}/ibus/component/*
%changelog
* Fri Sep 3 2010 Daiki Ueno <dueno@redhat.com> - 1.3.1-1
- Update to 1.3.1.
- Fix bug 615158 - Do not change the background colour of the pre-edit buffer
- Add gtk2-devel to BR
- Install ibus-setup-m17n in %%{_libexecdir}
* Thu Aug 26 2010 Daiki Ueno <dueno@redhat.com> - 1.3.0-4
- Rebuild with ibus 1.3.7 to avoid ABI incompatibility. Bug 627256.

View File

@ -1 +1 @@
898b5ce1a685df201f959ac8feeb5a82 ibus-m17n-1.3.0.tar.gz
38ff41207518812945c60084deba0080 ibus-m17n-1.3.1.tar.gz