void vfs_dir_load( VFSDir* dir ) { if ( G_LIKELY(dir->path) ) { dir->disp_path = g_filename_display_name( dir->path ); dir->flags = 0; /* FIXME: We should check access here! */ if( G_UNLIKELY( strcmp( dir->path, vfs_get_desktop_dir() ) == 0 ) ) dir->is_desktop = TRUE; else if( G_UNLIKELY( strcmp( dir->path, g_get_home_dir() ) == 0 ) ) dir->is_home = TRUE; if( G_UNLIKELY(is_dir_trash(dir->path)) ) { // g_free( dir->disp_path ); // dir->disp_path = g_strdup( _("Trash") ); dir->is_trash = TRUE; } if( G_UNLIKELY( is_dir_mount_point(dir->path)) ) dir->is_mount_point = TRUE; if( G_UNLIKELY( is_dir_remote(dir->path)) ) dir->is_remote = TRUE; if( G_UNLIKELY( is_dir_virtual(dir->path)) ) dir->is_virtual = TRUE; dir->task = vfs_async_task_new( (VFSAsyncFunc)vfs_dir_load_thread, dir ); g_signal_connect( dir->task, "finish", G_CALLBACK(on_list_task_finished), dir ); vfs_async_task_execute( dir->task ); } }
static void on_start_search( GtkWidget* btn, FindFile* data ) { char** argv; GError* err = NULL; int stdo, stde; char* cmd_line; GtkAllocation allocation; gtk_widget_get_allocation ( GTK_WIDGET( data->win ), &allocation ); int width = allocation.width; int height = allocation.height; if ( width && height ) { char* str = g_strdup_printf( "%d", width ); xset_set( "main_search", "x", str ); g_free( str ); str = g_strdup_printf( "%d", height ); xset_set( "main_search", "y", str ); g_free( str ); } gtk_widget_hide( data->search_criteria ); gtk_widget_show( data->search_result ); gtk_widget_hide( btn ); gtk_widget_show( data->stop_btn ); argv = compose_command( data ); cmd_line = g_strjoinv( " ", argv ); g_debug( "find command: %s", cmd_line ); g_free( cmd_line ); if( g_spawn_async_with_pipes( g_get_home_dir(), argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_STDERR_TO_DEV_NULL, NULL, NULL, &data->pid, NULL, &data->stdo, NULL, &err ) ) { GdkCursor* busy_cursor; data->task = vfs_async_task_new( (VFSAsyncFunc)search_thread, data ); g_signal_connect( data->task, "finish", G_CALLBACK( on_search_finish ), data ); vfs_async_task_execute( data->task ); busy_cursor = gdk_cursor_new( GDK_WATCH ); gdk_window_set_cursor( gtk_widget_get_window (data->search_result), busy_cursor ); gdk_cursor_unref( busy_cursor ); } else { g_error_free( err ); } g_strfreev( argv ); }
void vfs_thumbnail_loader_request( VFSDir* dir, VFSFileInfo* file, gboolean is_big ) { VFSThumbnailLoader* loader; ThumbnailRequest* req; gboolean new_task = FALSE; GList* l; /* g_debug( "request thumbnail: %s, is_big: %d", file->name, is_big ); */ if( G_UNLIKELY( ! dir->thumbnail_loader ) ) { dir->thumbnail_loader = vfs_thumbnail_loader_new( dir ); new_task = TRUE; } loader = dir->thumbnail_loader; if( G_UNLIKELY( ! loader->task ) ) { loader->task = vfs_async_task_new( (VFSAsyncFunc)thumbnail_loader_thread, loader ); new_task = TRUE; } vfs_async_task_lock( loader->task ); /* Check if the request is already scheduled */ for( l = loader->queue->head; l; l = l->next ) { req = (ThumbnailRequest*)l->data; /* If file with the same name is already in our queue */ if( req->file == file || 0 == strcmp( req->file->name, file->name ) ) break; } if( l ) { req = (ThumbnailRequest*)l->data; } else { req = g_slice_new0( ThumbnailRequest ); req->file = vfs_file_info_ref(file); g_queue_push_tail( dir->thumbnail_loader->queue, req ); } ++req->n_requests[ is_big ? LOAD_BIG_THUMBNAIL : LOAD_SMALL_THUMBNAIL ]; vfs_async_task_unlock( loader->task ); if( new_task ) vfs_async_task_execute( loader->task ); }