From 28d0c4a48579ab958010cf62c9d0507cf466a220 Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 28 Feb 2005 18:21:43 +0000 Subject: [PATCH] fixed gtk file dialog with empty filter from Collin git-svn-id: trunk@6863 - --- lcl/interfaces/gtk/gtkint.pp | 7 +++++-- lcl/interfaces/gtk/gtkobject.inc | 20 ++++++++++++++------ lcl/interfaces/gtk/gtkproc.inc | 9 +++++++-- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lcl/interfaces/gtk/gtkint.pp b/lcl/interfaces/gtk/gtkint.pp index 78220c699c..c534c513d9 100644 --- a/lcl/interfaces/gtk/gtkint.pp +++ b/lcl/interfaces/gtk/gtkint.pp @@ -219,8 +219,8 @@ type procedure InitializeFontDialog(FontDialog: TFontDialog; var SelWidget: PGtkWidget; Title: PChar); procedure InitializeCommonDialog(ADialog: TObject; AWindow: PGtkWidget); - procedure CreateOpenDialogFilter(OpenDialog: TOpenDialog; - SelWidget: PGtkWidget); + function CreateOpenDialogFilter(OpenDialog: TOpenDialog; + SelWidget: PGtkWidget): string; procedure CreatePreviewDialogControl(PreviewDialog: TPreviewFileDialog; SelWidget: PGtkWidget); procedure InitializeOpenDialog(OpenDialog: TOpenDialog; @@ -442,6 +442,9 @@ end. { ============================================================================= $Log$ + Revision 1.222 2005/02/28 18:21:43 mattias + fixed gtk file dialog with empty filter from Collin + Revision 1.221 2005/02/05 09:09:52 mattias implemented TListView for gtk2 From Andrew Haines diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index e1ee073721..4dddafdbeb 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -4154,10 +4154,11 @@ end; Params: OpenDialog: TOpenDialog; SelWidget: PGtkWidget Returns: - - Adds a Filter pulldown to a gtk file selection dialog. + Adds a Filter pulldown to a gtk file selection dialog. Returns the + inital filter mask. ------------------------------------------------------------------------------} -procedure TGtkWidgetSet.CreateOpenDialogFilter(OpenDialog: TOpenDialog; - SelWidget: PGtkWidget); +function TGtkWidgetSet.CreateOpenDialogFilter(OpenDialog: TOpenDialog; + SelWidget: PGtkWidget): string; var FilterList: TList; HBox, LabelWidget, FilterPullDownWidget, @@ -4215,6 +4216,7 @@ begin gtk_object_set_data(PGtkObject(SelWidget), 'LCLFilterList', FilterList); // set the initial filter + Result := 'none'; { Don't use '' as null return as this is used for *.* } if FilterList.Count>0 then begin i:=0; CurMask:=0; @@ -4226,8 +4228,7 @@ begin end; inc(i); end; - PopulateFileAndDirectoryLists(GTK_FILE_SELECTION(SelWidget), - PFileSelFilterEntry(FilterList[CurMask])^.Mask); + Result := PFileSelFilterEntry(FilterList[CurMask])^.Mask; end; end; @@ -4291,6 +4292,7 @@ procedure TGtkWidgetSet.InitializeOpenDialog(OpenDialog: TOpenDialog; var FileDetailLabel, HBox, FrameWidget: PGtkWidget; FileSelWidget: PGtkFileSelection; + InitialFilter: string; begin FileSelWidget:=GTK_FILE_SELECTION(SelWidget); @@ -4336,7 +4338,7 @@ begin CreateOpenDialogHistory(OpenDialog,SelWidget); // Filter - a frame with an option menu - CreateOpenDialogFilter(OpenDialog,SelWidget); + InitialFilter := CreateOpenDialogFilter(OpenDialog,SelWidget); // Details - a frame with a label if (ofViewDetail in OpenDialog.Options) then begin @@ -4364,6 +4366,9 @@ begin // set initial filename if OpenDialog.Filename<>'' then gtk_file_selection_set_filename(FileSelWidget,PChar(OpenDialog.Filename)); + + if InitialFilter <> 'none' then + PopulateFileAndDirectoryLists(FileSelWidget, InitialFilter); end; {------------------------------------------------------------------------------ @@ -6992,6 +6997,9 @@ end; { ============================================================================= $Log$ + Revision 1.633 2005/02/28 18:21:43 mattias + fixed gtk file dialog with empty filter from Collin + Revision 1.632 2005/02/26 18:39:56 mattias fixed gtk open dialog go up diff --git a/lcl/interfaces/gtk/gtkproc.inc b/lcl/interfaces/gtk/gtkproc.inc index 354c8a3e59..5b7468f2c5 100644 --- a/lcl/interfaces/gtk/gtkproc.inc +++ b/lcl/interfaces/gtk/gtkproc.inc @@ -3208,8 +3208,10 @@ begin Add(Dirs, AppendPathDelim(Info.Name)); until FindNext(Info) <> 0; FindClose(Info); - // add all files - if FindFirst(AppendPathDelim(Dir)+Mask, faAnyFile, Info) = 0 then + // add required files + Dir := AppendPathDelim(Dir)+Mask; + if Mask = '' then Dir := Dir + GetAllFilesMask; + if FindFirst(Dir, faAnyFile, Info) = 0 then repeat if (Info.Attr and faDirectory) <> faDirectory then Add(Files, Info.Name); @@ -8081,6 +8083,9 @@ end; { ============================================================================= $Log$ + Revision 1.345 2005/02/28 18:21:43 mattias + fixed gtk file dialog with empty filter from Collin + Revision 1.344 2005/02/26 18:39:56 mattias fixed gtk open dialog go up