Graeme Geldenhuys schreef:
Hi,

Attached is a proposed patch for TDirectoryEdit - please evaluate.

Due to the fact that Gtk1 doesn't have a native Directory Treeview
selection dialog like Windows, Gtk1 uses a normal File Open dialog.
The problem is that TDirectoryEdit returns the filename in the path as
well instead of only the directory part (when a user selects a
file!???!).

This proposed patch strips out the filename when the OS is not Windows
and only returns the directory path as it should.

Why doesn't the gtk interface return the Directory Name in the filename 
property?



------------------------------------------------------------------------

Index: lcl/editbtn.pas
===================================================================
--- lcl/editbtn.pas     (revision 10987)
+++ lcl/editbtn.pas     (working copy)
@@ -799,9 +799,9 @@
 procedure TDirectoryEdit.SetDirectory(const AValue: String);
 begin
   if (Text<>AValue) then
-    begin
-    Text:=AValue;
-    end;
+  begin
+    Text := AValue;
+  end;
 end;

This is a irrelevant change, is it? Or did I miss anything?

function TDirectoryEdit.CreateDialog: TCommonDialog;
@@ -818,7 +818,11 @@
Function TDirectoryEdit.GetDialogResult(D: TCommonDialog) : String;
 begin
-  Result:=TSelectDirectoryDialog(D).FileName;
+  {$IFDEF MSWINDOWS}
+  Result := TSelectDirectoryDialog(D).FileName;
+  {$ELSE}
+  Result := ExtractFilePath(TSelectDirectoryDialog(D).FileName);
+  {$ENDIF}
 end;

This is not a good solution, because
1. the code in {$IFDEF MSWINDOWS} should include the wince widget set, but 
doesn't.
2. the code in {$IFDEF MSWINDOWS} is activated for i386-win32-gtk2, which 
should not.

Vincent

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to