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
v3.5.13-sru
tpearson 15 years ago
parent 1c6affb83d
commit 70331186c8

@ -98,7 +98,13 @@ KBuildServiceTypeFactory::createEntry(const TQString &file, const char *resource
KServiceType* e; KServiceType* e;
if ( mime == "inode/directory" ) if ( mime == "inode/directory" )
e = new KFolderType( &desktopFile ); 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 ); e = new KDEDesktopMimeType( &desktopFile );
else if ( mime == "application/x-executable" || mime == "application/x-shellscript" ) else if ( mime == "application/x-executable" || mime == "application/x-shellscript" )
e = new KExecMimeType( &desktopFile ); e = new KExecMimeType( &desktopFile );
@ -250,7 +256,7 @@ KBuildServiceTypeFactory::addEntry(KSycocaEntry *newEntry, const char *resource)
// Already exists // Already exists
if (serviceType->desktopEntryPath().endsWith("kdelnk")) if (serviceType->desktopEntryPath().endsWith("kdelnk"))
return; // Skip return; // Skip
// Replace // Replace
KSycocaFactory::removeEntry(newEntry); KSycocaFactory::removeEntry(newEntry);
} }

@ -86,7 +86,13 @@ void KBookmarkImporter::scanIntern( TQDomElement & parentElem, const TQString &
groupElem.setAttribute("toolbar","yes"); groupElem.setAttribute("toolbar","yes");
scanIntern( groupElem, file.path() ); 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 ); KSimpleConfig cfg( file.path(), true );
cfg.setDesktopGroup(); cfg.setDesktopGroup();

@ -638,7 +638,13 @@ bool KPropsDlgPlugin::isDesktopFile( KFileItem * _item )
fclose(f); fclose(f);
// return true if desktop file // 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 ) 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 ); fileSystemSupportsACLs = ( statfs( pathCString.data(), &buf ) == 0 ) && ( buf.f_flags & MNT_ACLS );
#else #else
fileSystemSupportsACLs = fileSystemSupportsACLs =
getxattr( pathCString.data(), "system.posix_acl_access", NULL, 0 ) >= 0 getxattr( pathCString.data(), "system.posix_acl_access", NULL, 0 ) >= 0
#ifdef ENODATA #ifdef ENODATA
|| (errno == ENODATA) || (errno == ENODATA)
#endif #endif
#ifdef ENOATTR #ifdef ENOATTR
|| (errno == ENOATTR) || (errno == ENOATTR)
#endif #endif
; ;

@ -723,7 +723,13 @@ bool KFileItem::acceptsDrops()
if ( !m_bIsLocalURL ) if ( !m_bIsLocalURL )
return false; 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; return true;
// Executable, shell script ... ? // Executable, shell script ... ?

@ -127,7 +127,13 @@ pid_t KRun::runURL( const KURL& u, const TQString& _mimetype, TQWidget* window,
i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>").arg(u.htmlURL()) ); i18n("<qt>Unable to enter <b>%1</b>.\nYou do not have access rights to this location.</qt>").arg(u.htmlURL()) );
return 0; 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 ) if ( u.isLocalFile() && runExecutables )
return KDEDesktopMimeType::run( u, true ); return KDEDesktopMimeType::run( u, true );
@ -794,7 +800,7 @@ pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* wi
TQString error; TQString error;
int pid = 0; int pid = 0;
TQCString myasn = asn; TQCString myasn = asn;
// startServiceByDesktopPath() doesn't take TQWidget*, add it to the startup info now // startServiceByDesktopPath() doesn't take TQWidget*, add it to the startup info now
if( window != NULL ) if( window != NULL )
@ -810,7 +816,7 @@ pid_t KRun::run( const KService& _service, const KURL::List& _urls, TQWidget* wi
KStartupInfo::sendChange( id, data ); KStartupInfo::sendChange( id, data );
} }
} }
int i = KApplication::startServiceByDesktopPath( int i = KApplication::startServiceByDesktopPath(
_service.desktopEntryPath(), urls.toStringList(), &error, 0L, &pid, myasn _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. // 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 = KURL();
m_strURL.setPath( d->m_localPath ); m_strURL.setPath( d->m_localPath );
@ -1370,6 +1382,12 @@ void KRun::setSuggestedFileName( const TQString& fileName )
bool KRun::isExecutable( const TQString& serviceType ) bool KRun::isExecutable( const TQString& serviceType )
{ {
return ( serviceType == "application/x-desktop" || 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-executable" ||
serviceType == "application/x-msdos-program" || serviceType == "application/x-msdos-program" ||
serviceType == "application/x-shellscript" ); serviceType == "application/x-shellscript" );

@ -177,7 +177,14 @@ void PreviewJob::startPreview()
PreviewItem item; PreviewItem item;
item.item = it.current(); item.item = it.current();
TQMap<TQString, KService::Ptr>::ConstIterator plugin = mimeMap.find(it.current()->mimetype()); TQMap<TQString, KService::Ptr>::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(); TQString mimeType = it.current()->mimetype();
plugin = mimeMap.find(mimeType.replace(TQRegExp("/.*"), "/*")); plugin = mimeMap.find(mimeType.replace(TQRegExp("/.*"), "/*"));
@ -393,10 +400,10 @@ bool PreviewJob::statResultThumbnail()
// way (file:/path/to/file) // way (file:/path/to/file)
#ifdef KURL_TRIPLE_SLASH_FILE_PROT #ifdef KURL_TRIPLE_SLASH_FILE_PROT
d->origName = url.url(); d->origName = url.url();
#else #else
if (url.protocol() == "file") d->origName = "file://" + url.path(); if (url.protocol() == "file") d->origName = "file://" + url.path();
else d->origName = url.url(); else d->origName = url.url();
#endif #endif
KMD5 md5( TQFile::encodeName( d->origName ) ); KMD5 md5( TQFile::encodeName( d->origName ) );
d->thumbName = TQFile::encodeName( md5.hexDigest() ) + ".png"; 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("Thumb::Mimetype", 0, d->currentItem.item->mimetype());
thumb.setText("Software", 0, "KDE Thumbnail Generator"); thumb.setText("Software", 0, "KDE Thumbnail Generator");
KTempFile temp(d->thumbPath + "kde-tmp-", ".png"); 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. { //actually created the temp file.
thumb.save(temp.name(), "PNG"); thumb.save(temp.name(), "PNG");
rename(TQFile::encodeName(temp.name()), TQFile::encodeName(d->thumbPath + d->thumbName)); rename(TQFile::encodeName(temp.name()), TQFile::encodeName(d->thumbPath + d->thumbName));

@ -499,6 +499,12 @@ void BrowserRun::slotCopyToTempFileResult(KIO::Job *job)
bool BrowserRun::isTextExecutable( const TQString &serviceType ) bool BrowserRun::isTextExecutable( const TQString &serviceType )
{ {
return ( serviceType == "application/x-desktop" || 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" ); serviceType == "application/x-shellscript" );
} }

Loading…
Cancel
Save