#
# spec file for package texworks
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2007-09 by Jonathan Kew.
#
# 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:           texworks
Version:        0.4.0
Release:        2
License:        GPLv2+
Summary:        TeXshop-like TeX Editor
Url:            http://www.tug.org/texworks/
Group:          Productivity/Publishing/TeX/Frontends
Source0:        texworks-%{version}.tar.bz2
BuildRequires:  dbus-1-devel
BuildRequires:  desktop-file-utils
BuildRequires:  hunspell-devel
BuildRequires:  libpoppler-devel
BuildRequires:  libpoppler-qt4-devel
BuildRequires:  libqt4-devel
BuildRequires:  update-desktop-files
BuildRequires:  python-devel
BuildRequires:  lua-devel
Requires:       dbus-1
Requires:       hunspell
Requires:       poppler-tools
Requires:       texlive-latex
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
The TeXworks project is an effort to build a simple TeX front-end
program (working environment) that will be available for all today’s
major desktop operating systems—in particular, MS Windows (XP and
Vista), typical GNU/Linux distros and other X11-based systems, and
Mac OS X. It is deliberately modeled on Dick Koch’s award-winning
TeXShop for Mac OS X, which is credited with a resurgence of TeX
usage on the Mac platform.

%package plugin-python
License:        GPLv2+
Summary:        Plugins to add python scripting to texworks
Group:          Development/Libraries/Python
Requires:       python
Requires:       %{name} = %{version}

%description plugin-python
The TeXworks project is an effort to build a simple TeX front-end
program (working environment) that will be available for all today’s
major desktop operating systems—in particular, MS Windows (XP and
Vista), typical GNU/Linux distros and other X11-based systems, and
Mac OS X. It is deliberately modeled on Dick Koch’s award-winning
TeXShop for Mac OS X, which is credited with a resurgence of TeX
usage on the Mac platform.

This package adds python scripting abitilies to TeXworks.

%package plugin-lua
License:        GPLv2+
Summary:        Plugins to add python scripting to texworks
Group:          Development/Libraries/Other
Requires:       lua
Requires:       %{name} = %{version}

%description plugin-lua
The TeXworks project is an effort to build a simple TeX front-end
program (working environment) that will be available for all today’s
major desktop operating systems—in particular, MS Windows (XP and
Vista), typical GNU/Linux distros and other X11-based systems, and
Mac OS X. It is deliberately modeled on Dick Koch’s award-winning
TeXShop for Mac OS X, which is credited with a resurgence of TeX
usage on the Mac platform.

This package adds lua scripting abitilies to TeXworks.

%prep
%setup -q -n texworks-%{version}

%build

#Python plugin 
pushd plugins-src/TWPythonPlugin/
sed -i 's:/usr/local/lib:%{_libdir}:' TWPythonPlugin.pro
qmake -after \
             'INCLUDEPATH -= /usr/include/python2.6/' \
             'INCLUDEPATH += %{_includedir}/python%{py_ver}/' \
             'LIBS -= -lpython2.6' \
             'LIBS += -lpython%{py_ver}'
popd

#Lua plugin
pushd plugins-src/TWLuaPlugin/
sed -i 's:/usr/local/lib:%{_libdir}:' TWLuaPlugin.pro
qmake -after \
            'PKGCONFIG -= lua5.1' \
            'PKGCONFIG += lua'
popd

#Main package
qmake INSTALL_PREFIX=%{_prefix} DOCS_DIR=%{_docdir}/%{name} \
   -after \
          'QMAKE_CXXFLAGS -= -DTW_BUILD_ID=personal -DTW_HELPPATH=\\\"/usr/local/share/texworks-help\\\" -DTW_PLUGINPATH=\\\"/usr/local/lib/texworks\\\" -DTW_DICPATH=\\\"/usr/share/myspell/dicts\\\"' \
          'QMAKE_CXXFLAGS += -DTW_BUILD_ID=openSUSE -DTW_HELPPATH=\\\"%{_docdir}/%{name}/manual\\\" -DTW_PLUGINPATH=\\\"%{_libdir}/%{name}\\\" -DTW_DICPATH=\\\"%{_datadir}/myspell\\\"'

%install
#Python plugin 
pushd plugins-src/TWPythonPlugin/
make INSTALL_ROOT=%{buildroot} install
popd

#Lua plugin
pushd plugins-src/TWLuaPlugin/
make INSTALL_ROOT=%{buildroot} install
popd

#Main package
make INSTALL_ROOT=%{buildroot} install
%suse_update_desktop_file texworks Publishing WordProcessor

%clean
rm -rf %{buildroot}

%post
%if 0%{?suse_version} > 1130
%desktop_database_post
%else
gtk-update-icon-cache %{_datadir}/icons/hicolor || true
%endif

%postun
%if 0%{?suse_version} > 1130
%desktop_database_postun
%else
gtk-update-icon-cache %{_datadir}/icons/hicolor || true
%endif

%files
%defattr(-,root,root)
%doc COPYING README NEWS manual/
%{_bindir}/texworks
%{_datadir}/applications/texworks.desktop
%{_datadir}/pixmaps/*.png
%{_mandir}/man1/texworks.1.*

%files plugin-python
%defattr(-,root,root)
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*PythonPlugin.so

%files plugin-lua
%defattr(-,root,root)
%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*LuaPlugin.so

%changelog