* Allow XDG launcher to directly rewrite the XDG configuration file instead of going through a third party application

* Fix desktop icon builtin detection
* Desktop icon removal is now more intuitive


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1178835 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 14 years ago
parent d1839212f8
commit 6ade341229

@ -5,4 +5,5 @@ Name=My Computer
Name[en_US]=My Computer
OnlyShowIn=KDE;
Type=Link
URL=media:/
URL=media:/
X-Trinity-BuiltIn=true

@ -14,3 +14,4 @@ Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=
X-Trinity-BuiltIn=true

@ -6,3 +6,4 @@ Name[en_US]=My Network Places
OnlyShowIn=KDE;
Type=Link
URL=remote:/
X-Trinity-BuiltIn=true

@ -8,3 +8,4 @@ Exec=kjobviewer --all --show %i %m
OnlyShowIn=KDE;
X-DCOP-ServiceType=Unique
X-KDE-StartupNotify=true
X-Trinity-BuiltIn=true

@ -6,3 +6,4 @@ Icon=trashcan_full
EmptyIcon=trashcan_empty
Name=Trash
Comment=Contains removed files
X-Trinity-BuiltIn=true

@ -16,3 +16,4 @@ Type=Application
X-DCOP-ServiceType=
X-KDE-SubstituteUID=false
X-KDE-Username=
X-Trinity-BuiltIn=true

