From 2eb92b0da899c88cbc7595e4125962f8a9d0dfcb Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 9 Sep 2012 13:36:43 +0000 Subject: [PATCH] Allow using versions of libnotify < 0.7 in wxGTK. libnotify 0.4.5 included in Ubuntu Lucid (10.04) can be used for implementing wxNotificationMessage too, there is only a minor difference with 0.7 API. So while we stick check for 0.7 initially, accept lower versions too if 0.7 is not available. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72456 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- configure | 161 +++++++++++++++++++++++++++++++++++++++++-- configure.in | 19 +++-- setup.h.in | 4 ++ src/gtk/notifmsg.cpp | 7 ++ 4 files changed, 180 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 9979575fcc..ab85cccdc2 100755 --- a/configure +++ b/configure @@ -34032,6 +34032,7 @@ fi if test "$wxUSE_NOTIFICATION_MESSAGE" = "yes" ; then if test "$wxUSE_LIBNOTIFY" = "yes" ; then + HAVE_LIBNOTIFY=0 pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNOTIFY" >&5 @@ -34092,15 +34093,157 @@ fi echo "$LIBNOTIFY_PKG_ERRORS" >&5 - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNOTIFY" >&5 +$as_echo_n "checking for LIBNOTIFY... " >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$LIBNOTIFY_CFLAGS"; then + pkg_cv_LIBNOTIFY_CFLAGS="$LIBNOTIFY_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify >= 0.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_CFLAGS=`$PKG_CONFIG --cflags "libnotify >= 0.4" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$LIBNOTIFY_LIBS"; then + pkg_cv_LIBNOTIFY_LIBS="$LIBNOTIFY_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify >= 0.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_LIBS=`$PKG_CONFIG --libs "libnotify >= 0.4" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libnotify >= 0.4"` + else + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libnotify >= 0.4"` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNOTIFY_PKG_ERRORS" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 $as_echo "$as_me: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&2;} +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 +$as_echo "$as_me: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&2;} + +else + LIBNOTIFY_CFLAGS=$pkg_cv_LIBNOTIFY_CFLAGS + LIBNOTIFY_LIBS=$pkg_cv_LIBNOTIFY_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_LIBNOTIFY=1 +fi + elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBNOTIFY" >&5 +$as_echo_n "checking for LIBNOTIFY... " >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$LIBNOTIFY_CFLAGS"; then + pkg_cv_LIBNOTIFY_CFLAGS="$LIBNOTIFY_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify >= 0.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_CFLAGS=`$PKG_CONFIG --cflags "libnotify >= 0.4" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$LIBNOTIFY_LIBS"; then + pkg_cv_LIBNOTIFY_LIBS="$LIBNOTIFY_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libnotify >= 0.4\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libnotify >= 0.4") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_LIBNOTIFY_LIBS=`$PKG_CONFIG --libs "libnotify >= 0.4" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libnotify >= 0.4"` + else + LIBNOTIFY_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libnotify >= 0.4"` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBNOTIFY_PKG_ERRORS" >&5 + + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 $as_echo "$as_me: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&2;} +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&5 +$as_echo "$as_me: WARNING: libnotify not found, wxNotificationMessage will use generic implementation." >&2;} + +else + LIBNOTIFY_CFLAGS=$pkg_cv_LIBNOTIFY_CFLAGS + LIBNOTIFY_LIBS=$pkg_cv_LIBNOTIFY_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + HAVE_LIBNOTIFY=1 +fi + else LIBNOTIFY_CFLAGS=$pkg_cv_LIBNOTIFY_CFLAGS @@ -34108,13 +34251,19 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - GUI_TK_LIBRARY="$GUI_TK_LIBRARY $LIBNOTIFY_LIBS" - CFLAGS="$LIBNOTIFY_CFLAGS $CFLAGS" - CXXFLAGS="$LIBNOTIFY_CFLAGS $CXXFLAGS" - $as_echo "#define wxUSE_LIBNOTIFY 1" >>confdefs.h + HAVE_LIBNOTIFY=1 + $as_echo "#define wxUSE_LIBNOTIFY_0_7 1" >>confdefs.h fi + + if test "$HAVE_LIBNOTIFY" = "1" ; then + GUI_TK_LIBRARY="$GUI_TK_LIBRARY $LIBNOTIFY_LIBS" + CFLAGS="$LIBNOTIFY_CFLAGS $CFLAGS" + CXXFLAGS="$LIBNOTIFY_CFLAGS $CXXFLAGS" + $as_echo "#define wxUSE_LIBNOTIFY 1" >>confdefs.h + + fi fi fi diff --git a/configure.in b/configure.in index 8b0c1250b8..0ca7b1a007 100644 --- a/configure.in +++ b/configure.in @@ -5668,17 +5668,26 @@ if test "$WXGTK2" = 1; then if test "$wxUSE_NOTIFICATION_MESSAGE" = "yes" ; then if test "$wxUSE_LIBNOTIFY" = "yes" ; then + HAVE_LIBNOTIFY=0 PKG_CHECK_MODULES(LIBNOTIFY, [libnotify >= 0.7], [ - GUI_TK_LIBRARY="$GUI_TK_LIBRARY $LIBNOTIFY_LIBS" - CFLAGS="$LIBNOTIFY_CFLAGS $CFLAGS" - CXXFLAGS="$LIBNOTIFY_CFLAGS $CXXFLAGS" - AC_DEFINE(wxUSE_LIBNOTIFY) + HAVE_LIBNOTIFY=1 + AC_DEFINE(wxUSE_LIBNOTIFY_0_7) ], [ - AC_MSG_WARN([libnotify not found, wxNotificationMessage will use generic implementation.]) + PKG_CHECK_MODULES(LIBNOTIFY, [libnotify >= 0.4], + [HAVE_LIBNOTIFY=1], + [AC_MSG_WARN([libnotify not found, wxNotificationMessage will use generic implementation.])] + ) ] ) + + if test "$HAVE_LIBNOTIFY" = "1" ; then + GUI_TK_LIBRARY="$GUI_TK_LIBRARY $LIBNOTIFY_LIBS" + CFLAGS="$LIBNOTIFY_CFLAGS $CFLAGS" + CXXFLAGS="$LIBNOTIFY_CFLAGS $CXXFLAGS" + AC_DEFINE(wxUSE_LIBNOTIFY) + fi fi fi diff --git a/setup.h.in b/setup.h.in index 8d69056356..bda2a49482 100644 --- a/setup.h.in +++ b/setup.h.in @@ -826,6 +826,10 @@ * Use libnotify library. */ #define wxUSE_LIBNOTIFY 0 +/* + * Use libnotify 0.7+ API. + */ +#define wxUSE_LIBNOTIFY_0_7 0 /* * Use libXpm */ diff --git a/src/gtk/notifmsg.cpp b/src/gtk/notifmsg.cpp index d50dee2140..a3cf7ff39c 100644 --- a/src/gtk/notifmsg.cpp +++ b/src/gtk/notifmsg.cpp @@ -138,6 +138,13 @@ bool wxNotificationMessage::Show(int timeout) GetTitle().utf8_str(), GetMessage().utf8_str(), icon +#if !wxUSE_LIBNOTIFY_0_7 + // There used to be an "associated window" + // parameter in this function but it has + // disappeared by 0.7, so use it for previous + // versions only. + , 0 +#endif // libnotify < 0.7 ); if ( !m_notification ) {