From 6431ac298a7b33901c516845c551c9ff4c49e056 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Wed, 3 Aug 2022 08:00:59 +0900 Subject: [PATCH] Add icon tag in ibus-anthy.appdata.xml.in - Enable IBus.Engine::has-focus-id property - Add the escape_to_latin command as a vi-cooperative cancel --- ibus-anthy-HEAD.patch | 289 ++++++++++++++++++++++++++++++++++++++++++ ibus-anthy.spec | 7 +- 2 files changed, 295 insertions(+), 1 deletion(-) diff --git a/ibus-anthy-HEAD.patch b/ibus-anthy-HEAD.patch index 04dd165..30cd3e7 100644 --- a/ibus-anthy-HEAD.patch +++ b/ibus-anthy-HEAD.patch @@ -77,3 +77,292 @@ index 88b19b8..3e82f2e 100644 -- 2.34.1 +From 2e9f751c45f1002a75e44daa200a379808479e9f Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Tue, 2 Aug 2022 11:14:48 +0900 +Subject: [PATCH] data: Add icon tag in ibus-anthy.appdata.xml.in + +--- + data/ibus-anthy.appdata.xml.in | 22 +++++ + 1 files changed, 103 insertions(+), 77 deletions(-) + +diff --git a/data/ibus-anthy.appdata.xml.in b/data/ibus-anthy.appdata.xml.in +index 8f246e9..be67f9d 100644 +--- a/data/ibus-anthy.appdata.xml.in ++++ b/data/ibus-anthy.appdata.xml.in +@@ -1,10 +1,12 @@ + ++ + + org.freedesktop.ibus.engine.anthy + GFDL-1.3 + GPL-2.0 + Anthy + Japanese input method ++ /usr/share/icons/hicolor/scalable/apps/ibus-anthy.svg + +

+ The Anthy input method is designed for entering Japanese text. +@@ -15,9 +17,29 @@ + out on a traditional keyboard. +

+
++ ++ input-method ++ Japanese ++ + https://github.com/ibus/ibus/wiki + https://github.com/ibus/ibus-anthy/issues + https://github.com/ibus/ibus/wiki/FAQ ++ https://translate.fedoraproject.org/projects/ibus/ibus-anthy/ ++ ++ ++ ++

See the upstream release list.

