Ticket #7735: browser_color_v2.patch

File browser_color_v2.patch, 2.5 KB (added by lordhoto, 14 years ago)

Patch, which prevents the user from selection files in directory browser mode.

  • gui/browser.cpp

    diff --git a/gui/browser.cpp b/gui/browser.cpp
    index 3aa07d5..e7be115 100644
    a b void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  
    184184                        // If nothing is selected in the list widget, choose the current dir.
    185185                        // Else, choose the dir that is selected.
    186186                        int selection = _fileList->getSelected();
    187                         if (selection >= 0) {
     187                        if (selection >= 0)
    188188                                _choice = _nodeContent[selection];
    189                         } else {
     189                        else
    190190                                _choice = _node;
    191                         }
    192191                        setResult(1);
    193192                        close();
    194193                } else {
    void BrowserDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data  
    214213                if (_nodeContent[data].isDirectory()) {
    215214                        _node = _nodeContent[data];
    216215                        updateListing();
    217                 } else {
     216                } else if (!_isDirBrowser) {
    218217                        _choice = _nodeContent[data];
    219218                        setResult(1);
    220219                        close();
    221220                }
    222221                break;
     222        case kListSelectionChangedCmd:
     223                // We do not allow selecting directories in directory
     224                // browser mode, thus we will invalidate the selection
     225                // when the user selects an directory over here.
     226                if (data != (uint32)-1 && _isDirBrowser && !_nodeContent[data].isDirectory())
     227                        _fileList->setSelected(-1);
     228                break;
    223229        default:
    224230                Dialog::handleCommand(sender, cmd, data);
    225231        }
    void BrowserDialog::updateListing() {  
    233239        ConfMan.set("browser_lastpath", _node.getPath());
    234240
    235241        // Read in the data from the file system
    236         Common::FSNode::ListMode listMode =
    237                  _isDirBrowser ? Common::FSNode::kListDirectoriesOnly
    238                                : Common::FSNode::kListAll;
    239         if (!_node.getChildren(_nodeContent, listMode)) {
     242        if (!_node.getChildren(_nodeContent, Common::FSNode::kListAll))
    240243                _nodeContent.clear();
    241         } else {
     244        else
    242245                Common::sort(_nodeContent.begin(), _nodeContent.end());
    243         }
    244246
    245247        // Populate the ListWidget
    246248        Common::StringList list;
     249        ListWidget::ColorList colors;
    247250        for (Common::FSList::iterator i = _nodeContent.begin(); i != _nodeContent.end(); ++i) {
    248                 if (!_isDirBrowser && i->isDirectory())
     251                if (i->isDirectory())
    249252                        list.push_back(i->getDisplayName() + "/");
    250253                else
    251254                        list.push_back(i->getDisplayName());
     255
     256                if (_isDirBrowser) {
     257                        if (i->isDirectory())
     258                                colors.push_back(ThemeEngine::kFontColorNormal);
     259                        else
     260                                colors.push_back(ThemeEngine::kFontColorAlternate);
     261                }
    252262        }
    253         _fileList->setList(list);
     263
     264        if (_isDirBrowser)
     265                _fileList->setList(list, &colors);
     266        else
     267                _fileList->setList(list);
    254268        _fileList->scrollTo(0);
    255269
    256270        // Finally, redraw