Browse Source

Make sure XDG folders are created prior to their usage.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/69/head
Michele Calgaro 8 months ago
parent
commit
de79e754fa
Signed by: MicheleC GPG Key ID: 2A75B7CA8ADED5CF
2 changed files with 53 additions and 28 deletions
  1. +36
    -1
      tdecore/tdeglobalsettings.cpp
  2. +17
    -27
      tdeio/tdefile/tdefilespeedbar.cpp

+ 36
- 1
tdecore/tdeglobalsettings.cpp View File

@@ -173,6 +173,23 @@ static void readXdgUserDirs(TQString *desktop, TQString *documents, TQString *do
}
}

static void checkAndCreateXdgFolder(const TQString &folder, const TQString &path, TDEConfig *config)
{
bool pathOk = true;
if (!TQDir(path).exists())
{
if (!TDEStandardDirs::makeDir(path))
{
pathOk = false;
}
}

if (pathOk)
{
config->writePathEntry(folder, '"' + path + '"', true, false, false, false );
}
}

int TDEGlobalSettings::dndEventDelay()
{
TDEConfigGroup g( TDEGlobal::config(), "General" );
@@ -642,12 +659,30 @@ void TDEGlobalSettings::initPaths()
g.sync();
}

// Create folders if they do not exists.
TDEConfig *xdgconfig = new TDEConfig(TQDir::homeDirPath()+"/.config/user-dirs.dirs");
checkAndCreateXdgFolder("XDG_DESKTOP_DIR", *s_desktopPath, xdgconfig);
checkAndCreateXdgFolder("XDG_DOCUMENTS_DIR", *s_documentPath, xdgconfig);
checkAndCreateXdgFolder("XDG_DOWNLOAD_DIR", *s_downloadPath, xdgconfig);
checkAndCreateXdgFolder("XDG_MUSIC_DIR", *s_musicPath, xdgconfig);
checkAndCreateXdgFolder("XDG_PICTURES_DIR", *s_picturesPath, xdgconfig);
checkAndCreateXdgFolder("XDG_PUBLICSHARE_DIR", *s_publicSharePath, xdgconfig);
checkAndCreateXdgFolder("XDG_TEMPLATES_DIR", *s_templatesPath, xdgconfig);
checkAndCreateXdgFolder("XDG_VIDEOS_DIR", *s_videosPath, xdgconfig);
xdgconfig->sync();

// Autostart Path
*s_autostartPath = TDEGlobal::dirs()->localtdedir() + "Autostart/";
*s_autostartPath = g.readPathEntry( "Autostart" , *s_autostartPath);
*s_autostartPath = TQDir::cleanDirPath( *s_autostartPath );
if ( !s_autostartPath->endsWith("/") )
if (!s_autostartPath->endsWith("/"))
{
s_autostartPath->append('/');
}
if (!TQDir(*s_autostartPath).exists())
{
TDEStandardDirs::makeDir(*s_autostartPath);
}

// Make sure this app gets the notifications about those paths
if (kapp)


+ 17
- 27
tdeio/tdefile/tdefilespeedbar.cpp View File

@@ -44,37 +44,27 @@ KFileSpeedBar::KFileSpeedBar( TQWidget *parent, const char *name )

if ( m_initializeSpeedbar )
{
KURL u;
u.setPath( TDEGlobalSettings::desktopPath() );
insertItem( u, i18n("Desktop"), false );

//TODO: win32
if ((TDEGlobalSettings::documentPath() != (TQDir::homeDirPath()+"/")) &&
TQDir(TDEGlobalSettings::documentPath()).exists())
insertItem(TQDir::homeDirPath(), i18n("Home Folder"), false, "folder_home");
insertItem(TDEGlobalSettings::desktopPath(), i18n("Desktop"), false, "folder_txt");
insertItem(TDEGlobalSettings::documentPath(), i18n("Documents"), false, "folder_txt");
insertItem(TDEGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html");
insertItem(TDEGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound");
insertItem(TDEGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image");
insertItem(TDEGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder");
insertItem(TDEGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder_txt");
insertItem(TDEGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video");

KURL u = "media:/";
if (KProtocolInfo::isKnownProtocol(u))
{
u.setPath( TDEGlobalSettings::documentPath() );
insertItem( u, i18n("Documents"), false, "folder_txt" );
insertItem(u, i18n("Storage Media"), false, KProtocolInfo::icon("media"));
}

u.setPath( TQDir::homeDirPath() );
insertItem( u, i18n("Home Folder"), false, "folder_home" );

u = "media:/";
if ( KProtocolInfo::isKnownProtocol( u ) )
insertItem( u, i18n("Storage Media"), false, KProtocolInfo::icon( "media" ) );

// now add in the speedbar
insertItem(TDEGlobalSettings::downloadPath(), i18n( "Downloads" ), false, "folder_html" );
insertItem(TDEGlobalSettings::musicPath(), i18n( "Music" ), false, "folder_sound" );
insertItem(TDEGlobalSettings::picturesPath(), i18n( "Pictures" ), false, "folder_image" );
insertItem(TDEGlobalSettings::publicSharePath(), i18n( "Public" ), false, "folder" );
insertItem(TDEGlobalSettings::templatesPath(), i18n( "Templates" ), false, "folder" );
insertItem(TDEGlobalSettings::videosPath(), i18n( "Videos" ), false, "folder_video" );
u = "remote:/";
if ( KProtocolInfo::isKnownProtocol( u ) )
insertItem( u, i18n("Network Folders"), false,
KProtocolInfo::icon( "remote" ) );
if (KProtocolInfo::isKnownProtocol(u))
{
insertItem(u, i18n("Network Folders"), false, KProtocolInfo::icon("remote"));
}
}
}



Loading…
Cancel
Save