%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}

Summary:	Drop-down terminal for GNOME Desktop Environment
Summary(ja): 	GNOME 用のドロップダウン式の端末エミュレータ
Name:		guake
Version:	0.4.4
Release: 	2%{?_dist_release}
Source0:	%{name}-%{version}.tar.gz
#Source1:	guake-0.4.1-ja.po
Patch0:         0001-Fix-focus-issue-on-gnome-shell.patch
Patch1:         0001-Fix-notification.patch

License:	GPLv2+
Group:		Applications/Accessories
URL:		http://guake.org/

Requires(pre):	GConf2
Requires(post): GConf2
Requires(preun):GConf2

BuildRequires: python, python-devel
BuildRequires: gtk2-devel, pygtk2-devel
BuildRequires: vte, GConf2-devel, libffi-devel
BuildRequires: desktop-file-utils
BuildRequires: intltool, gettext
BuildRoot:	%{_tmppath}/%{name}-%{version}-root

Packager:	kazutaka

%description
Guake is a dropdown terminal made for the GNOME desktop environment.
Its style of window is based on an fps games, and one of its goals
is be easy to reach.

%description -l ja
Guake は GNOME デスクトップ環境向けに開発されたドロップダウン
形の端末です。
FPS ゲーム用端末と同じスタイルを採用しており、素早く利用できる、
というのがこのプログラムのゴールの一つです。


%prep
%setup -q
#%{__cp} %{SOURCE1} po/ja.po
sed -i 's/Encoding=UTF-8//g' data/guake.desktop.in data/guake-prefs.desktop.in
sed -i 's/Categories=GNOME;GTK;Utility;TerminalEmulator;/Categories=GNOME;GTK;Utility;/g' \
        data/guake.desktop.in

%patch0 -p1
%patch1 -p1

%build
%configure --disable-static \
           --disable-schemas-install
%{__make} %{?_smp_mflags}


%install
%{__rm} -rf $RPM_BUILD_ROOT
%{__make} install DESTDIR=$RPM_BUILD_ROOT

%find_lang %{name}
rm -f %{buildroot}%{_libdir}/%{name}/globalhotkeys.la

if [ "%{python_sitearch}" != "%{python_sitelib}" ]; then
  mv %{buildroot}%{python_sitelib}/%{name}/* %{buildroot}%{python_sitearch}/%{name}/
fi

%check
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}.desktop
desktop-file-validate %{buildroot}%{_datadir}/applications/%{name}-prefs.desktop

%pre
# uninstall old schemas before update
if [ "$1" -gt 1 ]; then
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
      %{_sysconfdir}/gconf/schemas/%{name}.schemas > /dev/null ||:
fi

%post
update-desktop-database &>/dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :

# install schemas after install/update
export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
gconftool-2 --makefile-install-rule \
    %{_sysconfdir}/gconf/schemas/%{name}.schemas > /dev/null ||:

%preun
# uninstall schemas before clean remove
if [ "$1" -eq 0 ]; then
  export GCONF_CONFIG_SOURCE=`gconftool-2 --get-default-source`
  gconftool-2 --makefile-uninstall-rule \
      %{_sysconfdir}/gconf/schemas/%{name}.schemas >/dev/null;
fi

%postun
update-desktop-database &>/dev/null || :
gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :


%clean
%{__rm} -rf $RPM_BUILD_ROOT


%files -f %{name}.lang
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO
%{_bindir}/%{name}
%{_bindir}/%{name}-prefs
%{_datadir}/%{name}
%{_datadir}/applications/%{name}-prefs.desktop
%{_datadir}/applications/%{name}.desktop
%{_datadir}/dbus-1/services/org.guake.Guake.service
%{_datadir}/icons/hicolor/*/
%{_datadir}/pixmaps/%{name}
%{python_sitearch}/%{name}
%{_mandir}/man1/guake.1*
%{_sysconfdir}/gconf/schemas/%{name}.schemas
#%{_sysconfdir}/xdg/autostart/%{name}.desktop


%changelog
* Fri Mar 21 2014 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.4.4-2
- rebuilt with new toolchain

* Sat Jul 28 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.4.4-1
- new upstream release
- added Patch1 from Fedora
- run gtk-update-icon-cache in %%post, %%posutn

* Thu Jun 28 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.4.3-2
- run desktop-file-validate in %%check

* Tue Jun 26 2012 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.4.3-1
- new upstream release
- added Patch0 from Fedora rawhide
- added BuildRequires: desktop-file-utils, gettext, intltool
- run desktop-file-validate in %%install

* Sun Oct 17 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.4.2-1
- new upstream release

* Sat Jul 17 2010 Kazutaka HARADA <kazutaka@vinelinux.org> 0.4.1-1
- initial build for Vine Linux
- add Source1: updated japanese translation (ja.po)
