[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    Re: KDE/kdebase/apps
From:       Allen Winter <winter () kde ! org>
Date:       2009-01-18 23:56:54
Message-ID: 200901181856.55574.winter () kde ! org
[Download RAW message or body]

On Sunday 18 January 2009 6:44:48 pm Jakob Petsovits wrote:
> SVN commit 913253 by jpetso:
> 
> Make kdialog use Plasma's notification bling (via D-Bus) if possible,
> keeping KPassivePopup as fallback in case the D-Bus invocation fails.
> The invocation code is a heavily simplified version of dimsuz's code
> in NotifyByPopup of KNotify, therefore his copyright instead of mine.
> 
> Ok to backport to 4.2, or rather not?
> 
You may.
If you think it makes a 4.2 release better.

> 
> M  +3 -0      config-apps.h.cmake  
> M  +3 -0      kdialog/CMakeLists.txt  
> M  +70 -0     kdialog/kdialog.cpp  
> 
> 
> --- trunk/KDE/kdebase/apps/config-apps.h.cmake #913252:913253
> @@ -69,6 +69,9 @@
> /* Define to 1 if you have the `vsnprintf' function. */
> #cmakedefine HAVE_VSNPRINTF 1
> 
> +/* Define to 1 if the QtDBus module is present. */
> +#cmakedefine QT_QTDBUS_FOUND 1
> +
> /* KDE's binaries directory */
> #define KDE_BINDIR "${BIN_INSTALL_DIR}"
> 
> --- trunk/KDE/kdebase/apps/kdialog/CMakeLists.txt #913252:913253
> @@ -12,6 +12,9 @@
> target_link_libraries(kdialog ${KDE4_KFILE_LIBS} ${KDE4_KIO_LIBS})
> if (Q_WS_X11)
> target_link_libraries(kdialog ${X11_X11_LIB})
> +  if (QT_QTDBUS_FOUND)
> +    target_link_libraries(kdialog ${QT_QTDBUS_LIBRARY})
> +  endif (QT_QTDBUS_FOUND)
> endif (Q_WS_X11)
> 
> install(TARGETS kdialog ${INSTALL_TARGETS_DEFAULT_ARGS})
> --- trunk/KDE/kdebase/apps/kdialog/kdialog.cpp #913252:913253
> @@ -2,6 +2,7 @@
> //  Copyright (C) 1998 Matthias Hoelzer <hoelzer@kde.org>
> //  Copyright (C) 2002 David Faure <faure@kde.org>
> //  Copyright (C) 2005 Brad Hards <bradh@frogmouth.net>
> +//  Copyright (C) 2008 by Dmitry Suzdalev <dimsuz@gmail.com>
> //
> //  This program is free software; you can redistribute it and/or modify
> //  it under the terms of the GNU General Public License as published by
> @@ -43,6 +44,12 @@
> #include <netwm.h>
> #endif
> 
> +#include "../config-apps.h"
> +#ifdef QT_QTDBUS_FOUND
> +#include <QtDBus/QDBusConnection>
> +#include <QtDBus/QDBusConnectionInterface>
> +#endif
> +
> #ifdef Q_WS_WIN
> #include <QtGui/QFileDialog>
> #endif
> @@ -85,6 +92,63 @@
> return QObject::eventFilter(o, e);
> }
> 
> +/**
> + * Display a passive notification popup using the D-Bus interface, if possible.
> + * @return true if the notification was successfully sent, false otherwise.
> + */
> +bool sendVisualNotification(QString text, QString title, int timeout)
> +{
> +#ifdef QT_QTDBUS_FOUND
> +  const QString dbusServiceName = "org.kde.VisualNotifications";
> +  const QString dbusInterfaceName = "org.kde.VisualNotifications";
> +  const QString dbusPath = "/VisualNotifications";
> +
> +  // check if service already exists on plugin instantiation
> +  QDBusConnectionInterface* interface = QDBusConnection::sessionBus().interface();
> +
> +  if (!interface || !interface->isServiceRegistered(dbusServiceName)) {
> +    //kDebug() << dbusServiceName << "D-Bus service not registered";
> +    return false;
> +  }
> +
> +  if (timeout == 0)
> +    timeout = 10 * 1000;
> +
> +  QDBusMessage m = QDBusMessage::createMethodCall(dbusServiceName, dbusPath, \
> dbusInterfaceName, "Notify"); +  QList<QVariant> args;
> +
> +  args.append("kdialog"); // app_name
> +  args.append(0U); // replaces_id
> +  args.append("kdialogPassivePopup"); // event_id
> +  args.append("dialog-information"); // app_icon
> +  args.append(title); // summary
> +  args.append(text); // body
> +  args.append(QStringList()); // actions - unused for plain passive popups
> +  args.append(QVariantMap()); // hints - unused atm
> +  args.append(timeout); // expire timout
> +
> +  m.setArguments(args);
> +
> +  QDBusMessage replyMsg = QDBusConnection::sessionBus().call(m);
> +  if(replyMsg.type() == QDBusMessage::ReplyMessage) {
> +    if (!replyMsg.arguments().isEmpty()) {
> +      return true;
> +    }
> +    // Not displaying any error messages as this is optional for kdialog
> +    // and KPassivePopup is a perfectly valid fallback.
> +    //else {
> +    //  kDebug() << "Error: received reply with no arguments.";
> +    //}
> +  } else if (replyMsg.type() == QDBusMessage::ErrorMessage) {
> +    //kDebug() << "Error: failed to send D-Bus message";
> +    //kDebug() << replyMsg;
> +  } else {
> +    //kDebug() << "Unexpected reply type";
> +  }
> +#endif
> +  return false;
> +}
> +
> static void outputStringList(const QStringList &list, bool separateOutput)
> {
> if ( separateOutput) {
> @@ -252,6 +316,12 @@
> duration = 1000 * args->arg(0).toInt();
> if (duration == 0)
> duration = 10000;
> +
> +        // try to use more stylish notifications
> +        if (sendVisualNotification(args->getOption("passivepopup"), title, \
> duration)) +          return 0;
> +
> +        // ...did not work, use KPassivePopup as fallback
> KPassivePopup *popup = KPassivePopup::message( KPassivePopup::Boxed, // style
> title,
> args->getOption("passivepopup"),
> 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic