Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-12

shell fnctionnalities

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Geoffray

Hi,

I'm actually trying to convert a Delphi component to Lazarus. The work is running Ok but I have some difficulties finding multiplatform equivalents working with FPC/Lazarus. This must be complicated as those functions are about shell integration and each shell have it's own approach.

Here is the typical code giving me headackes :

{$ifndef FPC}
//this windows specific function should be hard to convert
//we should need here something using mime types, anyway many more code
//should be required
procedure GetFileExtensionShellDescription(Ext: string;
  var FileTypeName: string; var ShellImageIndex: Integer);
var
  A, B: Integer;
  T: string;
  L: TImageList;
  sFI: TSHFileInfo; //this is windows specific but an other type could be
equivalent
  I: TIcon;
  Q: PChar;
  P: PFileDescriptionRecord;
begin
  FileTypeName := '';
  A := RegisteredExtensions.IndexOf(Ext); //this is a TStringList defined as
global before
  if A = -1 then
  begin
    New(P);
    P^.FileType := '';
    I := TIcon.Create;
    for B := 0 to 1 do
    begin
      if B = 0 then
        L := ShellSmallImageList
      else L := ShellLargeImageList; //both are TImageList
      GetMem(Q, MAX_PATH);
      GetTempPath(MAX_PATH, Q); //those lines could be replaced by GetTempDir
in FileUtil
      T := Q + 'TEMP' + Ext;
      FreeMem(Q);
      TFileStream.Create(T, fmCreate or fmOpenWrite).Destroy;
      //the following is the biggest problem... Impossible to find any
      //equivalent with Lazarus. Any ideas ? Mime types and Freedesktop
      //should provide this...
      if SHGetFileInfo(PChar(T), 0, sFI, SizeOf(sFI),
        SHGFI_TYPENAME or SHGFI_ICON or
        (SHGFI_SMALLICON * (1 - B) + B * SHGFI_LARGEICON))  0 then
      begin
        I.ReleaseHandle;
        I.Handle := sFI.hIcon;
        P^.FileType := sFI.szTypeName;
      end;
      P^.OpenImageIndex := L.AddIcon(I);
      P^.CloseImageIndex := P^.OpenImageIndex;
      if B = 1 then
        A := RegisteredExtensions.AddObject(Ext, TObject(P));
    end;
    I.Destroy;
  end;
  with PFileDescriptionRecord(RegisteredExtensions.Objects[A])^ do
  begin
    ShellImageIndex := CloseImageIndex;
    FileTypeName := FileType;
  end;
end;
{$endif}

The problem seems simple, we just need to get system icons from each each file extension but nothing is currently available in lazarus to to that. I know FreeDesktop is providing a common interface to be able to do that, as many software that don't have the same API can do that (eg. Gnome app under KDE use KDE theme). Is there a way to project a such implementation wich is the base for desktop integration. This should be a very good added value to Lazarus !

Thanks.

Geoffray "fatalerrors" Levasseur http://jeff.levasseur.tuxfamily.org/ Sic luceat lux et pax

Reply by email

Hans-Peter Diettrich
to Geoffray
I have some difficulties finding multiplatform equivalents working with FPC/Lazarus. This must be complicated as those functions are about shell integration and each shell have it's own approach.

Isn't this more a matter of FPC (RTL), than of Lazarus?

DoDi

Reply by email

Marco van de Voort
to Hans-Peter Diettrich
Hans-Peter Diettrich wrote 5 lines
> I have some difficulties finding multiplatform equivalents working > with FPC/Lazarus. This must be complicated as those functions are about shell > integration and each shell have it's own approach. Isn't this more a matter of FPC (RTL), than of Lazarus?

I don't think it necessarily belongs to either.

Reply by email

Geoffray
to Marco van de Voort

Le mardi 8 d?cembre 2009 23:02:48, Marco van de Voort a ?crit :

Show quoted text 9 lines
On Tue, Dec 08, 2009 at 10:36:22PM +0100, Hans-Peter Diettrich wrote: > > I have some difficulties finding multiplatform equivalents working > > with FPC/Lazarus. This must be complicated as those functions are about > > shell integration and each shell have it's own approach. > > Isn't this more a matter of FPC (RTL), than of Lazarus? I don't think it necessarily belongs to either.

I think both FPC and LCL should integrate some FreeDesktop more functionalities (with different levels). For exemple D-Bus should be more used (both with GTK and Qt) as Windows API is giving equivalent functionality (see ShellApi unit for exemple).

For exemple, I know D-Bus is used through Qt when using Qt interface but D-Bus don't seem to be used directly.

My goal is to underline what is strongly missing: some equivalent widely used on Windows GUI with shell API. We could think multiplatform equivalent is not possible but this may be a wrong idea as MacOS is certainly providing an equivalent and with Linux we have FreeDesktop.

Like all the widgetset Lasarus the support some low-level code will be platform specific (tipically rewriting ShellApi basics for Windows, writing an equivalent with MacOS, an other one with FreeDesktop...) and high-level ones will be multiplatform.

Geoffray "fatalerrors" Levasseur http://jeff.levasseur.tuxfamily.org/ Sic luceat lux et pax

Reply by email

Mattias Gaertner
to Geoffray
Show quoted text 10 lines
[...] My goal is to underline what is strongly missing: some equivalent widely used on Windows GUI with shell API. We could think multiplatform equivalent is not possible but this may be a wrong idea as MacOS is certainly providing an equivalent and with Linux we have FreeDesktop. Like all the widgetset Lasarus the support some low-level code will be platform specific (tipically rewriting ShellApi basics for Windows, writing an equivalent with MacOS, an other one with FreeDesktop...) and high-level ones will be multiplatform.

Sounds like a good candidate for a package on lazarus-ccr.

Mattias

Reply by email