File gcin.spec of Package gcin.2064

#
# spec file for package gcin
#
# Copyright (c) 2013 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 http://bugs.opensuse.org/
#


Name:           gcin
Version:        2.7.5
Release:        0
Summary:        Chinese input method server
License:        LGPL-2.1
Group:          System/I18n/Chinese
Url:            http://hyperrate.com/dir.php?eid=67
Source:         %{name}-%{version}.tar.bz2
Source1:        xim.d-gcin
Source2:        gcin-README.suse
Source3:        xim.gcin.suse.template
# PATCH-FIX-UPSTREAM swyear@opensuse.org - fix doc
Patch0:         configure146p12.diff
# PATCH-FIX-UPSTREAM swyear@opensuse.org - don't install 64x51 to 64, to pixmaps instead
Patch1:         icon_path.diff
# PATCH-FIX-UPSTREAM swyear@opensuse.org - fix qt3 detection so we still can build
Patch2:         gcin-libdir.patch
# PATCH-FIX-UPSTREAM marguerite@opensuse.org -fix gtk2/3 immodules install path
Patch3:         gcin-%{version}-gtk_immodules_path.patch
BuildRequires:  anthy-devel
BuildRequires:  fdupes
BuildRequires:  gtk2-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libqt4-devel
BuildRequires:  pkg-config
BuildRequires:  update-desktop-files
%if 0%{?suse_version} > 1130
BuildRequires:  gtk3-devel
BuildRequires:  libchewing-devel
%endif
Requires:       %{name}-branding
Requires:       %{name}-gtk2-immodule
Requires:       %{name}-qt4-immodule
%if 0%{?suse_version} > 1130
Requires:       %{name}-gtk3-immodule
%endif
Requires:       %{name}-chewing-module
Recommends:     libreoffice-gnome
Provides:       locale(zh_TW;zh_HK;zh_MO)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
gcin is a Chinese input method server for traditional Chinese.
It features a better GTK user interface.

%package branding-upstream
Summary:        Upstream branding of gcin
License:        LGPL-2.1
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}
Supplements:    packageand(%{name}:branding-upstream)
Provides:       %{name}-branding = %{version}
Conflicts:      otherproviders(%{name}-branding)

%description branding-upstream
This package provides upstream look and feel for gcin

%package gtk2-immodule
Summary:        Gcin gtk3 immodule
License:        LGPL-2.1
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}
%gtk2_immodule_requires

%description gtk2-immodule
gcin gtk2 immodule, support gtk2-based applications

%package qt4-immodule
Summary:        Gcin qt4 immodule
License:        GPL-2.0
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}

%description qt4-immodule
gcin qt4 immodule, support Qt4-based applications

%package anthy-module
Summary:        Gcin anthy module
License:        LGPL-2.1
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}

%description anthy-module
gcin anthy module, try this to input Japanese with libanthy

%if 0%{?suse_version} > 1130
%package chewing-module
Summary:        Gcin chewing module
License:        LGPL-2.1
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}

%description chewing-module
gcin chewing module, support famous chewing inputmethod for traditional
Chinese users

%package gtk3-immodule
Summary:        Gcin gtk3 immodule
License:        LGPL-2.1
Group:          System/I18n/Chinese
Requires:       %{name} = %{version}
%gtk3_immodule_requires

%description gtk3-immodule
gcin gtk3 immodule, support gtk3-based applications
%endif

%prep
%setup -q
%patch0
%patch1
%patch2 -p1
%patch3 -p1

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

# scripts/modify-XIM is mainly for Fedora/Mandriva and Qt3, obsoleted
rm -rf scripts/modify-XIM
sed -i "s/modify-XIM//" scripts/Makefile

%build
CFLAGS="%{optflags}" %configure --prefix=%{_prefix} --use_i18n=Y \
--use_anthy=Y --use_chewing=Y

make %{?_smp_mflags}

%install

%makeinstall

mkdir -p %{buildroot}%{_sysconfdir}/X11/xim.d/
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/X11/xim.d/gcin

