ibus/ibus-HEAD.patch
2014-01-31 19:07:31 +09:00

531 lines
18 KiB
Diff

From e6ec45d64a32d16245770f8b80e795a63e6ad553 Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Thu, 16 Jan 2014 13:22:12 +0900
Subject: [PATCH] data/dconf: Don't run "dconf update" if $(DESTDIR) is set
dconf changed as of
https://git.gnome.org/browse/dconf/commit/?id=c211fc46496597c7ddabd73d623bae4037754916
to actually emit an error if /etc/dconf/db is empty. When building
ibus in a system such as dpkg/rpm or gnome-continuous, there may
actually be nothing in that directory in the buildroot.
This will now cause "dconf update" as executed by this Makefile to
fail. The fix is to just check $(DESTDIR), like we should do for all
triggers (e.g. gtk-update-icon-cache too). It's never useful to
execute these from per-component Makefiles if $(DESTDIR) is set.
Instead, these meta-build systems (dpkg/rpm/jhbuild/Continuous) all
take care of execution of triggers on their own.
Review URL: https://codereview.appspot.com/51730044
Patch from Colin Walters <walters@verbum.org>.
---
data/dconf/Makefile.am | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/data/dconf/Makefile.am b/data/dconf/Makefile.am
index c841a34..62c20a3 100644
--- a/data/dconf/Makefile.am
+++ b/data/dconf/Makefile.am
@@ -61,6 +61,8 @@ org.freedesktop.ibus.gschema.xml.in: $(top_srcdir)/data/ibus.schemas.in
{ rc=$$?; $(RM) -rf $@; exit $$rc; }
install-data-hook:
- dconf update
+ if test -z "$(DESTDIR)"; then \
+ dconf update; \
+ fi
-include $(top_srcdir)/git.mk
--
1.8.0
From 8468de2f165ca7dba45b13cec09fdcde83a88204 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Fri, 24 Jan 2014 11:11:40 +0900
Subject: [PATCH 1/2] Enable python3 ibus-setup.
The default uses 'python' and if the path of python 3 is 'python3',
./configure --with-python=python3
Review URL: https://codereview.appspot.com/54930043
---
configure.ac | 8 ++++++++
setup/enginecombobox.py | 25 +++++++++++++++++--------
setup/enginetreeview.py | 13 +++++++------
setup/keyboardshortcut.py | 10 +++++-----
setup/main.py | 21 ++++++++++++---------
5 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/configure.ac b/configure.ac
index b7ef1eb..73d99ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -372,6 +372,13 @@ AM_CONDITIONAL([ENABLE_PYTHON_LIBRARY], [test x"$enable_python_library" = x"yes"
AM_CONDITIONAL([ENABLE_SETUP], [test x"$enable_setup" = x"yes"])
AM_CONDITIONAL([ENABLE_DAEMON], [true])
+# Define python version
+AC_ARG_WITH(python,
+ AS_HELP_STRING([--with-python[=PATH]],
+ [Select python2 or python3]),
+ [PYTHON=$with_python], []
+)
+
AM_PATH_PYTHON([2.5])
PYGOBJECT_REQUIRED=3.0.0
@@ -598,6 +605,7 @@ Build options:
Build shared libs $enable_shared
Build static libs $enable_static
CFLAGS $CFLAGS
+ python $PYTHON
Gtk2 immodule dir $GTK2_IM_MODULEDIR
Gtk3 immodule dir $GTK3_IM_MODULEDIR
Build gtk2 immodule $enable_gtk2
diff --git a/setup/enginecombobox.py b/setup/enginecombobox.py
index b45ad56..2a2a677 100644
--- a/setup/enginecombobox.py
+++ b/setup/enginecombobox.py
@@ -2,8 +2,8 @@
#
# ibus - The Input Bus
#
-# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2007-2010 Red Hat, Inc.
+# Copyright (c) 2007-2014 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2014 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -21,6 +21,8 @@
# USA
import locale
+import functools
+import sys
from gi.repository import GObject
from gi.repository import Gtk
@@ -72,8 +74,8 @@ class EngineComboBox(Gtk.ComboBox):
langs[l] = []
langs[l].append(e)
- keys = langs.keys()
- keys.sort(locale.strcoll)
+ keys = list(langs.keys())
+ keys.sort(key=functools.cmp_to_key(locale.strcoll))
loc = locale.getlocale()[0]
# None on C locale
if loc == None:
@@ -95,7 +97,7 @@ class EngineComboBox(Gtk.ComboBox):
if a.get_rank() == b.get_rank():
return locale.strcoll(a.get_longname(), b.get_longname())
return int(b.get_rank() - a.get_rank())
- langs[l].sort(cmp_engine)
+ langs[l].sort(key=functools.cmp_to_key(cmp_engine))
for e in langs[l]:
iter2 = self.__model.append(iter1)
self.__model.set(iter2, 0, e)
@@ -106,7 +108,10 @@ class EngineComboBox(Gtk.ComboBox):
def __icon_cell_data_cb(self, celllayout, renderer, model, iter, data):
engine = self.__model.get_value(iter, 0)
- if isinstance(engine, str) or isinstance (engine, unicode):
+ if isinstance(engine, str):
+ renderer.set_property("visible", False)
+ renderer.set_property("sensitive", False)
+ elif sys.version < '3' and isinstance (engine, unicode):
renderer.set_property("visible", False)
renderer.set_property("sensitive", False)
elif isinstance(engine, int):
@@ -121,7 +126,11 @@ class EngineComboBox(Gtk.ComboBox):
def __name_cell_data_cb(self, celllayout, renderer, model, iter, data):
engine = self.__model.get_value(iter, 0)
- if isinstance (engine, str) or isinstance (engine, unicode):
+ if isinstance (engine, str):
+ renderer.set_property("sensitive", False)
+ renderer.set_property("text", engine)
+ renderer.set_property("weight", Pango.Weight.NORMAL)
+ elif sys.version < '3' and isinstance (engine, unicode):
renderer.set_property("sensitive", False)
renderer.set_property("text", engine)
renderer.set_property("weight", Pango.Weight.NORMAL)
@@ -146,7 +155,7 @@ class EngineComboBox(Gtk.ComboBox):
iter = self.get_active_iter()
return self.get_model()[iter][0]
else:
- raise AttributeError, 'unknown property %s' % property.name
+ raise AttributeError('unknown property %s' % property.name)
def get_active_engine(self):
return self.get_property("active-engine")
diff --git a/setup/enginetreeview.py b/setup/enginetreeview.py
index f8ee092..b116c54 100644
--- a/setup/enginetreeview.py
+++ b/setup/enginetreeview.py
@@ -2,8 +2,8 @@
#
# ibus - The Input Bus
#
-# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2007-2010 Red Hat, Inc.
+# Copyright (c) 2007-2014 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2014 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -108,7 +108,8 @@ class EngineTreeView(Gtk.TreeView):
language_b = IBus.get_language_name(engine_b.get_language())
label_a = "%s - %s" % (language_a, engine_a.get_longname())
label_b = "%s - %s" % (language_b, engine_b.get_longname())
- return cmp(label_a, label_b)
+ # http://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons
+ return (label_a > label_b) - (label_a < label_b)
def __selection_changed_cb(self, *args):
self.notify("active-engine");
@@ -173,15 +174,15 @@ class EngineTreeView(Gtk.TreeView):
engines = [ r[0] for r in self.__model if r[0] != None]
return engines
else:
- raise AttributeError, 'unknown property %s' % prop.name
+ raise AttributeError('unknown property %s' % prop.name)
def do_set_property(self, prop, value):
if prop.name == "active-engine":
- raise AttributeError, "active-engine is readonly"
+ raise AttributeError("active-engine is readonly")
elif prop.name == "engines":
set_engines(value)
else:
- raise AttributeError, 'unknown property %s' % prop.name
+ raise AttributeError('unknown property %s' % prop.name)
def set_engines(self, engines):
self.__model.clear()
diff --git a/setup/keyboardshortcut.py b/setup/keyboardshortcut.py
index 1a88525..26bd77f 100644
--- a/setup/keyboardshortcut.py
+++ b/setup/keyboardshortcut.py
@@ -2,8 +2,8 @@
#
# ibus - The Input Bus
#
-# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2007-2010 Red Hat, Inc.
+# Copyright (c) 2007-2014 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2014 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -182,7 +182,7 @@ class KeyboardShortcutSelection(Gtk.VBox):
modifiers.append(name)
if keycode.startswith("_"):
keycode = keycode[1:]
- shortcut = "".join(map(lambda m: '<' + m + '>', modifiers))
+ shortcut = "".join(['<' + m + '>' for m in modifiers])
shortcut += keycode
return shortcut
@@ -335,6 +335,6 @@ if __name__ == "__main__":
Gtk.STOCK_OK, Gtk.ResponseType.OK))
dlg.add_shortcut("Control+Shift+space")
dlg.set_shortcuts(None)
- print dlg.run()
- print dlg.get_shortcuts()
+ print((dlg.run()))
+ print((dlg.get_shortcuts()))
diff --git a/setup/main.py b/setup/main.py
index d3f4414..cac10de 100644
--- a/setup/main.py
+++ b/setup/main.py
@@ -2,8 +2,8 @@
#
# ibus - The Input Bus
#
-# Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2007-2010 Red Hat, Inc.
+# Copyright (c) 2007-2014 Peng Huang <shawn.p.huang@gmail.com>
+# Copyright (c) 2007-2014 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -20,6 +20,9 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
+# for python2
+from __future__ import print_function
+
import os
import signal
import sys
@@ -45,7 +48,7 @@ from i18n import DOMAINNAME, _, N_, init as i18n_init
COLUMN_VISIBLE,
COLUMN_ICON,
COLUMN_DATA,
-) = range(6)
+) = list(range(6))
(
DATA_NAME,
@@ -57,7 +60,7 @@ from i18n import DOMAINNAME, _, N_, init as i18n_init
DATA_EXEC,
DATA_STARTED,
DATA_PRELOAD
-) = range(9)
+) = list(range(9))
class Setup(object):
def __flush_gtk_events(self):
@@ -286,7 +289,7 @@ class Setup(object):
obj.set_sensitive(False)
if prop.name == "engines":
- engine_names = map(lambda e: e.get_name(), engines)
+ engine_names = [e.get_name() for e in engines]
self.__settings_general.set_strv('preload-engines', engine_names)
def __button_engine_add_cb(self, button):
@@ -306,7 +309,7 @@ class Setup(object):
if len(args) == 0:
return
name = engine.get_name()
- if name in self.__engine_setup_exec_list.keys():
+ if name in list(self.__engine_setup_exec_list.keys()):
try:
wpid, sts = os.waitpid(self.__engine_setup_exec_list[name],
os.WNOHANG)
@@ -402,7 +405,7 @@ class Setup(object):
if data[DATA_STARTED] == False:
try:
self.__bus.register_start_engine(data[DATA_LANG], data[DATA_NAME])
- except Exception, e:
+ except Exception as e:
dlg = Gtk.MessageDialog(type = Gtk.MessageType.ERROR,
buttons = Gtk.ButtonsType.CLOSE,
message_format = str(e))
@@ -413,7 +416,7 @@ class Setup(object):
else:
try:
self.__bus.register_stop_engine(data[DATA_LANG], data[DATA_NAME])
- except Exception, e:
+ except Exception as e:
dlg = Gtk.MessageDialog(type = Gtk.MessageType.ERROR,
buttons = Gtk.ButtonsType.CLOSE,
message_format = str(e))
@@ -492,7 +495,7 @@ if __name__ == "__main__":
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
- print >> sys.stderr, "Using the fallback 'C' locale"
+ print("Using the fallback 'C' locale", file=sys.stderr)
locale.setlocale(locale.LC_ALL, 'C')
i18n_init()
--
1.8.0
From e2cd8f0870d8b15af71e839f9035dce333af3c4e Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Mon, 27 Jan 2014 11:38:46 +0900
Subject: [PATCH 2/2] Install IBus.py in python2 gi.override.
Review URL: https://codereview.appspot.com/56510043
---
bindings/pygobject/Makefile.am | 5 +++++
configure.ac | 13 ++++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/bindings/pygobject/Makefile.am b/bindings/pygobject/Makefile.am
index fc23209..d257b04 100644
--- a/bindings/pygobject/Makefile.am
+++ b/bindings/pygobject/Makefile.am
@@ -22,6 +22,11 @@
NULL =
+overrides2dir = $(py2overridesdir)
+overrides2_DATA = \
+ gi/overrides/IBus.py \
+ $(NULL)
+
overridesdir = $(pyoverridesdir)
overrides_PYTHON = \
gi/overrides/IBus.py \
diff --git a/configure.ac b/configure.ac
index 73d99ee..43071bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -380,6 +380,7 @@ AC_ARG_WITH(python,
)
AM_PATH_PYTHON([2.5])
+AC_PATH_PROG(PYTHON2, python2)
PYGOBJECT_REQUIRED=3.0.0
@@ -387,10 +388,16 @@ PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
[enable_pygobject=yes], [enable_pygobject=no])
if test "x$enable_pygobject" = "xyes"; then
- PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
+ PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
- pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
- AC_SUBST(pyoverridesdir)
+ pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
+ AC_SUBST(pyoverridesdir)
+
+ py2overridesdir="$pyoverridesdir"
+ if test x"$PYTHON2" != x""; then
+ py2overridesdir=`$PYTHON2 -c "import gi; print(gi._overridesdir)"`
+ fi
+ AC_SUBST(py2overridesdir)
fi
AM_CONDITIONAL(ENABLE_PYGOBJECT, test x"$enable_pygobject" = "xyes")
--
1.8.0
From 256e207d9574838c9ed5f9400eddc5ff2cbbec59 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Fri, 31 Jan 2014 16:10:07 +0900
Subject: [PATCH] Install pygtk2 libraries to python2 site-packages.
---
bindings/pygobject/Makefile.am | 11 +++++++++++
configure.ac | 19 ++++++++++++++-----
ibus/Makefile.am | 4 +++-
ibus/interface/Makefile.am | 4 +++-
4 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/bindings/pygobject/Makefile.am b/bindings/pygobject/Makefile.am
index d257b04..aa4c330 100644
--- a/bindings/pygobject/Makefile.am
+++ b/bindings/pygobject/Makefile.am
@@ -22,6 +22,7 @@
NULL =
+am__py2_compile = PYTHON=$(PYTHON2) $(SHELL) $(py_compile)
overrides2dir = $(py2overridesdir)
overrides2_DATA = \
gi/overrides/IBus.py \
@@ -52,4 +53,14 @@ EXTRA_DIST = \
test-override-ibus.py \
$(NULL)
+install-data-hook:
+ for data in $(overrides2_DATA); do \
+ file=`echo $$data | sed -e 's|^.*/||'`; \
+ dlist="$$dlist $$file"; \
+ done; \
+ $(am__py2_compile) --destdir "$(DESTDIR)" \
+ --basedir "$(overrides2dir)" \
+ $$dlist
+ $(NULL)
+
-include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
index 43071bc..03e4725 100644
--- a/configure.ac
+++ b/configure.ac
@@ -382,6 +382,10 @@ AC_ARG_WITH(python,
AM_PATH_PYTHON([2.5])
AC_PATH_PROG(PYTHON2, python2)
+if test x"$PYTHON2" = x""; then
+ PYTHON2=$PYTHON
+fi
+
PYGOBJECT_REQUIRED=3.0.0
PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
@@ -393,10 +397,7 @@ if test "x$enable_pygobject" = "xyes"; then
pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
AC_SUBST(pyoverridesdir)
- py2overridesdir="$pyoverridesdir"
- if test x"$PYTHON2" != x""; then
- py2overridesdir=`$PYTHON2 -c "import gi; print(gi._overridesdir)"`
- fi
+ py2overridesdir=`$PYTHON2 -c "import gi; print(gi._overridesdir)"`
AC_SUBST(py2overridesdir)
fi
@@ -419,6 +420,13 @@ if test x"$enable_python_library" = x"yes"; then
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_INCLUDES)
AC_SUBST(PYTHON_LIBS)
+
+ PYTHON2_PREFIX=`$PYTHON2 -c "import sys; sys.stdout.write(sys.prefix)"`
+ PYTHON2_VERSION=`$PYTHON2 -c "import sys; sys.stdout.write(sys.version[[:3]])"`
+ PYTHON2_LIBDIR="$PYTHON2_PREFIX/lib/python$PYTHON2_VERSION"
+ python2dir="$PYTHON2_LIBDIR/site-packages"
+ pkgpython2dir="$python2dir/ibus"
+ AC_SUBST(pkgpython2dir)
else
enable_python_library="no (disabled, use --enable-python-library to enable)"
fi
@@ -612,7 +620,8 @@ Build options:
Build shared libs $enable_shared
Build static libs $enable_static
CFLAGS $CFLAGS
- python $PYTHON
+ PYTHON $PYTHON
+ PYTHON2 $PYTHON2
Gtk2 immodule dir $GTK2_IM_MODULEDIR
Gtk3 immodule dir $GTK3_IM_MODULEDIR
Build gtk2 immodule $enable_gtk2
diff --git a/ibus/Makefile.am b/ibus/Makefile.am
index f120de1..0edabed 100644
--- a/ibus/Makefile.am
+++ b/ibus/Makefile.am
@@ -23,6 +23,8 @@ SUBDIRS = \
interface \
$(NULL)
+PYTHON = $(PYTHON2)
+
ibus_PYTHON = \
ascii.py \
application.py \
@@ -56,7 +58,7 @@ nodist_ibus_PYTHON = \
_config.py \
$(NULL)
-ibusdir = @pkgpythondir@
+ibusdir = @pkgpython2dir@
EXTRA_DIST = \
_config.py.in \
diff --git a/ibus/interface/Makefile.am b/ibus/interface/Makefile.am
index 6ce510b..de83c77 100644
--- a/ibus/interface/Makefile.am
+++ b/ibus/interface/Makefile.am
@@ -20,6 +20,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA
+PYTHON = $(PYTHON2)
+
ibus_interface_PYTHON = \
iconfig.py \
ienginefactory.py \
@@ -31,7 +33,7 @@ ibus_interface_PYTHON = \
__init__.py \
$(NULL)
-ibus_interfacedir = @pkgpythondir@/interface
+ibus_interfacedir = @pkgpython2dir@/interface
CLEANFILES = \
*.pyc \
--
1.8.0