95
98
/* signal handlers */
97
static void ptk_file_list_file_created( VFSDir* dir, VFSFileInfo* file,
100
static void ptk_file_list_file_deleted( VFSDir* dir, VFSFileInfo* file,
103
static void ptk_file_list_file_changed( VFSDir* dir, VFSFileInfo* file,
100
static void on_thumbnail_loaded( VFSDir* dir, VFSFileInfo* file, PtkFileList* list );
103
* already declared in ptk-file-list.h
104
void ptk_file_list_file_created( VFSDir* dir, VFSFileInfo* file,
107
void ptk_file_list_file_deleted( VFSDir* dir, VFSFileInfo* file,
110
void ptk_file_list_file_changed( VFSDir* dir, VFSFileInfo* file,
107
114
static GObjectClass* parent_class = NULL;
109
116
static GType column_types[ N_FILE_LIST_COLS ];
112
typedef struct _ThumbThreadData
119
118
GType ptk_file_list_get_type ( void )
121
120
static GType type = 0;
259
static void _ptk_file_list_file_changed( VFSDir* dir, VFSFileInfo* file,
262
ptk_file_list_file_changed( dir, file, list );
264
/* check if reloading of thumbnail is needed. */
265
if( vfs_file_info_is_image( file )
266
&& vfs_file_info_get_size( file ) < list->max_thumbnail )
268
if( ! vfs_file_info_is_thumbnail_loaded( file, list->big_thumbnail ) )
269
vfs_thumbnail_loader_request( list->dir, file, list->big_thumbnail );
273
static void _ptk_file_list_file_created( VFSDir* dir, VFSFileInfo* file,
276
ptk_file_list_file_created( dir, file, list );
278
/* check if reloading of thumbnail is needed. */
279
if( vfs_file_info_is_image( file )
280
&& vfs_file_info_get_size( file ) < list->max_thumbnail )
282
if( ! vfs_file_info_is_thumbnail_loaded( file, list->big_thumbnail ) )
283
vfs_thumbnail_loader_request( list->dir, file, list->big_thumbnail );
260
287
void ptk_file_list_set_dir( PtkFileList* list, VFSDir* dir )
266
291
if( list->dir == dir )
271
296
if( list->max_thumbnail > 0 )
273
for( l = list->files; l; l = l->next )
275
file = (VFSFileInfo*)l->data;
276
if( vfs_file_info_is_image( file )
277
&& vfs_file_info_get_size( file ) < list->max_thumbnail )
279
/* FIXME: vfs_dir_cancel_thumbnail_request( ); */
298
/* cancel all possible pending requests */
299
vfs_thumbnail_loader_cancel_all_requests( list->dir, list->big_thumbnail );
283
301
g_list_foreach( list->files, (GFunc)vfs_file_info_unref, NULL );
284
302
g_list_free( list->files );
285
303
g_signal_handlers_disconnect_by_func( list->dir,
286
ptk_file_list_file_created, list );
304
_ptk_file_list_file_created, list );
287
305
g_signal_handlers_disconnect_by_func( list->dir,
288
306
ptk_file_list_file_deleted, list );
289
307
g_signal_handlers_disconnect_by_func( list->dir,
290
ptk_file_list_file_changed, list );
291
vfs_dir_unref( list->dir );
308
_ptk_file_list_file_changed, list );
309
g_signal_handlers_disconnect_by_func( list->dir,
310
on_thumbnail_loaded, list );
311
g_object_unref( list->dir );
300
vfs_dir_ref( list->dir );
320
g_object_ref( list->dir );
302
322
g_signal_connect( list->dir, "file-created",
303
G_CALLBACK(ptk_file_list_file_created),
323
G_CALLBACK(_ptk_file_list_file_created),
305
325
g_signal_connect( list->dir, "file-deleted",
306
326
G_CALLBACK(ptk_file_list_file_deleted),
308
328
g_signal_connect( list->dir, "file-changed",
309
G_CALLBACK(ptk_file_list_file_changed),
329
G_CALLBACK(_ptk_file_list_file_changed),
312
332
if( dir && dir->file_list )
316
336
if( list->show_hidden ||
317
337
((VFSFileInfo*)l->data)->disp_name[0] != '.' )
319
list->files = g_list_prepend( list->files, l->data );
320
vfs_file_info_ref( (VFSFileInfo*)l->data );
339
list->files = g_list_prepend( list->files, vfs_file_info_ref( (VFSFileInfo*)l->data) );
425
444
case COL_FILE_BIG_ICON:
427
446
/* special file can use special icons saved as thumbnails*/
428
if( list->max_thumbnail > vfs_file_info_get_size( info )
447
if( list->max_thumbnail > vfs_file_info_get_size( info )
429
448
&& info->flags == VFS_FILE_INFO_NONE )
430
449
icon = vfs_file_info_get_big_thumbnail( info );
432
452
icon = vfs_file_info_get_big_icon( info );
468
488
g_value_set_string( value, vfs_file_info_get_disp_mtime(info) );
470
490
case COL_FILE_INFO:
471
vfs_file_info_ref( info );
472
g_value_set_pointer( value, info );
491
g_value_set_pointer( value, vfs_file_info_ref( info ) );
696
715
g_free( new_order );
718
gboolean ptk_file_list_find_iter( PtkFileList* list, GtkTreeIter* it, VFSFileInfo* fi )
721
for( l = list->files; l; l = l->next )
723
VFSFileInfo* fi2 = (VFSFileInfo*)l->data;
724
if( G_UNLIKELY( fi2 == fi
725
|| 0 == strcmp( vfs_file_info_get_name(fi), vfs_file_info_get_name(fi2) ) ) )
727
it->stamp = list->stamp;
729
it->user_data2 = fi2;
699
736
void ptk_file_list_file_created( VFSDir* dir,
700
737
VFSFileInfo* file,
701
738
PtkFileList* list )
711
748
for( l = list->files; l; l = l->next )
713
750
file2 = (VFSFileInfo*)l->data;
714
if( ptk_file_list_compare( file2, file, list ) >= 0 )
751
if( G_UNLIKELY( file == file2 || ptk_file_list_compare( file2, file, list ) == 0 ) )
753
/* The file is already in the list */
756
if( ptk_file_list_compare( file2, file, list ) > 0 )
720
list->files = g_list_insert_before( list->files, l, file );
721
vfs_file_info_ref( file );
762
list->files = g_list_insert_before( list->files, l, vfs_file_info_ref( file ) );
745
786
GtkTreePath* path;
788
/* If there is no file info, that means the dir itself was deleted. */
789
if( G_UNLIKELY( ! file ) )
791
/* Clear the whole list */
792
path = gtk_tree_path_new_from_indices(0, -1);
793
for( l = list->files; l; l = list->files )
795
gtk_tree_model_row_deleted( GTK_TREE_MODEL(list), path );
796
file = (VFSFileInfo*)l->data;
797
list->files = g_list_delete_link( list->files, l );
798
vfs_file_info_unref( file );
801
gtk_tree_path_free( path );
747
805
if( ! list->show_hidden && vfs_file_info_get_name(file)[0] == '.' )
750
808
l = g_list_find( list->files, file );
789
846
gtk_tree_path_free( path );
849
void on_thumbnail_loaded( VFSDir* dir, VFSFileInfo* file, PtkFileList* list )
851
/* g_debug( "LOADED: %s", file->name ); */
852
ptk_file_list_file_changed( dir, file, list );
793
void ptk_file_list_show_thumbnails( PtkFileList* list, gboolean big,
855
void ptk_file_list_show_thumbnails( PtkFileList* list, gboolean is_big,
794
856
int max_file_size )
797
859
VFSFileInfo* file;
860
int old_max_thumbnail;
862
old_max_thumbnail = list->max_thumbnail;
799
863
list->max_thumbnail = max_file_size;
800
/* FIXME: This is extremely buggy!!! must be fixed before release
801
Loading of big icons and small ones should be separate threads.
864
list->big_thumbnail = is_big;
865
/* FIXME: This is buggy!!! Further testing might be needed.
803
867
if( 0 == max_file_size )
869
if( old_max_thumbnail > 0 ) /* cancel thumbnails */
871
vfs_thumbnail_loader_cancel_all_requests( list->dir, list->big_thumbnail );
872
g_signal_handlers_disconnect_by_func( list->dir, on_thumbnail_loaded, list );
874
for( l = list->files; l; l = l->next )
876
file = (VFSFileInfo*)l->data;
877
if( vfs_file_info_is_image( file )
878
&& vfs_file_info_is_thumbnail_loaded( file, is_big ) )
880
/* update the model */
881
ptk_file_list_file_changed( list->dir, file, list );
888
g_signal_connect( list->dir, "thumbnail-loaded",
889
G_CALLBACK(on_thumbnail_loaded), list );
806
891
for( l = list->files; l; l = l->next )
809
894
if( vfs_file_info_is_image( file )
810
895
&& vfs_file_info_get_size( file ) < list->max_thumbnail )
812
if( vfs_file_info_is_thumbnail_loaded( file, big ) )
897
if( vfs_file_info_is_thumbnail_loaded( file, is_big ) )
813
898
ptk_file_list_file_changed( list->dir, file, list );
815
vfs_dir_request_thumbnail( list->dir, file, big );
821
/* I still have doubt if this works */
823
void ptk_file_list_show_hidden_files( PtkFileList* list )
825
GList *l, *l2, *new_item;
831
if( list->show_hidden )
833
for( l = list->dir->file_list; l; l = l->next )
835
info = (VFSFileInfo*)l->data;
836
if( vfs_file_info_get_disp_name(info)[0] != '.' )
838
for( i = 0, l2 = list->files; l2; l2 = l2->next, ++i )
840
if( ptk_file_list_compare(info, l2->data, list) >= 0 )
842
list->files = g_list_insert_before( list->files, info, l2 );
843
it.user_data = l2->prev;
844
it.user_data2 = info;
845
it.stamp = list->stamp;
846
path = gtk_tree_path_new_from_indices(i, -1);
847
gtk_tree_model_row_inserted( list, path, &it );
848
gtk_tree_path_free( path );
901
vfs_thumbnail_loader_request( list->dir, file, is_big );
902
/* g_debug( "REQUEST: %s", file->name ); */
855
void ptk_file_list_hide_hidden_files( PtkFileList* list )
861
if( ! list->show_hidden )
863
path = gtk_tree_path_new_first();
864
for( l = list->files; l; )
866
info = (VFSFileInfo*)l->data;
868
if( G_UNLIKELY(vfs_file_info_get_disp_name(info)[0] == '.') )
871
list->files = g_list_delete_link( list->files, l->prev );
872
gtk_tree_model_row_deleted( GTK_TREE_MODEL(list), path );
877
gtk_tree_path_next( path );
880
gtk_tree_path_free( path );