コード例 #1
0
/*static*/ void TabPage::onFolderStartLoading(FmFolder* _folder, TabPage* pThis) {
  if(!pThis->overrideCursor_) {
    // FIXME: sometimes FmFolder of libfm generates unpaired "start-loading" and
    // "finish-loading" signals of uncertain reasons. This should be a bug in libfm.
    // Until it's fixed in libfm, we need to workaround the problem here, not to
    // override the cursor twice.
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
    pThis->overrideCursor_ = true;
  }
#if 0
#if FM_CHECK_VERSION(1, 0, 2) && 0 // disabled
  if(fm_folder_is_incremental(_folder)) {
    /* create a model for the folder and set it to the view
       it is delayed for non-incremental folders since adding rows into
       model is much faster without handlers connected to its signals */
    FmFolderModel* model = fm_folder_model_new(folder, FALSE);
    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);
  }
  else
#endif
    fm_folder_view_set_model(fv, NULL);
#endif
}
コード例 #2
0
ファイル: tab-page.c プロジェクト: Mic92/stuurman
static void on_folder_start_loading(FmFolder* folder, FmTabPage* page)
{
    FmFolderView* fv = page->folder_view;
    /* g_debug("start-loading"); */
    /* FIXME: this should be set on toplevel parent */
    fm_set_busy_cursor(GTK_WIDGET(page));

    if(fm_folder_is_incremental(folder))
    {
        /* create a model for the folder and set it to the view
           it is delayed for non-incremental folders since adding rows into
           model is much faster without handlers connected to its signals */
        FmFolderModel* model = fm_folder_model_new(folder, FALSE);
        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);
    }
    else
        fm_folder_view_set_model(fv, NULL);

    page->loading = TRUE;
    g_object_notify_by_pspec(G_OBJECT(page), props[PROP_LOADING]);
}
コード例 #3
0
ファイル: fm-path-entry.c プロジェクト: gilir/libfm-debian
static void fm_path_entry_changed(GtkEditable *editable)
{
    FmPathEntry *entry = FM_PATH_ENTRY(editable);
    FmPathEntryPrivate *priv  = FM_PATH_ENTRY_GET_PRIVATE(entry);
    const gchar *original_key = gtk_entry_get_text( GTK_ENTRY(entry) );
    /* len of directory part */
    gint key_dir_len;
    gchar *last_slash = strrchr(original_key, G_DIR_SEPARATOR);

    if( priv->in_change || !priv->path )
        return;

    /* not path -> keep current completion model */
    if( last_slash == NULL )
        return;

    /* Check if path entry is not part of current completion folder model */
    key_dir_len = last_slash - original_key;
    if( !fm_path_equal_str(priv->path, original_key, key_dir_len) )
    {
        gchar* new_path = g_path_get_dirname(original_key);
        FmPath *new_fm_path = fm_path_new(new_path);
        g_free(new_path);
        if( new_fm_path != NULL )
        {
            /* set hidden parameter based on prev. model */
            /* FIXME: this is not very good */
            gboolean show_hidden = priv->completion_model ? fm_folder_model_get_show_hidden(priv->completion_model) : FALSE;
            if(priv->completion_model)
                g_object_unref(priv->completion_model);
            if(priv->model && fm_path_equal(priv->model->dir->dir_path, new_fm_path))
            {
                if(priv->path)
                    fm_path_unref(priv->path);
                priv->path = fm_path_ref(priv->model->dir->dir_path);
                fm_path_unref(new_fm_path);
                priv->completion_model = g_object_ref(priv->model);
            }
            else
            {
                FmFolder *new_fm_folder = fm_folder_get_for_path(new_fm_path);
                FmFolderModel *new_fm = fm_folder_model_new(new_fm_folder, show_hidden);
                g_object_unref(new_fm_folder);
                priv->completion_model = new_fm;
                if(priv->path)
                    fm_path_unref(priv->path);
                priv->path = new_fm_path;
            }
            gtk_entry_completion_set_model( priv->completion, GTK_TREE_MODEL(priv->completion_model) );
        }
        else
        {
            /* FIXME: Handle invalid Paths */
            g_warning("Invalid Path: %s", new_path);
        }
    }
}
コード例 #4
0
ファイル: tab-page.c プロジェクト: Mic92/stuurman
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]);
}
コード例 #5
0
/*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()));
}
コード例 #6
0
ファイル: fm-folder-view.c プロジェクト: afilmore/lxmanager
static void on_folder_loaded(FmFolder* folder, FmFolderView* fv)
{
    FmFolderModel* model;
    guint icon_size = 0;

    model = fm_folder_model_new(folder, fv->show_hidden);
    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), fv->sort_by, fv->sort_type);
    g_signal_connect(model, "sort-column-changed", G_CALLBACK(on_sort_col_changed), fv);

    switch(fv->mode)
    {
    case FM_FV_LIST_VIEW:
        cancel_pending_row_activated(fv);
        gtk_tree_view_set_model(GTK_TREE_VIEW(fv->view), model);
        icon_size = fm_config->small_icon_size;
        fm_folder_model_set_icon_size(model, icon_size);
        break;
    case FM_FV_ICON_VIEW:
        icon_size = fm_config->big_icon_size;
        fm_folder_model_set_icon_size(model, icon_size);
        exo_icon_view_set_model(EXO_ICON_VIEW(fv->view), model);
        break;
    case FM_FV_COMPACT_VIEW:
        icon_size = fm_config->small_icon_size;
        fm_folder_model_set_icon_size(model, icon_size);
        exo_icon_view_set_model(EXO_ICON_VIEW(fv->view), model);
        break;
    case FM_FV_THUMBNAIL_VIEW:
        icon_size = fm_config->thumbnail_size;
        fm_folder_model_set_icon_size(model, icon_size);
        exo_icon_view_set_model(EXO_ICON_VIEW(fv->view), model);
        break;
    }
    fv->model = model;
    on_model_loaded(model, fv);
}