void vfs_file_info_load_special_info( VFSFileInfo* fi, const char* file_path ) { /*if ( G_LIKELY(fi->type) && G_UNLIKELY(fi->type->name, "application/x-desktop") ) */ if ( G_UNLIKELY( g_str_has_suffix( fi->name, ".desktop") ) ) { VFSAppDesktop * desktop; const char* icon_name; if ( !desktop_dir ) desktop_dir = vfs_get_desktop_dir(); char* file_dir = g_path_get_dirname( file_path ); fi->flags |= VFS_FILE_INFO_DESKTOP_ENTRY; desktop = vfs_app_desktop_new( file_path ); //MOD display real filenames of .desktop files not in desktop folder if ( desktop_dir && !strcmp( file_dir, desktop_dir ) ) { if ( vfs_app_desktop_get_disp_name( desktop ) ) { vfs_file_info_set_disp_name( fi, vfs_app_desktop_get_disp_name( desktop ) ); } } if ( (icon_name = vfs_app_desktop_get_icon_name( desktop )) ) { GdkPixbuf* icon; int big_size, small_size; vfs_mime_type_get_icon_size( &big_size, &small_size ); if( ! fi->big_thumbnail ) { icon = vfs_app_desktop_get_icon( desktop, big_size, FALSE ); if( G_LIKELY(icon) ) fi->big_thumbnail =icon; } if( ! fi->small_thumbnail ) { icon = vfs_app_desktop_get_icon( desktop, small_size, FALSE ); if( G_LIKELY(icon) ) fi->small_thumbnail =icon; } } vfs_app_desktop_unref( desktop ); g_free( file_dir ); } }
/* * Parse Exec command line of app desktop file, and translate * it into a real command which can be passed to g_spawn_command_line_async(). * file_list is a null-terminated file list containing full * paths of the files passed to app. * returned char* should be freed when no longer needed. */ static char* translate_app_exec_to_command_line( VFSAppDesktop* app, GList* file_list ) { const char* pexec = vfs_app_desktop_get_exec( app ); char* file; GList* l; gchar *tmp; GString* cmd = g_string_new(""); gboolean add_files = FALSE; for( ; *pexec; ++pexec ) { if( *pexec == '%' ) { ++pexec; switch( *pexec ) { case 'U': for( l = file_list; l; l = l->next ) { tmp = g_filename_to_uri( (char*)l->data, NULL, NULL ); file = g_shell_quote( tmp ); g_free( tmp ); g_string_append( cmd, file ); g_string_append_c( cmd, ' ' ); g_free( file ); } add_files = TRUE; break; case 'u': if( file_list && file_list->data ) { file = (char*)file_list->data; tmp = g_filename_to_uri( file, NULL, NULL ); file = g_shell_quote( tmp ); g_free( tmp ); g_string_append( cmd, file ); g_free( file ); add_files = TRUE; } break; case 'F': case 'N': for( l = file_list; l; l = l->next ) { file = (char*)l->data; tmp = g_shell_quote( file ); g_string_append( cmd, tmp ); g_string_append_c( cmd, ' ' ); g_free( tmp ); } add_files = TRUE; break; case 'f': case 'n': if( file_list && file_list->data ) { file = (char*)file_list->data; tmp = g_shell_quote( file ); g_string_append( cmd, tmp ); g_free( tmp ); add_files = TRUE; } break; case 'D': for( l = file_list; l; l = l->next ) { tmp = g_path_get_dirname( (char*)l->data ); file = g_shell_quote( tmp ); g_free( tmp ); g_string_append( cmd, file ); g_string_append_c( cmd, ' ' ); g_free( file ); } add_files = TRUE; break; case 'd': if( file_list && file_list->data ) { tmp = g_path_get_dirname( (char*)file_list->data ); file = g_shell_quote( tmp ); g_free( tmp ); g_string_append( cmd, file ); g_free( tmp ); add_files = TRUE; } break; case 'c': g_string_append( cmd, vfs_app_desktop_get_disp_name( app ) ); break; case 'i': /* Add icon name */ if( vfs_app_desktop_get_icon_name( app ) ) { g_string_append( cmd, "--icon " ); g_string_append( cmd, vfs_app_desktop_get_icon_name( app ) ); } break; case 'k': /* Location of the desktop file */ break; case 'v': /* Device name */ break; case '%': g_string_append_c ( cmd, '%' ); break; case '\0': goto _finish; break; } } else /* not % escaped part */ { g_string_append_c ( cmd, *pexec ); } } _finish: if( ! add_files ) { g_string_append_c ( cmd, ' ' ); for( l = file_list; l; l = l->next ) { file = (char*)l->data; tmp = g_shell_quote( file ); g_string_append( cmd, tmp ); g_string_append_c( cmd, ' ' ); g_free( tmp ); } } return g_string_free( cmd, FALSE ); }