%suse_update_desktop_file -r -G "Set Up your inputmethod" gcin-tools Settings System SystemSetup
PRIORITY=30
pushd  %{buildroot}%{_sysconfdir}/X11/xim.d/
    for lang in en zh_TW zh_HK zh_MO ; do
        mkdir $lang
  pushd $lang
            ln -s ../gcin $PRIORITY-gcin
  popd
    done
popd

%find_lang %{name}
%fdupes %{buildroot}

# Convenient definition for the scriplets
%if "%{_lib}" == "lib64"
%define _gtk2_query_immodules %{_bindir}/gtk-query-immodules-2.0-64
%define _gtk2_query_immodules_update_cache %{_gtk2_query_immodules} > %{_sysconfdir}/gtk-2.0/gtk64.immodules
%else
%define _gtk2_query_immodules %{_bindir}/gtk-query-immodules-2.0
%define _gtk2_query_immodules_update_cache %{_gtk2_query_immodules} > %{_sysconfdir}/gtk-2.0/gtk.immodules
%endif

# Convenient definition for the scriplets
%if "%{_lib}" == "lib64"
%define _gtk3_query_immodules %{_bindir}/gtk-query-immodules-3.0-64
%else
%define _gtk3_query_immodules %{_bindir}/gtk-query-immodules-3.0
%endif
%define _gtk3_query_immodules_update_cache %{_gtk3_query_immodules} --update-cache

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%post anthy-module -p /sbin/ldconfig
%postun anthy-module -p /sbin/ldconfig
%post chewing-module -p /sbin/ldconfig
%postun chewing-module -p /sbin/ldconfig
%post qt4-immodule -p /sbin/ldconfig
%postun qt4-immodule -p /sbin/ldconfig

%post gtk2-immodule
/sbin/ldconfig
%{_gtk2_query_immodules_update_cache}

%postun gtk2-immodule
/sbin/ldconfig
%{_gtk2_query_immodules_update_cache}

%if 0%{?suse_version} > 1130
%post gtk3-immodule
/sbin/ldconfig
#Add icons to gnome3 panel
TARGET="/usr/share/gnome-shell/js/ui/statusIconDispatcher.js"
if [ -f $TARGET ] ; then
 if [ -z "`grep gcin $TARGET`" ] ; then
   mv $TARGET $TARGET-gcin
   # add gcin string to the file
   sed "/^const STANDARD_TRAY_ICON_IMPLEMENTATIONS/a \    'gcin': 'input-method'," $TARGET-gcin > $TARGET
 fi
fi

%{_gtk3_query_immodules_update_cache}

%postun gtk3-immodule
/sbin/ldconfig
%{_gtk3_query_immodules_update_cache}
%endif

%files -f %{name}.lang
%defattr(-,root,root)
%doc README.html Changelog.html COPYING AUTHORS gcin-README.suse xim.gcin.suse.template
%config %{_sysconfdir}/X11/xim.d/
%{_bindir}/*
%{_libdir}/gcin/
%{_datadir}/gcin/
%{_datadir}/pixmaps/gcin.png
%{_datadir}/applications/*
%dir %{_datadir}/icons/gcin
%exclude %{_libdir}/gcin/anthy-module.so
%exclude %{_libdir}/gcin/chewing-module.so

%files branding-upstream
%defattr(-,root,root)
%{_datadir}/icons/gcin/*

%files gtk2-immodule
%defattr(-,root,root)
%{_libdir}/gtk-2.0/2.10.0/immodules/im-gcin.so

%files qt4-immodule
%defattr(-,root,root)
%{_libdir}/qt4/plugins/inputmethods/im-gcin.so

%files anthy-module
%defattr(-,root,root)
%{_libdir}/gcin/anthy-module.so

%if 0%{?suse_version} > 1130
%files chewing-module
%defattr(-,root,root)
%{_libdir}/gcin/chewing-module.so

%files gtk3-immodule
%defattr(-,root,root)
%{_libdir}/gtk-3.0/3.0.0/immodules/im-gcin.so
%endif

%changelog
openSUSE Build Service is sponsored by