# This package depends on automagic byte compilation
# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2
%global _python_bytecompile_extra 1

Name:               onboard

Version:            1.4.1
%global             major_version       1.4

Release:            1
Summary:            On-screen keyboard for TabletPC and mobility impaired users (Xorg only)

# The entire source code is GPLv3 apart from translation strings and
# /gnome/Onboard_Indicator@onboard.org/convenience.js which are both BSD-3-clause
License:            GPLv3 and BSD
URL:                https://launchpad.net/onboard/
Source0:            %{url}%{major_version}/%{version}/+download/onboard-%{version}.tar.gz

# Wrong Python interpreter in Onboard/IconPalette.py
# Reported (2017-03-10, fixed in the upstream): https://bugs.launchpad.net/onboard/+bug/1671930
Patch0:             onboard-1.4.1-pythonversion.patch

BuildRequires:      gcc-c++
BuildRequires:      python3-devel
BuildRequires:      python3-distutils-extra
BuildRequires:      dconf-devel
BuildRequires:      libcanberra-devel
BuildRequires:      libxkbfile-devel
BuildRequires:      libXtst-devel
BuildRequires:      libX11-devel
BuildRequires:      hunspell-devel
BuildRequires:      python3-devel
BuildRequires:      intltool
BuildRequires:      python3-dbus
BuildRequires:      systemd-devel
BuildRequires:      desktop-file-utils

Requires:           iso-codes
Requires:           dbus-x11
Requires:           python3-gobject
Requires:           onboard-data

%if 0%{?fedora} < 25
Requires(post):     desktop-file-utils
Requires(postun):   desktop-file-utils
%endif

%description
Onboard is an onscreen keyboard useful for everybody that cannot use a
hardware keyboard; for example TabletPC users, mobility impaired users...

It has been designed with simplicity in mind and can be used right away
without the need of any configuration, as it can read the keyboard layout
from the X server.

%prep
%setup -q
%patch0

%build
%py3_build

%check
# No tests defined in the upstream

%install
%py3_install

# Remove icons for Ubuntu
rm %{buildroot}%{_datadir}/icons/ubuntu* -rf

desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{_builddir}/%{name}-%{version}/build/share/applications/onboard.desktop
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{_builddir}/%{name}-%{version}/build/share/applications/onboard-settings.desktop

# Fix the right-click menu of taskbar is displayed in English
install -d %{?buildroot}%{_datadir}/locale/
cp -ap %{_builddir}/%{name}-%{version}/build/mo/* %{?buildroot}%{_datadir}/locale/

# Fix permissions for a couple of scripts so the user may execute them (not normal behaviour, but still)
chmod +x %{buildroot}%{python3_sitearch}/Onboard/IconPalette.py %{buildroot}%{python3_sitearch}/Onboard/settings.py \
         %{buildroot}%{python3_sitearch}/Onboard/pypredict/lm_wrapper.py %{buildroot}%{_datadir}/%{name}/layoutstrings.py

%package data
Summary:        Data for Onboard
BuildArch:      noarch
Requires:       onboard

%description data
%{summary}.

%files
%{_bindir}/%{name}*
%{_datadir}/man/man1/onboard*
%{_datadir}/applications/%{name}*.desktop
%{python3_sitearch}/Onboard/
%{python3_sitearch}/onboard*.egg-info
%{_datadir}/glib-2.0/schemas/org.onboard.gschema.xml

%files data
%doc AUTHORS NEWS README HACKING
%license COPYING COPYING.BSD3 COPYING.GPL3
%defattr(-,root,root,-)
%{_datadir}/%{name}/
%{_datadir}/locale/
%{_datadir}/sounds/freedesktop/stereo/onboard-key-feedback.oga
%{_datadir}/icons/HighContrast/scalable/apps/onboard.svg
%{_datadir}/icons/hicolor/*/apps/onboard.*
%{_datadir}/dbus-1/services/org.onboard.Onboard.service
%{_datadir}/gnome-shell/extensions/Onboard_Indicator@onboard.org

%changelog
* Fri Aug 7 2020 weidong <weidong@uniontech.com> - 1.4.1-1
- Initial release for OpenEuler
