/*static*/ FmJobErrorAction TabPage::onFolderError(FmFolder* _folder, GError* err, FmJobErrorSeverity severity, TabPage* pThis) { if(err->domain == G_IO_ERROR) { if(err->code == G_IO_ERROR_NOT_MOUNTED && severity < FM_JOB_ERROR_CRITICAL) { FmPath* path = fm_folder_get_path(_folder); MountOperation* op = new MountOperation(pThis); op->mount(path); if(op->wait()) { // blocking event loop, wait for mount operation to finish. // This will reload the folder, which generates a new "start-loading" // signal, so we get more "start-loading" signals than "finish-loading" // signals. FIXME: This is a bug of libfm. // Because the two signals are not correctly paired, we need to // remove busy cursor here since "finish-loading" is not emitted. QApplication::restoreOverrideCursor(); // remove busy cursor pThis->overrideCursor_ = false; return FM_JOB_RETRY; } } } if(severity >= FM_JOB_ERROR_MODERATE) { /* Only show more severe errors to the users and * ignore milder errors. Otherwise too many error * message boxes can be annoying. * This fixes bug #3411298- Show "Permission denied" when switching to super user mode. * https://sourceforge.net/tracker/?func=detail&aid=3411298&group_id=156956&atid=801864 * */ // FIXME: consider replacing this modal dialog with an info bar to improve usability QMessageBox::critical(pThis, tr("Error"), QString::fromUtf8(err->message)); } return FM_JOB_CONTINUE; }
void ProxyFilter::setVirtHidden(FmFolder* folder) { virtHiddenList_ = QStringList(); // reset the list if(!folder) return; if(FmPath* path = fm_folder_get_path(folder)) { char* pathStr = fm_path_to_str(path); if(pathStr) { QString dotHidden = QString(pathStr) + QString("/.hidden"); g_free(pathStr); QFile file(dotHidden); if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in(&file); while(!in.atEnd()) virtHiddenList_.append(in.readLine()); file.close(); } } } }
static FmJobErrorAction on_folder_error(FmFolder* folder, GError* err, FmJobErrorSeverity severity, FmTabPage* page) { GtkWindow* win = GTK_WINDOW(GET_MAIN_WIN(page)); if(err->domain == G_IO_ERROR) { if( err->code == G_IO_ERROR_NOT_MOUNTED && severity < FM_JOB_ERROR_CRITICAL ) { FmPath* path = fm_folder_get_path(folder); if(fm_mount_path(win, path, TRUE)) return FM_JOB_RETRY; } } if(severity >= FM_JOB_ERROR_MODERATE) { /* Only show more severe errors to the users and * ignore milder errors. Otherwise too many error * message boxes can be annoying. * This fixes bug #3411298- Show "Permission denied" when switching to super user mode. * https://sourceforge.net/tracker/?func=detail&aid=3411298&group_id=156956&atid=801864 * */ fm_show_error(win, NULL, err->message); } return FM_JOB_CONTINUE; }
void TabPage::chdir(FmPath* newPath, bool addHistory) { if(folder_) { // we're already in the specified dir if(fm_path_equal(newPath, fm_folder_get_path(folder_))) return; // remember the previous folder path that we have browsed. lastFolderPath_ = fm_folder_get_path(folder_); if(addHistory) { // store current scroll pos in the browse history BrowseHistoryItem& item = history_.currentItem(); QAbstractItemView* childView = folderView_->childView(); item.setScrollPos(childView->verticalScrollBar()->value()); } // free the previous model if(folderModel_) { proxyModel_->setSourceModel(NULL); folderModel_->unref(); // unref the cached model folderModel_ = NULL; } freeFolder(); } char* disp_name = fm_path_display_basename(newPath); title_ = QString::fromUtf8(disp_name); Q_EMIT titleChanged(title_); g_free(disp_name); folder_ = fm_folder_from_path(newPath); proxyFilter_->setVirtHidden(folder_); if(addHistory) { // add current path to browse history history_.add(path()); } g_signal_connect(folder_, "start-loading", G_CALLBACK(onFolderStartLoading), this); g_signal_connect(folder_, "finish-loading", G_CALLBACK(onFolderFinishLoading), this); g_signal_connect(folder_, "error", G_CALLBACK(onFolderError), this); g_signal_connect(folder_, "fs-info", G_CALLBACK(onFolderFsInfo), this); /* destroy the page when the folder is unmounted or deleted. */ g_signal_connect(folder_, "removed", G_CALLBACK(onFolderRemoved), this); g_signal_connect(folder_, "unmount", G_CALLBACK(onFolderUnmount), this); g_signal_connect(folder_, "content-changed", G_CALLBACK(onFolderContentChanged), this); folderModel_ = CachedFolderModel::modelFromFolder(folder_); proxyModel_->setSourceModel(folderModel_); proxyModel_->sort(proxyModel_->sortColumn(), proxyModel_->sortOrder()); Settings& settings = static_cast<Application*>(qApp)->settings(); proxyModel_->setFolderFirst(settings.sortFolderFirst()); proxyModel_->sort(settings.sortColumn(), settings.sortOrder()); if(fm_folder_is_loaded(folder_)) { onFolderStartLoading(folder_, this); onFolderFinishLoading(folder_, this); onFolderFsInfo(folder_, this); } else onFolderStartLoading(folder_, this); }
FmPath* fm_tab_page_get_cwd(FmTabPage* page) { g_return_val_if_fail(page, NULL); return page->folder ? fm_folder_get_path(page->folder) : NULL; }