Accepting request 781214 from home:hillwood:branches:M17N

- Use python3, python2 is EOF. Add ibus-sunpinyin-migrate-to-python3.patch

OBS-URL: https://build.opensuse.org/request/show/781214
OBS-URL: https://build.opensuse.org/package/show/M17N/ibus-sunpinyin?expand=0&rev=33
This commit is contained in:
Hillwood Yang 2020-03-03 13:25:08 +00:00 committed by Git OBS Bridge
parent 14731aaaa0
commit e3b48b12a2
3 changed files with 584 additions and 3 deletions

View File

@ -0,0 +1,574 @@
diff -Nur sunpinyin/wrapper/ibus/debian/changelog sunpinyin-new/wrapper/ibus/debian/changelog
--- sunpinyin/wrapper/ibus/debian/changelog 1970-01-01 08:00:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/debian/changelog 2020-03-03 20:33:45.210426000 +0800
@@ -0,0 +1,5 @@
+ibus-sunpinyin (2.0.2~git20100607) unstable; urgency=low
+
+ * first debian package
+
+ -- Mike Qin <mikeandmore@gmail.com> Mon, 23 May 2010 11:20:00 +0800
diff -Nur sunpinyin/wrapper/ibus/debian/control.in sunpinyin-new/wrapper/ibus/debian/control.in
--- sunpinyin/wrapper/ibus/debian/control.in 1970-01-01 08:00:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/debian/control.in 2020-03-03 20:33:45.210426000 +0800
@@ -0,0 +1,15 @@
+Source: ibus-sunpinyin
+Section: util
+Priority: optional
+Maintainer: Mike Qin <mikeandmore@gmail.com>
+Build-Depends: @cdbs@, pkg-config, libgtk2.0-dev (>=2.12.0),
+ libsqlite3-dev (>=3.6), libsunpinyin3-dev, libibus-dev (>=1.2.0)
+Standards-Version: 3.8.4
+Homepage: http://code.google.com/p/sunpinyin/
+
+Package: ibus-sunpinyin
+Architecture: any
+Section: util
+Priority: optional
+Depends: libsunpinyin3, ${shlibs:Depends}, ${misc:Depends}
+Homepage: http://code.google.com/p/sunpinyin/
diff -Nur sunpinyin/wrapper/ibus/debian/rules sunpinyin-new/wrapper/ibus/debian/rules
--- sunpinyin/wrapper/ibus/debian/rules 1970-01-01 08:00:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/debian/rules 2020-03-03 20:33:45.210426000 +0800
@@ -0,0 +1,10 @@
+#!/usr/bin/make -f
+# -*- mode: makefile; indent-tabs-mode: t -*- vim:noet:ts=4
+
+include /usr/share/cdbs/1/class/scons.mk
+include /usr/share/cdbs/1/rules/debhelper.mk
+
+DEB_SCONS_BUILD_OPTIONS := --prefix=/usr
+DEB_SCONS_INSTALL_OPTIONS := $(DEB_SCONS_BUILD_OPTIONS) \
+ --install-sandbox=$(DEB_DESTDIR)
+
diff -Nur sunpinyin/wrapper/ibus/.gitignore sunpinyin-new/wrapper/ibus/.gitignore
--- sunpinyin/wrapper/ibus/.gitignore 1970-01-01 08:00:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/.gitignore 2020-03-03 20:33:45.210426000 +0800
@@ -0,0 +1,3 @@
+cmakebuild/
+setup/ibus-setup-sunpinyin
+
diff -Nur sunpinyin/wrapper/ibus/po/.gitignore sunpinyin-new/wrapper/ibus/po/.gitignore
--- sunpinyin/wrapper/ibus/po/.gitignore 1970-01-01 08:00:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/po/.gitignore 2020-03-03 20:33:45.210426000 +0800
@@ -0,0 +1,4 @@
+POTFILES
+stamp-it
+Makefile.in.in
+
diff -Nur sunpinyin/wrapper/ibus/setup/ibus-setup-sunpinyin.in sunpinyin-new/wrapper/ibus/setup/ibus-setup-sunpinyin.in
--- sunpinyin/wrapper/ibus/setup/ibus-setup-sunpinyin.in 2016-05-08 21:57:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/setup/ibus-setup-sunpinyin.in 2020-03-03 21:08:09.694916205 +0800
@@ -4,4 +4,4 @@
exec_prefix=${prefix}
export IBUS_PREFIX=${prefix}
export IBUS_LOCALEDIR=${prefix}/share/locale
-exec python @DATA_DIR@/setup/main.py $@
+exec python3 @DATA_DIR@/setup/main.py $@
diff -Nur sunpinyin/wrapper/ibus/setup/main.py sunpinyin-new/wrapper/ibus/setup/main.py
--- sunpinyin/wrapper/ibus/setup/main.py 2016-05-08 21:57:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/setup/main.py 2020-03-03 21:07:39.739075161 +0800
@@ -1,5 +1,6 @@
+#!/usr/bin/python3
# -*- coding: utf-8 -*-
-#
+#
# Copyright (c) 2009 Leo Zheng <zym361@gmail.com>, Kov Chai <tchaikov@gmail.com>
# *
# The contents of this file are subject to the terms of either the GNU Lesser
@@ -7,12 +8,12 @@
# Distribution License ("CDDL")(collectively, the "License"). You may not use this
# file except in compliance with the License. You can obtain a copy of the CDDL at
# http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at
-# http://www.opensource.org/licenses/lgpl-license.php. See the License for the
+# http://www.opensource.org/licenses/lgpl-license.php. See the License for the
# specific language governing permissions and limitations under the License. When
# distributing the software, include this License Header Notice in each file and
# include the full text of the License in the License file as well as the
# following notice:
-#
+#
# NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
# (CDDL)
# For Covered Software in this distribution, this License shall be governed by the
@@ -20,9 +21,9 @@
# Any litigation relating to this License shall be subject to the jurisdiction of
# the Federal Courts of the Northern District of California and the state courts
# of the State of California, with venue lying in Santa Clara County, California.
-#
+#
# Contributor(s):
-#
+#
# If you wish your version of this file to be governed by only the CDDL or only
# the LGPL Version 2.1, indicate your decision by adding "[Contributor]" elects to
# include this software in this distribution under the [CDDL or LGPL Version 2.1]
@@ -31,14 +32,26 @@
# Version 2.1, or to extend the choice of license to its licensees as provided
# above. However, if you add LGPL Version 2.1 code and therefore, elected the LGPL
# Version 2 license, then the option applies only if the new code is made subject
-# to such option by the copyright holder.
+# to such option by the copyright holder.
#
import sys
import os
from os import path
-import gtk
-import ibus
+try:
+ import gtk
+ import glib
+except ImportError:
+ from gi import require_version as gi_require_version
+ gi_require_version('Gtk', '3.0')
+ from gi.repository import Gtk as gtk
+ from gi.repository import GLib as glib
+try:
+ import ibus
+except ImportError:
+ from gi import require_version as gi_require_version
+ gi_require_version('IBus', '1.0')
+ from gi.repository import IBus as ibus
import gettext
import locale
@@ -52,27 +65,35 @@
@staticmethod
def pr(message):
print >> sys.stderr, message
-
+
+
class Option(object):
"""Option serves as an interface of ibus.config
it is used to synchronize the configuration with setting on user interface
"""
config = ibus.Bus().get_config()
-
+ __wrappers = {
+ type(True): glib.Variant.new_boolean,
+ type(1): glib.Variant.new_int32,
+ type('str'): glib.Variant.new_string,
+ type([]): glib.Variant.new_strv,
+ }
+
def __init__(self, name, default):
self.name = name
self.default = default
-
+ self.__wrap = self.__wrappers[type(self.default)]
+
def read(self):
section, key = self.__get_config_name()
- return self.config.get_value(section, key, self.default)
+ wrapped = self.config.get_value(section, key)
+ return self.default if wrapped is None else wrapped.unpack()
def write(self, v):
section, key = self.__get_config_name()
- return self.config.set_value(section, key, type(self.default)(v))
+ return self.config.set_value(section, key, self.__wrap(v))
-
def __get_config_name(self):
keys = self.name.rsplit(SEPARATOR ,1)
if len(keys) == 2:
@@ -96,7 +117,7 @@
def init(self):
pass
-
+
def read_config(self):
"""update user inferface with ibus.config
"""
@@ -106,13 +127,13 @@
def write_config(self):
v = self.save_ui_setting()
self.write(v)
-
+
def save_ui_setting(self):
"""save user interface settings into self.v
"""
self.v = self.__get_value()
return self.v
-
+
def is_changed(self):
return self.v != self.__get_value()
@@ -127,7 +148,7 @@
self.widget.set_value(v)
except:
self.widget.set_active(v)
-
+
class CheckBoxOption(TrivalOption):
def __init__(self, name, default, owner):
super(CheckBoxOption, self).__init__(name, default, owner)
@@ -140,7 +161,7 @@
default = options.index(default)
super(ComboBoxOption, self).__init__(name, default, owner)
self.options = options
-
+
def init(self):
model = gtk.ListStore(str)
for v in self.options:
@@ -156,7 +177,7 @@
except ValueError:
# otherwise save its index
return active
-
+
def __set_value(self, v):
try:
# if the options are just numbers, we treat 'self.v' as the literal
@@ -166,7 +187,7 @@
except ValueError:
active = v
self.widget.set_active(active)
-
+
class RadioOption(Option):
"""option represented using multiple Raidio buttons
"""
@@ -177,7 +198,7 @@
def init_ui(self):
self.read_config()
-
+
def read_config(self):
self.v = self.read()
name = SEPARATOR.join([self.name, self.v])
@@ -200,7 +221,7 @@
def __init__(self, name, mapping):
self.name = name
self.mapping = mapping
-
+
class MappingOption(object):
"""an option which presents some sort of mapping, e.g. fuzzy pinyin mapping
@@ -211,7 +232,7 @@
self.name = name
self.widget = owner.get_object(name)
self.mappings = mappings
-
+
def get_mappings(self):
if self.widget.get_active():
return [':'.join(self.mappings)]
@@ -223,18 +244,18 @@
def get_active(self):
return self.widget.get_active()
-
+
is_enabled = property(get_active, set_active)
def key(self):
return self.mappings[0]
-
+
class MultiMappingOption(Option):
def __init__(self, name, options, default=[]):
Option.__init__(self, name, default)
self.options = options
self.saved_pairs = default
-
+
def read_config(self):
if not self.saved_pairs:
self.saved_pairs = self.read()
@@ -242,24 +263,24 @@
for opt in self.options:
opt.is_enabled = (opt.key() in keys)
# throw away unknown pair
-
+
def write_config(self):
# ignore empty settings
if self.saved_pairs:
self.write(self.saved_pairs)
-
+
def save_ui_setting(self):
self.saved_pairs = sum([opt.get_mappings() for opt in self.options
if opt.is_enabled], [])
return self.saved_pairs
-
+
def set_active_all(self, enabled):
for opt in self.options:
opt.is_enabled = enabled
-
+
class MultiCheckDialog (object):
""" a modal dialog box with 'choose all' and 'choose none' button
-
+
TODO: another option is to use radio button
"""
def __init__ (self, ui_name, config_name, mappings, option_klass=MappingOption):
@@ -269,25 +290,26 @@
self.option_klass = option_klass
self.saved_settings = []
self.mapping_options = None
-
+
def get_setup_name(self):
"""assuming the name of dialog looks like 'dlg_fuzzy_setup'
"""
return '_'.join(['dlg', self.ui_name, 'setup'])
-
- def __init_ui(self):
+
+ def __init_ui(self, parent_window):
dlg_name = self.get_setup_name()
self.__xml = gtk.Builder()
self.__xml.add_objects_from_file(XML_FILE, [dlg_name])
self.__dlg = self.__xml.get_object(dlg_name)
assert self.__dlg is not None, "dialog %s not found in %s" % (dlg_name, XML_FILE)
+ self.__dlg.set_transient_for(parent_window)
handlers = {'_'.join(["on", self.ui_name, "select_all_clicked"]) : self.on_button_check_all_clicked,
'_'.join(["on", self.ui_name, "unselect_all_clicked"]) : self.on_button_uncheck_all_clicked,
'_'.join(["on", self.ui_name, "ok_clicked"]) : self.on_button_ok_clicked,
'_'.join(["on", self.ui_name, "cancel_clicked"]) : self.on_button_cancel_clicked}
self.__xml.connect_signals(handlers)
- options = [self.option_klass(m.name, m.mapping, self.__xml)
+ options = [self.option_klass(m.name, m.mapping, self.__xml)
for m in self.mappings]
self.mapping_options = MultiMappingOption(self.config_name, options, self.saved_settings)
@@ -298,15 +320,15 @@
pass
init_ui = read_config = dummy
-
- def run(self):
- self.__init_ui()
+
+ def run(self, parent_window):
+ self.__init_ui(parent_window)
self.__read_config()
self.__dlg.run()
-
+
def __read_config(self):
self.mapping_options.read_config()
-
+
def __save_ui_settings(self):
"""save to in-memory storage, will flush to config if not canceled in main_window
"""
@@ -315,20 +337,20 @@
def write_config(self):
if self.mapping_options is not None:
self.mapping_options.write_config()
-
+
def on_button_check_all_clicked(self, button):
self.mapping_options.set_active_all(True)
-
+
def on_button_uncheck_all_clicked(self, button):
self.mapping_options.set_active_all(False)
-
+
def on_button_ok_clicked(self, button):
"""update given options with settings in UI, these settings will be
written to config if user push 'OK' or 'Apply' in the main window
"""
self.__save_ui_settings()
self.__dlg.destroy()
-
+
def on_button_cancel_clicked(self, button):
self.__dlg.destroy()
@@ -353,7 +375,7 @@
ui_name = 'fuzzy',
config_name = 'QuanPin/Fuzzy/Pinyins',
mappings = mappings)
-
+
class CorrectionSetupDialog (MultiCheckDialog):
def __init__(self):
mappings = [MappingInfo('QuanPin/AutoCorrection/GnNg', ('gn','ng')),
@@ -374,7 +396,7 @@
self.init_keys_values(mappings)
else:
self.widget.set_sensitive(False)
-
+
def init_keys_values(self, mappings):
self.keys = [m[0] for m in mappings]
values_with_closing = [v or k for k, v in mappings]
@@ -412,7 +434,7 @@
self.widget.set_active(enabled)
is_enabled = property(MappingOption.get_active, set_active)
-
+
def key(self):
for k, v in self.mappings:
if v is not None:
@@ -460,13 +482,13 @@
def __init__ (self):
self.__bus = ibus.Bus()
self.__config = self.__bus.get_config()
-
-
+
+
def run(self):
self.__init_ui("main_window")
self.__read_config()
gtk.main()
-
+
def __init_ui(self, name):
self.__init_gettext()
xml_file = path.join(path.dirname(__file__), XML_FILE)
@@ -488,19 +510,19 @@
self.__fuzzy_setup = FuzzySetupDialog()
self.__correction_setup = CorrectionSetupDialog()
self.__punctmapping_setup = PunctMappingSetupDialog()
-
+
self.__options = [
TrivalOption("General/MemoryPower", 3, self.__xml),
TrivalOption("General/PageSize", 10, self.__xml),
TrivalOption("General/MaxBest", 1, self.__xml),
TrivalOption("General/MaxTailCandidate", 0, self.__xml),
-
+
RadioOption("General/InitialStatus/Mode", 'Chinese', ['Chinese', 'English'], self.__xml),
RadioOption("General/InitialStatus/Punct", 'Full', ['Full', 'Half'], self.__xml),
RadioOption("General/InitialStatus/Letter", 'Half', ['Full', 'Half'], self.__xml),
RadioOption("General/Charset", 'GBK', ['GB2312', 'GBK', 'GB18030'], self.__xml),
CheckBoxOption("General/PunctMapping/Enabled", False, self.__xml),
-
+
RadioOption("Keyboard/ModeSwitch", 'Shift', ['Shift', 'Control'], self.__xml),
RadioOption("Keyboard/PunctSwitch", 'None', ['ControlComma',
'ControlPeriod',
@@ -510,7 +532,7 @@
CheckBoxOption("Keyboard/Page/CommaPeriod", False, self.__xml),
CheckBoxOption("Keyboard/CancelBackspace", True, self.__xml),
CheckBoxOption("Keyboard/SmartPunct", True, self.__xml),
-
+
RadioOption("Pinyin/Scheme", 'QuanPin', ['QuanPin', 'ShuangPin'], self.__xml),
ComboBoxOption("Pinyin/ShuangPinType", 'MS2003', ['MS2003',
'ABC',
@@ -522,7 +544,7 @@
CheckBoxOption("QuanPin/AutoCorrection/Enabled", False, self.__xml),
CheckBoxOption("QuanPin/FuzzySegs/Enabled", False, self.__xml),
CheckBoxOption("QuanPin/InnerFuzzy/Enabled", False, self.__xml),
-
+
self.__fuzzy_setup,
self.__correction_setup,
self.__punctmapping_setup,
@@ -534,7 +556,7 @@
return opt
else:
return None
-
+
def __read_config(self):
for opt in self.__options:
opt.init_ui()
@@ -543,7 +565,7 @@
self.on_chk_correction_enabled_toggled(None)
self.on_chk_punctmapping_enabled_toggled(None)
self.on_radio_shuangpin_toggled(None)
-
+
def __write_config(self):
for opt in self.__options:
opt.write_config()
@@ -563,14 +585,14 @@
enabled = radio.get_active()
combo = self.__xml.get_object("Pinyin/ShuangPinType")
combo.set_sensitive(enabled)
-
+
def on_chk_fuzzy_enabled_toggled(self, button):
self.__update_enabling_button("QuanPin/Fuzzy/Enabled",
"button_fuzzy_setup")
-
+
def on_button_fuzzy_setup_clicked(self, button):
- self.__fuzzy_setup.run()
-
+ self.__fuzzy_setup.run(self.window)
+
def on_chk_correction_enabled_toggled(self, button):
self.__update_enabling_button("QuanPin/AutoCorrection/Enabled",
"button_correction_setup")
@@ -580,19 +602,19 @@
"QuanPin/InnerFuzzy/Enabled")
def on_button_correction_setup_clicked(self, button):
- self.__correction_setup.run()
-
+ self.__correction_setup.run(self.window)
+
def on_chk_punctmapping_enabled_toggled(self, button):
self.__update_enabling_button("General/PunctMapping/Enabled",
"button_punctmapping_setup")
-
+
def on_button_punctmapping_setup_clicked(self, button):
- self.__punctmapping_setup.run()
-
+ self.__punctmapping_setup.run(self.window)
+
def on_main_ok_clicked(self, button):
self.__write_config()
self.__quit()
-
+
def on_main_apply_clicked(self, button):
self.__write_config()
@@ -601,7 +623,7 @@
def __quit(self):
gtk.main_quit()
-
+
if __name__ == "__main__":
MainWindow().run()
diff -Nur sunpinyin/wrapper/ibus/setup/setup.xml sunpinyin-new/wrapper/ibus/setup/setup.xml
--- sunpinyin/wrapper/ibus/setup/setup.xml 2016-05-08 21:57:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/setup/setup.xml 2020-03-03 20:33:45.210426000 +0800
@@ -50,7 +50,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
- <signal name="clicked" handler="on_correction_uncheck_all_clicked" swapped="no"/>
+ <signal name="clicked" handler="on_correction_unselect_all_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
diff -Nur sunpinyin/wrapper/ibus/src/sunpinyin_engine.cpp sunpinyin-new/wrapper/ibus/src/sunpinyin_engine.cpp
--- sunpinyin/wrapper/ibus/src/sunpinyin_engine.cpp 2016-05-08 21:57:00.000000000 +0800
+++ sunpinyin-new/wrapper/ibus/src/sunpinyin_engine.cpp 2020-03-03 20:33:45.210426000 +0800
@@ -131,7 +131,7 @@
if (getenv("DISABLE_HARD_FORWARD") == NULL) {
// Ctrl+<space> is pressed. let's just hard code these.
- // it looks rediculous, but on what else do you need to do this hack?
+ // it looks ridiculous, but on what else do you need to do this hack?
if (key.code == 0x20 && key.modifiers == IM_CTRL_MASK) {
m_hard_forward = !m_hard_forward;
return TRUE;

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Mar 3 12:38:51 UTC 2020 - Hillwood Yang <hillwood@opensuse.org>
- Use python3, python2 is EOF. Add ibus-sunpinyin-migrate-to-python3.patch
-------------------------------------------------------------------
Fri Apr 13 08:09:00 UTC 2018 - hillwood@opensuse.org

View File

@ -26,6 +26,8 @@ Url: https://github.com/sunpinyin/sunpinyin
Source: https://github.com/sunpinyin/sunpinyin/archive/v3.0.0-rc1/sunpinyin-3.0.0-rc1.tar.gz
# PATCH-FIX-UPSTREAM ibus-sunpinyin-scons-on-py3.patch dimstar@opensuse.org -- Fix build with scons using python3 as interpreter
Patch0: ibus-sunpinyin-scons-on-py3.patch
# PATCH-FIX-UPSTREAM ibus-sunpinyin-migrate-to-python3.patch hillwood@opensuse.org -- Use python3, python2 is EOF
Patch1: ibus-sunpinyin-migrate-to-python3.patch
BuildRequires: gcc-c++
BuildRequires: intltool
BuildRequires: scons >= 1.2.0
@ -33,7 +35,6 @@ BuildRequires: pkgconfig(ibus-1.0)
BuildRequires: pkgconfig(python2)
BuildRequires: pkgconfig(sqlite3)
BuildRequires: pkgconfig(sunpinyin-2.0)
Requires: python-ibus
Requires: sunpinyin-data
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -44,6 +45,7 @@ SunPinyin with IBus framework.
%prep
%setup -q -n sunpinyin-3.0.0-rc1
%patch0 -p1
%patch1 -p1
sed -i "s/LIBEXECDIR'\].*ibus-sunpinyin.*/LIBEXECDIR'\]/" SConstruct
%build
@ -64,8 +66,8 @@ popd
%files -f %{name}.lang
%defattr(-,root,root)
%doc wrapper/ibus/README wrapper/ibus/COPYING
%doc wrapper/ibus/LGPL.LICENSE wrapper/ibus/OPENSOLARIS.LICENSE
%doc wrapper/ibus/README
%license wrapper/ibus/COPYING wrapper/ibus/LGPL.LICENSE wrapper/ibus/OPENSOLARIS.LICENSE
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/ibus-engine-sunpinyin
%{_libdir}/%{name}/ibus-setup-sunpinyin