void DockBarExtension::loadContainerConfig()
{
    KConfig *conf = config();
    conf->setGroup("General");
    QStringList applets = conf->readListEntry("Applets");

    QStringList fail_list;
    for(QStringList::Iterator it = applets.begin(); it != applets.end(); ++it)
    {
        if(!conf->hasGroup(*it))
            continue;
        conf->setGroup(*it);
        QString cmd = conf->readPathEntry("Command");
        QString resName = conf->readPathEntry("resName");
        QString resClass = conf->readEntry("resClass");
        if(cmd.isEmpty() || resName.isEmpty() || resClass.isEmpty())
            continue;

        DockContainer *c = new DockContainer(cmd, this, resName, resClass);
        addContainer(c);

        KProcess proc;
        proc << KShell::splitArgs(cmd);
        if(!proc.start(KProcess::DontCare))
        {
            fail_list.append(cmd);
            removeContainer(c);
        }
    }
    if(!fail_list.isEmpty())
        KMessageBox::queuedMessageBox(0, KMessageBox::Information,
                                      i18n("The following dockbar applets could not be started: %1").arg(fail_list.join(", ")),
                                      i18n("kicker: information"), 0);
    saveContainerConfig();
}
Beispiel #2
0
void ExtensionManager::removeAllContainers()
{
    while (!_containers.isEmpty())
    {
        ExtensionContainer* e = _containers.first();
        _containers.remove(e);
        e->deleteLater(); // Wait till we return to the main event loop
    }

    saveContainerConfig();
}
void DockBarExtension::mouseReleaseEvent(QMouseEvent *e)
{
    if(e->button() != LeftButton)
        return;
    if(dragging_container)
    {
        releaseMouse();
        original_container->embed(dragging_container->embeddedWinId());
        delete dragging_container;
        dragging_container = 0;
        layoutContainers();
        saveContainerConfig();
    }
}
Beispiel #4
0
void ExtensionManager::removeContainer(ExtensionContainer* e)
{
    if (!e)
    {
        return;
    }

    e->removeSessionConfigFile();
    _containers.remove(e);
    e->deleteLater(); // Wait till we return to the main event loop
    saveContainerConfig();

    if (!m_loadingContainers) {
        emit desktopIconsAreaChanged(desktopIconsArea(e->xineramaScreen()),
                                     e->xineramaScreen());
    }
}
Beispiel #5
0
void ExtensionManager::addExtension( const TQString& desktopFile )
{
    PluginManager* pm = PluginManager::the();
    ExtensionContainer *e = pm->createExtensionContainer(desktopFile,
                                                         false, // is not startup
                                                         TQString::null, // no config
                                                         uniqueId());
    

    kdDebug(1210) << "ExtensionManager::addExtension" << endl;

    if (e)
    {
        e->readConfig();
        // as a new panel, the position will be set to the preferred position
        // we just need to make sure this works with the rest of the panel layout
        e->setPosition(initialPanelPosition(e->position()));
        kdDebug(1210)<<"after e->readConfig(): pos="<<e->position()<<endl;
        addContainer(e);
        e->show();
        e->writeConfig();
        saveContainerConfig();
    }
}
void DockBarExtension::windowAdded(WId win)
{
    // try to read WM_COMMAND
    int argc;
    char **argv;
    QString command;
    if(XGetCommand(qt_xdisplay(), win, &argv, &argc))
    {
        command = KShell::joinArgs(argv, argc);
        XFreeStringList(argv);
    }

    // try to read wm hints
    WId resIconwin = 0;
    XWMHints *wmhints = XGetWMHints(qt_xdisplay(), win);
    if(0 != wmhints)
    {   // we managed to read wm hints
        // read IconWindowHint
        bool is_valid = false;
        /* a good dockapp set the icon hint and the state hint,
           if it uses its icon, the window initial state must be "withdrawn"
           if not, then the initial state must be "normal"
           this filters the problematic Eterm whose initial state is "normal"
           and which has an iconwin.
        */
        if((wmhints->flags & IconWindowHint) && (wmhints->flags & StateHint))
        {
            resIconwin = wmhints->icon_window;
            is_valid = (resIconwin && wmhints->initial_state == 0) || (resIconwin == 0 && wmhints->initial_state == 1);

            /* an alternative is a window who does not have an icon,
               but whose initial state is set to "withdrawn". This has been
               added for wmxmms... I hope it won't swallow to much windows :-/
            */
        }
        else if((wmhints->flags & IconWindowHint) == 0 && (wmhints->flags & StateHint))
        {
            is_valid = (wmhints->initial_state == 0);
        }
        XFree(wmhints);
        if(!is_valid)
            return; // we won't swallow this one
    }
    else
        return;

    // The following if statement was at one point commented out,
    // without a comment as to why. This caused problems like
    // Eterm windows getting swallowed whole. So, perhaps now I'll
    // get bug reports about whatever commenting it out was supposed
    // to fix.
    if(resIconwin == 0)
        resIconwin = win;

    // try to read class hint
    XClassHint hint;
    QString resClass, resName;
    if(XGetClassHint(qt_xdisplay(), win, &hint))
    {
        resName = hint.res_name;
        resClass = hint.res_class;
    }
    else
    {
        kdDebug() << "Could not read XClassHint of window " << win << endl;
        return;
    }
    /* withdrawing the window prevents kwin from managing the window,
       which causes the double-launch bug (one instance from the kwin
       session, and one from the dockbar) bug when kde is restarted */
    if(resIconwin != win)
    {
        XWithdrawWindow(qt_xdisplay(), win, qt_xscreen());
        while(KWin::windowInfo(win, NET::XAWMState).mappingState() != NET::Withdrawn)
            ;
    }

    // add a container
    embedWindow(resIconwin, command, resName, resClass);
    saveContainerConfig();
}
void DockBarExtension::settingsChanged(DockContainer *)
{
    saveContainerConfig();
}
void DockBarExtension::embeddedWindowDestroyed(DockContainer *c)
{
    removeContainer(c);
    saveContainerConfig();
    emit updateLayout();
}