@ -190,6 +190,8 @@ KDIconView::KDIconView( TQWidget *parent, const char* name )
setAcceptDrops(false);
viewport()->setAcceptDrops(false);
}
g_pConfig = new KConfig("kdesktoprc");
}
KDIconView::~KDIconView()
@ -719,6 +721,74 @@ void KDIconView::slotPopupPasteTo()
paste( m_popupURL );
}
// These two functions and the following class are all lifted from desktopbehavior_impl.cpp to handle the media icons
class DesktopBehaviorMediaItem : public QCheckListItem
{
public:
DesktopBehaviorMediaItem(TQListView *parent, const TQString name, const TQString mimetype, bool on)
: TQCheckListItem(parent, name, CheckBox),
m_mimeType(mimetype){setOn(on);}
const TQString &mimeType() const { return m_mimeType; }
private:
TQString m_mimeType;
};
void KDIconView::fillMediaListView()
{
if (!mMediaListView)
mMediaListView = new TQListView();
mMediaListView->hide();
mMediaListView->clear();
KMimeType::List mimetypes = KMimeType::allMimeTypes();
TQValueListIterator<KMimeType::Ptr> it2(mimetypes.begin());
g_pConfig->setGroup( "Media" );
TQString excludedMedia=g_pConfig->readEntry("exclude","media/hdd_mounted,media/hdd_unmounted,media/floppy_unmounted,media/cdrom_unmounted,media/floppy5_unmounted");
for (; it2 != mimetypes.end(); ++it2) {
if ( ((*it2)->name().startsWith("media/")) )
{
bool ok=excludedMedia.contains((*it2)->name())==0;
new DesktopBehaviorMediaItem (mMediaListView, (*it2)->comment(), (*it2)->name(),ok);
}
}
}
void KDIconView::saveMediaListView()
{
g_pConfig->setGroup( "Media" );
TQStringList exclude;
for (DesktopBehaviorMediaItem *it=static_cast<DesktopBehaviorMediaItem *>(mMediaListView->firstChild());
it; it=static_cast<DesktopBehaviorMediaItem *>(it->nextSibling()))
{
if (!it->isOn()) exclude << it->mimeType();
}
g_pConfig->writeEntry("exclude",exclude);
g_pConfig->sync();
// Reload kdesktop configuration to apply changes
TQByteArray data;
int konq_screen_number = KApplication::desktop()->primaryScreen();
TQCString appname;
if (konq_screen_number == 0)
appname = "kdesktop";
else
appname.sprintf("kdesktop-screen-%d", konq_screen_number);
kapp->dcopClient()->send( appname, "KDesktopIface", "configure()", data );
}
void KDIconView::removeBuiltinIcon(TQString iconName)
{
DesktopBehaviorMediaItem *changeItem;
fillMediaListView();
changeItem = static_cast<DesktopBehaviorMediaItem *>(mMediaListView->findItem(iconName, 0));
if (changeItem != 0) {
changeItem->setOn(false);
}
saveMediaListView();
KMessageBox::information(0, i18n("You have chosen to remove a system icon") + TQString(".\n") + i18n("You can restore this icon in the future through the") + TQString(" \"") + ("Device Icons") + TQString("\" ") + i18n("tab in the") + TQString(" \"") + i18n("Behavior") + TQString("\" ") + i18n("pane of the Desktop Settings control module."), "System Icon Removed", "sysiconremovedwarning");
}
/**
* The files on the desktop come from a variety of sources.
* If an attempt is made to delete a .desktop file that does
@ -762,49 +832,44 @@ bool KDIconView::deleteGlobalDesktopFiles()
// Ignore these special files
// Name URL Type OnlyShowIn
// My Documents $HOME/Documents Link KDE;
// My Documents kxdglauncher --xdgname DOCUMENTS Application KDE;
// My Computer media:/ Link KDE;
// My Network Places remote:/ Link KDE;
// Printers [exec] kjobviewer --all --show %i %m Application KDE;
// Trash trash:/ Link KDE;
// Web Browser <dont care> Application KDE;
// Web Browser kfmclient openBrowser %u Application KDE;
if ( isDesktopFile(fItem) ) {
KSimpleConfig cfg( fItem->url().path(), true );
cfg.setDesktopGroup();
if ( cfg.readEntry( "Type" ) == "Link" &&
cfg.readEntry( "URL" ) == "$HOME/Documents" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Documents" ) {
removeBuiltinIcon("My Documents");
continue;
}
if ( cfg.readEntry( "Type" ) == "Link" &&
cfg.readEntry( "URL" ) == "media:/" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Computer" ) {
removeBuiltinIcon("My Computer");
continue;
}
if ( cfg.readEntry( "Type" ) == "Link" &&
cfg.readEntry( "URL" ) == "remote:/" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "My Network Places" ) {
removeBuiltinIcon("My Network Places");
continue;
}
if ( cfg.readEntry( "Type" ) == "Application" &&
cfg.readEntry( "Exec" ) == "kjobviewer --all --show %i %m" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Printers" ) {
removeBuiltinIcon("Printers");
continue;
}
if ( cfg.readEntry( "Type" ) == "Link" &&
cfg.readEntry( "URL" ) == "trash:/" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Trash" ) {
removeBuiltinIcon("Trash");
continue;
}
if ( cfg.readEntry( "Type" ) == "Application" &&
cfg.readEntry( "OnlyShowIn" ) == "KDE;" &&
if ( cfg.readEntry( "X-Trinity-BuiltIn" ) == "true" &&
cfg.readEntry( "Name" ) == "Web Browser" ) {
removeBuiltinIcon("Web Browser");
continue;
}
}

@ -24,6 +24,7 @@
#include <kaction.h>
#include <kfileitem.h>
#include <kdirnotify.h>
#include <kmessagebox.h>
class KDirLister;
class KonqSettings;
@ -173,6 +174,9 @@ protected:
void moveToFreePosition(TQIconViewItem *item );
bool deleteGlobalDesktopFiles();
void removeBuiltinIcon(TQString iconName);
void fillMediaListView();
void saveMediaListView();
static void renameDesktopFile(const TQString &path, const TQString &name);
@ -260,6 +264,9 @@ private:
bool m_gotIconsArea;
bool m_needDesktopAlign;
TQListView *mMediaListView;
KConfig *g_pConfig;
};
#endif

@ -30,6 +30,7 @@
#include <kglobalsettings.h>
#include <kinputdialog.h>
#include <kmessagebox.h>
#include <kconfig.h>
#include <stdlib.h>
@ -130,9 +131,14 @@ int main( int argc, char **argv)
directoryOk = TRUE;
}
if (directoryOk == true) {
char systemcommand[8192];
sprintf(systemcommand, "xdg-user-dirs-update --set DOCUMENTS \"%s\"", newDirectory.ascii());
system(systemcommand);
TQString xdgModifiedDirectory = newDirectory;
xdgModifiedDirectory = xdgModifiedDirectory.replace(TQDir::homeDirPath(), "$HOME");
while (xdgModifiedDirectory.endsWith("/")) {
xdgModifiedDirectory.truncate(xdgModifiedDirectory.length()-1);
}
KConfig config(TQDir::homeDirPath() + "/.config/user-dirs.dirs", false, false);
config.writeEntry("XDG_DOCUMENTS_DIR", TQString("\"") + xdgModifiedDirectory + TQString("\""), true);
config.sync();
if (args->isSet( "getpath" ) == true) {
printf("%s\n\r", getDocumentPath().ascii());
return 0;

Loading…
Cancel
Save