From 70331186c82001a2652bf40e01d49dc8a8ac3a4b Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 15 Sep 2010 21:18:13 +0000 Subject: Commit 1/2 of new (and optional!) builtin desktop icons git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1175771 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kded/kbuildservicetypefactory.cpp | 10 ++++++++-- kio/bookmarks/kbookmarkimporter_kde1.cc | 8 +++++++- kio/kfile/kpropertiesdialog.cpp | 14 ++++++++++---- kio/kio/kfileitem.cpp | 8 +++++++- kio/kio/krun.cpp | 26 ++++++++++++++++++++++---- kio/kio/previewjob.cpp | 15 +++++++++++---- kparts/browserrun.cpp | 6 ++++++ 7 files changed, 71 insertions(+), 16 deletions(-) diff --git a/kded/kbuildservicetypefactory.cpp b/kded/kbuildservicetypefactory.cpp index 4861c3fba..b5259c5cd 100644 --- a/kded/kbuildservicetypefactory.cpp +++ b/kded/kbuildservicetypefactory.cpp @@ -98,7 +98,13 @@ KBuildServiceTypeFactory::createEntry(const TQString &file, const char *resource KServiceType* e; if ( mime == "inode/directory" ) e = new KFolderType( &desktopFile ); - else if ( mime == "application/x-desktop" ) + else if ( (mime == "application/x-desktop") + || (mime == "media/builtin-mydocuments") + || (mime == "media/builtin-mycomputer") + || (mime == "media/builtin-mynetworkplaces") + || (mime == "media/builtin-printers") + || (mime == "media/builtin-trash") + || (mime == "media/builtin-webbrowser") ) e = new KDEDesktopMimeType( &desktopFile ); else if ( mime == "application/x-executable" || mime == "application/x-shellscript" ) e = new KExecMimeType( &desktopFile ); @@ -250,7 +256,7 @@ KBuildServiceTypeFactory::addEntry(KSycocaEntry *newEntry, const char *resource) // Already exists if (serviceType->desktopEntryPath().endsWith("kdelnk")) return; // Skip - + // Replace KSycocaFactory::removeEntry(newEntry); } diff --git a/kio/bookmarks/kbookmarkimporter_kde1.cc b/kio/bookmarks/kbookmarkimporter_kde1.cc index 510787ab1..49999e675 100644 --- a/kio/bookmarks/kbookmarkimporter_kde1.cc +++ b/kio/bookmarks/kbookmarkimporter_kde1.cc @@ -86,7 +86,13 @@ void KBookmarkImporter::scanIntern( TQDomElement & parentElem, const TQString & groupElem.setAttribute("toolbar","yes"); scanIntern( groupElem, file.path() ); } - else if ( res->name() == "application/x-desktop" ) + else if ( (res->name() == "application/x-desktop") + || (res->name() == "media/builtin-mydocuments") + || (res->name() == "media/builtin-mycomputer") + || (res->name() == "media/builtin-mynetworkplaces") + || (res->name() == "media/builtin-printers") + || (res->name() == "media/builtin-trash") + || (res->name() == "media/builtin-webbrowser") ) { KSimpleConfig cfg( file.path(), true ); cfg.setDesktopGroup(); diff --git a/kio/kfile/kpropertiesdialog.cpp b/kio/kfile/kpropertiesdialog.cpp index 9e26f12bb..89529830a 100644 --- a/kio/kfile/kpropertiesdialog.cpp +++ b/kio/kfile/kpropertiesdialog.cpp @@ -638,7 +638,13 @@ bool KPropsDlgPlugin::isDesktopFile( KFileItem * _item ) fclose(f); // return true if desktop file - return ( _item->mimetype() == "application/x-desktop" ); + return ( (_item->mimetype() == "application/x-desktop") + || (_item->mimetype() == "media/builtin-mydocuments") + || (_item->mimetype() == "media/builtin-mycomputer") + || (_item->mimetype() == "media/builtin-mynetworkplaces") + || (_item->mimetype() == "media/builtin-printers") + || (_item->mimetype() == "media/builtin-trash") + || (_item->mimetype() == "media/builtin-webbrowser") ); } void KPropsDlgPlugin::setDirty( bool b ) @@ -1881,11 +1887,11 @@ static bool fileSystemSupportsACL( const TQCString& pathCString ) fileSystemSupportsACLs = ( statfs( pathCString.data(), &buf ) == 0 ) && ( buf.f_flags & MNT_ACLS ); #else fileSystemSupportsACLs = - getxattr( pathCString.data(), "system.posix_acl_access", NULL, 0 ) >= 0 -#ifdef ENODATA + getxattr( pathCString.data(), "system.posix_acl_access", NULL, 0 ) >= 0 +#ifdef ENODATA || (errno == ENODATA) #endif -#ifdef ENOATTR +#ifdef ENOATTR || (errno == ENOATTR) #endif ; diff --git a/kio/kio/kfileitem.cpp b/kio/kio/kfileitem.cpp index 9f89765d2..010832573 100644 --- a/kio/kio/kfileitem.cpp +++ b/kio/kio/kfileitem.cpp @@ -723,7 +723,13 @@ bool KFileItem::acceptsDrops() if ( !m_bIsLocalURL ) return false; - if ( mimetype() == "application/x-desktop") + if (( mimetype() == "application/x-desktop") || + ( mimetype() == "media/builtin-mydocuments") || + ( mimetype() == "media/builtin-mycomputer") || + ( mimetype() == "media/builtin-mynetworkplaces") || + ( mimetype() == "media/builtin-printers") || + ( mimetype() == "media/builtin-trash") || + ( mimetype() == "media/builtin-webbrowser")) return true; // Executable, shell script ... ? diff --git a/kio/kio/krun.cpp b/kio/kio/krun.cpp index 199a6b5b9..f02ced30d 100644 --- a/kio/kio/krun.cpp +++ b/kio/kio/krun.cpp @@ -127,7 +127,13 @@ pid_t KRun::runURL( const KURL& u, const TQString& _mimetype, TQWidget* window, i18n("Unable to enter %1.\nYou do not have access rights to this location.").arg(u.htmlURL()) ); return 0; } - else if ( _mimetype == "application/x-desktop" ) + else if ( (_mimetype == "application/x-desktop") || + (_mimetype == "media/builtin-mydocuments") || + (_mimetype == "media/builtin-mycomputer") || + (_mimetype == "media/builtin-mynetworkplaces") || + (_mimetype == "media/builtin-printers") || + (_mimetype == "media/builtin-trash") || + (_mimetype == "media/builtin-webbrowser") ) { if ( u.isLocalFile() && runExecutables ) return KDEDesktopMimeType::run( u, true ); @@ -794,7 +800,7 @@ pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* wi TQString error; int pid = 0; - + TQCString myasn = asn; // startServiceByDesktopPath() doesn't take TQWidget*, add it to the startup info now if( window != NULL ) @@ -810,7 +816,7 @@ pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* wi KStartupInfo::sendChange( id, data ); } } - + int i = KApplication::startServiceByDesktopPath( _service.desktopEntryPath(), urls.toStringList(), &error, 0L, &pid, myasn ); @@ -1300,7 +1306,13 @@ void KRun::foundMimeType( const TQString& type ) } // Resolve .desktop files from media:/, remote:/, applications:/ etc. - if ( type == "application/x-desktop" /* or inheriting? */ && !d->m_localPath.isEmpty() ) + if ( ((type == "application/x-desktop") || + (type == "media/builtin-mydocuments") || + (type == "media/builtin-mycomputer") || + (type == "media/builtin-mynetworkplaces") || + (type == "media/builtin-printers") || + (type == "media/builtin-trash") || + (type == "media/builtin-webbrowser")) /* or inheriting? */ && (!d->m_localPath.isEmpty()) ) { m_strURL = KURL(); m_strURL.setPath( d->m_localPath ); @@ -1370,6 +1382,12 @@ void KRun::setSuggestedFileName( const TQString& fileName ) bool KRun::isExecutable( const TQString& serviceType ) { return ( serviceType == "application/x-desktop" || + serviceType == "media/builtin-mydocuments" || + serviceType == "media/builtin-mycomputer" || + serviceType == "media/builtin-mynetworkplaces" || + serviceType == "media/builtin-printers" || + serviceType == "media/builtin-trash" || + serviceType == "media/builtin-webbrowser" || serviceType == "application/x-executable" || serviceType == "application/x-msdos-program" || serviceType == "application/x-shellscript" ); diff --git a/kio/kio/previewjob.cpp b/kio/kio/previewjob.cpp index 2a2ad91cc..3802093c1 100644 --- a/kio/kio/previewjob.cpp +++ b/kio/kio/previewjob.cpp @@ -177,7 +177,14 @@ void PreviewJob::startPreview() PreviewItem item; item.item = it.current(); TQMap::ConstIterator plugin = mimeMap.find(it.current()->mimetype()); - if (plugin == mimeMap.end() && it.current()->mimetype() != "application/x-desktop") + if (plugin == mimeMap.end() + && (it.current()->mimetype() != "application/x-desktop") + && (it.current()->mimetype() != "media/builtin-mydocuments") + && (it.current()->mimetype() != "media/builtin-mycomputer") + && (it.current()->mimetype() != "media/builtin-mynetworkplaces") + && (it.current()->mimetype() != "media/builtin-printers") + && (it.current()->mimetype() != "media/builtin-trash") + && (it.current()->mimetype() != "media/builtin-webbrowser")) { TQString mimeType = it.current()->mimetype(); plugin = mimeMap.find(mimeType.replace(TQRegExp("/.*"), "/*")); @@ -393,10 +400,10 @@ bool PreviewJob::statResultThumbnail() // way (file:/path/to/file) #ifdef KURL_TRIPLE_SLASH_FILE_PROT d->origName = url.url(); -#else +#else if (url.protocol() == "file") d->origName = "file://" + url.path(); else d->origName = url.url(); -#endif +#endif KMD5 md5( TQFile::encodeName( d->origName ) ); d->thumbName = TQFile::encodeName( md5.hexDigest() ) + ".png"; @@ -508,7 +515,7 @@ void PreviewJob::slotThumbData(KIO::Job *, const TQByteArray &data) thumb.setText("Thumb::Mimetype", 0, d->currentItem.item->mimetype()); thumb.setText("Software", 0, "KDE Thumbnail Generator"); KTempFile temp(d->thumbPath + "kde-tmp-", ".png"); - if (temp.status() == 0) //Only try to write out the thumbnail if we + if (temp.status() == 0) //Only try to write out the thumbnail if we { //actually created the temp file. thumb.save(temp.name(), "PNG"); rename(TQFile::encodeName(temp.name()), TQFile::encodeName(d->thumbPath + d->thumbName)); diff --git a/kparts/browserrun.cpp b/kparts/browserrun.cpp index b3e81f8d2..4d23d6300 100644 --- a/kparts/browserrun.cpp +++ b/kparts/browserrun.cpp @@ -499,6 +499,12 @@ void BrowserRun::slotCopyToTempFileResult(KIO::Job *job) bool BrowserRun::isTextExecutable( const TQString &serviceType ) { return ( serviceType == "application/x-desktop" || + serviceType == "media/builtin-mydocuments" || + serviceType == "media/builtin-mycomputer" || + serviceType == "media/builtin-mynetworkplaces" || + serviceType == "media/builtin-printers" || + serviceType == "media/builtin-trash" || + serviceType == "media/builtin-webbrowser" || serviceType == "application/x-shellscript" ); } -- cgit v1.2.1