Ejemplo n.º 1
0
void ptk_file_list_file_created( VFSDir* dir,
                                 VFSFileInfo* file,
                                 PtkFileList* list )
{
    GList* l;
    GtkTreeIter it;
    GtkTreePath* path;
    VFSFileInfo* file2;

    if( ! list->show_hidden && vfs_file_info_get_name(file)[0] == '.' )
        return;

    for( l = list->files; l; l = l->next )
    {
        file2 = (VFSFileInfo*)l->data;
        if( G_UNLIKELY( file == file2 || ptk_file_list_compare( file2, file, list ) == 0 ) )
        {
            /* The file is already in the list */
            return;
        }
        if( ptk_file_list_compare( file2, file, list ) > 0 )
        {
            break;
        }
    }

    list->files = g_list_insert_before( list->files, l, vfs_file_info_ref( file ) );
    ++list->n_files;

    if( l )
        l = l->prev;
    else
        l = g_list_last( list->files );

    it.stamp = list->stamp;
    it.user_data = l;
    it.user_data2 = file;

    path = gtk_tree_path_new_from_indices( g_list_index(list->files, l->data), -1 );

    gtk_tree_model_row_inserted( GTK_TREE_MODEL(list), path, &it );

    gtk_tree_path_free( path );
}
Ejemplo n.º 2
0
void ptk_file_list_file_created( VFSDir* dir,
                                 VFSFileInfo* file,
                                 PtkFileList* list )
{
    GList* l, *ll = NULL;
    GtkTreeIter it;
    GtkTreePath* path;
    VFSFileInfo* file2;
    
    if( ! list->show_hidden && vfs_file_info_get_name(file)[0] == '.' )
        return;

    gboolean is_desktop = vfs_file_info_is_desktop_entry( file ); //sfm
    gboolean is_desktop2;
    
    for( l = list->files; l; l = l->next )
    {
        file2 = (VFSFileInfo*)l->data;
        if( G_UNLIKELY( file == file2 ) )
        {
            /* The file is already in the list */
            return;
        }
        
        is_desktop2 = vfs_file_info_is_desktop_entry( file2 );
        if ( is_desktop || is_desktop2 )
        {
            // at least one is a desktop file, need to compare filenames
            if ( file->name && file2->name )
            {
                if ( !strcmp( file->name, file2->name ) )
                    return;
            }
        }
        else if ( ptk_file_list_compare( file2, file, list ) == 0 )
        {
            // disp_name matches ?
            // ptk_file_list_compare may return 0 on differing display names
            // if case-insensitive - need to compare filenames
            if ( list->sort_natural && list->sort_case )
                return;
            else if ( !strcmp( file->name, file2->name ) )
                return;
        }

        if ( !ll && ptk_file_list_compare( file2, file, list ) > 0 )
        {
            if ( !is_desktop && !is_desktop2 )
                break;
            else
                ll = l; // store insertion location based on disp_name
        }
    }

    if ( ll )
        l = ll;

    list->files = g_list_insert_before( list->files, l, vfs_file_info_ref( file ) );
    ++list->n_files;

    if( l )
        l = l->prev;
    else
        l = g_list_last( list->files );

    it.stamp = list->stamp;
    it.user_data = l;
    it.user_data2 = file;

    path = gtk_tree_path_new_from_indices( g_list_index(list->files, l->data), -1 );

    gtk_tree_model_row_inserted( GTK_TREE_MODEL(list), path, &it );

    gtk_tree_path_free( path );
}