/* FIXME: call this if the view is already loaded before it's added to * main window. Update title and tab label using dir_fi of the FmFolder object. */ static void on_folder_view_loaded(FmFolderView* view, FmPath* path, FmTabPage* page) { FmIcon* icon; const FmNavHistoryItem* item; FmFolder* folder; folder = fm_folder_view_get_folder(view); if(folder) { #if 0 if(folder->dir_fi) { icon = folder->dir_fi->icon; if(icon) { icon->gicon; /* FIXME: load icon. we need to change window icon when switching pages. */ gtk_window_set_icon_name(GTK_WINDOW(win), "folder"); } } #endif fm_folder_query_filesystem_info(folder); } /* scroll to recorded position */ item = fm_nav_history_get_cur(page->nav_history); gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(view)), item->scroll_pos); /* update status text */ g_free(page->status_text[FM_STATUS_TEXT_NORMAL]); page->status_text[FM_STATUS_TEXT_NORMAL] = format_status_text(page); g_signal_emit(page, signals[STATUS], 0, FM_STATUS_TEXT_NORMAL, page->status_text[FM_STATUS_TEXT_NORMAL]); }
static void on_folder_finish_loading(FmFolder* folder, FmTabPage* page) { FmFolderView* fv = page->folder_view; const FmNavHistoryItem* item; GtkScrolledWindow* scroll = GTK_SCROLLED_WINDOW(fv); /* Note: most of the time, we delay the creation of the * folder model and do it after the whole folder is loaded. * That is because adding rows into model is much faster when no handlers * are connected to its signals. So we detach the model from folder view * and create the model again when it's fully loaded. * This optimization, however, is not used for FmFolder objects * with incremental loading (search://) */ if(fm_folder_view_get_model(fv) == NULL) { /* create a model for the folder and set it to the view */ FmFolderModel* model = fm_folder_model_new(folder, app_config->show_hidden); fm_folder_view_set_model(fv, model); fm_folder_model_set_sort(model, app_config->sort_by, (app_config->sort_type == GTK_SORT_ASCENDING) ? FM_SORT_ASCENDING : FM_SORT_DESCENDING); g_object_unref(model); } fm_folder_query_filesystem_info(folder); /* FIXME: is this needed? */ if (page->select_path_after_chdir) { fm_folder_view_select_file_path(fv, page->select_path_after_chdir); fm_path_unref(page->select_path_after_chdir); page->select_path_after_chdir = NULL; } // fm_path_entry_set_path(entry, path); /* scroll to recorded position */ item = fm_nav_history_get_cur(page->nav_history); gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(scroll), item->scroll_pos); /* update status bar */ /* update status text */ g_free(page->status_text[FM_STATUS_TEXT_NORMAL]); page->status_text[FM_STATUS_TEXT_NORMAL] = format_status_text(page); g_signal_emit(page, signals[STATUS], 0, (guint)FM_STATUS_TEXT_NORMAL, page->status_text[FM_STATUS_TEXT_NORMAL]); fm_unset_busy_cursor(GTK_WIDGET(page)); /* g_debug("finish-loading"); */ page->loading = FALSE; g_object_notify_by_pspec(G_OBJECT(page), props[PROP_LOADING]); }
/*static*/ void TabPage::onFolderFinishLoading(FmFolder* _folder, TabPage* pThis) { // FIXME: is this needed? FmFileInfo* fi = fm_folder_get_info(_folder); if(fi) { // if loading of the folder fails, it's possible that we don't have FmFileInfo. pThis->title_ = QString::fromUtf8(fm_file_info_get_disp_name(fi)); Q_EMIT pThis->titleChanged(pThis->title_); } fm_folder_query_filesystem_info(_folder); // FIXME: is this needed? #if 0 FmFolderView* fv = folder_view; const FmNavHistoryItem* item; GtkScrolledWindow* scroll = GTK_SCROLLED_WINDOW(fv); /* Note: most of the time, we delay the creation of the * folder model and do it after the whole folder is loaded. * That is because adding rows into model is much faster when no handlers * are connected to its signals. So we detach the model from folder view * and create the model again when it's fully loaded. * This optimization, however, is not used for FmFolder objects * with incremental loading (search://) */ if(fm_folder_view_get_model(fv) == NULL) { /* create a model for the folder and set it to the view */ FmFolderModel* model = fm_folder_model_new(folder, app_config->show_hidden); fm_folder_view_set_model(fv, model); #if FM_CHECK_VERSION(1, 0, 2) /* since 1.0.2 sorting should be applied on model instead of view */ fm_folder_model_set_sort(model, app_config->sort_by, (app_config->sort_type == GTK_SORT_ASCENDING) ? FM_SORT_ASCENDING : FM_SORT_DESCENDING); #endif g_object_unref(model); } #endif // update status text QString& text = pThis->statusText_[StatusTextNormal]; text = pThis->formatStatusText(); Q_EMIT pThis->statusChanged(StatusTextNormal, text); if(pThis->overrideCursor_) { QApplication::restoreOverrideCursor(); // remove busy cursor pThis->overrideCursor_ = false; } // After finishing loading the folder, the model is updated, but Qt delays the UI update // for performance reasons. Therefore at this point the UI is not up to date. // Of course, the scrollbar ranges are not updated yet. We solve this by installing an Qt timeout handler. QTimer::singleShot(10, pThis, SLOT(restoreScrollPos())); }
static void fm_tab_page_chdir_without_history(FmTabPage* page, FmPath* path) { FmFolderView* folder_view = FM_FOLDER_VIEW(page->folder_view); FmFolder* folder = fm_folder_view_get_folder(folder_view); char * disp_path = fm_path_display_name(path, FALSE); fm_tab_label_set_tooltip_text(FM_TAB_LABEL(page->tab_label), disp_path); g_free(disp_path); char* disp_name = fm_path_display_basename(path); fm_tab_label_set_text(FM_TAB_LABEL(page->tab_label), disp_name); g_free(disp_name); /* disconnect from previous folder */ disconnect_folder(page, folder); /* chdir to a new folder */ fm_folder_view_chdir(folder_view, path); folder = fm_folder_view_get_folder(folder_view); if(folder) { g_signal_connect(folder, "fs-info", G_CALLBACK(on_folder_fs_info), page); // on_folder_fs_info(folder, win); fm_folder_query_filesystem_info(folder); } fm_side_pane_chdir(FM_SIDE_PANE(page->side_pane), path); /* destroy the page when the folder is unmounted or deleted. */ g_signal_connect_swapped(folder, "unmount", G_CALLBACK(gtk_widget_destroy), page); g_signal_connect_swapped(folder, "removed", G_CALLBACK(gtk_widget_destroy), page); g_signal_connect(folder, "content-changed", G_CALLBACK(on_folder_content_changed), page); g_signal_connect(folder, "fs-info", G_CALLBACK(on_folder_fs_info), page); /* tell the world that our current working directory is changed */ g_signal_emit(page, signals[CHDIR], 0, path); }