diff --git a/ibus-m17n-HEAD.patch b/ibus-m17n-HEAD.patch new file mode 100644 index 0000000..9b98dea --- /dev/null +++ b/ibus-m17n-HEAD.patch @@ -0,0 +1,263 @@ +diff --git a/Makefile.am b/Makefile.am +index eac3b9d..14a674d 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -69,7 +69,7 @@ debian/changelog: + version=@VERSION@; \ + serie=$(serie); \ + if test -z "$$serie"; then \ +- serie=lucid; \ ++ serie=maverick; \ + fi; \ + if test -z "$$release"; then \ + release=1; \ +diff --git a/configure.ac b/configure.ac +index 17077f2..4df68b6 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -89,7 +89,22 @@ fi + AM_CONDITIONAL([HAVE_GTK],[test x$with_gtk != xno]) + + # check if minput_list, which is available in m17n-lib 1.6.2+ (CVS) ++save_CFLAGS="$CFLAGS" ++save_LIBS="$LIBS" ++CFLAGS="$CFLAGS $M17N_CFLAGS" ++LIBS="$LIBS $M17N_LIBS" + AC_REPLACE_FUNCS([minput_list]) ++CFLAGS="$save_CFLAGS" ++LIBS="$save_LIBS" ++ ++# check if ibus_engine_get_surrounding_text, which is available in ibus-1.3.99+ (git master) ++save_CFLAGS="$CFLAGS" ++save_LIBS="$LIBS" ++CFLAGS="$CFLAGS $IBUS_CFLAGS" ++LIBS="$LIBS $IBUS_LIBS" ++AC_CHECK_FUNCS([ibus_engine_get_surrounding_text]) ++CFLAGS="$save_CFLAGS" ++LIBS="$save_LIBS" + + # define GETTEXT_* variables + GETTEXT_PACKAGE=ibus-m17n +diff --git a/src/engine.c b/src/engine.c +index 62359c1..60816b0 100644 +--- a/src/engine.c ++++ b/src/engine.c +@@ -1,4 +1,7 @@ + /* vim:set et sts=4: */ ++#ifdef HAVE_CONFIG_H ++#include ++#endif + + #include + #include +@@ -6,23 +9,6 @@ + #include "m17nutil.h" + #include "engine.h" + +-/* type module to assign different GType to each engine */ +-#define IBUS_TYPE_M17N_TYPE_MODULE (ibus_m17n_type_module_get_type ()) +-#define IBUS_M17N_TYPE_MODULE (module) (G_TYPE_CHECK_INSTANCE_CAST (module, IBUS_TYPE_M17N_TYPE_MODULE, IBusM17NTypeModule) +- +-typedef struct _IBusM17NTypeModule IBusM17NTypeModule; +-typedef struct _IBusM17NTypeModuleClass IBusM17NTypeModuleClass; +- +-struct _IBusM17NTypeModule +-{ +- GTypeModule parent_instance; +-}; +- +-struct _IBusM17NTypeModuleClass +-{ +- GTypeModuleClass parent_class; +-}; +- + typedef struct _IBusM17NEngine IBusM17NEngine; + typedef struct _IBusM17NEngineClass IBusM17NEngineClass; + +@@ -53,10 +39,7 @@ struct _IBusM17NEngineClass { + }; + + /* functions prototype */ +-static GType +- ibus_m17n_type_module_get_type (void); + static void ibus_m17n_engine_class_init (IBusM17NEngineClass *klass); +-static void ibus_m17n_engine_class_finalize (IBusM17NEngineClass *klass); + static void ibus_m17n_config_value_changed (IBusConfig *config, + const gchar *section, + const gchar *name, +@@ -119,7 +102,6 @@ static void ibus_m17n_engine_update_lookup_table + static IBusEngineClass *parent_class = NULL; + + static IBusConfig *config = NULL; +-static IBusM17NTypeModule *module = NULL; + + void + ibus_m17n_init (IBusBus *bus) +@@ -128,55 +110,6 @@ ibus_m17n_init (IBusBus *bus) + if (config) + g_object_ref_sink (config); + ibus_m17n_init_common (); +- +- module = g_object_new (IBUS_TYPE_M17N_TYPE_MODULE, NULL); +-} +- +-static gboolean +-ibus_m17n_type_module_load (GTypeModule *module) +-{ +- return TRUE; +-} +- +-static void +-ibus_m17n_type_module_unload (GTypeModule *module) +-{ +-} +- +-static void +-ibus_m17n_type_module_class_init (IBusM17NTypeModuleClass *klass) +-{ +- GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (klass); +- +- module_class->load = ibus_m17n_type_module_load; +- module_class->unload = ibus_m17n_type_module_unload; +-} +- +-static GType +-ibus_m17n_type_module_get_type (void) +-{ +- static GType type = 0; +- +- static const GTypeInfo type_info = { +- sizeof (IBusM17NTypeModuleClass), +- (GBaseInitFunc) NULL, +- (GBaseFinalizeFunc) NULL, +- (GClassInitFunc) ibus_m17n_type_module_class_init, +- (GClassFinalizeFunc) NULL, +- NULL, +- sizeof (IBusM17NTypeModule), +- 0, +- (GInstanceInitFunc) NULL, +- }; +- +- if (type == 0) { +- type = g_type_register_static (G_TYPE_TYPE_MODULE, +- "IBusM17NTypeModule", +- &type_info, +- (GTypeFlags) 0); +- } +- +- return type; + } + + static gboolean +@@ -239,14 +172,14 @@ ibus_m17n_engine_get_type_for_name (const gchar *engine_name) + + GTypeInfo type_info = { + sizeof (IBusM17NEngineClass), +- (GBaseInitFunc) NULL, +- (GBaseFinalizeFunc) NULL, +- (GClassInitFunc) ibus_m17n_engine_class_init, +- (GClassFinalizeFunc)ibus_m17n_engine_class_finalize, ++ (GBaseInitFunc) NULL, ++ (GBaseFinalizeFunc) NULL, ++ (GClassInitFunc) ibus_m17n_engine_class_init, ++ (GClassFinalizeFunc) NULL, + NULL, + sizeof (IBusM17NEngine), + 0, +- (GInstanceInitFunc) ibus_m17n_engine_init, ++ (GInstanceInitFunc) ibus_m17n_engine_init, + }; + + if (!ibus_m17n_scan_engine_name (engine_name, &lang, &name)) { +@@ -264,11 +197,10 @@ ibus_m17n_engine_get_type_for_name (const gchar *engine_name) + g_assert (type == 0 || g_type_is_a (type, IBUS_TYPE_ENGINE)); + + if (type == 0) { +- type = g_type_module_register_type (G_TYPE_MODULE (module), +- IBUS_TYPE_ENGINE, +- type_name, +- &type_info, +- (GTypeFlags) 0); ++ type = g_type_register_static (IBUS_TYPE_ENGINE, ++ type_name, ++ &type_info, ++ (GTypeFlags) 0); + } + g_free (type_name); + +@@ -408,14 +340,6 @@ ibus_m17n_config_value_changed (IBusConfig *config, + } + + static void +-ibus_m17n_engine_class_finalize (IBusM17NEngineClass *klass) +-{ +- if (klass->im) +- minput_close_im (klass->im); +- g_free (klass->config_section); +-} +- +-static void + ibus_m17n_engine_init (IBusM17NEngine *m17n) + { + IBusText* label; +@@ -986,8 +910,57 @@ ibus_m17n_engine_callback (MInputContext *context, + } + else if (command == Minput_reset) { + } +- else if (command == Minput_get_surrounding_text) { +- } +- else if (command == Minput_delete_surrounding_text) { ++ /* ibus_engine_get_surrounding_text is only available in the current ++ git master (1.3.99+) */ ++#ifdef HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT ++ else if (command == Minput_get_surrounding_text && ++ (((IBusEngine *) m17n)->client_capabilities & ++ IBUS_CAP_SURROUNDING_TEXT) != 0) { ++ IBusText *text; ++ guint cursor_pos, nchars, nbytes; ++ MText *mt, *surround; ++ int len, pos; ++ ++ ibus_engine_get_surrounding_text ((IBusEngine *) m17n, ++ &text, ++ &cursor_pos); ++ nchars = ibus_text_get_length (text); ++ nbytes = g_utf8_offset_to_pointer (text->text, nchars) - text->text; ++ mt = mconv_decode_buffer (Mcoding_utf_8, text->text, nbytes); ++ g_object_unref (text); ++ ++ len = (long) mplist_value (m17n->context->plist); ++ if (len < 0) { ++ pos = cursor_pos + len; ++ if (pos < 0) ++ pos = 0; ++ surround = mtext_duplicate (mt, pos, cursor_pos); ++ } ++ else if (len > 0) { ++ pos = cursor_pos + len; ++ if (pos > nchars) ++ pos = nchars; ++ surround = mtext_duplicate (mt, cursor_pos, pos); ++ } ++ else { ++ surround = mtext (); ++ } ++ m17n_object_unref (mt); ++ mplist_set (m17n->context->plist, Mtext, surround); ++ m17n_object_unref (surround); ++ } ++#endif /* !HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT */ ++ else if (command == Minput_delete_surrounding_text && ++ (((IBusEngine *) m17n)->client_capabilities & ++ IBUS_CAP_SURROUNDING_TEXT) != 0) { ++ int len; ++ ++ len = (long) mplist_value (m17n->context->plist); ++ if (len < 0) ++ ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, ++ len, -len); ++ else if (len > 0) ++ ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, ++ 0, len); + } + } diff --git a/ibus-m17n-surrounding-text.patch b/ibus-m17n-surrounding-text.patch deleted file mode 100644 index 37c90c5..0000000 --- a/ibus-m17n-surrounding-text.patch +++ /dev/null @@ -1,99 +0,0 @@ -From 589f9dc5998dc5ea620d1e6fa1a64045574b1dc1 Mon Sep 17 00:00:00 2001 -From: Daiki Ueno -Date: Mon, 7 Mar 2011 15:06:38 +0900 -Subject: [PATCH] Support surrounding-text commands. - ---- - src/engine.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- - src/m17nutil.c | 8 ++++++++ - 2 files changed, 55 insertions(+), 2 deletions(-) - -diff --git a/src/engine.c b/src/engine.c -index 62359c1..ebe7ccc 100644 ---- a/src/engine.c -+++ b/src/engine.c -@@ -986,8 +986,53 @@ ibus_m17n_engine_callback (MInputContext *context, - } - else if (command == Minput_reset) { - } -- else if (command == Minput_get_surrounding_text) { -+ else if (command == Minput_get_surrounding_text && -+ (((IBusEngine *) m17n)->client_capabilities & -+ IBUS_CAP_SURROUNDING_TEXT) != 0) { -+ IBusText *text; -+ guint cursor_pos, nchars, nbytes; -+ MText *mt, *surround; -+ int len, pos; -+ -+ ibus_engine_get_surrounding_text ((IBusEngine *) m17n, -+ &text, -+ &cursor_pos); -+ nchars = ibus_text_get_length (text); -+ nbytes = g_utf8_offset_to_pointer (text->text, nchars) - text->text; -+ mt = mconv_decode_buffer (Mcoding_utf_8, text->text, nbytes); -+ g_object_unref (text); -+ -+ len = (long) mplist_value (m17n->context->plist); -+ if (len < 0) { -+ pos = cursor_pos + len; -+ if (pos < 0) -+ pos = 0; -+ surround = mtext_duplicate (mt, pos, cursor_pos); -+ } -+ else if (len > 0) { -+ pos = cursor_pos + len; -+ if (pos > nchars) -+ pos = nchars; -+ surround = mtext_duplicate (mt, cursor_pos, pos); -+ } -+ else { -+ surround = mtext (); -+ } -+ m17n_object_unref (mt); -+ mplist_set (m17n->context->plist, Mtext, surround); -+ m17n_object_unref (surround); - } -- else if (command == Minput_delete_surrounding_text) { -+ else if (command == Minput_delete_surrounding_text && -+ (((IBusEngine *) m17n)->client_capabilities & -+ IBUS_CAP_SURROUNDING_TEXT) != 0) { -+ int len; -+ -+ len = (long) mplist_value (m17n->context->plist); -+ if (len < 0) -+ ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, -+ len, -len); -+ else if (len > 0) -+ ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, -+ 0, len); - } - } -diff --git a/src/m17nutil.c b/src/m17nutil.c -index 1150cc4..db99686 100644 ---- a/src/m17nutil.c -+++ b/src/m17nutil.c -@@ -91,6 +91,13 @@ ibus_m17n_parse_color (const gchar *hex) - return color; - } - -+#define DEFAULT_REQUIRES (IBUS_CAP_PREEDIT_TEXT | \ -+ IBUS_CAP_AUXILIARY_TEXT | \ -+ IBUS_CAP_LOOKUP_TABLE | \ -+ IBUS_CAP_FOCUS | \ -+ IBUS_CAP_PROPERTY | \ -+ IBUS_CAP_SURROUNDING_TEXT) -+ - static IBusEngineDesc * - ibus_m17n_engine_new (MSymbol lang, - MSymbol name, -@@ -122,6 +129,7 @@ ibus_m17n_engine_new (MSymbol lang, - "icon", engine_icon ? engine_icon : "", - "layout", "us", - "rank", config->rank, -+ "requires", DEFAULT_REQUIRES, - NULL); - #else - engine = ibus_engine_desc_new (engine_name, --- -1.7.4 - diff --git a/ibus-m17n.spec b/ibus-m17n.spec index fcc840e..a3cc0a3 100644 --- a/ibus-m17n.spec +++ b/ibus-m17n.spec @@ -2,7 +2,7 @@ Name: ibus-m17n Version: 1.3.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: The M17N engine for IBus platform License: GPLv2+ Group: System Environment/Libraries @@ -10,14 +10,14 @@ URL: http://code.google.com/p/ibus/ Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz Patch0: ibus-m17n-iok.patch -Patch1: ibus-m17n-surrounding-text.patch +Patch1: ibus-m17n-HEAD.patch # The following BR is for autogen and not necessary when packging # released tarballs. -# BuildRequires: gettext-devel -# BuildRequires: libtool -# BuildRequires: pkgconfig -# BuildRequires: gnome-common +BuildRequires: gettext-devel +BuildRequires: libtool +BuildRequires: pkgconfig +BuildRequires: gnome-common BuildRequires: m17n-lib-devel BuildRequires: gtk3-devel BuildRequires: ibus-devel >= %{require_ibus_version} @@ -33,8 +33,8 @@ the input table maps from m17n-db. %prep %setup -q %patch0 -p1 -b .iok -%patch1 -p1 -b .surrounding-text -# NOCONFIGURE=1 ./autogen.sh +%patch1 -p1 -b .HEAD +NOCONFIGURE=1 ./autogen.sh %build %configure --disable-static --with-gtk=3.0 @@ -55,6 +55,9 @@ make DESTDIR=${RPM_BUILD_ROOT} install %{_datadir}/ibus/component/* %changelog +* Mon May 23 2011 Daiki Ueno - 1.3.2-3 +- Update ibus-m17n-HEAD.patch. + * Mon May 23 2011 Daiki Ueno - 1.3.2-2 - Bump the release to fix upgrade path. - Fix bug 706602 - ibus-m17n-1.3.2-2.fc14 > ibus-m17n-1.3.2-1.fc15