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

List:       kde-commits
Subject:    KDE/kdelibs
From:       Luboš Luňák <l.lunak () kde ! org>
Date:       2010-03-30 9:52:14
Message-ID: 20100330095214.7C4E0AC889 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1108993 by lunakl:

Implement APPLICATION_ID from the startup spec.
http://lists.freedesktop.org/archives/xdg/2010-March/011401.html



 M  +30 -0     kdeui/kernel/kstartupinfo.cpp  
 M  +13 -0     kdeui/kernel/kstartupinfo.h  
 M  +1 -0      kinit/klauncher.cpp  
 M  +2 -0      kio/kio/krun.cpp  


--- trunk/KDE/kdelibs/kdeui/kernel/kstartupinfo.cpp #1108992:1108993
@@ -54,6 +54,7 @@
 #include <kdebug.h>
 #include <kapplication.h>
 #include <signal.h>
+#include <kstandarddirs.h>
 #ifdef Q_WS_X11
 #include <kwindowsystem.h>
 #include <kxmessages.h>
@@ -118,6 +119,7 @@
     int screen;
     int xinerama;
     WId launched_by;
+    QString application_id;
     };
 
 class KStartupInfo::Private
@@ -1215,6 +1217,8 @@
         ret += QString::fromLatin1( " XINERAMA=%1" ).arg( xinerama );
     if( launched_by != 0 )
         ret += QString::fromLatin1( " LAUNCHED_BY=%1" ).arg( (long)launched_by );
+    if( !application_id.isEmpty())
+        ret += QString::fromLatin1( " APPLICATION_ID=%1" ).arg( application_id );
     return ret;
     }
 
@@ -1234,6 +1238,7 @@
     const QString screen_str = QString::fromLatin1( "SCREEN=" );
     const QString xinerama_str = QString::fromLatin1( "XINERAMA=" );
     const QString launched_by_str = QString::fromLatin1( "LAUNCHED_BY=" );
+    const QString application_id_str = QString::fromLatin1( "APPLICATION_ID=" );
     for( QStringList::ConstIterator it = items.begin();
          it != items.end();
          ++it )
@@ -1270,6 +1275,8 @@
             d->xinerama = get_num( *it );
         else if( ( *it ).startsWith( launched_by_str ))
             d->launched_by = ( WId ) get_num( *it );
+        else if( ( *it ).startsWith( application_id_str ))
+            d->application_id = get_str( *it );
         }
     }
 
@@ -1315,6 +1322,8 @@
         d->xinerama = data_P.xinerama();
     if( data_P.launchedBy() != 0 && launchedBy() != 0 ) // don't overwrite
         d->launched_by = data_P.launchedBy();
+    if( !data_P.applicationId().isEmpty() && applicationId().isEmpty()) // don't overwrite
+        d->application_id = data_P.applicationId();
     }
 
 KStartupInfoData::KStartupInfoData() : d(new Private)
@@ -1504,6 +1513,27 @@
     return d->launched_by;
     }
 
+void KStartupInfoData::setApplicationId( const QString& desktop )
+    {
+    if( desktop.startsWith( '/' ))
+        {
+        d->application_id = desktop;
+        return;
+        }
+    // the spec requires this is always a full path, in order for everyone to be able to find it
+    QString desk = KStandardDirs::locate( "apps", desktop );
+    if( desk.isEmpty())
+        desk = KStandardDirs::locate( "services", desktop );
+    if( desk.isEmpty())
+        return;
+    d->application_id = desk;
+    }
+
+QString KStartupInfoData::applicationId() const
+    {
+    return d->application_id;
+    }
+
 static
 long get_num( const QString& item_P )
     {
--- trunk/KDE/kdelibs/kdeui/kernel/kstartupinfo.h #1108992:1108993
@@ -631,6 +631,19 @@
          */
         void setLaunchedBy( WId window );
 
+        /**
+         * The .desktop file used to initiate this startup notification, or empty. This information
+         * should be used only to identify the application, not to read any additional information.
+         * @since 4.5
+         **/
+        QString applicationId() const;
+
+        /**
+         * Sets the .desktop file that was used to initiate the startup notification.
+         * @since 4.5
+         */
+        void setApplicationId( const QString& desktop );
+
 	/**
 	 * Updates the notification data from the given data. Some data, such as the desktop
 	 * or the name, won't be rewritten if already set.
--- trunk/KDE/kdelibs/kinit/klauncher.cpp #1108992:1108993
@@ -924,6 +924,7 @@
         data.setWMClass( wmclass );
     if( silent )
         data.setSilent( KStartupInfoData::Yes );
+    data.setApplicationId( service->entryPath());
     // the rest will be sent by kdeinit
     KStartupInfo::sendStartupX( dpy, id, data );
     if( mCached_dpy != dpy && mCached_dpy != NULL )
--- trunk/KDE/kdelibs/kio/kio/krun.cpp #1108992:1108993
@@ -567,6 +567,8 @@
         if (window) {
             data.setLaunchedBy(window->winId());
         }
+        if(service)
+            data.setApplicationId(service->entryPath());
         KStartupInfo::sendStartup(id, data);
     }
     int pid = KProcessRunner::run(proc, executable, id);
[prev in list] [next in list] [prev in thread] [next in thread] 

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