File ibus.spec of Package ibus

# spec file for package ibus
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%define gtk_binary_version %(pkg-config  --variable=gtk_binary_version gtk+-2.0)
%if 0%{?suse_version} == 1315
%define with_python3 0
%define with_python3 1
%if 0%{?suse_version} > 1315
%define with_wayland 1
%define with_wayland 0

Name:           ibus
Version:        1.5.8
Release:        0
Summary:        Intelligent Input Bus for Linux OS
License:        LGPL-2.1+
Group:          System/I18n/Chinese
Source:         %{name}-%{version}.tar.gz
Source2:        README.SUSE
Source3:        xim.ibus.suse.template
Source4:        xim.d-ibus-121
Source5:        kde.tar.gz
Source6:        kde-12.2.tar.gz
Source7:        macros.ibus
Source99:       baselibs.conf
# PATCH-FIX-OPENSUSE ibus-python-install-dir.patch
Patch0:         ibus-python-install-dir.patch
# PATCH-FIX-OPENSUSE reload-preload-engines-until-users-customize-the-list.patch
Patch3:         show-input-mode-icon.patch
# PATFH-FIX-SUSE ibus-xim-fix-re-focus-after-lock.patch bnc#874869 -- Fix lost XIM input after screenlock
Patch4:         ibus-xim-fix-re-focus-after-lock.patch
# Ibus will use python3 only when variable PYTHON2 is empty.
# Thus ibus-setup and bindings are still bytecompiled with python2.
# Then python3 support is useless, so we force python3 when python3
# is enabled, and fix syntax errors in
Patch5:         ibus-force-python3.patch
# lower vala version
Patch6:         ibus-vala-0.18.patch
BuildRequires:  dbus-1-glib-devel
BuildRequires:  dbus-1-python-devel >= 0.83.0
BuildRequires:  dconf-devel >= 0.7.5
BuildRequires:  fdupes
BuildRequires:  gconf2-devel
BuildRequires:  gettext-devel
BuildRequires:  glib2-devel >= 2.26.0
BuildRequires:  gobject-introspection-devel >= 0.9.6
BuildRequires:  gtk-doc >= 1.9
BuildRequires:  gtk2-devel
BuildRequires:  intltool
BuildRequires:  iso-codes-devel
BuildRequires:  libnotify-devel >= 0.7
BuildRequires:  libtool
# directory ownership {
BuildRequires:  oxygen-icon-theme
BuildRequires:  oxygen-icon-theme-scalable
BuildRequires:  x11-tools
# }
BuildRequires:  pkg-config
%if %{with_python3}
BuildRequires:  python3
BuildRequires:  python3-gobject2-devel
Requires:       python3-gobject2
BuildRequires:  python
BuildRequires:  python-gobject-devel
Requires:       python-gobject
BuildRequires:  update-desktop-files
BuildRequires:  pkgconfig(vapigen)
%if %{with_wayland}
BuildRequires:  pkgconfig(wayland-client) >= 1.2.0
BuildRequires:  pkgconfig(xkbcommon)
Requires:       dbus-1-python
Requires:       dconf
Requires:       iso-codes
Requires:       libibus-1_0-5 = %{version}
# ibus-setup will require typelib(Gdk) typelib(GdkX11), typelib(Gtk)
# which are provided by two packages in openSUSE, so we limit their
# versions to 3.0 only.
Requires:       typelib-1_0-Gtk-3_0
Recommends:     %{name}-lang

#Fix cursor following problem in KDE4 for libreoffice.
%if 0%{?suse_version} != 1315
Supplements:    packageand(libreoffice:libreoffice-gnome)

Provides:       locale(ja;ko;zh)
Obsoletes:      ibus-gnome-shell
Obsoletes:      libibus-1_0-0
%if %{with_python3}
Obsoletes:      python-ibus
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

IBus means Intelligent Input Bus. It is a new input framework for Linux OS. It provides
full featured and user friendly input method user interface. It also may help
developers to develop input method easily.

%package -n libibus-1_0-5
Summary:        IBus libraries
Group:          System/I18n/Chinese

%description -n libibus-1_0-5
This package contains the libraries for IBus

%package -n typelib-1_0-IBus-1_0
Summary:        IBus libraries -- Introspection bindings
Group:          System/I18n/Chinese

%description -n typelib-1_0-IBus-1_0
This package contains the introspection bindings for the IBus library.

%package gtk
Summary:        IBus im module for gtk2
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}
Supplements:    packageand(ibus:gtk2)

%description gtk
This package contains ibus im module for gtk2

%package gtk3
Summary:        IBus im module for gtk3
Group:          System/I18n/Chinese
BuildRequires:  gtk3-devel
Requires:       %{name} = %{version}
Supplements:    packageand(ibus:gtk3)

%description gtk3
This package contains ibus im module for gtk3

%if %{with_python3}
%package -n python3-ibus
Summary:        Python3 module for ibus
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}
Requires:       python3

%description -n python3-ibus
This package contains python3 module for ibus

%package -n python-ibus
Summary:        Python module for ibus
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}

%description -n python-ibus
This package contains python module for ibus


%package branding-openSUSE-KDE
Summary:        openSUSE branding for KDE
Group:          System/GUI/KDE
Requires:       ibus = %{version}
Supplements:    packageand(ibus:branding-openSUSE-KDE)
Supplements:    packageand(ibus:kdelibs4)
Provides:       ibus-branding = %{version}
Conflicts:      otherproviders(ibus-branding)
%if 0%{?suse_version} >= 1140
BuildArch:      noarch

%description branding-openSUSE-KDE
openSUSE branding for KDE monochrome icons in systray.

%package devel
Summary:        Development tools for ibus
Group:          Development/Libraries/Other
Requires:       dbus-1-devel
Requires:       glib2-devel
Requires:       gtk-doc
Requires:       ibus = %{version}
Requires:       libibus-1_0-5 = %{version}
Requires:       typelib-1_0-IBus-1_0 = %{version}

%description devel
The ibus-devel package contains the header files and developer
docs for ibus.


%setup -q
%patch0 -p1

# hack to fix incompatibility of gtk-query-immodules-2.0 (bnc#845860)
%if 0%{?suse_version} < 1310
%patch6 -p1
sed -i \
    -e's@\(gtk-query-immodules-2.0-64\) --update-cache@\1 > <prefix>%{_sysconfdir}/gtk-2.0/gtk64.immodules@g' \
    -e's@\(gtk-query-immodules-2.0\) --update-cache@\1 > <prefix>%{_sysconfdir}/gtk-2.0/gtk.immodules@g' \

%patch3 -p1
%patch4 -p1

%if %{with_python3}
%patch5 -p1

cp -r %{SOURCE2} .
cp -r %{SOURCE3} .

autoreconf -fi
intltoolize -f
%configure --disable-static \
           --enable-gtk3 \
           --enable-vala \
%if %{with_python3}
	   --with-python=python3 \
           --enable-python-library \
           --enable-introspection \
           --disable-gconf \
           --enable-dconf \
           --enable-gtk-doc \
%if %{with_wayland}
           --enable-wayland \
           --enable-surrounding-text \

make %{?_smp_mflags}

make DESTDIR=%{buildroot} install %{?_smp_mflags}

# autostart
mkdir -p %{buildroot}%{_sysconfdir}/X11/xim.d/
install -m 644 %{SOURCE4} %{buildroot}%{_sysconfdir}/X11/xim.d/ibus

sed -i 1i"SYS_LIB=%{_lib}" %{buildroot}%{_sysconfdir}/X11/xim.d/ibus

pushd %{buildroot}%{_sysconfdir}/X11/xim.d/
    for lang in am ar as bn el fa gu he hi hr ja ka kk kn ko lo ml my \
                pa ru sk vi zh_TW zh_CN zh_HK zh_SG \
                de fr it es nl cs pl da nn nb fi en sv
        mkdir $lang
        pushd $lang
            ln -s ../ibus $PRIORITY-ibus

# remove static libs
find %{buildroot}/%{_libdir} -name "*.la" -type f -delete -print

mkdir -p %{buildroot}%{_datadir}/pixmaps
ln -sf %{_datadir}/icons/hicolor/48x48/apps/ibus-keyboard.png \

# touch for %%ghost
touch %{buildroot}/%{_sysconfdir}/dconf/db/ibus

# fix kde monochrome icons
%if 0%{?suse_version} >= 1230
cp -r %{SOURCE5} ./
cp -r %{SOURCE6} ./
mv kde-12.2.tar.gz kde.tar.gz
tar -xzf kde.tar.gz
pushd kde
for i in 16 22 24 32 48 ; do
	mkdir -p %{buildroot}%{_datadir}/icons/oxygen/${i}x${i}/apps/
	cp -r ibus-keyboard.${i}x${i}.png %{buildroot}%{_datadir}/icons/oxygen/${i}x${i}/apps/ibus-keyboard.png
mkdir -p %{buildroot}%{_datadir}/icons/oxygen/scalable/apps/
cp -r ibus-keyboard.svgz %{buildroot}%{_datadir}/icons/oxygen/scalable/apps/

# install macros
mkdir -p %{buildroot}%{_sysconfdir}/rpm
install -m 644 %{SOURCE7} %{buildroot}%{_sysconfdir}/rpm

%suse_update_desktop_file -r %{name}-setup System X-SuSE-Core-System

%fdupes %{buildroot}

%find_lang ibus10 %{?no_lang_C}


dconf update

dconf update

%post gtk

%postun gtk

%post -n libibus-1_0-5 -p /sbin/ldconfig

%postun -n libibus-1_0-5 -p /sbin/ldconfig

%post gtk3

%postun gtk3

%doc AUTHORS COPYING README README.SUSE xim.ibus.suse.template
%config %{_sysconfdir}/rpm/macros.ibus
%config %{_sysconfdir}/X11/xim.d/*
%dir %config %{_sysconfdir}/dconf/db/ibus.d
# These files are not config files. Users must not modify them.
%ghost %{_sysconfdir}/dconf/db/ibus.d/00-upstream-settings
%ghost %{_sysconfdir}/dconf/db/ibus
%ghost %{_sysconfdir}/dconf/profile/ibus

%files lang -f ibus10.lang

%files -n libibus-1_0-5

%files -n typelib-1_0-IBus-1_0

%files gtk

%files gtk3

%if %{with_python3}
%files -n python3-ibus


%files -n python-ibus


%files devel

%files branding-openSUSE-KDE
%dir %{_datadir}/icons/oxygen/24x24
%dir %{_datadir}/icons/oxygen/24x24/apps