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

List:       kde-core-devel
Subject:    Re: Support for tryExec in sidebar plugins
From:       Marcus Camen <mcamen () mcamen ! de>
Date:       2004-07-19 19:05:50
Message-ID: 200407192105.55163.mcamen () mcamen ! de
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


On Monday 19 July 2004 20:43, David Faure wrote:
> On Monday 19 July 2004 20:33, Marcus Camen wrote:
> > Hi *,
> >
> > AFAIK for kdm session files (like twm.desktop) we read the 'TryExec'
> > key in the .desktop file and check if the given executable is
> > available or not. The same applies for KService which is used by the
> > Kontact plugin system (e.g. David and Daniel committed a modified
> > newsticker plugin today).
> >
> > The attached patch implements a similar functionality in
> > kdebase/konqueror/sidebar/sidebar_widget.cpp. It affects the 'Add
> > New' popup menu in a way that sidebar plugins which have
> > (TryExec==foo && executable foo does not exist) will not be shown.
> > Therefore a user will not be able to add non-functional plugins.
>
> I like the idea but I think it should be implemented with
> KDesktopFile::tryExec()

Yeah, I ripped from kdm/kfrontend/kgreeter.h  ;)
Patch with KDesktopFile is attached.

-- 
Marcus

["sidebar-KDesktopFile.diff" (text/x-diff)]

Index: sidebar_widget.cpp
===================================================================
RCS file: /home/kde/kdebase/konqueror/sidebar/sidebar_widget.cpp,v
retrieving revision 1.128
diff -u -5 -p -d -r1.128 sidebar_widget.cpp
--- sidebar_widget.cpp	26 Jun 2004 16:33:30 -0000	1.128
+++ sidebar_widget.cpp	19 Jul 2004 19:00:10 -0000
@@ -40,10 +40,11 @@
 #include <kpopupmenu.h>
 #include <kprocess.h>
 #include <kurlrequesterdlg.h>
 #include <kinputdialog.h>
 #include <kfiledialog.h>
+#include <kdesktopfile.h>
 #include "konqsidebar.h"
 
 #include "sidebar_widget.h"
 #include "sidebar_widget.moc"
 
@@ -73,14 +74,18 @@ void addBackEnd::aboutToShowAddMenu()
 	menu->clear();
 	int i = 0;
 
 	for (QStringList::Iterator it = list.begin(); it != list.end(); ++it, i++ )
 	{
-		KSimpleConfig *confFile;
+		KDesktopFile *confFile;
 
-		confFile = new KSimpleConfig(*it, true);
-		confFile->setGroup("Desktop Entry");
+		confFile = new KDesktopFile(*it, true);
+		if (! confFile->tryExec()) {
+			delete confFile;
+			i--;
+			continue;
+		}
 		if (m_universal) {
 			if (confFile->readEntry("X-KDE-KonqSidebarUniversal").upper()!="TRUE") {
 				delete confFile;
 				i--;
 				continue;
@@ -90,11 +95,11 @@ void addBackEnd::aboutToShowAddMenu()
 				delete confFile;
 				i--;
 				continue;
 			}
 		}
-		QString icon = confFile->readEntry("Icon");
+		QString icon = confFile->readIcon();
 		if (!icon.isEmpty())
 		{
 			menu->insertItem(SmallIcon(icon),
 					 confFile->readEntry("Name"), i);
 		} else {

[Attachment #6 (application/pgp-signature)]

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

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