void Region::merge(unsigned int dir)
{
    bool first = true;

    if (dir & R_VERT)
    {
        mergeDir(R_UP, first);
        if (_down) _down->mergeDir(R_DOWN);
    }
    else if (dir & R_HORI)
    {
        mergeDir(R_RIGHT, first);
        if (_left)  _left->mergeDir(R_LEFT);
    }
}
Example #2
0
/************************************************
 A <MergeDir> contains the name of a directory. Each file in the given directory
 which ends in the ".menu" extension should be merged in the same way that a
 <MergeFile> would be. If the filename given as a <MergeDir> is not an absolute
 path, it should be located relative to the location of the menu file being parsed.
 The files inside the merged directory are not merged in any specified order.

 Duplicate <MergeDir> elements (that specify the same directory) are handled as with
 duplicate <AppDir> elements (the last duplicate is used).

 KDE additional scans ~/.config/menus.
 ************************************************/
void XdgMenuReader::processMergeDirTag(QDomElement& element, QStringList* mergedFiles)
{
    //qDebug() << "Process " << element;// << "in" << mFileName;

    mergeDir(element.text(), element, mergedFiles);
    element.parentNode().removeChild(element);
}
Example #3
0
/************************************************
 The element has no content. The element should be treated as if it were a list of
 <MergeDir> elements containing the default merge directory locations. When expanding
 <DefaultMergeDirs> to a list of <MergeDir>, the default locations that are earlier
 in the search path go later in the <Menu> so that they have priority.

 Note that a system that uses either gnome-applications.menu or kde-applications.menu
 depending on the desktop environment in use must still use applications-merged as the
 default merge directory in both cases.

 Implementations may chose to use .menu files with names other than application.menu
 for tasks or menus other than the main application menu. In that case the first part
 of the name of the default merge directory is derived from the name of the .menu file.
 ************************************************/
void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList* mergedFiles)
{
    //qDebug() << "Process " << element;// << "in" << mFileName;

    QString menuBaseName = QFileInfo(mMenu->menuFileName()).baseName();
    int n = menuBaseName.lastIndexOf('-');
    if (n>-1)
        menuBaseName = menuBaseName.mid(n+1);

    QStringList dirs = XdgDirs::configDirs();
    dirs << XdgDirs::configHome();

    foreach (QString dir, dirs)
    {
        mergeDir(QString("%1/menus/%2-merged").arg(dir).arg(menuBaseName), element, mergedFiles);
    }
Example #4
0
/************************************************
 The element has no content. The element should be treated as if it were a list of
 <MergeDir> elements containing the default merge directory locations. When expanding
 <DefaultMergeDirs> to a list of <MergeDir>, the default locations that are earlier
 in the search path go later in the <Menu> so that they have priority.

 Note that a system that uses either gnome-applications.menu or kde-applications.menu
 depending on the desktop environment in use must still use applications-merged as the
 default merge directory in both cases.

 Implementations may chose to use .menu files with names other than application.menu
 for tasks or menus other than the main application menu. In that case the first part
 of the name of the default merge directory is derived from the name of the .menu file.
 ************************************************/
void XdgMenuReader::processDefaultMergeDirsTag(QDomElement& element, QStringList* mergedFiles)
{
    //qDebug() << "Process " << element;// << "in" << mFileName;

    QString menuBaseName = QFileInfo(mMenu->menuFileName()).baseName();
    int n = menuBaseName.lastIndexOf(QLatin1Char('-'));
    if (n>-1)
        menuBaseName = menuBaseName.mid(n+1);

    QStringList dirs = XdgDirs::configDirs();
    dirs << XdgDirs::configHome();

    for (const QString &dir : qAsConst(dirs))
    {
        mergeDir(QString::fromLatin1("%1/menus/%2-merged").arg(dir, menuBaseName), element, mergedFiles);
    }

    if (menuBaseName == QLatin1String("applications"))
        mergeFile(QString::fromLatin1("%1/menus/applications-kmenuedit.menu").arg(XdgDirs::configHome()), element, mergedFiles);
}
Example #5
0
int walkDirs(char *input_dir, char *output_dir) {
    char partname[256];
    struct stat stats;

    printf("Processing directory %s\n", input_dir);
#ifdef HAVE_DIRENT_H
    DIR *dir;
    struct dirent *dirent;

    if ((dir = opendir(input_dir)) != NULL) {
	while ((dirent = readdir(dir))) {
	    char dirname[256];

	    if (dirent->d_name[0] == '.') continue;
	    snprintf(dirname, sizeof(dirname), "%s/%s", input_dir,
		     dirent->d_name);

	    if (stat(dirname, &stats) == 0) {
		if (S_ISDIR(stats.st_mode)) {
		    walkDirs(dirname, output_dir);
		}
	    }
	}

	closedir(dir);
    }
#endif

    snprintf(partname, sizeof(partname), "%s/-part.txt", input_dir);
    if (stat(partname, &stats) == 0) {
	if (access(partname, 4) == 0) // have read access
	    mergeDir(input_dir, output_dir);
	else
	    printf("WARNING: skipping unreadable directory %s\n", partname);
    }

    return(0);
}