++
++ https://github.com/ibus/ibus-anthy/releases ++
++
++ IBus ++ ++ ++ The Anthy input method is designed for entering Japanese text. ++ https://camo.githubusercontent.com/3646c511fba557137a316be913f01fc3114e0db9c990acdfa18c29f52b5a6538/687474703a2f2f696275732e6769746875622e696f2f696d616765732f322e706e67#/ibus-anthy.jpg ++ ++ + ibus-anthy + tfujiwar_AT_redhat.com +
+-- +2.35.3 + +From 8aed07707fba1b7fafed73227916718458409c29 Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Wed, 3 Aug 2022 07:38:28 +0900 +Subject: [PATCH] engine: Enable IBus.Engine::has-focus-id property + +IBusEngineClass::has-focus-id propery has been available +since IBus 1.5.27 +IBusEngineClass::focus_in_id() class method is used instead of +IBusEngineClass::focus_id() one in case has-focus-id is %TRUE +and object_path and client name are available with the class method. +--- + engine/python2/engine.py | 22 +++++++++++++++++----- + engine/python3/engine.py | 22 +++++++++++++++++----- + 2 files changed, 34 insertions(+), 10 deletions(-) + +diff --git a/engine/python2/engine.py b/engine/python2/engine.py +index 2fb47b5..d97314a 100644 +--- a/engine/python2/engine.py ++++ b/engine/python2/engine.py +@@ -4,7 +4,7 @@ + # ibus-anthy - The Anthy engine for IBus + # + # Copyright (c) 2007-2008 Peng Huang +-# Copyright (c) 2010-2021 Takao Fujiwara ++# Copyright (c) 2010-2022 Takao Fujiwara + # Copyright (c) 2007-2018 Red Hat, Inc. + # + # This program is free software; you can redistribute it and/or modify +@@ -127,9 +127,15 @@ class Engine(IBus.EngineSimple): + __latin_with_shift = True + + def __init__(self, bus, object_path): +- super(Engine, self).__init__(engine_name="anthy", +- connection=bus.get_connection(), +- object_path=object_path) ++ if hasattr(IBus.Engine.props, 'has_focus_id'): ++ super(Engine, self).__init__(engine_name="anthy", ++ connection=bus.get_connection(), ++ object_path=object_path, ++ has_focus_id=True) ++ else: ++ super(Engine, self).__init__(engine_name="anthy", ++ connection=bus.get_connection(), ++ object_path=object_path) + + self.add_table_by_locale(None) + # create anthy context +@@ -1048,6 +1054,12 @@ class Engine(IBus.EngineSimple): + return self.__argb(255, r, g, b) + + def do_focus_in(self): ++ self.do_focus_in_id(None, None) ++ ++ def do_focus_out(self): ++ self.do_focus_out_id(None) ++ ++ def do_focus_in_id(self, object_path, client): + self.register_properties(self.__prop_list) + self.__refresh_typing_mode_property() + mode = self.__prefs.get_value('common', 'behavior-on-focus-out') +@@ -1059,7 +1071,7 @@ class Engine(IBus.EngineSimple): + if size != self.__lookup_table.get_page_size(): + self.__lookup_table.set_page_size(size) + +- def do_focus_out(self): ++ def do_focus_out_id(self, object_path): + if self.__has_input_purpose: + self.__input_purpose = 0 + mode = self.__prefs.get_value('common', 'behavior-on-focus-out') +diff --git a/engine/python3/engine.py b/engine/python3/engine.py +index df4e20d..34b7f9f 100644 +--- a/engine/python3/engine.py ++++ b/engine/python3/engine.py +@@ -4,7 +4,7 @@ + # ibus-anthy - The Anthy engine for IBus + # + # Copyright (c) 2007-2008 Peng Huang +-# Copyright (c) 2010-2021 Takao Fujiwara ++# Copyright (c) 2010-2022 Takao Fujiwara + # Copyright (c) 2007-2018 Red Hat, Inc. + # + # This program is free software; you can redistribute it and/or modify +@@ -128,9 +128,15 @@ class Engine(IBus.EngineSimple): + __latin_with_shift = True + + def __init__(self, bus, object_path): +- super(Engine, self).__init__(engine_name="anthy", +- connection=bus.get_connection(), +- object_path=object_path) ++ if hasattr(IBus.Engine.props, 'has_focus_id'): ++ super(Engine, self).__init__(engine_name="anthy", ++ connection=bus.get_connection(), ++ object_path=object_path, ++ has_focus_id=True) ++ else: ++ super(Engine, self).__init__(engine_name="anthy", ++ connection=bus.get_connection(), ++ object_path=object_path) + + self.add_table_by_locale(None) + # create anthy context +@@ -1043,6 +1049,12 @@ class Engine(IBus.EngineSimple): + return self.__argb(255, r, g, b) + + def do_focus_in(self): ++ self.do_focus_in_id(None, None) ++ ++ def do_focus_out(self): ++ self.do_focus_out_id(None) ++ ++ def do_focus_in_id(self, object_path, client): + self.register_properties(self.__prop_list) + self.__refresh_typing_mode_property() + mode = self.__prefs.get_value('common', 'behavior-on-focus-out') +@@ -1054,7 +1066,7 @@ class Engine(IBus.EngineSimple): + if size != self.__lookup_table.get_page_size(): + self.__lookup_table.set_page_size(size) + +- def do_focus_out(self): ++ def do_focus_out_id(self, object_path): + if self.__has_input_purpose: + self.__input_purpose = 0 + mode = self.__prefs.get_value('common', 'behavior-on-focus-out') +-- +2.35.3 + +From debc427fad513063cf251a1668584a198c692bd6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mangano?= +Date: Wed, 3 Aug 2022 07:38:59 +0900 +Subject: [PATCH] Add the escape_to_latin command as a vi-cooperative cancel (#29) +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When writing Japanese in Vim, everytime I switch from Insert mode back to +Normal mode, I need to also switch back the IBus input mode to Latin or +else Vim won’t take any of my input. This is kind fo annoying as key +sequences like `:w` easily get wired into muscle memory. + +For comparison, uim has got a vi-cooperative mode for that use case. See + for illustration. + +Here’s a new command which, when converting, behaves like cancel, but +otherwise switches to Latin and sends the Escape key. To make IBus +vi-cooperative, a user can map the Escape key to escape_to_latin instead +of cancel. +--- + engine/python2/engine.py | 14 ++++++++++++++ + engine/python3/engine.py | 14 ++++++++++++++ + setup/python2/anthyprefs.py | 1 + + setup/python3/anthyprefs.py | 1 + + 4 files changed, 30 insertions(+) + +diff --git a/engine/python2/engine.py b/engine/python2/engine.py +index d97314a..218b485 100644 +--- a/engine/python2/engine.py ++++ b/engine/python2/engine.py +@@ -2333,6 +2333,20 @@ class Engine(IBus.EngineSimple): + self.__invalidate() + return True + ++ def __cmd_escape_to_latin(self, keyval, state): ++ """ ++ Vi-cooperative variant of cancel_all. When Vi users press Escape, they ++ expect to return to Normal mode where an IME would not make sense. This ++ command automatically switches back to Latin when sending Escape. When ++ converting, Escape will cancel the conversion instead. ++ """ ++ if self._chk_mode('0'): ++ if Engine.__input_mode != INPUT_MODE_LATIN: ++ self.__cmd_latin_mode(keyval, state) ++ return False ++ else: ++ return self.__cmd_cancel_all(keyval, state) ++ + def __cmd_reconvert(self, keyval, state): + if not self.__preedit_ja_string.is_empty(): + # if user has inputed some chars +diff --git a/engine/python3/engine.py b/engine/python3/engine.py +index 34b7f9f..abb9c02 100644 +--- a/engine/python3/engine.py ++++ b/engine/python3/engine.py +@@ -2327,6 +2327,20 @@ class Engine(IBus.EngineSimple): + self.__invalidate() + return True + ++ def __cmd_escape_to_latin(self, keyval, state): ++ """ ++ Vi-cooperative variant of cancel_all. When Vi users press Escape, they ++ expect to return to Normal mode where an IME would not make sense. This ++ command automatically switches back to Latin when sending Escape. When ++ converting, Escape will cancel the conversion instead. ++ """ ++ if self._chk_mode('0'): ++ if Engine.__input_mode != INPUT_MODE_LATIN: ++ self.__cmd_latin_mode(keyval, state) ++ return False ++ else: ++ return self.__cmd_cancel_all(keyval, state) ++ + def __cmd_reconvert(self, keyval, state): + if not self.__preedit_ja_string.is_empty(): + # if user has inputed some chars +diff --git a/setup/python2/anthyprefs.py b/setup/python2/anthyprefs.py +index 5e3bade..c614491 100644 +--- a/setup/python2/anthyprefs.py ++++ b/setup/python2/anthyprefs.py +@@ -276,6 +276,7 @@ _cmd_keys = [ + 'predict', + 'cancel', + 'cancel_all', ++ 'escape_to_latin', + 'reconvert', + # 'do_nothing', + +diff --git a/setup/python3/anthyprefs.py b/setup/python3/anthyprefs.py +index 33b2a31..404aa09 100644 +--- a/setup/python3/anthyprefs.py ++++ b/setup/python3/anthyprefs.py +@@ -269,6 +269,7 @@ _cmd_keys = [ + 'predict', + 'cancel', + 'cancel_all', ++ 'escape_to_latin', + 'reconvert', + # 'do_nothing', + +-- +2.35.3 + diff --git a/ibus-anthy.spec b/ibus-anthy.spec index 33b0bec..85c19df 100644 --- a/ibus-anthy.spec +++ b/ibus-anthy.spec @@ -18,7 +18,7 @@ Name: ibus-anthy Version: 1.5.14 -Release: 5%{?dist} +Release: 6%{?dist} Summary: The Anthy engine for IBus input platform License: GPLv2+ URL: https://github.com/ibus/ibus/wiki @@ -156,6 +156,11 @@ make -C data check %{_datadir}/installed-tests/%{name} %changelog +* Wed Aug 03 2022 Takao Fujiwara - 1.5.14-6 +- Add icon tag in ibus-anthy.appdata.xml.in +- Enable IBus.Engine::has-focus-id property +- Add the escape_to_latin command as a vi-cooperative cancel + * Thu Jul 21 2022 Fedora Release Engineering - 1.5.14-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild