From b9703b29819b619037cc282d719c187e51bacd30 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 23 Dec 2024 23:59:45 +0100 Subject: Port to g-i generated glib2 bindings Includes switch to FPC -Mobjfpc and related pointer style fixes. --- .gitignore | 1 + Makefile | 4 +- UChecksum.pas | 38 ++-- UChecksumDruid.pas | 42 ++-- UChmod.pas | 32 +-- UChown.pas | 6 +- UColumns.pas | 15 +- UConfig.pas | 4 +- UConnectionManager.pas | 68 +++--- UConnectionProperties.pas | 22 +- UCopyMove.pas | 4 +- UCore.pas | 12 +- UCoreClasses.pas | 19 +- UCoreUtils.pas | 67 +++--- UCoreWorkers.pas | 73 +++--- UDirDelete.pas | 4 +- UEngines.pas | 56 ++--- UError.pas | 69 +++--- UFileAssoc.pas | 4 +- UFileTypeSettings.pas | 87 ++++--- UGnome.pas | 268 ++++++++-------------- ULibc.pas | 4 +- ULocale.pas | 25 +- UMain.pas | 532 +++++++++++++++++-------------------------- UMounterPrefs.pas | 42 ++-- UNewDir.pas | 4 +- UOverwrite.pas | 20 +- UPreferences.pas | 46 ++-- UProgress.pas | 9 +- UProperties.pas | 144 ------------ UQuickConnect.pas | 30 +-- URemoteWait.pas | 9 +- URunFromVFS.pas | 14 +- USearch.pas | 57 ++--- USelect.pas | 9 +- USplitFile.pas | 4 +- USymlink.pas | 6 +- UTestPlugin.pas | 9 +- UToolTips.pas | 18 +- UViewer.pas | 24 +- libgtk_kylix/GTKClasses.pas | 14 +- libgtk_kylix/GTKConsts.pas | 2 +- libgtk_kylix/GTKControls.pas | 73 +++--- libgtk_kylix/GTKDialogs.pas | 18 +- libgtk_kylix/GTKExtCtrls.pas | 24 +- libgtk_kylix/GTKForms.pas | 47 ++-- libgtk_kylix/GTKMenus.pas | 32 ++- libgtk_kylix/GTKPixbuf.pas | 3 +- libgtk_kylix/GTKStdCtrls.pas | 94 ++++---- libgtk_kylix/GTKText.pas | 4 +- libgtk_kylix/GTKUtils.pas | 24 +- libgtk_kylix/GTKView.pas | 95 ++++---- tuxcmd.dpr | 59 +---- vfs/UVFSCore.pas | 280 +++++++++++------------ vfs/uVFSprototypes.pas | 6 +- 55 files changed, 1112 insertions(+), 1564 deletions(-) delete mode 100644 UProperties.pas diff --git a/.gitignore b/.gitignore index fc48819..d5657ba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.desk *.lpi *.kof +*.rsj *.*~ *.so diff --git a/Makefile b/Makefile index 8f8add9..46a9e3b 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ LIB_SUFFIX=`if test \`uname -m\` = x86_64 -o \`uname -m\` = ppc64; then echo 64; # -Cg generates internal compiler errors on i386 # -XX prevents linking errors of unresolved and unused symbols # "-k-z noexecstack" (with quotes as a single parameter) avoids marking stack as executable, allowing to work correctly with SELinux in Enforcing mode -CFLAGS= -vweh -Un -Ci -Co -XX "-k-z noexecstack" +CFLAGS= -vewnhib -Sch -Un -Ci -Co -XX "-k-z noexecstack" EXTRA_CFLAGS= -O3 @@ -48,7 +48,7 @@ tuxcmd:: echo " ConstFPCCompilerHostProcessorString = '`fpc -iSP`';" >> fpcver.inc echo " ConstFPCTargetOSString = '`fpc -iTO`';" >> fpcver.inc echo " ConstFPCTargetProcessorString = '`fpc -iTP`';" >> fpcver.inc - fpc -Mdelphi $(CFLAGS) $(EXTRA_CFLAGS) \ + fpc -Mobjfpc $(CFLAGS) $(EXTRA_CFLAGS) \ -Fu./bindings -Fu./libgtk_kylix -Fu./translations -Fu./vfs \ tuxcmd.dpr diff --git a/UChecksum.pas b/UChecksum.pas index 8b3dbb7..2dcb3df 100644 --- a/UChecksum.pas +++ b/UChecksum.pas @@ -22,7 +22,7 @@ unit UChecksum; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKText, + lazglib2, lazgobject2, gtk2, pango, SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView, GTKText, UEngines; type @@ -85,7 +85,7 @@ begin CommentOpen := False; Processing := False; Stop := False; - OnDestroy := FormDestroy; + OnDestroy := @FormDestroy; SetDefaultSize(750, 350); Caption := LANGVerifyChecksumsCaption; Buttons := [mbClose]; @@ -119,11 +119,11 @@ begin HPaned.Child2 := CommentTextViewScrolledWindow; ClientArea.AddControlEx(HPaned, True, True, 3); ClientArea.AddControlEx(BottomBox, False, True, 0); - OnKeyDown := FormKeyDown; - OnCloseQuery := FormCloseQuery; - OnResponse := FormResponse; - OnShow := FormShow; - CheckButton.OnClick := CheckButtonClick; + OnKeyDown := @FormKeyDown; + OnCloseQuery := @FormCloseQuery; + OnResponse := @FormResponse; + OnShow := @FormShow; + CheckButton.OnClick := @CheckButtonClick; if CheckButton.Enabled then CheckButton.SetFocus else ActionArea.SetFocus; @@ -136,8 +136,8 @@ begin FileList := TGTKListView.CreateTyped(Self, True, [lcPointer]); FileList.SelectionMode := smSingle; FileList.Tooltip := LANGFileListTooltip; - FileList.CellDataFunc := ListViewCellDataFunc; - FileList.CompareFunc := CompareFunc; + FileList.CellDataFunc := @ListViewCellDataFunc; + FileList.CompareFunc := @CompareFunc; FileList.RulesHint := True; Column := FileList.Columns.Add; Column.Caption := LANGFilenameColumnCaption; @@ -215,7 +215,7 @@ begin end; Exit; end; - if (Stat <> nil) and (Stat.Size > 128*1024) then begin + if (Stat <> nil) and (Stat^.Size > 128*1024) then begin i := integer(Application.MessageBox(Format(LANGTheFileSYouAreTryingToOpenIsQuiteBig, [StrToUTF8(ExtractFileName(FileName))]), [mbYes, mbNo], mbWarning, mbNone, mbNo)); FreeDataItem(Stat); if (i = integer(mbNo)) or (i = 251) then Exit; @@ -282,7 +282,6 @@ var Item: TFileListItem; S1, S2: string; i: integer; Stat: PDataItem; - Error: PGError; begin TrimCRLFESC(s); if Length(s) < 1 then Exit; @@ -325,10 +324,9 @@ begin Item.Name := ExtractFileName(s2); Item.FullPath := IncludeTrailingPathDelimiter(Path) + s2; end; - Error := nil; Stat := Engine.GetFileInfo(Item.FullPath, True, True, nil); if Assigned(Stat) then begin - Item.Size := Stat.Size; + Item.Size := Stat^.Size; FreeDataItem(Stat); end else Item.Size := 0; List.Add(Item); @@ -345,12 +343,12 @@ begin Path := gtk_tree_model_get_path(tree_model, iter); if not Assigned(Path) then Exit; (Sender as TGTKListView).ConvertPathToChild(Path); - Data := List[gtk_tree_path_get_indices(Path)^]; + Data := TFileListItem(List[gtk_tree_path_get_indices(Path)^]); gtk_tree_path_free(Path); case gtk_tree_view_column_get_sort_column_id(tree_column) of - 0: g_object_set(cell, 'text', StrToUTF8(PChar(Format('[%s] %s', [StatusStr[Data.Status], Data.Name]))), nil); - -1: if not Data.IsMD5 then g_object_set(cell, 'text', PChar('0x' + IntToHex(Data.CRC, 8)), nil) - else g_object_set(cell, 'text', PChar(Data.MD5), nil); + 0: g_object_set(PGObject(cell), 'text', [StrToUTF8(PChar(Format('[%s] %s', [StatusStr[Data.Status], Data.Name]))), nil]); + -1: if not Data.IsMD5 then g_object_set(PGObject(cell), 'text', [PChar('0x' + IntToHex(Data.CRC, 8)), nil]) + else g_object_set(PGObject(cell), 'text', [PChar(Data.MD5), nil]); end; end; @@ -361,11 +359,11 @@ begin Result := 0; Path := gtk_tree_model_get_path(model, a); if not Assigned(Path) then Exit; - Data1 := List[gtk_tree_path_get_indices(Path)^]; + Data1 := TFileListItem(List[gtk_tree_path_get_indices(Path)^]); gtk_tree_path_free(Path); Path := gtk_tree_model_get_path(model, b); if not Assigned(Path) then Exit; - Data2 := List[gtk_tree_path_get_indices(Path)^]; + Data2 := TFileListItem(List[gtk_tree_path_get_indices(Path)^]); gtk_tree_path_free(Path); if (Sender as TGTKView).SortColumnID = 0 then Result := CompareTextsEx(PChar(Data1.Name), PChar(Data2.Name)); end; @@ -420,7 +418,7 @@ begin FileList.Items[i].Selected := True; FileList.Items[i].SetCursor(0, False, False, 0, 0); Application.ProcessMessages; - Data := List[i]; + Data := TFileListItem(List[i]); CRC := 0; if Data.IsMD5 then MDInit(MDContext, MD_VERSION_5); Error := nil; diff --git a/UChecksumDruid.pas b/UChecksumDruid.pas index fb62775..90df615 100644 --- a/UChecksumDruid.pas +++ b/UChecksumDruid.pas @@ -22,9 +22,8 @@ unit UChecksumDruid; interface uses - glib2, gdk2, gtk2, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, - GTKView, GTKText, GTKUtils, - UEngines; + lazglib2, gdk2, gtk2, SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, + GTKUtils, UEngines; type TFChecksumDruid = class(TGTKDialog) @@ -76,7 +75,7 @@ var implementation -uses ULocale, UCoreUtils, ULibc, UCore, DateUtils, UConfig, UError, StrUtils, md5, crc; +uses ULocale, UCoreUtils, ULibc, DateUtils, UConfig, UError, md5, crc; procedure TFChecksumDruid.FormCreate(Sender: TObject); @@ -89,8 +88,8 @@ begin BufferPos := 0; SetDefaultSize(400, 210); Caption := LANGCreateChecksumsCaption; - OnDestroy := FormDestroy; - OnResponse := FormResponse; + OnDestroy := @FormDestroy; + OnResponse := @FormResponse; FileNames := TStringList.Create; ShowSeparator := False; Buttons := []; @@ -99,11 +98,11 @@ begin DruidArea.BorderWidth := 2; ClientArea.AddControlEx(DruidArea, True, True, 0); CancelButton := TGTKButton.CreateFromStock(Self, 'gtk-cancel'); - CancelButton.OnClick := CancelButtonClick; + CancelButton.OnClick := @CancelButtonClick; BackButton := TGTKButton.CreateFromStock(Self, 'gtk-go-back'); - BackButton.OnClick := BackButtonClick; + BackButton.OnClick := @BackButtonClick; ForwardButton := TGTKButton.CreateFromStock(Self, 'gtk-go-forward'); - ForwardButton.OnClick := ForwardButtonClick; + ForwardButton.OnClick := @ForwardButtonClick; ButtonBox := TGTKHButtonBox.Create(Self); ButtonBox.Layout := blEnd; ButtonBox.Spacing := 10; @@ -133,7 +132,7 @@ begin CreatePages; SetCurrentPage(1, True); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFChecksumDruid.FormDestroy(Sender: TObject); @@ -198,10 +197,10 @@ begin FileNameEntry := TGTKEntry.Create(Self); FileNameEntry.Text := 'checksums.sfv'; FileNameEntry.SetSizeRequest(215, -1); - FileNameEntry.OnChanged := FileNameEntryChanged; + FileNameEntry.OnChanged := @FileNameEntryChanged; FilenameLabel.FocusControl := FileNameEntry; SeparateFileCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGCCHKSUMCreateSeparateChecksumFiles); - SeparateFileCheckBox.OnToggled := SeparateFileCheckBoxToggled; + SeparateFileCheckBox.OnToggled := @SeparateFileCheckBoxToggled; Page3ClientArea.BorderWidth := 30; FileNameHBox := TGTKHBox.Create(Self); FileNameHBox.Homogeneous := False; @@ -448,7 +447,7 @@ begin for i := 0 to FileNames.Count - 1 do begin Stat := Engine.GetFileInfo(FileNames[i], True, True, nil); if Assigned(Stat) then begin - Inc(MaxSize, Stat.Size); + Inc(MaxSize, Stat^.Size); FreeDataItem(Stat); end; end; @@ -464,6 +463,7 @@ begin Stat := Engine.GetFileInfo(FileNames[i], True, True, nil); Application.ProcessMessages; try + s := ''; if ProcessFile(FileNames[i], SFVRadioButton.Checked, s) then begin if not SeparateFileCheckBox.Checked then s2 := ProcessPattern(Engine, StrToUTF8(FileNameEntry.Text), IncludeTrailingPathDelimiter(ExtractFilePath(FileNames[0])), '', False) @@ -473,7 +473,7 @@ begin end; except end; if Assigned(Stat) then begin - Progress.Value := LastValue + Stat.Size; + Progress.Value := LastValue + Stat^.Size; FreeDataItem(Stat); end; Progress.Text := Format('%d %%', [Trunc(Progress.Fraction * 100)]); @@ -494,7 +494,7 @@ function TFChecksumDruid.ProcessFile(const FName: string; const IsItSFV: boolean const ChksumBlockSize = 65536*4; var FD: TEngineFileDes; Count: integer; - Buffer: Pointer; + FBuffer: Pointer; CRC: LongWord; MDContext: TMDContext; MDDigest: TMDDigest; @@ -503,8 +503,8 @@ begin HashString := ''; Result := False; try - Buffer := malloc(ChksumBlockSize); - memset(Buffer, 0, ChksumBlockSize); + FBuffer := malloc(ChksumBlockSize); + memset(FBuffer, 0, ChksumBlockSize); except ErrorLabel.Caption := ErrorLabel.Caption + LANGAnErrorOccuredWhileInitializingMemoryBlock + #10; Exit; @@ -522,22 +522,22 @@ begin Exit; end; repeat - Count := Engine.ReadFile(FD, Buffer, ChksumBlockSize, @Error); + Count := Engine.ReadFile(FD, FBuffer, ChksumBlockSize, @Error); if Error <> nil then begin ErrorLabel.Caption := ErrorLabel.Caption + Format(LANGCCHKSUMAnErrorOccuredWhileReadingFileSS, [StrToUTF8(ExtractFileName(FName)), Error^.message]); g_error_free(Error); Engine.CloseFile(FD, nil); Exit; end; - if IsItSFV then CRC := CRC32(CRC, Buffer, Count) - else MDUpdate(MDContext, Buffer^, Count); + if IsItSFV then CRC := CRC32(CRC, FBuffer, Count) + else MDUpdate(MDContext, FBuffer^, Count); Progress.Value := Progress.Value + Count; Progress.Text := Format('%d %%', [Trunc(Progress.Fraction * 100)]); Application.ProcessMessages; CheckStop; until (Count < ChksumBlockSize) or Stop; Engine.CloseFile(FD, nil); - libc_free(Buffer); + libc_free(FBuffer); if IsItSFV then HashString := IntToHex(CRC, 8) else begin diff --git a/UChmod.pas b/UChmod.pas index 7601e08..d4d43ba 100644 --- a/UChmod.pas +++ b/UChmod.pas @@ -22,7 +22,7 @@ unit UChmod; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKMenus; + SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKMenus; type TFChmod = class(TGTKDialog) @@ -75,7 +75,7 @@ begin HBox2.Homogeneous := False; HBox2.BorderWidth := 5; RecursiveCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_ApplyRecursivelyFor); - RecursiveCheckButton.OnToggled := RecursiveCheckButtonToggled; + RecursiveCheckButton.OnToggled := @RecursiveCheckButtonToggled; RecursiveOptionMenu := TGTKOptionMenu.Create(Self); miAllFiles := TGTKMenuItem.Create(Self); miAllFiles.Caption := LANGFChmod_miAllFiles; @@ -127,37 +127,37 @@ begin VBox := TGTKVBox.Create(Self); VBox.BorderWidth := 5; cbSUID := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_SUID); - VBox.AddControlEx(cbSUID, False, False, 0); cbSUID.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbSUID, False, False, 0); cbSUID.OnToggled := @PermissionsCheckBoxToggle; cbSGID := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_SGID); - VBox.AddControlEx(cbSGID, False, False, 0); cbSGID.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbSGID, False, False, 0); cbSGID.OnToggled := @PermissionsCheckBoxToggle; cbSticky := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_Sticky); - VBox.AddControlEx(cbSticky, False, False, 0); cbSticky.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbSticky, False, False, 0); cbSticky.OnToggled := @PermissionsCheckBoxToggle; VBox.AddControlEx(TGTKHSeparator.Create(Self), False, False, 2); cbUSRRead := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_RUSR); - VBox.AddControlEx(cbUSRRead, False, False, 0); cbUSRRead.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbUSRRead, False, False, 0); cbUSRRead.OnToggled := @PermissionsCheckBoxToggle; cbUSRWrite := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_WUSR); - VBox.AddControlEx(cbUSRWrite, False, False, 0); cbUSRWrite.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbUSRWrite, False, False, 0); cbUSRWrite.OnToggled := @PermissionsCheckBoxToggle; cbUSRExec := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_XUSR); - VBox.AddControlEx(cbUSRExec, False, False, 0); cbUSRExec.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbUSRExec, False, False, 0); cbUSRExec.OnToggled := @PermissionsCheckBoxToggle; VBox.AddControlEx(TGTKHSeparator.Create(Self), False, False, 2); cbGRPRead := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_RGRP); - VBox.AddControlEx(cbGRPRead, False, False, 0); cbGRPRead.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbGRPRead, False, False, 0); cbGRPRead.OnToggled := @PermissionsCheckBoxToggle; cbGRPWrite := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_WGRP); - VBox.AddControlEx(cbGRPWrite, False, False, 0); cbGRPWrite.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbGRPWrite, False, False, 0); cbGRPWrite.OnToggled := @PermissionsCheckBoxToggle; cbGRPExec := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_XGRP); - VBox.AddControlEx(cbGRPExec, False, False, 0); cbGRPExec.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbGRPExec, False, False, 0); cbGRPExec.OnToggled := @PermissionsCheckBoxToggle; VBox.AddControlEx(TGTKHSeparator.Create(Self), False, False, 2); cbALLRead := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_ROTH); - VBox.AddControlEx(cbALLRead, False, False, 0); cbALLRead.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbALLRead, False, False, 0); cbALLRead.OnToggled := @PermissionsCheckBoxToggle; cbALLWrite := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_WOTH); - VBox.AddControlEx(cbALLWrite, False, False, 0); cbALLWrite.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbALLWrite, False, False, 0); cbALLWrite.OnToggled := @PermissionsCheckBoxToggle; cbALLExec := TGTKCheckButton.CreateWithLabel(Self, LANGFChmod_XOTH); - VBox.AddControlEx(cbALLExec, False, False, 0); cbALLExec.OnToggled := PermissionsCheckBoxToggle; + VBox.AddControlEx(cbALLExec, False, False, 0); cbALLExec.OnToggled := @PermissionsCheckBoxToggle; PermissionFrame.AddControl(VBox); Busy := False; - OnKeyDown := FormKeyDown; - OctalEntry.OnChanged := OctalEntryChanged; + OnKeyDown := @FormKeyDown; + OctalEntry.OnChanged := @OctalEntryChanged; RecursiveCheckButtonToggled(Self); end; diff --git a/UChown.pas b/UChown.pas index 5e09809..0e95c44 100644 --- a/UChown.pas +++ b/UChown.pas @@ -116,7 +116,7 @@ begin GroupFrame.AddControl(GroupListViewScrolledWindow); FillData; - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFChown.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); @@ -156,8 +156,8 @@ begin FileLabel.Caption := Format(LANGFChmod_FileLabel, [StrToUTF8(FileName), AttrToStr(Mode), AttrToOctal(Mode), susr, sgrp]); FileLabel.UseMarkup := True; if Length(FileName) > 20 then FileLabel.SetSizeRequest(200, -1); - OwnerListView.OnSelectionChanged := OwnerListViewSelectionChanged; - GroupListView.OnSelectionChanged := GroupListViewSelectionChanged; + OwnerListView.OnSelectionChanged := @OwnerListViewSelectionChanged; + GroupListView.OnSelectionChanged := @GroupListViewSelectionChanged; end; procedure TFChown.FillData; diff --git a/UColumns.pas b/UColumns.pas index d59b990..773b399 100644 --- a/UColumns.pas +++ b/UColumns.pas @@ -22,8 +22,7 @@ unit UColumns; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, + gdk2, gtk2, SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKView, GTKPixbuf, UCoreClasses; type @@ -52,7 +51,7 @@ var implementation -uses ULocale, UCoreUtils, UConfig, UCore; +uses ULocale, UConfig; procedure TFColumns.FormCreate(Sender: TObject); @@ -106,7 +105,7 @@ begin Column.Resizable := False; Column.FixedWidth := 20; Column.SizingMode := smFixed; - Column.OnToggled := ListViewColumnToggled; + Column.OnToggled := @ListViewColumnToggled; Column := ListView.Columns.Add; Column.AddAttribute('text', 1); Column.Resizable := False; @@ -134,9 +133,9 @@ begin AddColumnItems; - ListView.OnSelectionChanged := ListViewSelectionChanged; - MoveUpButton.OnClick := MoveUpDownButtonButtonClick; - MoveDownButton.OnClick := MoveUpDownButtonButtonClick; + ListView.OnSelectionChanged := @ListViewSelectionChanged; + MoveUpButton.OnClick := @MoveUpDownButtonButtonClick; + MoveDownButton.OnClick := @MoveUpDownButtonButtonClick; ListView.SetFocus; end; @@ -194,13 +193,11 @@ end; procedure TFColumns.ApplyColumnList; var i, j: integer; TempIDs, TempArrayI: array[1..ConstNumPanelColumns] of integer; - TempArrayB: array[1..ConstNumPanelColumns] of boolean; begin // Copy the old items for i := 1 to ConstNumPanelColumns do begin TempIDs[i] := ConfColumnIDs[i]; TempArrayI[i] := ConfColumnSizes[i]; - TempArrayB[i] := ConfColumnVisible[i]; end; // Search for moved columns diff --git a/UConfig.pas b/UConfig.pas index e34d7dd..ed62068 100644 --- a/UConfig.pas +++ b/UConfig.pas @@ -28,9 +28,7 @@ resourcestring ConstAboutVersion = '0.6.83-dev'; ConstAboutBuildDate = '2024-10-25'; -{$IFDEF FPC} - {$INCLUDE fpcver.inc} -{$ENDIF} +{$INCLUDE fpcver.inc} const ConfDefaultNormalItemFGColor = '#000000'; ConfDefaultActiveItemFGColor = '#FFFFFF'; diff --git a/UConnectionManager.pas b/UConnectionManager.pas index a9cbbfb..bf9e67f 100644 --- a/UConnectionManager.pas +++ b/UConnectionManager.pas @@ -22,8 +22,8 @@ unit UConnectionManager; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, + lazglib2, gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, + GTKPixbuf, GTKMenus, UCore, UCoreWorkers, UCoreClasses, UVFSCore, UEngines; type @@ -66,7 +66,7 @@ type Thread: TOpenConnectionThread; SourcePanelEngine: TPanelEngine; ConnectedEngine: TVFSEngine; - function DoConnectInternal(const URI: string; Engine: TVFSEngine; ParentForm: TCustomGTKForm; VFSQuickConnectMode: boolean; Error: PPGError): boolean; + function DoConnectInternal(const URI: string; Engine: TVFSEngine; AParentForm: TCustomGTKForm; VFSQuickConnectMode: boolean; Error: PPGError): boolean; end; var @@ -133,7 +133,7 @@ begin ListView := TGTKListView.CreateTyped(Self, True, [lcPointer, lcText, lcText]); ListView.SelectionMode := smSingle; - ListView.OnKeyDown := ListViewKeyDown; + ListView.OnKeyDown := @ListViewKeyDown; { gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(ListView.FWidget), GDK_BUTTON1_MASK, @row_targets, 1, GDK_ACTION_MOVE); @@ -215,21 +215,21 @@ begin ConnectMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText); ConnectMenuItem.Caption := LANGConnMgr_ConnectButton; ConnectMenuItem.StockIcon := 'gtk-connect'; - ConnectMenuItem.OnClick := ConnectButtonClick; + ConnectMenuItem.OnClick := @ConnectButtonClick; AddConnectionMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText); AddConnectionMenuItem.Caption := LANGConnMgr_AddConnectionButtonCaption; AddConnectionMenuItem.StockIcon := 'gtk-add'; - AddConnectionMenuItem.OnClick := AddConnectionButtonClick; + AddConnectionMenuItem.OnClick := @AddConnectionButtonClick; EditMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText); EditMenuItem.Caption := LANGConnMgr_EditButtonCaption; - EditMenuItem.OnClick := EditButtonClick; + EditMenuItem.OnClick := @EditButtonClick; RemoveMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText); RemoveMenuItem.Caption := LANGConnMgr_RemoveButtonCaption; RemoveMenuItem.StockIcon := 'gtk-remove'; - RemoveMenuItem.OnClick := RemoveButtonClick; + RemoveMenuItem.OnClick := @RemoveButtonClick; DuplicateMenuItem := TGTKMenuItem.CreateTyped(Self, itImageText); DuplicateMenuItem.Caption := LANGFConnectionManager_DuplicateMenuItem_Caption; - DuplicateMenuItem.OnClick := DuplicateButtonClick; + DuplicateMenuItem.OnClick := @DuplicateButtonClick; ItemsPopupMenu.Add(ConnectMenuItem); ItemsPopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); ItemsPopupMenu.Add(AddConnectionMenuItem); @@ -238,8 +238,8 @@ begin ItemsPopupMenu.Add(RemoveMenuItem); FillList; - ListView.OnSelectionChanged := ListViewSelectionChanged; - ListView.OnDblClick := ListViewDblClick; + ListView.OnSelectionChanged := @ListViewSelectionChanged; + ListView.OnDblClick := @ListViewDblClick; ListView.PopupMenu := ItemsPopupMenu; ListView.SetFocus; if (ListView.Items.Count > 0) and (ConfConnMgrActiveItem >= 0) and (ConfConnMgrActiveItem < ListView.Items.Count) then begin @@ -247,17 +247,17 @@ begin ListView.Items[ConfConnMgrActiveItem].SetCursor(0, False, False, 0, 0); end; ListViewSelectionChanged(Self); - AddConnectionButton.OnClick := AddConnectionButtonClick; - EditButton.OnClick := EditButtonClick; - DuplicateButton.OnClick := DuplicateButtonClick; - RemoveButton.OnClick := RemoveButtonClick; - CloseButton.OnClick := CloseButtonClick; - ConnectButton.OnClick := ConnectButtonClick; - StopButton.OnClick := StopButtonClick; - QuickConnectButton.OnClick := QuickConnectButtonClick; - OnKeyDown := FormKeyDown; - OnClose := FormClose; - OnResponse := FormResponse; + AddConnectionButton.OnClick := @AddConnectionButtonClick; + EditButton.OnClick := @EditButtonClick; + DuplicateButton.OnClick := @DuplicateButtonClick; + RemoveButton.OnClick := @RemoveButtonClick; + CloseButton.OnClick := @CloseButtonClick; + ConnectButton.OnClick := @ConnectButtonClick; + StopButton.OnClick := @StopButtonClick; + QuickConnectButton.OnClick := @QuickConnectButtonClick; + OnKeyDown := @FormKeyDown; + OnClose := @FormClose; + OnResponse := @FormResponse; end; procedure TFConnectionManager.ListViewSelectionChanged(Sender: TObject); @@ -360,7 +360,7 @@ begin try Item := ListView.Selected; if Item = nil then Exit; - ConnMgrItem := Item.AsPointer(0); + ConnMgrItem := TConnMgrItem(Item.AsPointer(0)); if ConnMgrItem = nil then Exit; FConnectionProperties := TFConnectionProperties.Create(Self); FConnectionProperties.NameEntry.Text := ConnMgrItem.ConnectionName; @@ -402,7 +402,7 @@ begin try Item := ListView.Selected; if Item = nil then Exit; - ConnMgrItem := Item.AsPointer(0); + ConnMgrItem := TConnMgrItem(Item.AsPointer(0)); if ConnMgrItem = nil then Exit; FConnectionProperties := TFConnectionProperties.Create(Self); FConnectionProperties.NameEntry.Text := ''; @@ -449,7 +449,7 @@ var Item: TGTKListItem; begin Item := ListView.Selected; if Item = nil then Exit; - ConnMgrItem := Item.AsPointer(0); + ConnMgrItem := TConnMgrItem(Item.AsPointer(0)); if ConnMgrItem = nil then Exit; if Application.MessageBox(PGtkWindow(FWidget), Format(LANGConnMgr_DoYouWantDelete, [Item.AsString(1)]), [mbYes, mbNo], mbQuestion, mbYes, mbNo) = mbYes then @@ -457,7 +457,7 @@ begin OldIndex := ListView.ConvertToSorted(Item.Index); if ConnectionMgrList.Count > 0 then for i := 0 to ConnectionMgrList.Count - 1 do - if ConnectionMgrList[i] = ConnMgrItem then begin + if TConnMgrItem(ConnectionMgrList[i]) = ConnMgrItem then begin ConnectionMgrList.Delete(i); Break; end; @@ -483,7 +483,7 @@ var i: integer; begin if ConnectionMgrList.Count > 0 then for i := 0 to ConnectionMgrList.Count - 1 do begin - ConnMgrItem := ConnectionMgrList[i]; + ConnMgrItem := TConnMgrItem(ConnectionMgrList[i]); Item := ListView.Items.Add; Item.SetValue(0, ConnMgrItem); Item.SetValue(1, ConnMgrItem.ConnectionName); @@ -542,7 +542,7 @@ var Engine: TVFSEngine; Error: PGError; begin FActiveConnInfo := nil; - if ListView.Selected <> nil then FActiveConnInfo := ListView.Selected.AsPointer(0); + if ListView.Selected <> nil then FActiveConnInfo := TConnMgrItem(ListView.Selected.AsPointer(0)); if FActiveConnInfo = nil then Exit; if PluginList.Count = 0 then begin @@ -555,7 +555,7 @@ begin if Length(FActiveConnInfo.PluginID) > 0 then for i := 0 to PluginList.Count - 1 do if TVFSPlugin(PluginList[i]).ModuleID = FActiveConnInfo.PluginID then begin - VFSPlugin := PluginList[i]; + VFSPlugin := TVFSPlugin(PluginList[i]); Break; end; if VFSPlugin = nil then begin @@ -563,12 +563,12 @@ begin if Length(TVFSPlugin(PluginList[i]).Services) > 0 then for j := 0 to Length(TVFSPlugin(PluginList[i]).Services) - 1 do if WideCompareText(TVFSPlugin(PluginList[i]).Services[j], FActiveConnInfo.ServiceType) = 0 then begin - VFSPlugin := PluginList[i]; + VFSPlugin := TVFSPlugin(PluginList[i]); Break; end; if VFSPlugin <> nil then Break; end; - if VFSPlugin = nil then VFSPlugin := PluginList[0]; // Fallback in hope some other plugin can handle it + if VFSPlugin = nil then VFSPlugin := TVFSPlugin(PluginList[0]); // Fallback in hope some other plugin can handle it end; if (SourcePanelEngine is TVFSEngine) and ConfReplaceConnectionWarning then begin @@ -624,15 +624,15 @@ begin ModalResult := mbOK; end; -function TFConnectionManager.DoConnectInternal(const URI: string; Engine: TVFSEngine; ParentForm: TCustomGTKForm; VFSQuickConnectMode: boolean; Error: PPGError): boolean; +function TFConnectionManager.DoConnectInternal(const URI: string; Engine: TVFSEngine; AParentForm: TCustomGTKForm; VFSQuickConnectMode: boolean; Error: PPGError): boolean; begin Result := False; FSilenceError := False; Thread := TOpenConnectionThread.Create; try - Thread.VFSConnectionManagerMode := ParentForm = Self; + Thread.VFSConnectionManagerMode := AParentForm = Self; Thread.VFSQuickConnectMode := VFSQuickConnectMode; - Thread.DialogsParentWindow := ParentForm; + Thread.DialogsParentWindow := AParentForm; Thread.AEngine := Engine; Thread.URI := URI; Thread.Resume; diff --git a/UConnectionProperties.pas b/UConnectionProperties.pas index 7b9ef1b..a7dd921 100644 --- a/UConnectionProperties.pas +++ b/UConnectionProperties.pas @@ -22,7 +22,7 @@ unit UConnectionProperties; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKMenus; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKMenus; type TFConnectionProperties = class(TGTKDialog) @@ -207,15 +207,15 @@ begin Lock := True; - OnKeyDown := FormKeyDown; - NameEntry.OnChanged := NameEntryChanged; - URIEntry.OnChanged := URIEntryChanged; - ServiceTypeOptionMenu.OnChanged := ServiceTypeOptionMenuChanged; - ServerEntry.OnChanged := ServiceTypeOptionMenuChanged; - UserNameEntry.OnChanged := ServiceTypeOptionMenuChanged; - PasswordEntry.OnChanged := ServiceTypeOptionMenuChanged; - TargetDirEntry.OnChanged := ServiceTypeOptionMenuChanged; - MaskPasswordCheckButton.OnToggled := MaskPasswordCheckButtonToggled; + OnKeyDown := @FormKeyDown; + NameEntry.OnChanged := @NameEntryChanged; + URIEntry.OnChanged := @URIEntryChanged; + ServiceTypeOptionMenu.OnChanged := @ServiceTypeOptionMenuChanged; + ServerEntry.OnChanged := @ServiceTypeOptionMenuChanged; + UserNameEntry.OnChanged := @ServiceTypeOptionMenuChanged; + PasswordEntry.OnChanged := @ServiceTypeOptionMenuChanged; + TargetDirEntry.OnChanged := @ServiceTypeOptionMenuChanged; + MaskPasswordCheckButton.OnToggled := @MaskPasswordCheckButtonToggled; NameEntry.SetFocus; @@ -310,7 +310,7 @@ begin CurrentURI := MakeURI(False); URIEntry.OnChanged := nil; URIEntry.Text := MakeURI(MaskPasswordCheckButton.Checked); - URIEntry.OnChanged := URIEntryChanged; + URIEntry.OnChanged := @URIEntryChanged; NameEntryChanged(Sender); end; diff --git a/UCopyMove.pas b/UCopyMove.pas index 2848068..0bbbcf2 100644 --- a/UCopyMove.pas +++ b/UCopyMove.pas @@ -22,7 +22,7 @@ unit UCopyMove; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; type TFCopyMove = class(TGTKDialog) @@ -61,7 +61,7 @@ begin Box.AddControlEx(Entry, False, False, 0); Box.BorderWidth := 8; ClientArea.AddControlEx(Box, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; Entry.SetFocus; end; diff --git a/UCore.pas b/UCore.pas index ea13f18..5ff1e0a 100644 --- a/UCore.pas +++ b/UCore.pas @@ -20,7 +20,7 @@ unit UCore; interface -uses glib2, Classes, GTKForms, GTKView, ULibc, UEngines, UCoreUtils, UVFSCore; +uses lazglib2, Classes, GTKForms, GTKView, ULibc, UEngines, UCoreUtils, UVFSCore; // Panel utilities @@ -59,10 +59,10 @@ type TGetDirSizeThread = class(TThread) private FCancelled: boolean; + FFinished: boolean; protected procedure Execute; override; public - Finished: boolean; Engine: TPanelEngine; Path: string; Result: Int64; @@ -739,7 +739,7 @@ end; procedure TGetDirSizeThread.Execute; begin Result := Engine.GetDirSize(Path); - Finished := True; + FFinished := True; end; constructor TGetDirSizeThread.Create; @@ -747,7 +747,7 @@ begin inherited Create(True); FreeOnTerminate := False; FCancelled := False; - Finished := False; + FFinished := False; Result := -1; end; @@ -788,7 +788,7 @@ var t: time_t; Thread.Engine := Engine; Thread.Resume; // Thread.Execute; - while not Thread.Finished do begin + while not Thread.FFinished do begin Sleep(ConstInternalProgressTimer); if not b and (__time(nil) >= t + 2) then begin FRemoteWait := TFRemoteWait.Create(Application); @@ -1119,7 +1119,7 @@ begin StatBuf := malloc(sizeof(Tstat64)); memset(StatBuf, 0, sizeof(Tstat64)); if lstat64(PChar(APath + string(Buf)), StatBuf) = 0 then - if __S_ISTYPE(StatBuf.st_mode, __S_IFDIR) + if __S_ISTYPE(StatBuf^.st_mode, __S_IFDIR) then PurgeDirectory(APath + string(Buf)) else begin // DebugMsg(['Removing ', APath + string(Buf)]); diff --git a/UCoreClasses.pas b/UCoreClasses.pas index 0c2a605..f4b8579 100644 --- a/UCoreClasses.pas +++ b/UCoreClasses.pas @@ -21,8 +21,7 @@ unit UCoreClasses; interface -uses gdk2pixbuf, gtk2, gdk2, glib2, SysUtils, Classes, ULibc, IniFiles, GTKClasses, GTKStdCtrls, GTKDialogs, GTKPixbuf, UGnome, - UEngines; +uses gtk2, lazglib2, lazgobject2, SysUtils, Classes, ULibc, IniFiles, GTKStdCtrls, GTKPixbuf; type TSystemUser = class public @@ -52,7 +51,7 @@ type TSystemUser = class private FReadOnly: boolean; public - constructor Create(const FileName: string; const ReadOnly: boolean); + constructor Create(const AFileName: string; ReadOnly: boolean); override; procedure UpdateFile; override; end; @@ -96,7 +95,7 @@ type TSystemUser = class implementation -uses GTKForms, GTKUtils, ULocale, UConfig, UCore, UCoreUtils; +uses GTKForms, ULocale, UCoreUtils; @@ -204,10 +203,10 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) -constructor TMyIniFile.Create(const FileName: string; const ReadOnly: boolean); +constructor TMyIniFile.Create(const AFileName: string; ReadOnly: boolean); begin FReadOnly := ReadOnly; - inherited Create(FileName); + inherited Create(AFileName); end; procedure TMyIniFile.UpdateFile; @@ -231,7 +230,7 @@ begin gtk_box_pack_start(PGtkBox(FHBox), FLabel, True, True, 0); gtk_box_pack_start(PGtkBox(FHBox), FEventBoxRight, False, False, 0); gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); gtk_widget_show(FLabel); gtk_widget_show(FImage); gtk_widget_show(FHBox); @@ -253,7 +252,7 @@ begin gtk_box_pack_start(PGtkBox(FHBox), FImage, False, False, 0); gtk_box_pack_start(PGtkBox(FHBox), FEventBoxRight, False, False, 0); gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); gtk_widget_show(FLabel); gtk_widget_show(FImage); gtk_widget_show(FHBox); @@ -302,7 +301,7 @@ begin gtk_box_pack_start(PGtkBox(FHBox), FImage, False, False, 0); gtk_box_pack_start(PGtkBox(FHBox), FLabel, True, True, 0); gtk_container_add(PGtkContainer(FWidget), FHBox); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); gtk_widget_show(FLabel); gtk_widget_show(FImage); gtk_widget_show(FHBox); @@ -316,7 +315,7 @@ begin FLabel := gtk_label_new(''); FImage := gtk_image_new; gtk_container_add(PGtkContainer(FWidget), FImage); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); gtk_widget_show(FLabel); gtk_widget_show(FImage); Show; diff --git a/UCoreUtils.pas b/UCoreUtils.pas index b0ea388..c204d4e 100644 --- a/UCoreUtils.pas +++ b/UCoreUtils.pas @@ -21,7 +21,7 @@ unit UCoreUtils; interface -uses gtk2, gdk2, glib2, SysUtils, Classes, ULibc, GTKClasses, UEngines; +uses gtk2, gdk2, glib2, lazglib2, SysUtils, Classes, ULibc, GTKClasses, UEngines; type PIntArray = ^TIntArray; @@ -35,7 +35,7 @@ const ConstERRSpawn = 26; ConstURIIllegalCharacters = '%:@/'; function FormatSize(Value: Int64; Base: integer; OverrideSizeFormat: integer = -1): string; -function FormatDate(Value: time_t; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; +function FormatDate(Value: time_t; const DoFormatTime, DoFormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; function StripDate(Value: time_t): time_t; function IncludeLeadingDot(s: string): string; @@ -117,6 +117,7 @@ function EnsureUTF8String(s: PChar): PChar; overload; function Min(Val1, Val2: longint): longint; function XORStr(const s: string; Key: byte): string; +function CLAMP(x, MinX, MaxX: integer): integer; function FindCommonRoot(BasePath, DestPath: string): string; function BuildRelativePath(BasePath, DestPath: string): string; @@ -164,7 +165,7 @@ begin if f < 0 then f := ConfSizeFormat; case f of 0 : begin // System default formatting - p := g_strdup_printf('%''llu', Int64(Value div Base)); + p := g_strdup_printf('%''llu', [Int64(Value div Base)]); if p = nil then begin DebugMsg(['FormatSize(0): sprintf() failed, using old format function.']); Result := FormatFloat('###,###,##0', Value div Base); @@ -188,16 +189,16 @@ begin 5 : begin // 123kB - Grouped if (Value >= 1024*1024*1024) or (Base = 1024*1024*1024) then begin x := Value / (1024*1024*1024); - p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f GB'), x); + p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f GB'), [x]); end else if (Value >= 1024*1024) or (Base = 1024*1024) then begin x := Value / (1024*1024); - p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f MB'), x); + p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f MB'), [x]); end else if (Value >= 1024) or (Base = 1024) then begin x := Value / 1024; - p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f kB'), x); - end else p := g_strdup_printf('%d', Value); + p := g_strdup_printf(PChar('%''.' + IntToStr(ConfSizeGroupPrecision) + 'f kB'), [x]); + end else p := g_strdup_printf('%d', [Value]); if p = nil then begin DebugMsg(['FormatSize(5): g_strdup_printf() failed, using old format function.']); s := '###,###,##0'; @@ -227,7 +228,7 @@ begin end; (********************************************************************************************************************************) -function FormatDate(Value: time_t; const FormatTime, FormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; +function FormatDate(Value: time_t; const DoFormatTime, DoFormatDate: boolean; OverrideTimeFormat: integer = -1; OverrideDateFormat: integer = -1; OverrideDateTimeFormat: integer = -1; OverrideCustomDateFormat: string = ''; OverrideCustomTimeFormat: string = ''): string; var DateString, TimeString: string; DateFormat, TimeFormat: string; CustDateFormat, CustTimeFormat: string; @@ -254,7 +255,7 @@ begin time_tm := localtime(@Value); - if FormatDate then begin + if DoFormatDate then begin case df of 0: DateFormat := '%x'; // System format 1: DateFormat := '%Y-%m-%d'; // 2008-06-24 @@ -281,7 +282,7 @@ begin libc_free(Buf); end; - if FormatTime then begin + if DoFormatTime then begin case tf of 0: TimeFormat := '%X'; // System format 1: TimeFormat := '%I:%M %P'; // 01:11 pm @@ -304,15 +305,15 @@ begin TimeString := String(StrToUTF8(Buf)); libc_free(Buf); end; - - if FormatDate and FormatTime then begin + + if DoFormatDate and DoFormatTime then begin case dtf of 0: Result := Format('%s %s', [DateString, TimeString]); else Result := Format('%s %s', [TimeString, DateString]); end; end else - if FormatTime then Result := TimeString else - if FormatDate then Result := DateString; + if DoFormatTime then Result := TimeString else + if DoFormatDate then Result := DateString; end; function StripDate(Value: time_t): time_t; @@ -400,13 +401,13 @@ end; (********************************************************************************************************************************) function GetHomePath: string; begin - Result := PgcharToString(g_get_home_dir); + Result := String(g_get_home_dir); end; (********************************************************************************************************************************) function GetUserName: string; begin - Result := PgcharToString(g_get_user_name); + Result := String(g_get_user_name); end; (********************************************************************************************************************************) @@ -416,7 +417,7 @@ begin s := malloc(65536); memset(s, 0, 65536); ULibc.gethostname(s, 65536); - Result := PgcharToString(strdup(s)); + Result := String(strdup(s)); libc_free(s); end; @@ -820,7 +821,7 @@ const Authors : array[0..1] of PChar = ('Tomáš Bžatek - Korean'; var AboutBox: PGtkWidget; begin - if (libGnomeUI2Handle = nil) or (@gnome_about_new = nil) + if (libGnomeUI2Handle = nil) or (gnome_about_new = nil) then Application.MessageBox(Format(LANGAboutString, [ConstAboutVersion, ConstAboutBuildDate])) else begin AboutBox := gnome_about_new('Tux Commander', nil, 'Copyright © 2002-2024 Tomáš Bžatek', @@ -841,7 +842,7 @@ begin List := g_list_append(List, AppIcon48.FPixbuf); List := g_list_append(List, AppIcon64.FPixbuf); List := g_list_append(List, AppIcon128.FPixbuf); - gtk_window_set_default_icon_list(List); + gtk_window_set_default_icon_list(GLIB2.PGList(List)); g_list_free(List); end; @@ -1124,9 +1125,9 @@ begin case VType of vtPointer: begin {$IFDEF CPU64} - P := g_strdup_printf('%.16p', VPointer); + P := g_strdup_printf('%.16p', [VPointer]); {$ELSE} - P := g_strdup_printf('%.8p', VPointer); + P := g_strdup_printf('%.8p', [VPointer]); {$ENDIF} Write(ErrOutput, P); g_free(P); @@ -1143,9 +1144,7 @@ begin vtCurrency: Write(ErrOutput, CurrToStr(VCurrency^)); vtVariant: Write(ErrOutput, string(VVariant^)); vtInt64: Write(ErrOutput, IntToStr(VInt64^)); -{$IFDEF FPC} vtQWord: Write(ErrOutput, IntToStr(VQWord^)); -{$ENDIF} end; WriteLn(ErrOutput); end; @@ -1603,11 +1602,9 @@ begin DebugMsg(['*** StrToUTF8: error converting "', s, '" to UTF-8 (read ', bytes_read, ', written ', bytes_written, '): ', m]); g_error_free(error); end; - if @g_filename_display_name <> nil then begin - nss := g_filename_display_name(ns); - Result := strdup(nss); // PPC compatibility - g_free(nss); - end else Result := strdup(ns); // PPC compatibility + nss := g_filename_display_name(ns); + Result := strdup(nss); // PPC compatibility + g_free(nss); g_free(ns); end; @@ -1629,8 +1626,7 @@ end; function EnsureUTF8String(s: PChar): PChar; begin - Result := s; - if @g_filename_display_name <> nil then Result := g_filename_display_name(s); + Result := g_filename_display_name(s); end; @@ -1847,17 +1843,24 @@ end; (********************************************************************************************************************************) +function CLAMP(x, MinX, MaxX: integer): integer; +begin + if xMaxX then + Result:=MaxX + else + Result:=x; +end; initialization -{$IFDEF FPC} // Set path separators only to a standard Unix slash -- otherwise all path functions will treat ending backslash as a delimiter, // causing problems with directory names ending with a backslash (it's a valid character in Unix). // Kylix behaves fine, only forward slash is honored. AllowDirectorySeparators := ['/']; -{$ENDIF} InternalLockInit(True); SetupSignals; diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas index c6a8d28..307e695 100644 --- a/UCoreWorkers.pas +++ b/UCoreWorkers.pas @@ -20,7 +20,7 @@ unit UCoreWorkers; interface -uses glib2, gtk2, SyncObjs, Classes, GTKForms, ULibc, UEngines, UCoreUtils, UVFSCore, uVFSprototypes, UCore, UDirDelete; +uses lazglib2, lazgobject2, gtk2, SyncObjs, Classes, GTKForms, ULibc, UEngines, UCoreUtils, UVFSCore, uVFSprototypes, UCore, UDirDelete; type TWorkerThreadJobType = (WORKER_JOB_DUMMY, WORKER_JOB_DELETE, WORKER_JOB_COPY, WORKER_JOB_MOVE, WORKER_JOB_EXTRACT_TO_TEMP, @@ -28,7 +28,7 @@ type TWorkerThreadJobType = (WORKER_JOB_DUMMY, WORKER_JOB_DELETE, WORKER_JOB_COP type TVFSCallbackThread = class(TThread) private - FThreadID: __pthread_t; + FPThreadID: __pthread_t; FFinished: boolean; VFSCallbackEvent: TSimpleEvent; @@ -216,8 +216,7 @@ procedure ProcessThreadEvents(SenderThread: TVFSCallbackThread); implementation uses SysUtils, DateUtils, StrUtils, UConfig, UOverwrite, ULocale, - UCoreClasses, URemoteWait, UMain, UGnome, UNewDir, UProgress, - UError, crc; + URemoteWait, UMain, UGnome, UNewDir, UProgress, UError, crc; @@ -245,7 +244,7 @@ end; procedure TVFSCallbackThread.PrepareExecute; begin - FThreadID := pthread_self; + FPThreadID := pthread_self; VFSCallbackCancelled := False; end; @@ -253,7 +252,7 @@ end; procedure vfs_ask_question_callback(const AMessage: PChar; const Choices: PPChar; choice: PInteger; cancel_choice: Integer; user_data: Pointer); cdecl; var Thread: TVFSCallbackThread; begin - Thread := user_data; + Thread := TVFSCallbackThread(user_data); if (Thread = nil) { or (not (Thread is TVFSCallbackThread))} then begin DebugMsg(['(ERROR): vfs_ask_question_callback: user_data is not TVFSCallbackThread, exiting.']); Exit; @@ -271,7 +270,7 @@ begin Thread.VFSCallbackCancelled := (choice^ < 0) or (choice^ = cancel_choice); Exit; end; - if pthread_self = Thread.FThreadID then begin + if pthread_self = Thread.FPThreadID then begin DebugMsg(['******* vfs_ask_question_callback spawned, user_data = ', user_data, ', ThreadID = ', pthread_self]); Thread.VFSAskQuestion_Message := AMessage; Thread.VFSAskQuestion_Choices := Choices; @@ -285,7 +284,7 @@ begin Exit; end; DebugMsg(['!! (ERROR): vfs_ask_question_callback spawned neither from the main thread nor from active TVFSCallbackThread, dropping the callback to prevent data corruption.']); - DebugMsg([' ThreadID = 0x', IntToHex(pthread_self, 16), ', TVFSCallbackThread ID = 0x', IntToHex(Thread.FThreadID, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]); + DebugMsg([' ThreadID = 0x', IntToHex(pthread_self, 16), ', TVFSCallbackThread ID = 0x', IntToHex(Thread.FPThreadID, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]); end; function vfs_ask_password_callback(const AMessage: PChar; const default_user: PChar; const default_domain: PChar; const default_password: PChar; flags: TVFSAskPasswordFlags; @@ -295,7 +294,7 @@ var Thread: TVFSCallbackThread; def_pass: PChar; begin Result := False; - Thread := user_data; + Thread := TVFSCallbackThread(user_data); if (Thread = nil) { or (not (Thread is TVFSCallbackThread))} then begin DebugMsg(['(ERROR): vfs_ask_question_callback: user_data is not TVFSCallbackThread, exiting.']); Exit; @@ -342,7 +341,7 @@ begin Result := HandleVFSAskPasswordCallback(Thread.DialogsParentWindow.FWidget, AMessage, default_user, default_domain, def_pass, flags, username, password, anonymous, domain, password_save); Thread.VFSCallbackCancelled := Result = False; end else - if pthread_self = Thread.FThreadID then begin + if pthread_self = Thread.FPThreadID then begin DebugMsg(['******* vfs_ask_password_callback spawned, user_data = ', user_data, ', ThreadID = ', pthread_self, ', Application.ThreadID = ', Application.ThreadID]); Thread.VFSAskPassword_Message := AMessage; Thread.VFSAskPassword_default_user := default_user; @@ -364,7 +363,7 @@ begin end else begin DebugMsg(['!! (ERROR): vfs_ask_password_callback spawned neither from the main thread nor from active TVFSCallbackThread, dropping the callback to prevent data corruption.']); - DebugMsg([' ThreadID = 0x', IntToHex(pthread_self, 16), ', TVFSCallbackThread ID = 0x', IntToHex(Thread.FThreadID, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]); + DebugMsg([' ThreadID = 0x', IntToHex(pthread_self, 16), ', TVFSCallbackThread ID = 0x', IntToHex(Thread.FPThreadID, 16), ', Application.ThreadID = 0x', IntToHex(Application.ThreadID, 16)]); end; // Save password back to the engine @@ -984,6 +983,8 @@ end; Result := False; Exit; end; + s := ''; + s2 := ''; GetCopyProgressErrorLabels(TWorkerThread(Sender), Error, s, s2); case ShowDirDeleteDialog(DIR_DELETE_SET_COPY_ERROR, s, s2, StrToUTF8(Error^.message)) of DIR_DELETE_IGNORE : Result := True; @@ -1028,7 +1029,7 @@ var DefResponse: integer; // Global variables for this function if (g_error_matches (LocalError, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED))) then g_propagate_error (Error, LocalError) else begin - g_set_error(Error, TUXCMD_ERROR, gint(MaskErrorCode), LocalError^.message); + g_set_error_literal(Error, TUXCMD_ERROR, gint(MaskErrorCode), LocalError^.message); g_error_free(LocalError); end; end; @@ -1063,7 +1064,7 @@ var DefResponse: integer; // Global variables for this function BSize := DestEngine.GetBlockSize; Buffer := malloc(BSize); if Buffer = nil then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_ALLOC_FAILED), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_ALLOC_FAILED), '%m', []); CopyFilesWorker_ProgressFunc(Self, 0, Error^); // Memory allocation failed Exit; end; @@ -1132,7 +1133,7 @@ var DefResponse: integer; // Global variables for this function Result := False; try AEngine := nil; - FCopyProgressFunc := CopyFilesWorker_ProgressFunc; + FCopyProgressFunc := @CopyFilesWorker_ProgressFunc; // local -> local if (SrcEngine is TLocalTreeEngine) and (DestEngine is TLocalTreeEngine) @@ -1387,6 +1388,8 @@ var DefResponse: integer; // Global variables for this function Result := False; Exit; end; + s := ''; + s2 := ''; GetCopyProgressErrorLabels(Self, Error, s, s2); s3 := StrToUTF8(Error^.message); if (Error^.domain = TUXCMD_ERROR) then @@ -1566,9 +1569,9 @@ begin if List.Count > 0 then begin StartPassed := True; if SrcEngine is TVFSEngine then - StartPassed := StartPassed and (SrcEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); + StartPassed := StartPassed and (SrcEngine as TVFSEngine).StartCopyOperation(PVFSAskQuestionCallback(@vfs_ask_question_callback), PVFSAskPasswordCallback(@vfs_ask_password_callback), PVFSProgressCallback(@vfs_copy_progress_callback), Self); if DestEngine is TVFSEngine then - StartPassed := StartPassed and (DestEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); + StartPassed := StartPassed and (DestEngine as TVFSEngine).StartCopyOperation(PVFSAskQuestionCallback(@vfs_ask_question_callback), PVFSAskPasswordCallback(@vfs_ask_password_callback), PVFSProgressCallback(@vfs_copy_progress_callback), Self); if StartPassed then for i := 0 to List.Count - 1 do begin @@ -1614,9 +1617,9 @@ begin // We need to ensure these to be called in case of error if SrcEngine is TVFSEngine then - (SrcEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); + (SrcEngine as TVFSEngine).StopCopyOperation(PVFSProgressCallback(@vfs_copy_progress_callback), Self); if DestEngine is TVFSEngine then - (DestEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); + (DestEngine as TVFSEngine).StopCopyOperation(PVFSProgressCallback(@vfs_copy_progress_callback), Self); end; end; @@ -1869,6 +1872,8 @@ var FD: TEngineFileDes; xx: string; begin Result := False; + x := 0; + xx := ''; AEngine.GetFileSystemInfo(FilePath, x, TDF, xx); // Calculate part size if SplitMaxSize = 0 then begin @@ -1949,6 +1954,8 @@ begin CommitGUIUpdate; repeat + x := 0; + xx := ''; AEngine.GetFileSystemInfo(FilePath, x, TDF, xx); // Delete target files if necessary if SplitDeleteTarget and ((TDF < 512) or (TDF < FileSize) or (TDF < SplitMaxSize)) then try @@ -2279,19 +2286,19 @@ function TOpenDirThread.ChangeDir(Engine: TPanelEngine; Path: string; var SelIte NewPath := IncludeTrailingPathDelimiter(NewPath); end; -var APath: string; +var FPath: string; begin Result := False; try - APath := Engine.Path; - if Path = '..' then GoUp(APath) + FPath := Engine.Path; + if Path = '..' then GoUp(FPath) else begin - APath := IncludeTrailingPathDelimiter(APath); + FPath := IncludeTrailingPathDelimiter(FPath); Path := IncludeTrailingPathDelimiter(Path); if (Length(Path) > 0) and (Path[1] <> '/') - then APath := APath + Path - else APath := Path; - APath := IncludeTrailingPathDelimiter(APath); + then FPath := FPath + Path + else FPath := Path; + FPath := IncludeTrailingPathDelimiter(FPath); end; // AutoFallback loop @@ -2301,15 +2308,15 @@ begin ChDirError := nil; end; if Engine is TVFSEngine - then Result := (Engine as TVFSEngine).ChangeDirEx(APath, @vfs_ask_question_callback, @vfs_ask_password_callback, nil, Self, @ChDirError) - else Result := Engine.ChangeDir(APath, @ChDirError); + then Result := (Engine as TVFSEngine).ChangeDirEx(FPath, PVFSAskQuestionCallback(@vfs_ask_question_callback), PVFSAskPasswordCallback(@vfs_ask_password_callback), nil, Self, @ChDirError) + else Result := Engine.ChangeDir(FPath, @ChDirError); if not Result then begin - PrefixTuxcmdError(@ChDirError, ExcludeTrailingPathDelimiter(APath)); - GoUp(APath); + PrefixTuxcmdError(@ChDirError, ExcludeTrailingPathDelimiter(FPath)); + GoUp(FPath); end; - until Result or (not AutoFallback) or (Length(APath) <= 1); + until Result or (not AutoFallback) or (Length(FPath) <= 1); if Result then - Engine.Path := APath; + Engine.Path := FPath; except on E: Exception do begin Result := False; @@ -2333,7 +2340,7 @@ begin xEngine.SavePath := AEngine.Path; // AEngine must be set here since VFSOpenEx callbacks will reference it AEngine := xEngine; - VFSOpenResult := (AEngine as TVFSEngine).VFSOpenEx(AFullPath, @vfs_ask_question_callback, @vfs_ask_password_callback, nil, Self, @VFSOpenError); + VFSOpenResult := (AEngine as TVFSEngine).VFSOpenEx(AFullPath, PVFSAskQuestionCallback(@vfs_ask_question_callback), PVFSAskPasswordCallback(@vfs_ask_password_callback), nil, Self, @VFSOpenError); end else VFSOpenResult := True; if VFSOpenResult and (not FCancelled) then begin @@ -2374,7 +2381,7 @@ procedure TOpenConnectionThread.Execute; begin PrepareExecute; try - OpenResult := (AEngine as TVFSEngine).VFSOpenURI(URI, @vfs_ask_question_callback, @vfs_ask_password_callback, nil, Self, @OpenError); + OpenResult := (AEngine as TVFSEngine).VFSOpenURI(URI, PVFSAskQuestionCallback(@vfs_ask_question_callback), PVFSAskPasswordCallback(@vfs_ask_password_callback), nil, Self, @OpenError); finally FFinished := True; end; diff --git a/UDirDelete.pas b/UDirDelete.pas index 3a3b4c5..953a41a 100644 --- a/UDirDelete.pas +++ b/UDirDelete.pas @@ -22,7 +22,7 @@ unit UDirDelete; interface uses - SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; const DIR_DELETE_CANCEL = 0; DIR_DELETE_DELETE = 1; @@ -68,7 +68,7 @@ begin ClientArea.AddControlEx(Label1, True, True, 0); ClientArea.AddControlEx(Label2, True, True, 0); ClientArea.AddControlEx(Label3, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFDirDelete.AddButtons(ButtonSet: TFDirDeleteButtonSet); diff --git a/UEngines.pas b/UEngines.pas index 7a0ccad..4373910 100644 --- a/UEngines.pas +++ b/UEngines.pas @@ -21,7 +21,7 @@ unit UEngines; interface -uses glib2, gdk2, Classes, ULibc; +uses lazglib2, gdk2, Classes, ULibc; const omRead = 0; @@ -182,7 +182,7 @@ function DuplicateDataItem(DataItem: PDataItemSL): PDataItemSL; overload; implementation -uses SysUtils, UCoreUtils, UGnome, UError; +uses SysUtils, UCoreUtils, UError; (********************************************************************************************************************************) constructor TPanelEngine.Create; @@ -244,13 +244,13 @@ begin Result := False; try if libc_chdir(PChar(APath)) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHDIR), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHDIR), '%m', []); DebugMsg(['*** TLocalTreeEngine.GetListing(APath=', APath, '): chdir error: ', strerror(errno)]); Exit; end; Handle := opendir(PChar(APath)); if Handle = nil then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m', []); DebugMsg(['*** TLocalTreeEngine.GetListing(APath=', APath, '): opendir() handle == NULL: ', strerror(errno)]); Exit; end; @@ -291,7 +291,7 @@ begin StatBuf := malloc(sizeof(Tstat64)); memset(StatBuf, 0, sizeof(Tstat64)); if lstat64(PChar(APath), StatBuf) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_STAT), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_STAT), '%m', []); DebugMsg(['*** TLocalTreeEngine.GetFileInfo(APath=', APath, '): Error reading file via lstat64: ', strerror(errno)]); libc_free(StatBuf); Result := nil; @@ -390,12 +390,12 @@ begin try APath := IncludeTrailingPathDelimiter(NewPath); if libc_chdir(PChar(APath)) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHDIR), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHDIR), '%m', []); Exit; end; Handle := opendir(PChar(APath)); if Handle = nil then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m', []); Exit; end; { if not Assigned(readdir(Handle)) then begin @@ -403,7 +403,7 @@ begin Exit; end; } if closedir(Handle) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPENDIR), '%m', []); Exit; end; Result := True; @@ -473,7 +473,7 @@ begin Result := False; if __mkdir(PChar(NewDir), OctalToAttr(ConfDefaultDirCreationMask)) <> 0 then begin if Self.DirectoryExists(NewDir, False) or (@g_mkdir_with_parents = nil) or (g_mkdir_with_parents(PChar(NewDir), OctalToAttr(ConfDefaultDirCreationMask)) <> 0) - then g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_MKDIR), '%m') + then g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_MKDIR), '%m', []) else Result := True; end else Result := True; end; @@ -483,7 +483,7 @@ function TLocalTreeEngine.Remove(const APath: string; Error: PPGError): boolean; begin Result := False; if libc_remove(PChar(ExcludeTrailingPathDelimiter(APath))) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_REMOVE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_REMOVE), '%m', []); end else Result := True; end; @@ -492,7 +492,7 @@ function TLocalTreeEngine.MakeSymLink(const NewFileName, PointTo: string; Error: begin Result := False; if symlink(PChar(PointTo), PChar(NewFileName)) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SYMLINK), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SYMLINK), '%m', []); end else Result := True; end; @@ -501,7 +501,7 @@ function TLocalTreeEngine.Chmod(const FileName: string; Mode: cuLong; Error: PPG begin Result := False; if libc_chmod(PChar(FileName), Mode) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHMOD), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHMOD), '%m', []); end else Result := True; end; @@ -510,7 +510,7 @@ function TLocalTreeEngine.Chown(const FileName: string; UID, GID: cuLong; Error: begin Result := False; if libc_chown(PChar(FileName), UID, GID) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHOWN), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CHOWN), '%m', []); end else Result := True; end; @@ -519,7 +519,7 @@ function TLocalTreeEngine.RenameFile(const SourceFile, DestFile: string; Error: begin Result := False; if libc_rename(PChar(SourceFile), PChar(DestFile)) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_RENAME), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_RENAME), '%m', []); end else Result := True; end; @@ -534,7 +534,7 @@ begin timebuf^.actime := atime; timebuf^.modtime := mtime; if utime(PChar(APath), timebuf) <> 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TIMESTAMPS), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TIMESTAMPS), '%m', []); end else Result := True; libc_free(timebuf); except @@ -565,7 +565,7 @@ begin // Open source file for reading fsrc := open64(PChar(SourceFile), ConfDefaultOpenFlagsRead, 0); if fsrc < 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_OPEN), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_OPEN), '%m', []); if @ProgressFunc <> nil then ProgressFunc(Sender, 0, Error^); Exit; @@ -574,7 +574,7 @@ begin if Append then fdest := open64(PChar(DestFile), ConfDefaultOpenFlagsAppend, 0) else fdest := open64(PChar(DestFile), ConfDefaultOpenFlagsWrite, ConfDefaultFileCreationMask); if fdest < 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_OPEN), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_OPEN), '%m', []); libc_close(fsrc); if @ProgressFunc <> nil then ProgressFunc(Sender, 0, Error^); @@ -583,7 +583,7 @@ begin Buffer := malloc(FBlockSize); if Buffer = nil then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_ALLOC_FAILED), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_ALLOC_FAILED), '%m', []); libc_close(fdest); libc_close(fsrc); if @ProgressFunc <> nil then @@ -596,7 +596,7 @@ begin // Read block BytesRead := libc_read(fsrc, Buffer, FBlockSize); if BytesRead < 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_READ), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_READ), '%m', []); Result := False; if @ProgressFunc <> nil then Result := ProgressFunc(Sender, BytesDone + BytesRead, Error^); @@ -617,7 +617,7 @@ begin BytesRemaining := BytesRemaining - BytesWritten; until (BytesRemaining = 0) or (BytesWritten <= 0); if BytesWritten < 0 then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_WRITE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_WRITE), '%m', []); Result := False; if @ProgressFunc <> nil then ProgressFunc(Sender, BytesDone + BytesRead, Error^); @@ -635,7 +635,7 @@ begin if libc_close(fdest) <> 0 then if Result then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_CLOSE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_TARGET_CLOSE), '%m', []); Result := False; if @ProgressFunc <> nil then ProgressFunc(Sender, BytesDone, Error^); @@ -644,7 +644,7 @@ begin end; if libc_close(fsrc) <> 0 then if Result then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_CLOSE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SOURCE_CLOSE), '%m', []); Result := False; if @ProgressFunc <> nil then Result := ProgressFunc(Sender, BytesDone, Error^); @@ -813,13 +813,13 @@ begin end; omAppend: flags := ConfDefaultOpenFlagsAppend; else begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPEN_FILE), 'Invalid file mode %d', Mode); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPEN_FILE), 'Invalid file mode %d', [Mode]); Exit; end; end; r := open64(PChar(APath), flags, m); - if r < 0 then g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPEN_FILE), '%m') + if r < 0 then g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_OPEN_FILE), '%m', []) else Result := Pointer(r); end; @@ -828,7 +828,7 @@ function TLocalTreeEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: begin Result := libc_read(LongInt(FileDescriptor), Buffer, ABlockSize); if Result < 0 then - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_READ_FILE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_READ_FILE), '%m', []); end; (********************************************************************************************************************************) @@ -836,7 +836,7 @@ function TLocalTreeEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer begin Result := libc_write(LongInt(FileDescriptor), Buffer, BytesCount); if Result < 0 then - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_WRITE_FILE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_WRITE_FILE), '%m', []); end; (********************************************************************************************************************************) @@ -844,7 +844,7 @@ function TLocalTreeEngine.CloseFile(const FileDescriptor: TEngineFileDes; Error: begin Result := libc_close(LongInt(FileDescriptor)) = 0; if not Result then - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CLOSE_FILE), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CLOSE_FILE), '%m', []); end; (********************************************************************************************************************************) @@ -852,7 +852,7 @@ function TLocalTreeEngine.FileSeek(const FileDescriptor: TEngineFileDes; const A begin Result := lseek64(LongInt(FileDescriptor), AbsoluteOffset, SEEK_SET); if Result = -1 then - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SEEK), '%m'); + g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_SEEK), '%m', []); end; (********************************************************************************************************************************) diff --git a/UError.pas b/UError.pas index d557189..3863575 100644 --- a/UError.pas +++ b/UError.pas @@ -21,7 +21,7 @@ unit UError; interface -uses glib2, gtk2, Classes, SysUtils, ULibc, GTKForms; +uses lazglib2, gtk2, Classes, SysUtils, GTKForms; type TuxcmdErrorEnum = ( TUXCMD_ERROR_CANCELLED, @@ -154,10 +154,8 @@ end; function g_io_error_from_errno(err_no: gint): GIOErrorEnum; begin // Prefer native library call - if @__g_io_error_from_errno <> nil then begin - Result := __g_io_error_from_errno(err_no); - Exit; - end; + Result := g_io_error_from_errno(err_no); +(* case err_no of EEXIST: Result := G_IO_ERROR_EXISTS; EISDIR: Result := G_IO_ERROR_IS_DIRECTORY; @@ -199,12 +197,13 @@ begin ENOTSOCK: Result := G_IO_ERROR_INVALID_ARGUMENT; else Result := G_IO_ERROR_FAILED; end; +*) end; (********************************************************************************************************************************) procedure tuxcmd_set_error_from_exception(Error: PPGError; E: Exception); begin - g_set_error(Error, TUXCMD_ERROR, integer(TUXCMD_ERROR_EXCEPTION), 'Exception raised: %s', PChar(E.Message)); + g_set_error(Error, TUXCMD_ERROR, integer(TUXCMD_ERROR_EXCEPTION), 'Exception raised: %s', [PChar(E.Message)]); end; (********************************************************************************************************************************) @@ -214,47 +213,43 @@ var Dialog: PGtkWidget; begin if Error <> nil then error_str := Error^.message else error_str := ''; - if @gtk_message_dialog_new_with_markup <> nil - then dialog := gtk_message_dialog_new_with_markup (PGtkWindow(Parent.FWidget), GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - '%s'#10#10'%s', - PChar(Text), error_str) - else dialog := gtk_message_dialog_new (PGtkWindow(Parent.FWidget), GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, - '%s'#10#10'%s', PChar(Text), error_str); - gtk_window_set_title (PGtkWindow(dialog), ''); - gtk_dialog_run (PGtkDialog(Dialog)); - gtk_widget_destroy (PGtkWidget(Dialog)); + dialog := gtk_message_dialog_new_with_markup(PGtkWindow(Parent.FWidget), GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, + '%s'#10#10'%s', + PChar(Text), error_str); + gtk_window_set_title(PGtkWindow(dialog), ''); + gtk_dialog_run(PGtkDialog(Dialog)); + gtk_widget_destroy(PGtkWidget(Dialog)); end; procedure PrefixTuxcmdError(Error: PPGError; const FileName: string); begin if (Error = nil) or (Error^ = nil) then Exit; - if (Error^.domain <> TUXCMD_ERROR) then Exit; - case TuxcmdErrorEnum(Error^.code) of - TUXCMD_ERROR_CHDIR: g_prefix_error(Error, 'Error changing directory to ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_OPENDIR: g_prefix_error(Error, 'Error opening directory ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_STAT: g_prefix_error(Error, 'Error getting file info for ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_MKDIR: g_prefix_error(Error, 'Error creating directory ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_REMOVE: g_prefix_error(Error, 'Error deleting ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_SYMLINK: g_prefix_error(Error, 'Error creating symlink ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_CHMOD: g_prefix_error(Error, 'Error changing permissions of ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_CHOWN: g_prefix_error(Error, 'Error changing owner/group of ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_RENAME: g_prefix_error(Error, 'Error renaming file ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_TIMESTAMPS: g_prefix_error(Error, 'Error changing timestamps of ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_OPEN_FILE: g_prefix_error(Error, 'Error opening file ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_READ_FILE: g_prefix_error(Error, 'Error reading file ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_WRITE_FILE: g_prefix_error(Error, 'Error writing file ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_CLOSE_FILE: g_prefix_error(Error, 'Error closing file ''%s'': ', StrToUTF8(PChar(FileName))); - TUXCMD_ERROR_SEEK: g_prefix_error(Error, 'Error seeking in file ''%s'': ', StrToUTF8(PChar(FileName))); + if ((Error^)^.domain <> TUXCMD_ERROR) then Exit; + case TuxcmdErrorEnum((Error^)^.code) of + TUXCMD_ERROR_CHDIR: g_prefix_error(Error, 'Error changing directory to ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_OPENDIR: g_prefix_error(Error, 'Error opening directory ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_STAT: g_prefix_error(Error, 'Error getting file info for ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_MKDIR: g_prefix_error(Error, 'Error creating directory ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_REMOVE: g_prefix_error(Error, 'Error deleting ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_SYMLINK: g_prefix_error(Error, 'Error creating symlink ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_CHMOD: g_prefix_error(Error, 'Error changing permissions of ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_CHOWN: g_prefix_error(Error, 'Error changing owner/group of ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_RENAME: g_prefix_error(Error, 'Error renaming file ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_TIMESTAMPS: g_prefix_error(Error, 'Error changing timestamps of ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_OPEN_FILE: g_prefix_error(Error, 'Error opening file ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_READ_FILE: g_prefix_error(Error, 'Error reading file ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_WRITE_FILE: g_prefix_error(Error, 'Error writing file ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_CLOSE_FILE: g_prefix_error(Error, 'Error closing file ''%s'': ', [StrToUTF8(PChar(FileName))]); + TUXCMD_ERROR_SEEK: g_prefix_error(Error, 'Error seeking in file ''%s'': ', [StrToUTF8(PChar(FileName))]); end; end; procedure VFSToTuxcmdError(Error: PPGError; Operation: TuxcmdErrorEnum); var OldError: PGError; begin - if (Error = nil) or (Error^ = nil) or (Error^.domain <> G_IO_ERROR) then Exit; - case GIOErrorEnum(Error^.code) of + if (Error = nil) or (Error^ = nil) or ((Error^)^.domain <> G_IO_ERROR) then Exit; + case GIOErrorEnum((Error^)^.code) of G_IO_ERROR_FAILED, G_IO_ERROR_NOT_FOUND, G_IO_ERROR_EXISTS, @@ -288,7 +283,7 @@ begin G_IO_ERROR_NO_SUCH_DEVICE: begin OldError := Error^; Error^ := nil; - g_set_error(Error, TUXCMD_ERROR, gint(Operation), '%s', OldError^.message); + g_set_error(Error, TUXCMD_ERROR, gint(Operation), '%s', [OldError^.message]); g_free (OldError); end; end; diff --git a/UFileAssoc.pas b/UFileAssoc.pas index 4b4f355..60ee2d5 100644 --- a/UFileAssoc.pas +++ b/UFileAssoc.pas @@ -206,7 +206,7 @@ begin if b then Break; end; if b then begin - Result := PluginList[i]; + Result := TVFSPlugin(PluginList[i]); MaxFound := Length(s); end; end; @@ -236,7 +236,7 @@ begin if b then Break; end; if b then begin - Result := AssocList[i]; + Result := TFileAssoc(AssocList[i]); MaxFound := Length(s); end; end; diff --git a/UFileTypeSettings.pas b/UFileTypeSettings.pas index 55ce5c5..d6d7eca 100644 --- a/UFileTypeSettings.pas +++ b/UFileTypeSettings.pas @@ -22,9 +22,8 @@ unit UFileTypeSettings; interface uses - gtk2, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKUtils, GTKDialogs, - GTKPixbuf, GTKClasses, - UCoreClasses, UGnome; + gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKUtils, GTKDialogs, + GTKPixbuf, GTKClasses, UGnome; type TFFileTypeSettings = class(TGTKDialog) @@ -131,7 +130,7 @@ begin Column.AddAttribute('text', 0); Column.SortID := 0; Column.Resizable := True; - g_object_set(G_OBJECT(Column.FColumn), 'sizing', 2, 'fixed-width', 150, nil); + g_object_set(G_OBJECT(Column.FColumn), 'sizing', [2, 'fixed-width', 150, nil]); { Column.FixedWidth := 300; Column.SizingMode := smFixed; } Column.SetProperty('ellipsize', 3); @@ -297,10 +296,10 @@ begin ColorLabel.UseUnderline := True; ColorButton := TGnomeColorButton.Create(Self); ColorButton.SetSizeRequest(40, -1); - ColorButton.OnColorChanged := ColorButtonColorChanged; + ColorButton.OnColorChanged := @ColorButtonColorChanged; ColorLabel.FocusControl := ColorButton; DefaultColorCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGDefaultColor); - DefaultColorCheckBox.OnToggled := DefaultColorCheckBoxToggled; + DefaultColorCheckBox.OnToggled := @DefaultColorCheckBoxToggled; ColorHBox.AddControlEx(ColorLabel, False, False, 4); ColorHBox.AddControlEx(ColorButton, False, False, 5); ColorHBox.AddControlEx(DefaultColorCheckBox, False, False, 5); @@ -310,11 +309,11 @@ begin IconLabel.Caption := LANGIcon; IconLabel.UseUnderline := True; IconEntry := TGTKEntry.Create(Self); - IconEntry.OnChanged := IconEntryChanged; + IconEntry.OnChanged := @IconEntryChanged; IconLabel.FocusControl := IconEntry; BrowseIconButton := TGTKButton.Create(Self); BrowseIconButton.Caption := LANGBrowseButton_Caption; - BrowseIconButton.OnClick := BrowseIconButtonClick; + BrowseIconButton.OnClick := @BrowseIconButtonClick; Icon := TGTKImage.Create(Self); Icon.SetSizeRequest(24, 24); IconFrame := TGTKFrame.CreateWithoutLabel(Self); @@ -323,7 +322,7 @@ begin if FUseGnomeIconEntry then begin GnomeIconButton := TGnomeIconEntry.Create(Self); GnomeIconButton.Filename := ''; - GnomeIconButton.OnIconChanged := GnomeIconButtonIconChanged; + GnomeIconButton.OnIconChanged := @GnomeIconButtonIconChanged; end; Table2 := TGTKTable.Create(Self); @@ -347,28 +346,28 @@ begin Notebook.AppendPage(FNameExtVBox3, LANGNotebookPageExtensions); Notebook.AppendPage(ActionsVBox, LANGNotebookPageActions); - OnKeyDown := FormKeyDown; - OnDestroy := FormDestroy; - AddFiletypeButton.OnClick := AddFiletypeButtonClick; - RemoveFiletypeButton.OnClick := RemoveFiletypeButtonClick; - ListView.OnSelectionChanged := ListViewSelectionChanged; - AddExtButton.OnClick := AddExtButtonClick; - RemoveExtButton.OnClick := RemoveExtButtonClick; - FNameExtEntry.OnKeyDown := FNameExtEntryKeyDown; - FNameExtListView.OnSelectionChanged := FNameExtListViewSelectionChanged; - AssocDescriptionEntry.OnChanged := AssocDescriptionEntryChanged; - ActionsListView.OnSelectionChanged := ActionsListViewSelectionChanged; - AddActionButton.OnClick := AddActionButtonClick; - RemoveActionButton.OnClick := RemoveActionButtonClick; - DescriptionEntry.OnChanged := DescriptionEntryChanged; - CommandEntry.OnChanged := CommandEntryChanged; - RunInTerminalCheckBox.OnToggled := RunInTerminalCheckBoxToggled; - AutodetectCheckBox.OnToggled := AutodetectCheckBoxToggled; - SetDefaultActionButton.OnClick := SetDefaultActionButtonClick; - BrowseButton.OnClick := BrowseButtonClick; - - ListView.CellDataFunc := ListViewCellDataFunc; - ActionsListView.CellDataFunc := ActionsListViewCellDataFunc; + OnKeyDown := @FormKeyDown; + OnDestroy := @FormDestroy; + AddFiletypeButton.OnClick := @AddFiletypeButtonClick; + RemoveFiletypeButton.OnClick := @RemoveFiletypeButtonClick; + ListView.OnSelectionChanged := @ListViewSelectionChanged; + AddExtButton.OnClick := @AddExtButtonClick; + RemoveExtButton.OnClick := @RemoveExtButtonClick; + FNameExtEntry.OnKeyDown := @FNameExtEntryKeyDown; + FNameExtListView.OnSelectionChanged := @FNameExtListViewSelectionChanged; + AssocDescriptionEntry.OnChanged := @AssocDescriptionEntryChanged; + ActionsListView.OnSelectionChanged := @ActionsListViewSelectionChanged; + AddActionButton.OnClick := @AddActionButtonClick; + RemoveActionButton.OnClick := @RemoveActionButtonClick; + DescriptionEntry.OnChanged := @DescriptionEntryChanged; + CommandEntry.OnChanged := @CommandEntryChanged; + RunInTerminalCheckBox.OnToggled := @RunInTerminalCheckBoxToggled; + AutodetectCheckBox.OnToggled := @AutodetectCheckBoxToggled; + SetDefaultActionButton.OnClick := @SetDefaultActionButtonClick; + BrowseButton.OnClick := @BrowseButtonClick; + + ListView.CellDataFunc := @ListViewCellDataFunc; + ActionsListView.CellDataFunc := @ActionsListViewCellDataFunc; ListViewSelectionChanged(Self); ListView.SetFocus; end; @@ -510,7 +509,7 @@ procedure TFFileTypeSettings.RemoveFiletypeButtonClick(Sender: TObject); var Item: TFileAssoc; begin if Assigned(ListView.Selected) and Assigned(ListView.Selected.AsPointer(2)) then begin - Item := ListView.Selected.AsPointer(2); + Item := TFileAssoc(ListView.Selected.AsPointer(2)); Item.Free; IntAssocList.Remove(Item); ListView.Items.Delete(ListView.Selected.Index); @@ -552,7 +551,7 @@ begin DefaultColorCheckBox.Checked := True; Exit; end; - Item := ListView.Selected.AsPointer(2); + Item := TFileAssoc(ListView.Selected.AsPointer(2)); FNameExtListView.Items.Clear; if Length(Item.Extensions) > 0 then for i := 0 to Length(Item.Extensions) - 1 do @@ -666,7 +665,7 @@ begin CommandEntry.Text := ''; Exit; end; - Action := ActionsListView.Selected.AsPointer(2); + Action := TAssocAction(ActionsListView.Selected.AsPointer(2)); DescriptionEntry.Text := Action.ActionName; CommandEntry.Text := Action.ActionCommand; RunInTerminalCheckBox.Checked := Action.RunInTerminal; @@ -695,9 +694,9 @@ begin try if (ActionsListView.Items.Count = 0) or (not Assigned(ActionsListView.Selected)) or (not Assigned(ListView.Selected)) or (not Assigned(ListView.Selected.AsPointer(2))) then Exit; - Item := ListView.Selected.AsPointer(2); - Action := ActionsListView.Selected.AsPointer(2); - if (Item.DefaultAction > Item.ActionList.Count - 1) or (Item.ActionList[Item.DefaultAction] = Action) + Item := TFileAssoc(ListView.Selected.AsPointer(2)); + Action := TAssocAction(ActionsListView.Selected.AsPointer(2)); + if (Item.DefaultAction > Item.ActionList.Count - 1) or (TAssocAction(Item.ActionList[Item.DefaultAction]) = Action) then Item.DefaultAction := 0; if Item.DefaultAction > ActionsListView.Selected.Index then Dec(Item.DefaultAction); Action.Free; @@ -714,7 +713,7 @@ begin Assigned(ActionsListView.Selected) and Assigned(ActionsListView.Selected.AsPointer(2)) then begin TAssocAction(ActionsListView.Selected.AsPointer(2)).ActionName := DescriptionEntry.Text; - Item := ListView.Selected.AsPointer(2); + Item := TFileAssoc(ListView.Selected.AsPointer(2)); if (Item.ActionList.Count - 1 >= Item.DefaultAction) and (ActionsListView.Selected.AsPointer(2) = Item.ActionList[Item.DefaultAction]) then ActionsListView.Selected.SetValue(0, DescriptionEntry.Text + LANGDefault) else ActionsListView.Selected.SetValue(0, DescriptionEntry.Text); @@ -852,10 +851,10 @@ begin if Assigned(Data) and (Data is TFileAssoc) and ((Data.FileTypeName = ConstFTAMetaDirectory) or (Data.FileTypeName = ConstFTAMetaFile)) then case ColumnID of - 0: g_object_set(cell, 'markup', g_strconcat('', s, '', nil), nil); - 1: g_object_set(cell, 'markup', g_strconcat('', s, '', nil), nil); + 0: g_object_set(cell, 'markup', [g_strconcat('', s, '', nil), nil]); + 1: g_object_set(cell, 'markup', [g_strconcat('', s, '', nil), nil]); end - else g_object_set(cell, 'markup', s, nil); + else g_object_set(cell, 'markup', [s, nil]); end; @@ -870,15 +869,15 @@ begin ImageCol := False; if ColumnID = 0 then ImageCol := GTK_IS_CELL_RENDERER_PIXBUF(cell); if ImageCol then Exit; - Item := ListView.Selected.AsPointer(2); + Item := TFileAssoc(ListView.Selected.AsPointer(2)); if Item = nil then Exit; Data := nil; gtk_tree_model_get(tree_model, iter, 2, @Data, -1); gtk_tree_model_get(tree_model, iter, ColumnID, @s, -1); if Assigned(Data) and (Data is TAssocAction) and (Item.ActionList.IndexOf(Data) = Item.DefaultAction) - then g_object_set(cell, 'markup', g_strconcat('', s, '', nil), nil) - else g_object_set(cell, 'markup', s, nil); + then g_object_set(cell, 'markup', [g_strconcat('', s, '', nil), nil]) + else g_object_set(cell, 'markup', [s, nil]); end; (********************************************************************************************************************************) diff --git a/UGnome.pas b/UGnome.pas index 2536d42..6d690a2 100644 --- a/UGnome.pas +++ b/UGnome.pas @@ -21,7 +21,7 @@ unit UGnome; interface -uses glib2, gdk2, gdk2pixbuf, gtk2, Classes, ULibc, UError, +uses glib2, lazglib2, lazgobject2, gdk2, gdk2pixbuf, gtk2, Classes, ULibc, GTKForms, GTKControls, GTKStdCtrls, GTKExtCtrls, GTKClasses, GTKDialogs, GTKUtils, GTKConsts, uVFSprototypes; @@ -125,7 +125,7 @@ type TGnomeColorButton = class(TGTKButton) procedure RemovePage(PageNo: integer); function GetTabCaption(PageNo: integer): string; procedure SetTabCaption(PageNo: integer; Caption: string); - procedure SetTabTooltip(PageNo: integer; Tooltip: string); + procedure SetTabTooltip(PageNo: integer; ATooltip: string); published property PageIndex: integer read GetPageIndex write SetPageIndex; property ShowCloseButtons: boolean read FShowCloseButtons write SetShowCloseButtons default False; @@ -176,7 +176,7 @@ type PGnomeColorPicker = PGtkWidget; const AFTER_ALL_TABS = -1; NOT_IN_APP_WINDOWS = -2; -var libGlib2Handle, libGio2Handle, libGtk2Handle, libGnome2Handle, libGnomeUI2Handle: Pointer; +var libGtk2Handle, libGnome2Handle, libGnomeUI2Handle: Pointer; gnome_about_new: function (const name, version, copyright, comments: Pchar; const authors, documenters: PPchar; const translator_credits: Pchar; logo_pixbuf: PGdkPixbuf): PGtkWidget; cdecl; gnome_program_init: function (const app_id, app_version: PChar; const module_info: Pointer; argc: integer; argv: PPChar): Pointer; varargs; cdecl; @@ -193,19 +193,15 @@ var libGlib2Handle, libGio2Handle, libGtk2Handle, libGnome2Handle, libGnomeUI2Ha gnome_date_edit_set_time: procedure (gde: PGnomeDateEdit; the_time: time_t); cdecl; gnome_date_edit_get_time: function (gde: PGnomeDateEdit): time_t; cdecl; - gtk_event_box_set_visible_window: procedure (event_box: PGtkEventBox; visible_window: gboolean); cdecl; - gtk_icon_size_lookup_for_settings: function (settings: PGtkSettings; size: TGtkIconSize; width, height: Pgint): gboolean; cdecl; - gtk_window_set_icon_name: procedure (window: PGtkWindow; const name: Pgchar); cdecl; - g_filename_display_name: function (const filename: PChar): PChar; cdecl; - gtk_message_dialog_new_with_markup: function (parent:PGtkWindow; flags:TGtkDialogFlags; - _type:TGtkMessageType; buttons:TGtkButtonsType; - message_format:Pgchar):PGtkWidget; varargs; cdecl; - g_mkdir_with_parents: function (const pathname: PChar; mode: integer): integer; cdecl; - __g_io_error_from_errno: function (err_no: gint): GIOErrorEnum; cdecl; -function _gtk_notebook_insert_page(notebook:PGtkNotebook; child:PGtkWidget;tab_label:PGtkWidget; position:gint):gint; cdecl; external gtklib name 'gtk_notebook_insert_page'; -procedure g_prefix_error(err: PPGError; format: Pgchar); varargs; cdecl; external gliblib name 'g_prefix_error'; +procedure gtk_event_box_set_visible_window(event_box: PGtkEventBox; visible_window: gboolean); cdecl; external gtklib; +function gtk_icon_size_lookup_for_settings(settings: PGtkSettings; size: TGtkIconSize; width, height: Pgint): gboolean; cdecl; external gtklib; +procedure gtk_window_set_icon_name(window: PGtkWindow; const name: Pgchar); cdecl; external gtklib; +function gtk_notebook_insert_page(notebook:PGtkNotebook; child:PGtkWidget;tab_label:PGtkWidget; position:gint):gint; cdecl; external gtklib; +function gtk_message_dialog_new_with_markup(parent:PGtkWindow; flags:TGtkDialogFlags; + _type:TGtkMessageType; buttons:TGtkButtonsType; + message_format:Pgchar):PGtkWidget; varargs; cdecl; external gtklib; @@ -214,7 +210,7 @@ procedure LoadGnomeLibs; implementation -uses SysUtils, DateUtils, UConfig, UCoreUtils, ULocale, UFileAssoc; +uses SysUtils, DateUtils, UCoreUtils, ULocale, UFileAssoc; (********************************************************************************************************************************) @@ -256,11 +252,11 @@ begin inherited Create(AOwner); FUseGnomeUI := Assigned(gnome_color_picker_new) and Assigned(gnome_color_picker_get_i16) and Assigned(gnome_color_picker_set_i16); if FUseGnomeUI then begin - FWidget := gnome_color_picker_new; - g_signal_connect(PGtkObject(FWidget), 'color-set', G_CALLBACK(@TGnomeColorButton_color_set), Self); + FWidget := gnome_color_picker_new(); + g_signal_connect_data(PGObject(FWidget), 'color-set', TGCallback(@TGnomeColorButton_color_set), Self, nil, G_CONNECT_DEFAULT); end else begin FWidget := gtk_button_new_with_label(''); // This should be here due to height-related troubles - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGnomeColorButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGnomeColorButton_OnClick), Self, nil, G_CONNECT_DEFAULT); BorderStyle := bsHalf; end; Show; @@ -325,7 +321,7 @@ begin inherited Create(AOwner); FIconChanged := nil; FWidget := gnome_icon_entry_new('History', 'Browse'); - g_signal_connect(PGtkObject(FWidget), 'changed', G_CALLBACK(@TGnomeIconEntry_changed), Self); + g_signal_connect_data(PGObject(FWidget), 'changed', TGCallback(@TGnomeIconEntry_changed), Self, nil, G_CONNECT_DEFAULT); Show; end; @@ -400,9 +396,9 @@ begin FBusy := False; // Set up drag-and-drop - g_signal_connect(FWidget, 'button-press-event', G_CALLBACK(@button_press_cb), Self); - g_signal_connect(FWidget, 'button-release-event', G_CALLBACK(@button_release_cb), Self); - g_signal_connect(FWidget, 'scroll-event', G_CALLBACK(@scroll_event_callback), Self); + g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@button_press_cb), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@button_release_cb), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'scroll-event', TGCallback(@scroll_event_callback), Self, nil, G_CONNECT_DEFAULT); gtk_widget_add_events(FWidget, GDK_BUTTON1_MOTION_MASK); Show; @@ -453,13 +449,11 @@ begin char_width := pango_font_metrics_get_approximate_digit_width(metrics); pango_font_metrics_unref(metrics); } - if @gtk_icon_size_lookup_for_settings <> nil - then gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(hbox), GTK_ICON_SIZE_MENU, @w, @h) - else begin w := 16; h := 16; end; + gtk_icon_size_lookup_for_settings(gtk_widget_get_settings(hbox), GTK_ICON_SIZE_MENU, @w, @h); // gtk_widget_set_size_request(hbox, TAB_WIDTH_N_CHARS * PANGO_PIXELS(char_width) + 2 * w, -1); - button := g_object_get_data(G_OBJECT(hbox), 'close-button'); + button := g_object_get_data(PGObject(hbox), 'close-button'); gtk_widget_set_size_request(button, w + 2, h + 2); end; @@ -469,7 +463,7 @@ var tab: PGtkWidget; position: integer; CanClose: boolean; begin - tab := g_object_get_data(G_OBJECT(widget), 'child'); + tab := g_object_get_data(PGObject(widget), 'child'); ntb := TEphyNotebook(data); position := gtk_notebook_page_num(GTK_NOTEBOOK(ntb.FWidget), GTK_WIDGET(tab)); @@ -495,10 +489,10 @@ begin hbox := gtk_hbox_new(FALSE, 0); label_ebox := gtk_event_box_new(); - if @gtk_event_box_set_visible_window <> nil then gtk_event_box_set_visible_window(GTK_EVENT_BOX (label_ebox), FALSE); + gtk_event_box_set_visible_window(GTK_EVENT_BOX (label_ebox), FALSE); gtk_box_pack_start(GTK_BOX (hbox), label_ebox, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(label_ebox), 'button-press-event', G_CALLBACK(@label_ebox_button_pressed), Self); - g_object_set_data(G_OBJECT(label_ebox), 'child', Child.FWidget); + g_signal_connect_data(PGObject(label_ebox), 'button-press-event', TGCallback(@label_ebox_button_pressed), Self, nil, G_CONNECT_DEFAULT); + g_object_set_data(PGObject(label_ebox), 'child', Child.FWidget); label_hbox := gtk_hbox_new (FALSE, 0); gtk_container_add(GTK_CONTAINER (label_ebox), label_hbox); @@ -507,7 +501,7 @@ begin close_button := gtk_button_new (); gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE); // don't allow focus on the close button - g_object_set(G_OBJECT(close_button), 'can-focus', gboolean(FALSE), nil); + g_object_set(PGObject(close_button), 'can-focus', [gboolean(FALSE), nil]); gtk_button_set_relief (GTK_BUTTON (close_button), GTK_RELIEF_NONE); rcstyle := gtk_rc_style_new (); @@ -520,9 +514,9 @@ begin gtk_box_pack_start (GTK_BOX (hbox), close_button, FALSE, FALSE, 0); gtk_tooltips_set_tip(FTooltips, close_button, PChar(LANGEphyNotebookCloseTab), nil); - g_object_set_data(G_OBJECT(close_button), 'tab', hbox); - g_object_set_data(G_OBJECT(close_button), 'child', Child.FWidget); - g_signal_connect(G_OBJECT(close_button), 'clicked', G_CALLBACK(@close_button_clicked_cb), Self); + g_object_set_data(PGObject(close_button), 'tab', hbox); + g_object_set_data(PGObject(close_button), 'child', Child.FWidget); + g_signal_connect_data(PGObject(close_button), 'clicked', TGCallback(@close_button_clicked_cb), Self, nil, G_CONNECT_DEFAULT); // setup site icon, empty by default icon := gtk_image_new (); @@ -537,7 +531,7 @@ begin gtk_box_pack_start (GTK_BOX(label_hbox), _label, TRUE, TRUE, 0); // Set minimal size - g_signal_connect(hbox, 'style-set', G_CALLBACK(@tab_label_style_set_cb), nil); + g_signal_connect_data(PGObject(hbox), 'style-set', TGCallback(@tab_label_style_set_cb), nil, nil, G_CONNECT_DEFAULT); gtk_widget_show (hbox); @@ -547,13 +541,13 @@ begin gtk_widget_show (image); if FShowCloseButtons then gtk_widget_show (close_button); - g_object_set_data (G_OBJECT (hbox), 'label', _label); - g_object_set_data (G_OBJECT (hbox), 'label-ebox', label_ebox); - g_object_set_data (G_OBJECT (hbox), 'icon', icon); - g_object_set_data (G_OBJECT (hbox), 'close-button', close_button); - g_object_set_data (G_OBJECT (hbox), 'tooltips', FTooltips); + g_object_set_data(PGObject(hbox), 'label', _label); + g_object_set_data(PGObject(hbox), 'label-ebox', label_ebox); + g_object_set_data(PGObject(hbox), 'icon', icon); + g_object_set_data(PGObject(hbox), 'close-button', close_button); + g_object_set_data(PGObject(hbox), 'tooltips', FTooltips); - Result := _gtk_notebook_insert_page(PGtkNotebook(FWidget), Child.FWidget, hbox, Position); + Result := gtk_notebook_insert_page(PGtkNotebook(FWidget), Child.FWidget, hbox, Position); end; procedure TEphyNotebook.RemovePage(PageNo: integer); @@ -565,24 +559,24 @@ function TEphyNotebook.GetTabCaption(PageNo: integer): string; var wid, lab: PGtkWidget; begin wid := gtk_notebook_get_tab_label(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo)); - lab := g_object_get_data (G_OBJECT(wid), 'label'); - Result := PgcharToString(gtk_label_get_text(GTK_LABEL(lab))); + lab := g_object_get_data (PGObject(wid), 'label'); + Result := String(gtk_label_get_text(GTK_LABEL(lab))); end; procedure TEphyNotebook.SetTabCaption(PageNo: integer; Caption: string); var wid, lab: PGtkWidget; begin wid := gtk_notebook_get_tab_label(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo)); - lab := g_object_get_data (G_OBJECT(wid), 'label'); - gtk_label_set_text(GTK_LABEL(lab), StringToPgchar(Caption)); + lab := g_object_get_data (PGObject(wid), 'label'); + gtk_label_set_text(GTK_LABEL(lab), PChar(Caption)); end; -procedure TEphyNotebook.SetTabTooltip(PageNo: integer; Tooltip: string); +procedure TEphyNotebook.SetTabTooltip(PageNo: integer; ATooltip: string); var wid, lab: PGtkWidget; begin wid := gtk_notebook_get_tab_label(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo)); - lab := g_object_get_data (G_OBJECT(wid), 'label-ebox'); - gtk_tooltips_set_tip(FTooltips, lab, StringToPgchar(Tooltip), nil); + lab := g_object_get_data (PGObject(wid), 'label-ebox'); + gtk_tooltips_set_tip(FTooltips, lab, PChar(ATooltip), nil); end; function TEphyNotebook.GetPageIndex: integer; @@ -762,23 +756,23 @@ begin // disconnect the signals before ungrabbing! if toplevel_grab_broken_handler_id <> 0 then begin - g_signal_handler_disconnect(toplevel, toplevel_grab_broken_handler_id); + g_signal_handler_disconnect(PGObject(toplevel), toplevel_grab_broken_handler_id); toplevel_grab_broken_handler_id := 0; end; if grab_notify_handler_id <> 0 then begin - g_signal_handler_disconnect(FWidget, grab_notify_handler_id); + g_signal_handler_disconnect(PGObject(FWidget), grab_notify_handler_id); grab_notify_handler_id := 0; end; if toplevel_motion_notify_handler_id <> 0 then begin - g_signal_handler_disconnect(toplevel, toplevel_motion_notify_handler_id); + g_signal_handler_disconnect(PGObject(toplevel), toplevel_motion_notify_handler_id); toplevel_motion_notify_handler_id := 0; end; if toplevel_button_release_handler_id <> 0 then begin - g_signal_handler_disconnect(toplevel, toplevel_button_release_handler_id); + g_signal_handler_disconnect(PGObject(toplevel), toplevel_button_release_handler_id); toplevel_button_release_handler_id := 0; end; if motion_notify_handler_id <> 0 then begin - g_signal_handler_disconnect(FWidget, motion_notify_handler_id); + g_signal_handler_disconnect(PGObject(FWidget), motion_notify_handler_id); motion_notify_handler_id := 0; end; @@ -934,10 +928,10 @@ begin if (toplevel_grab_broken_handler_id = 0) and (toplevel_motion_notify_handler_id = 0) and (toplevel_button_release_handler_id = 0) and (grab_notify_handler_id = 0) then begin - toplevel_grab_broken_handler_id := g_signal_connect(toplevel, 'grab-broken-event', G_CALLBACK(@grab_broken_event_cb), Self); - toplevel_motion_notify_handler_id := g_signal_connect(toplevel, 'motion-notify-event', G_CALLBACK(@toplevel_motion_notify_cb), Self); - toplevel_button_release_handler_id := g_signal_connect(toplevel, 'button-release-event', G_CALLBACK(@toplevel_button_release_cb), Self); - grab_notify_handler_id := g_signal_connect(FWidget, 'grab-notify', G_CALLBACK(@grab_notify_cb), Self); + toplevel_grab_broken_handler_id := g_signal_connect_data(PGObject(toplevel), 'grab-broken-event', TGCallback(@grab_broken_event_cb), Self, nil, G_CONNECT_DEFAULT); + toplevel_motion_notify_handler_id := g_signal_connect_data(PGObject(toplevel), 'motion-notify-event', TGCallback(@toplevel_motion_notify_cb), Self, nil, G_CONNECT_DEFAULT); + toplevel_button_release_handler_id := g_signal_connect_data(PGObject(toplevel), 'button-release-event', TGCallback(@toplevel_button_release_cb), Self, nil, G_CONNECT_DEFAULT); + grab_notify_handler_id := g_signal_connect_data(PGObject(FWidget), 'grab-notify', TGCallback(@grab_notify_cb), Self, nil, G_CONNECT_DEFAULT); drag_start_idx := gtk_notebook_get_current_page(GTK_NOTEBOOK(FWidget)); Result := True; @@ -1032,7 +1026,7 @@ begin dest->priv->motion_notify_handler_id = g_signal_connect (G_OBJECT (dest), "motion-notify-event", - G_CALLBACK (motion_notify_cb), + TGCallback (motion_notify_cb), NULL); *) @@ -1046,11 +1040,11 @@ begin // start drag handling in dest notebook dest.x_start := Trunc(event^.x_root); dest.y_start := Trunc(event^.y_root); - dest.motion_notify_handler_id := g_signal_connect(G_OBJECT(dest.FWidget), 'motion-notify-event', G_CALLBACK(@motion_notify_cb), dest); + dest.motion_notify_handler_id := g_signal_connect_data(PGObject(dest.FWidget), 'motion-notify-event', TGCallback(@motion_notify_cb), dest, nil, G_CONNECT_DEFAULT); dest.drag_start(event^.time); -{ dest.motion_notify_handler_id := g_signal_connect(G_OBJECT(dest.FWidget), 'motion-notify-event', G_CALLBACK(@motion_notify_cb), nil); +{ dest.motion_notify_handler_id := g_signal_connect(PGObject(dest.FWidget), 'motion-notify-event', TGCallback(@motion_notify_cb), nil); dest.drag_start(event^.time); } end; end; @@ -1073,7 +1067,7 @@ var tab: PGtkWidget; begin Result := False; ntb := TEphyNotebook(data); - tab := g_object_get_data(G_OBJECT(widget), 'child'); + tab := g_object_get_data(PGObject(widget), 'child'); position := gtk_notebook_page_num(GTK_NOTEBOOK(ntb.FWidget), GTK_WIDGET(tab)); // DebugMsg(['@******* label_ebox_button_pressed, button = ', event^.button, ', Position = ', position, ', data = 0x', IntToHex(Integer(data), 8), ', widget = 0x', IntToHex(Integer(widget), 8)]); @@ -1112,7 +1106,7 @@ begin ntb.x_start := Trunc(event^.x_root); ntb.y_start := Trunc(event^.y_root); DebugMsg(['@################# x_start = ', ntb.x_start, ', y_start = ', ntb.y_start]); - ntb.motion_notify_handler_id := g_signal_connect(G_OBJECT(notebook), 'motion-notify-event', G_CALLBACK(@motion_notify_cb), data); + ntb.motion_notify_handler_id := g_signal_connect_data(PGObject(notebook), 'motion-notify-event', TGCallback(@motion_notify_cb), data, nil, G_CONNECT_DEFAULT); end; if tab_clicked >= 0 then begin @@ -1203,17 +1197,17 @@ begin Exit; end; Dialog := gtk_message_dialog_new(ParentWindow, GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, TMessageStyleID[Integer(Style)], - GTK_BUTTONS_NONE, '%s', StringToPgchar(Text)); - CheckBox := PGtkCheckButton(gtk_check_button_new_with_mnemonic(StringToPgchar(DontShowAgainText))); + GTK_BUTTONS_NONE, '%s', PChar(Text)); + CheckBox := PGtkCheckButton(gtk_check_button_new_with_mnemonic(PChar(DontShowAgainText))); gtk_widget_show(PGtkWidget(CheckBox)); - gtk_box_pack_end(GTK_BOX(GTK_DIALOG(Dialog).vbox), PGtkWidget(CheckBox), False, False, 12); + gtk_box_pack_end(GTK_BOX(GTK_DIALOG(Dialog)^.vbox), PGtkWidget(CheckBox), False, False, 12); for i := 1 to NumMessageButtons do if TMessageButton(i - 1) in Buttons then begin w := gtk_dialog_add_button(PGtkDialog(Dialog), MessageButtonID[i], i); if TMessageButton(i - 1) = Default then gtk_widget_grab_focus(w); end; - if Escape <> mbNone then g_signal_connect(PGtkObject(Dialog), 'key-press-event', G_CALLBACK(@Gnome_MessageBox_key_press_event), - Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]})); + if Escape <> mbNone then g_signal_connect_data(PGObject(Dialog), 'key-press-event', TGCallback(@Gnome_MessageBox_key_press_event), + Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]}), nil, G_CONNECT_DEFAULT); if Default <> mbNone then gtk_dialog_set_default_response(PGtkDialog(Dialog), Ord(Default)); Result := TMessageButton(gtk_dialog_run(PGtkDialog(Dialog)) - 1); DontShowAgainChecked := gtk_toggle_button_get_active(PGtkToggleButton(CheckBox)); @@ -1244,7 +1238,7 @@ begin primary := g_strndup (AMessage, primary - AMessage); end; - if (primary <> nil) and (secondary <> nil) and (@gtk_message_dialog_new_with_markup <> nil) + if (primary <> nil) and (secondary <> nil) then dialog := gtk_message_dialog_new_with_markup (PGtkWindow(DialogParent), 0, GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, '%s'#10'%s', @@ -1359,8 +1353,8 @@ begin gtk_table_attach (GTK_TABLE (table), alabel, 0, 1, row, row + 1, GTK_FILL, GTK_EXPAND or GTK_FILL, 0, 0); gtk_table_attach_defaults (GTK_TABLE (table), PGtkWidget(entry), 1, 2, row, row + 1); gtk_label_set_mnemonic_widget (PGtkLabel(alabel), PGtkWidget(entry)); - g_signal_connect (entry, 'changed', G_CALLBACK (@pw_dialog_verify_input), user_data); - g_signal_connect (entry, 'activate', G_CALLBACK (@pw_dialog_cycle_focus), user_data); + g_signal_connect_data(PGObject(entry), 'changed', TGCallback (@pw_dialog_verify_input), user_data, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(entry), 'activate', TGCallback (@pw_dialog_cycle_focus), user_data, nil, G_CONNECT_DEFAULT); Result := entry; end; @@ -1439,14 +1433,14 @@ begin anon_box := gtk_vbox_new (FALSE, 6); gtk_box_pack_start (GTK_BOX (vbox), anon_box, FALSE, FALSE, 0); - priv.choice_anon := gtk_radio_button_new_with_mnemonic (nil, PChar(LANGGtkMountOperation_ConnectAnonymously)); - gtk_box_pack_start (GTK_BOX (anon_box), priv.choice_anon, FALSE, FALSE, 0); - g_signal_connect (priv.choice_anon, 'toggled', G_CALLBACK (@pw_dialog_anonymous_toggled), @priv); + priv.choice_anon := gtk_radio_button_new_with_mnemonic(nil, PChar(LANGGtkMountOperation_ConnectAnonymously)); + gtk_box_pack_start(GTK_BOX (anon_box), priv.choice_anon, FALSE, FALSE, 0); + g_signal_connect_data(PGObject(priv.choice_anon), 'toggled', TGCallback (@pw_dialog_anonymous_toggled), @priv, nil, G_CONNECT_DEFAULT); - group := gtk_radio_button_get_group (GTK_RADIO_BUTTON (priv.choice_anon)); - priv.choice_user := gtk_radio_button_new_with_mnemonic (group, PChar(LANGGtkMountOperation_ConnectAsUser)); - gtk_box_pack_start (GTK_BOX (anon_box), priv.choice_user, FALSE, FALSE, 0); - g_signal_connect (priv.choice_user, 'toggled', G_CALLBACK (@pw_dialog_anonymous_toggled), @priv); + group := LAZGLIB2.PGSList(gtk_radio_button_get_group(GTK_RADIO_BUTTON(priv.choice_anon))); + priv.choice_user := gtk_radio_button_new_with_mnemonic(GLIB2.PGSList(group), PChar(LANGGtkMountOperation_ConnectAsUser)); + gtk_box_pack_start(GTK_BOX(anon_box), priv.choice_user, FALSE, FALSE, 0); + g_signal_connect_data(PGObject(priv.choice_user), 'toggled', TGCallback (@pw_dialog_anonymous_toggled), @priv, nil, G_CONNECT_DEFAULT); end; rows := 0; @@ -1457,8 +1451,8 @@ begin // The table that holds the entries priv.entry_container := gtk_alignment_new (0.0, 0.0, 1.0, 1.0); - if can_anonymous then g_object_set (priv.entry_container, 'left-padding', 12, nil); - gtk_box_pack_start (GTK_BOX (vbox), priv.entry_container, FALSE, FALSE, 0); + if can_anonymous then g_object_set(PGObject(priv.entry_container), 'left-padding', [12, nil]); + gtk_box_pack_start(GTK_BOX(vbox), priv.entry_container, FALSE, FALSE, 0); table := gtk_table_new (rows, 2, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 12); @@ -1484,9 +1478,9 @@ begin if (flags and VFS_ASK_PASSWORD_ARCHIVE_MODE) = VFS_ASK_PASSWORD_ARCHIVE_MODE then begin unmask_checkbox := gtk_check_button_new_with_mnemonic (PChar(LANGFSetPassword_ShowPasswordCheckButton)); - g_object_set(G_OBJECT(unmask_checkbox), 'can-focus', 0, nil); + g_object_set(PGObject(unmask_checkbox), 'can-focus', [0, nil]); gtk_box_pack_start (GTK_BOX (vbox), unmask_checkbox, FALSE, FALSE, 0); - g_signal_connect (unmask_checkbox, 'toggled', G_CALLBACK (@unmask_checkbox_toggled), @priv); + g_signal_connect_data(PGObject(unmask_checkbox), 'toggled', TGCallback (@unmask_checkbox_toggled), @priv, nil, G_CONNECT_DEFAULT); end; if ((flags and VFS_ASK_PASSWORD_SAVING_SUPPORTED) = VFS_ASK_PASSWORD_SAVING_SUPPORTED) or @@ -1500,17 +1494,17 @@ begin radio_forget := gtk_radio_button_new_with_mnemonic (nil, s); gtk_box_pack_start (GTK_BOX (remember_box), radio_forget, FALSE, FALSE, 0); - group := gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_forget)); + group := LAZGLIB2.PGSList(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_forget))); // gnome-keyring only if (flags and VFS_ASK_PASSWORD_SAVING_SUPPORTED) = VFS_ASK_PASSWORD_SAVING_SUPPORTED then begin - radio_session := gtk_radio_button_new_with_mnemonic (group, PChar(LANGGtkMountOperation_RememberPasswordUntilYouLogout)); + radio_session := gtk_radio_button_new_with_mnemonic(GLIB2.PGSList(group), PChar(LANGGtkMountOperation_RememberPasswordUntilYouLogout)); gtk_box_pack_start (GTK_BOX (remember_box), radio_session, FALSE, FALSE, 0); - group := gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_session)); + group := LAZGLIB2.PGSList(gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio_session))); end; if (flags and VFS_ASK_PASSWORD_SAVING_SUPPORTED) = 0 then s := PChar(LANGGtkMountOperation_SavePasswordInConnectionManager) else s := PChar(LANGGtkMountOperation_RememberForever); - radio_remember := gtk_radio_button_new_with_mnemonic (group, s); + radio_remember := gtk_radio_button_new_with_mnemonic(GLIB2.PGSList(group), s); gtk_box_pack_start (GTK_BOX (remember_box), radio_remember, FALSE, FALSE, 0); // Select to save password when internal saving is supported @@ -1610,101 +1604,25 @@ end; (********************************************************************************************************************************) (********************************************************************************************************************************) -procedure SetupGnomeLibs; -var g: Pointer; -begin - try - if Assigned(gnome_program_init) and Assigned(libgnomeui_module_info_get) and Assigned(libgnome_module_info_get) then begin - DebugMsg(['Initializing Gnome...']); - g := gnome_program_init('TuxCommander', PChar(ConstAboutVersion), libgnomeui_module_info_get, GTKForms.argc, GTKForms.argv, - 'show-crash-dialog', 0, nil); - DebugMsg([' *GnomeProgram = ', g]); - - end; - except end; -end; - procedure LoadGnomeLibs; begin // Set default values - @gnome_about_new := nil; - @gnome_program_init := nil; - @libgnome_module_info_get := nil; - @libgnomeui_module_info_get := nil; - @gnome_color_picker_new := nil; - @gnome_color_picker_get_i16 := nil; - @gnome_color_picker_set_i16 := nil; - @gnome_icon_entry_new := nil; - @gnome_icon_entry_set_pixmap_subdir := nil; - @gnome_icon_entry_get_filename := nil; - @gnome_icon_entry_set_filename := nil; - @gnome_date_edit_new := nil; - @gnome_date_edit_set_time := nil; - @gnome_date_edit_get_time := nil; - @gtk_event_box_set_visible_window := nil; - @gtk_icon_size_lookup_for_settings := nil; - @gtk_window_set_icon_name := nil; - @g_filename_display_name := nil; - @gtk_message_dialog_new_with_markup := nil; - @g_mkdir_with_parents := nil; - @__g_io_error_from_errno := nil; - - // Dynamic loading - libGlib2Handle := dlopen('libglib-2.0.so.0', RTLD_LAZY); - if libGlib2Handle = nil then libGlib2Handle := dlopen('libglib-2.0.so', RTLD_LAZY); - if libGlib2Handle <> nil then begin - @g_filename_display_name := dlsym(libGlib2Handle, 'g_filename_display_name'); - @g_mkdir_with_parents := dlsym(libGlib2Handle, 'g_mkdir_with_parents'); - DebugMsg(['libglib-2.0.so loaded, @g_filename_display_name = ', @g_filename_display_name]); - end; - libGio2Handle := dlopen('libgio-2.0.so.0', RTLD_LAZY); - if libGio2Handle = nil then libGio2Handle := dlopen('libgio-2.0.so', RTLD_LAZY); - if libGio2Handle <> nil then begin - @__g_io_error_from_errno := dlsym(libGio2Handle, 'g_io_error_from_errno'); - end; - libGtk2Handle := dlopen('libgtk-x11-2.0.so.0', RTLD_LAZY); - if libGtk2Handle = nil then libGtk2Handle := dlopen('libgtk-x11-2.0.so', RTLD_LAZY); - if libGtk2Handle <> nil then begin - @gtk_event_box_set_visible_window := dlsym(libGtk2Handle, 'gtk_event_box_set_visible_window'); - @gtk_icon_size_lookup_for_settings := dlsym(libGtk2Handle, 'gtk_icon_size_lookup_for_settings'); - @gtk_window_set_icon_name := dlsym(libGtk2Handle, 'gtk_window_set_icon_name'); - @gtk_message_dialog_new_with_markup := dlsym(libGtk2Handle, 'gtk_message_dialog_new_with_markup'); - DebugMsg(['libgtk-x11-2.0.so loaded, @gtk_event_box_set_visible_window = ', @gtk_event_box_set_visible_window, - ', @gtk_icon_size_lookup_for_settings = ', @gtk_icon_size_lookup_for_settings]); - end; - libGnome2Handle := dlopen('libgnome-2.so.0', RTLD_LAZY); - if libGnome2Handle = nil then libGnome2Handle := dlopen('libgnome-2.so', RTLD_LAZY); - if libGnome2Handle <> nil then begin - @gnome_program_init := dlsym(libGnome2Handle, 'gnome_program_init'); - @libgnome_module_info_get := dlsym(libGnome2Handle, 'libgnome_module_info_get'); - DebugMsg(['libgnome-2.so loaded, @gnome_program_init = ', @gnome_program_init, ', @libgnome_module_info_get = ', @libgnome_module_info_get]); - end; - libGnomeUI2Handle := dlopen('libgnomeui-2.so.0', RTLD_LAZY); - if libGnomeUI2Handle = nil then libGnomeUI2Handle := dlopen('libgnomeui-2.so', RTLD_LAZY); - if libGnomeUI2Handle <> nil then begin - @gnome_about_new := dlsym(libGnomeUI2Handle, 'gnome_about_new'); - @gnome_color_picker_new := dlsym(libGnomeUI2Handle, 'gnome_color_picker_new'); - @gnome_color_picker_get_i16 := dlsym(libGnomeUI2Handle, 'gnome_color_picker_get_i16'); - @gnome_color_picker_set_i16 := dlsym(libGnomeUI2Handle, 'gnome_color_picker_set_i16'); - @libgnomeui_module_info_get := dlsym(libGnomeUI2Handle, 'libgnomeui_module_info_get'); - @gnome_icon_entry_new := dlsym(libGnomeUI2Handle, 'gnome_icon_entry_new'); - @gnome_icon_entry_set_pixmap_subdir := dlsym(libGnomeUI2Handle, 'gnome_icon_entry_set_pixmap_subdir'); - @gnome_icon_entry_get_filename := dlsym(libGnomeUI2Handle, 'gnome_icon_entry_get_filename'); - @gnome_icon_entry_set_filename := dlsym(libGnomeUI2Handle, 'gnome_icon_entry_set_filename'); - @gnome_date_edit_new := dlsym(libGnomeUI2Handle, 'gnome_date_edit_new'); - @gnome_date_edit_set_time := dlsym(libGnomeUI2Handle, 'gnome_date_edit_set_time'); - @gnome_date_edit_get_time := dlsym(libGnomeUI2Handle, 'gnome_date_edit_get_time'); - DebugMsg(['libgnomeui-2.so loaded, @gnome_about_new = ', @gnome_about_new, ', @gnome_color_picker_new = ', @gnome_color_picker_new, - ', @gnome_icon_entry_new = 0x', @gnome_icon_entry_new, ', @gnome_date_edit_new = ', @gnome_date_edit_new, - ', @libgnomeui_module_info_get = ', @libgnomeui_module_info_get]); - end; - SetupGnomeLibs; + gnome_about_new := nil; + gnome_program_init := nil; + libgnome_module_info_get := nil; + libgnomeui_module_info_get := nil; + gnome_color_picker_new := nil; + gnome_color_picker_get_i16 := nil; + gnome_color_picker_set_i16 := nil; + gnome_icon_entry_new := nil; + gnome_icon_entry_set_pixmap_subdir := nil; + gnome_icon_entry_get_filename := nil; + gnome_icon_entry_set_filename := nil; + gnome_date_edit_new := nil; + gnome_date_edit_set_time := nil; + gnome_date_edit_get_time := nil; end; -initialization -finalization -// if libGnomeUI2Handle <> 0 then FreeLibrary(libGnomeUI2Handle); -// if libGnome2Handle <> 0 then FreeLibrary(libGnome2Handle); end. diff --git a/ULibc.pas b/ULibc.pas index f7fa32f..cf3e528 100644 --- a/ULibc.pas +++ b/ULibc.pas @@ -21,9 +21,7 @@ unit ULibc; interface -{$IFDEF FPC} - {$PACKRECORDS C} -{$ENDIF} +{$PACKRECORDS C} const GLIBC_LIB = 'libc.so.6'; DL_LIB = 'libdl.so.2'; diff --git a/ULocale.pas b/ULocale.pas index d591187..5fc62a0 100644 --- a/ULocale.pas +++ b/ULocale.pas @@ -251,10 +251,11 @@ uses SysUtils, UTranslation_EN, UTranslation_CZ, UTranslation_RU, UTranslation_D UTranslation_ES, UTranslation_PL, UTranslation_UA, UTranslation_SR, UTranslation_HU, UTranslation_IT, UTranslation_CHT, UTranslation_CHS, UTranslation_SK, UTranslation_PT, UTranslation_KO; - +type PLangProc = ^TLangProc; + TLangProc = procedure (); const LangTable: array of string = nil; - LangProcTable: array of pointer = nil; + LangProcTable: array of PLangProc = nil; var Lang: string; @@ -281,7 +282,7 @@ end; procedure SetTranslationTexts(ForceLocale: string = ''); var LangIdx: integer; - SetProc: procedure; + SetProc: TLangProc; begin if not (Assigned(LangTable) and (Length(LangTable) > 0)) then begin WriteLn('**** tuxcmd CRITICAL: No usable translations found. At least one is required. Probably you have compiled the application incorrectly.'); @@ -290,10 +291,10 @@ begin // Assign default language - English try Lang := 'EN'; - LangIdx := LookupLanguages; + LangIdx := LookupLanguages(); if LangIdx >= 0 then begin - SetProc := LangProcTable[LangIdx]; - SetProc; + SetProc := TLangProc(LangProcTable[LangIdx]); + SetProc(); end; except end; // Assign other languages @@ -305,22 +306,22 @@ begin if Length(Trim(Lang)) = 0 then Lang := 'en_US'; // Default language end else Lang := ForceLocale; Lang := Trim(AnsiUpperCase(Lang)); - LangIdx := LookupLanguages; + LangIdx := LookupLanguages(); if (LangIdx = -1) and (Length(Lang) > 5) then begin Lang := Copy(Lang, 1, 5); - LangIdx := LookupLanguages; + LangIdx := LookupLanguages(); end; if (LangIdx = -1) and (Length(Lang) > 2) then begin Lang := Copy(Lang, 1, 2); - LangIdx := LookupLanguages; + LangIdx := LookupLanguages(); end; if LangIdx = -1 then begin Lang := 'EN'; - LangIdx := LookupLanguages; + LangIdx := LookupLanguages(); end; - SetProc := LangProcTable[LangIdx]; + SetProc := TLangProc(LangProcTable[LangIdx]); try - SetProc; + SetProc(); except on E: Exception do WriteLn('*** Exception ', E.ClassName, ' raised in SetProc - language ', LangTable[LangIdx], ', procedure @ ', integer(@SetProc), ': ', E.Message); end; diff --git a/UMain.pas b/UMain.pas index 359397f..69258e2 100644 --- a/UMain.pas +++ b/UMain.pas @@ -22,7 +22,7 @@ unit UMain; interface uses - gtk2, gdk2, gdk2pixbuf, glib2, pango, StrUtils, SysUtils, Types, Classes, DateUtils, + gtk2, gdk2, gdk2pixbuf, lazglib2, lazgobject2, pango, StrUtils, SysUtils, Types, Classes, DateUtils, GTKForms, GTKControls, GTKMenus, GTKStdCtrls, GTKExtCtrls, GTKView, GTKConsts, GTKUtils, GTKClasses, GTKPixbuf, UEngines, UConfig, UGnome, UVFSCore, UCoreClasses; @@ -175,7 +175,6 @@ type function NotebookFindNotebookAtPointerEvent(Sender: TObject; const AbsX, AbsY: integer): TEphyNotebook; function NotebookMoveTabToAnotherNotebook(Sender: TObject; Destination: TEphyNotebook; const SourceTabNo, DestTabNo: integer): boolean; procedure NotebookTabFocusOnlyEvent(Sender: TObject; const TabNum: integer); - procedure miFilePropertiesClick(Sender: TObject); procedure PasswordButtonClick(Sender: TObject); procedure miPathBoxCopyPathClick(Sender: TObject); procedure miCopyNamesClick(Sender: TObject); @@ -221,22 +220,22 @@ type procedure EditViewFile(LeftPanel: boolean; AListView: TGTKListView; View, NewFile: boolean); procedure RunFile(Path: string; Engine: TPanelEngine; CustomAction: integer); function ActivateCommandLine(Key: word; const ActualPosition: boolean = False): boolean; - procedure ApplySettings(RebuildListViews, RebuildIcons, Startup: boolean); + procedure ApplySettings(RebuildListViews, RebuildIcons, AStartup: boolean); procedure RefreshBookmarksMenu; procedure PopupFileMenuPos; procedure HandleFormFocusIn; procedure SwitchPanelCtrlLeftRight(LeftPanel, LeftArrowPressed: boolean); procedure FillMounterBar; - procedure RebuildListViews(DoRefresh: boolean); + procedure RebuildListViews(ADoRefresh: boolean); procedure FillPluginMenu; procedure NewTab(LeftPanel, SendSelectedDirToBg: boolean; CustomPath: string = ''); - procedure SwitchTab(TabNo: integer; LeftPanel, SetFocus: boolean); + procedure SwitchTab(TabNo: integer; LeftPanel, ASetFocus: boolean); procedure CloseTab(TabNo: integer; LeftPanel, CloseVFSEngine: boolean); procedure AddTabs(LeftPanel: boolean; TabList: TStringList; TabSortIDs, TabSortTypes: TList; SetTabActive: integer); function HandleVFSArchive(LeftPanel: boolean; const FullPath, HighlightItem, TargetPath: string): boolean; function CloseVFS(LeftPanel, SuppressRefresh: boolean): string; procedure ShowBookmarkQuick(LeftPanel: boolean); - procedure SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, Tooltip: string); + procedure SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, ATooltip: string); procedure NewTabInternal(LeftPanel: boolean; _Engine: TPanelEngine; _Path: string; NewTabPosition: integer; SwitchToNewTab: boolean); procedure CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean); function HandleRunFromArchive(var APath: string; Engine: TPanelEngine; Command, FileTypeDesc: string; BypassDialog: boolean): boolean; @@ -263,7 +262,7 @@ uses ULibc, UCoreUtils, ULocale, UChecksum, UChecksumDruid, USplitFile, UFileTypeSettings, UFileAssoc, UChmod, UChown, USymlink, UPreferences, UViewer, UToolTips, UMounterPrefs, UColumns, - UTestPlugin, UConnectionManager, USearch, UProperties, + UTestPlugin, UConnectionManager, USearch, URunFromVFS, uVFSprototypes, UQuickConnect, UConnectionProperties, UError; @@ -309,13 +308,13 @@ begin ConstructMenu; InplaceEditTimer := TGTKTimer.Create(Self); InplaceEditTimer.Enabled := False; - InplaceEditTimer.OnTimer := InplaceEditTimerTimer; + InplaceEditTimer.OnTimer := @InplaceEditTimerTimer; RebuildListViewsTimer := TGTKTimer.Create(Self); RebuildListViewsTimer.Enabled := False; - RebuildListViewsTimer.OnTimer := RebuildListViewsTimerTimer; + RebuildListViewsTimer.OnTimer := @RebuildListViewsTimerTimer; RightMouseSelectPopupTimer := TGTKTimer.Create(Self); RightMouseSelectPopupTimer.Enabled := False; - RightMouseSelectPopupTimer.OnTimer := RightMouseSelectPopupTimerTimer; + RightMouseSelectPopupTimer.OnTimer := @RightMouseSelectPopupTimerTimer; MounterBarHandleBox := TGTKHandleBox.Create(Self); MounterBarHandleBox.SetSizeRequest(10, -1); MainVBox.AddControlEx(MounterBarHandleBox, False, True, 0); @@ -344,7 +343,7 @@ begin OpenTerminalButton.BorderStyle := bsNone; OpenTerminalButton.CanFocus := False; OpenTerminalButton.Tooltip := LANGOpenTerminalButton_Tooltip; - OpenTerminalButton.OnClick := OpenTerminalButtonClick; + OpenTerminalButton.OnClick := @OpenTerminalButtonClick; CommandLineHBox.AddControlEx(CommandLineLabel, False, False, 0); CommandLineHBox.AddControlEx(CommandLineCombo, True, True, 5); CommandLineHBox.AddControlEx(TGTKVSeparator.Create(Self), False, False, 2); @@ -391,13 +390,13 @@ begin F6Button.Caption := LANGF6Button_Caption; F7Button.Caption := LANGF7Button_Caption; F8Button.Caption := LANGF8Button_Caption; - F2Button.OnClick := F6ButtonClick; - F3Button.OnClick := F3F4ButtonClick; - F4Button.OnClick := F3F4ButtonClick; - F5Button.OnClick := F5ButtonClick; - F6Button.OnClick := F6ButtonClick; - F7Button.OnClick := F7ButtonClick; - F8Button.OnClick := F8ButtonClick; + F2Button.OnClick := @F6ButtonClick; + F3Button.OnClick := @F3F4ButtonClick; + F4Button.OnClick := @F3F4ButtonClick; + F5Button.OnClick := @F5ButtonClick; + F6Button.OnClick := @F6ButtonClick; + F7Button.OnClick := @F7ButtonClick; + F8Button.OnClick := @F8ButtonClick; F2Button.CanFocus := False; F3Button.CanFocus := False; F4Button.CanFocus := False; @@ -405,51 +404,51 @@ begin F6Button.CanFocus := False; F7Button.CanFocus := False; F8Button.CanFocus := False; - PanelSeparator.OnMouseUp := PanelSeparatorMouseUp; + PanelSeparator.OnMouseUp := @PanelSeparatorMouseUp; // Events - OnResize := FormResize; - OnDestroy := FormDestroy; - OnKeyDown := FormKeyDown; - OnClose := FormClose; - g_signal_connect_after(FWidget, 'event-after', G_CALLBACK(@form_event_handler), nil); - PanelSeparator.OnResize := PanelSeparatorResize; - LeftListView.OnKeyDown := ListViewKeyDown; - RightListView.OnKeyDown := ListViewKeyDown; - LeftListView.OnEnter := ListViewEnter; - RightListView.OnEnter := ListViewEnter; - LeftPathLabelEventBox.OnMouseDown := PathLabelMouseDown; - RightPathLabelEventBox.OnMouseDown := PathLabelMouseDown; - LeftUpButton.OnClick := PathButtonClick; - LeftRootButton.OnClick := PathButtonClick; - LeftHomeButton.OnClick := PathButtonClick; - RightUpButton.OnClick := PathButtonClick; - RightRootButton.OnClick := PathButtonClick; - RightHomeButton.OnClick := PathButtonClick; - LeftEqualButton.OnClick := miTargetSourceClick; - RightEqualButton.OnClick := miTargetSourceClick; - LeftDisconnectButton.OnClick := DisconnectButtonClick; - RightDisconnectButton.OnClick := DisconnectButtonClick; - LeftLeaveArchiveButton.OnClick := LeaveArchiveButtonClick; - RightLeaveArchiveButton.OnClick := LeaveArchiveButtonClick; - LeftListView.CompareFunc := CompareFunc; - RightListView.CompareFunc := CompareFunc; - LeftListView.CellDataFunc := ListViewCellDataFunc; - RightListView.CellDataFunc := ListViewCellDataFunc; - LeftListView.OnMouseDown := ListViewMouseDown; - RightListView.OnMouseDown := ListViewMouseDown; - LeftListView.OnMouseUp := ListViewMouseUp; - RightListView.OnMouseUp := ListViewMouseUp; -{ LeftListView.OnDblClick := ListViewDblClick; - RightListView.OnDblClick := ListViewDblClick;} - LeftListView.OnSelectionChanged := ListViewSelectionChanged; - RightListView.OnSelectionChanged := ListViewSelectionChanged; - LeftListView.OnMouseMove := ListViewMouseMove; - RightListView.OnMouseMove := ListViewMouseMove; - LeftQuickFindEntry.OnEnter := QuickFindEntryEnter; - RightQuickFindEntry.OnEnter := QuickFindEntryEnter; - LeftPanelNotebook.OnTabSwitched := TabNotebookSwitchPage; - RightPanelNotebook.OnTabSwitched := TabNotebookSwitchPage; + OnResize := @FormResize; + OnDestroy := @FormDestroy; + OnKeyDown := @FormKeyDown; + OnClose := @FormClose; + g_signal_connect_data(PGObject(FWidget), 'event-after', TGCallback(@form_event_handler), nil, nil, [G_CONNECT_AFTER]); + PanelSeparator.OnResize := @PanelSeparatorResize; + LeftListView.OnKeyDown := @ListViewKeyDown; + RightListView.OnKeyDown := @ListViewKeyDown; + LeftListView.OnEnter := @ListViewEnter; + RightListView.OnEnter := @ListViewEnter; + LeftPathLabelEventBox.OnMouseDown := @PathLabelMouseDown; + RightPathLabelEventBox.OnMouseDown := @PathLabelMouseDown; + LeftUpButton.OnClick := @PathButtonClick; + LeftRootButton.OnClick := @PathButtonClick; + LeftHomeButton.OnClick := @PathButtonClick; + RightUpButton.OnClick := @PathButtonClick; + RightRootButton.OnClick := @PathButtonClick; + RightHomeButton.OnClick := @PathButtonClick; + LeftEqualButton.OnClick := @miTargetSourceClick; + RightEqualButton.OnClick := @miTargetSourceClick; + LeftDisconnectButton.OnClick := @DisconnectButtonClick; + RightDisconnectButton.OnClick := @DisconnectButtonClick; + LeftLeaveArchiveButton.OnClick := @LeaveArchiveButtonClick; + RightLeaveArchiveButton.OnClick := @LeaveArchiveButtonClick; + LeftListView.CompareFunc := @CompareFunc; + RightListView.CompareFunc := @CompareFunc; + LeftListView.CellDataFunc := @ListViewCellDataFunc; + RightListView.CellDataFunc := @ListViewCellDataFunc; + LeftListView.OnMouseDown := @ListViewMouseDown; + RightListView.OnMouseDown := @ListViewMouseDown; + LeftListView.OnMouseUp := @ListViewMouseUp; + RightListView.OnMouseUp := @ListViewMouseUp; +{ LeftListView.OnDblClick := @ListViewDblClick; + RightListView.OnDblClick := @ListViewDblClick;} + LeftListView.OnSelectionChanged := @ListViewSelectionChanged; + RightListView.OnSelectionChanged := @ListViewSelectionChanged; + LeftListView.OnMouseMove := @ListViewMouseMove; + RightListView.OnMouseMove := @ListViewMouseMove; + LeftQuickFindEntry.OnEnter := @QuickFindEntryEnter; + RightQuickFindEntry.OnEnter := @QuickFindEntryEnter; + LeftPanelNotebook.OnTabSwitched := @TabNotebookSwitchPage; + RightPanelNotebook.OnTabSwitched := @TabNotebookSwitchPage; LeftPanelNotebook.PopupMenu := TabPopupMenu; RightPanelNotebook.PopupMenu := TabPopupMenu; AfterStart; @@ -495,10 +494,10 @@ begin RightBookmarkButton.CanFocus := False; LeftPasswordButton.CanFocus := False; RightPasswordButton.CanFocus := False; - LeftBookmarkButton.OnClick := BookmarkButtonClick; - RightBookmarkButton.OnClick := BookmarkButtonClick; - LeftPasswordButton.OnClick := PasswordButtonClick; - RightPasswordButton.OnClick := PasswordButtonClick; + LeftBookmarkButton.OnClick := @BookmarkButtonClick; + RightBookmarkButton.OnClick := @BookmarkButtonClick; + LeftPasswordButton.OnClick := @PasswordButtonClick; + RightPasswordButton.OnClick := @PasswordButtonClick; LeftScrolledWindow := TGTKScrolledWindow.Create(Self); RightScrolledWindow := TGTKScrolledWindow.Create(Self); LeftListView := TGTKListView.CreateTyped(Self, True, [lcPointer]); @@ -577,12 +576,12 @@ begin LeftPanelNotebook.AllowDragDrop := True; LeftPanelNotebook.AllowDragOutside := True; LeftPanelNotebook.ShowTooltips := True; - LeftPanelNotebook.OnNotebookReordered := NotebookReordered; - LeftPanelNotebook.OnTabClose := NotebookTabClosed; - LeftPanelNotebook.OnTabDoubleClick := NotebookTabDoubleClick; - LeftPanelNotebook.OnFindNotebookAtPointer := NotebookFindNotebookAtPointerEvent; - LeftPanelNotebook.OnMoveTabToAnotherNotebook := NotebookMoveTabToAnotherNotebook; - LeftPanelNotebook.OnTabFocusOnlyEvent := NotebookTabFocusOnlyEvent; + LeftPanelNotebook.OnNotebookReordered := @NotebookReordered; + LeftPanelNotebook.OnTabClose := @NotebookTabClosed; + LeftPanelNotebook.OnTabDoubleClick := @NotebookTabDoubleClick; + LeftPanelNotebook.OnFindNotebookAtPointer := @NotebookFindNotebookAtPointerEvent; + LeftPanelNotebook.OnMoveTabToAnotherNotebook := @NotebookMoveTabToAnotherNotebook; + LeftPanelNotebook.OnTabFocusOnlyEvent := @NotebookTabFocusOnlyEvent; RightPanelNotebook := TEphyNotebook.Create(Self); RightPanelNotebook.Visible := False; RightPanelNotebook.SetSizeRequest(10, -1); @@ -593,12 +592,12 @@ begin RightPanelNotebook.AllowDragDrop := True; RightPanelNotebook.AllowDragOutside := True; RightPanelNotebook.ShowTooltips := True; - RightPanelNotebook.OnNotebookReordered := NotebookReordered; - RightPanelNotebook.OnTabClose := NotebookTabClosed; - RightPanelNotebook.OnTabDoubleClick := NotebookTabDoubleClick; - RightPanelNotebook.OnFindNotebookAtPointer := NotebookFindNotebookAtPointerEvent; - RightPanelNotebook.OnMoveTabToAnotherNotebook := NotebookMoveTabToAnotherNotebook; - RightPanelNotebook.OnTabFocusOnlyEvent := NotebookTabFocusOnlyEvent; + RightPanelNotebook.OnNotebookReordered := @NotebookReordered; + RightPanelNotebook.OnTabClose := @NotebookTabClosed; + RightPanelNotebook.OnTabDoubleClick := @NotebookTabDoubleClick; + RightPanelNotebook.OnFindNotebookAtPointer := @NotebookFindNotebookAtPointerEvent; + RightPanelNotebook.OnMoveTabToAnotherNotebook := @NotebookMoveTabToAnotherNotebook; + RightPanelNotebook.OnTabFocusOnlyEvent := @NotebookTabFocusOnlyEvent; LeftListBox := TGTKVBox.Create(Self); LeftListBox.AddControlEx(LeftScrolledWindow, True, True, 0); RightListBox := TGTKVBox.Create(Self); @@ -702,54 +701,54 @@ begin miChangePermissions := TGTKMenuItem.CreateTyped(Self, itImageText); miChangePermissions.Caption := LANGmiChangePermissions_Caption; miChangePermissions.StockIcon := 'gtk-convert'; - miChangePermissions.OnClick := miChangePermissionsClick; + miChangePermissions.OnClick := @miChangePermissionsClick; mnuFile.Add(miChangePermissions); miChangeOwner := TGTKMenuItem.Create(Self); miChangeOwner.Caption := LANGmiChangeOwner_Caption; - miChangeOwner.OnClick := miChangeOwnerClick; + miChangeOwner.OnClick := @miChangeOwnerClick; mnuFile.Add(miChangeOwner); mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miCreateSymlink := TGTKMenuItem.CreateTyped(Self, itImageText); miCreateSymlink.Caption := LANGmiCreateSymlink_Caption; miCreateSymlink.StockIcon := 'gtk-jump-to'; - miCreateSymlink.OnClick := miCreateSymlinkClick; + miCreateSymlink.OnClick := @miCreateSymlinkClick; mnuFile.Add(miCreateSymlink); miEditSymlink := TGTKMenuItem.Create(Self); miEditSymlink.Caption := LANGmiEditSymlink_Caption; - miEditSymlink.OnClick := miEditSymlinkClick; + miEditSymlink.OnClick := @miEditSymlinkClick; mnuFile.Add(miEditSymlink); mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miSplitFile := TGTKMenuItem.Create(Self); miSplitFile.Caption := LANGmiSplitFileCaption; - miSplitFile.OnClick := miSplitFileClick; + miSplitFile.OnClick := @miSplitFileClick; mnuFile.Add(miSplitFile); miMergeFiles := TGTKMenuItem.Create(Self); miMergeFiles.Caption := LANGmiMergeFilesCaption; - miMergeFiles.OnClick := miMergeFilesClick; + miMergeFiles.OnClick := @miMergeFilesClick; mnuFile.Add(miMergeFiles); mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miVerifyChecksums := TGTKMenuItem.Create(Self); miVerifyChecksums.Caption := LANGmiVerifyChecksums; - miVerifyChecksums.OnClick := miVerifyChecksumsClick; + miVerifyChecksums.OnClick := @miVerifyChecksumsClick; mnuFile.Add(miVerifyChecksums); miCreateChecksums := TGTKMenuItem.Create(Self); miCreateChecksums.Caption := LANGmiCreateChecksumsCaption; - miCreateChecksums.OnClick := miCreateChecksumsClick; + miCreateChecksums.OnClick := @miCreateChecksumsClick; mnuFile.Add(miCreateChecksums); mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miDiff := TGTKMenuItem.Create(Self); miDiff.Caption := '_Diff'; - miDiff.OnClick := miDiffClick; + miDiff.OnClick := @miDiffClick; mnuFile.Add(miDiff); miSynchronizeDirs := TGTKMenuItem.Create(Self); miSynchronizeDirs.Caption := 'S_ynchronize directories'; - miSynchronizeDirs.OnClick := miSynchronizeDirsClick; + miSynchronizeDirs.OnClick := @miSynchronizeDirsClick; mnuFile.Add(miSynchronizeDirs); mnuFile.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miExit := TGTKMenuItem.CreateTyped(Self, itImageText); miExit.Caption := LANGmiExit_Caption; miExit.StockIcon := 'gtk-quit'; - miExit.OnClick := miExitClick; + miExit.OnClick := @miExitClick; mnuFile.Add(miExit); mnuMark := TGTKMenuItem.Create(Self); @@ -760,28 +759,28 @@ begin miSelectGroup.Caption := LANGmiSelectGroup_Caption; miSelectGroup.ShortCuts.Add(MakeGDKShortCut(GDK_KP_PLUS, False, False, False, False)); miSelectGroup.StockIcon := 'gtk-add'; - miSelectGroup.OnClick := mnuMarkClick; + miSelectGroup.OnClick := @mnuMarkClick; mnuMark.Add(miSelectGroup); miUnselectGroup := TGTKMenuItem.CreateTyped(Self, itImageText); miUnselectGroup.Caption := LANGmiUnselectGroup_Caption; miUnselectGroup.ShortCuts.Add(MakeGDKShortCut(GDK_KP_MINUS, False, False, False, False)); miUnselectGroup.StockIcon := 'gtk-remove'; - miUnselectGroup.OnClick := mnuMarkClick; + miUnselectGroup.OnClick := @mnuMarkClick; mnuMark.Add(miUnselectGroup); miSelectAll := TGTKMenuItem.Create(Self); miSelectAll.Caption := LANGmiSelectAll_Caption; miSelectAll.ShortCuts.Add(MakeGDKShortCut(GDK_KP_PLUS, False, False, False, True)); - miSelectAll.OnClick := mnuMarkClick; + miSelectAll.OnClick := @mnuMarkClick; mnuMark.Add(miSelectAll); miUnselectAll := TGTKMenuItem.Create(Self); miUnselectAll.Caption := LANGmiUnselectAll_Caption; miUnselectAll.ShortCuts.Add(MakeGDKShortCut(GDK_KP_MINUS, False, False, False, True)); - miUnselectAll.OnClick := mnuMarkClick; + miUnselectAll.OnClick := @mnuMarkClick; mnuMark.Add(miUnselectAll); miInvertSelection := TGTKMenuItem.Create(Self); miInvertSelection.Caption := LANGmiInvertSelection_Caption; miInvertSelection.ShortCuts.Add(MakeGDKShortCut(GDK_KP_ASTERISK, False, False, False, False)); - miInvertSelection.OnClick := mnuMarkClick; + miInvertSelection.OnClick := @mnuMarkClick; mnuMark.Add(miInvertSelection); mnuCommands := TGTKMenuItem.Create(Self); @@ -792,43 +791,43 @@ begin miSearch.StockIcon := 'gtk-find'; miSearch.Caption := LANGmiSearchCaption2; miSearch.ShortCuts.AddName('F7'); - miSearch.OnClick := miSearchClick; + miSearch.OnClick := @miSearchClick; mnuCommands.Add(miSearch); mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miRefresh := TGTKMenuItem.CreateTyped(Self, itImageText); miRefresh.Caption := LANGmiRefresh_Caption; miRefresh.StockIcon := 'gtk-refresh'; miRefresh.ShortCuts.AddName('R'); - miRefresh.OnClick := miRefreshClick; + miRefresh.OnClick := @miRefreshClick; mnuCommands.Add(miRefresh); miShowDirectorySizes := TGTKMenuItem.CreateTyped(Self, itImageText); miShowDirectorySizes.Caption := LANGmiShowDirectorySizes_Caption; - miShowDirectorySizes.OnClick := miShowDirectorySizesClick; + miShowDirectorySizes.OnClick := @miShowDirectorySizesClick; mnuCommands.Add(miShowDirectorySizes); mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miCopyNames := TGTKMenuItem.CreateTyped(Self, itImageText); miCopyNames.Caption := LANGCopyFileNamesToClipboard; miCopyNames.ShortCuts.AddName('F2'); - miCopyNames.OnClick := miCopyNamesClick; + miCopyNames.OnClick := @miCopyNamesClick; mnuCommands.Add(miCopyNames); miCopyFullPaths := TGTKMenuItem.CreateTyped(Self, itImageText); miCopyFullPaths.Caption := LANGCopyFullPathNamesToClipboard; miCopyFullPaths.ShortCuts.AddName('F2'); miCopyFullPaths.StockIcon := 'gtk-copy'; - miCopyFullPaths.OnClick := miCopyNamesClick; + miCopyFullPaths.OnClick := @miCopyNamesClick; mnuCommands.Add(miCopyFullPaths); mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miNewTab := TGTKMenuItem.CreateTyped(Self, itImageText); miNewTab.Caption := LANGmiNewTab_Caption; miNewTab.ShortCuts.AddName('T'); - miNewTab.OnClick := miDuplicateTabClick; + miNewTab.OnClick := @miDuplicateTabClick; miNewTab.StockIcon := 'gtk-index'; mnuCommands.Add(miNewTab); mnuCommands.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miTargetSource := TGTKMenuItem.CreateTyped(Self, itImageText); miTargetSource.Caption := LANGmiTargetSource_Caption; // miTargetSource.ShortCuts.AddName('O'); - miTargetSource.OnClick := miTargetSourceClick; + miTargetSource.OnClick := @miTargetSourceClick; mnuCommands.Add(miTargetSource); mnuShow := TGTKMenuItem.Create(Self); @@ -838,7 +837,7 @@ begin miShowDotFiles := TGTKMenuItem.CreateTyped(Self, itCheck); miShowDotFiles.Caption := LANGmiShowDotFiles_Caption; miShowDotFiles.Checked := ConfShowDotFiles; - miShowDotFiles.OnClick := miShowDotFilesClick; + miShowDotFiles.OnClick := @miShowDotFilesClick; miShowDotFiles.ShortCuts.Add(ShowDotFilesShortcut); mnuShow.Add(miShowDotFiles); mnuShow.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); @@ -857,20 +856,20 @@ begin miShowTwoMounterBar.Checked := ConfShowMounterBar = 2; mnuShow.Add(miShowTwoMounterBar); // Assign of the events has to be done after all radio items are created - miNoMounterBar.OnClick := miShowMounterBarClick; - miShowOneMounterBar.OnClick := miShowMounterBarClick; - miShowTwoMounterBar.OnClick := miShowMounterBarClick; + miNoMounterBar.OnClick := @miShowMounterBarClick; + miShowOneMounterBar.OnClick := @miShowMounterBarClick; + miShowTwoMounterBar.OnClick := @miShowMounterBarClick; mnuBookmarks := TGTKMenuItem.Create(Self); mnuBookmarks.Caption := LANGmnuBookmarks_Caption; - mnuBookmarks.OnPopup := mnuBookmarksPopup; - mnuBookmarks.OnClick := mnuBookmarksPopup; + mnuBookmarks.OnPopup := @mnuBookmarksPopup; + mnuBookmarks.OnClick := @mnuBookmarksPopup; MainMenu.Items.Add(mnuBookmarks); // mnuBookmarks.Add(TGTKMenuItem.CreateTyped(Self, itTearOff)); miAddBookmark := TGTKMenuItem.CreateTyped(Self, itImageText); miAddBookmark.Caption := LANGmiAddBookmark_Caption; miAddBookmark.StockIcon := 'gtk-add'; - miAddBookmark.OnClick := miAddBookmarkClick; + miAddBookmark.OnClick := @miAddBookmarkClick; mnuBookmarks.Add(miAddBookmark); miEditBookmarks := TGTKMenuItem.CreateTyped(Self, itImageText); miEditBookmarks.Caption := LANGmiEditBookmarks_Caption; @@ -884,7 +883,7 @@ begin BookmarkPopup := TGTKMenuItem.Create(Self); BookmarkPopupDelete := TGTKMenuItem.Create(Self); BookmarkPopupDelete.Caption := LANGBookmarkPopupDelete_Caption; - BookmarkPopupDelete.OnClick := BookmarkPopupDeleteClick; + BookmarkPopupDelete.OnClick := @BookmarkPopupDeleteClick; BookmarkPopup.Add(BookmarkPopupDelete); mnuNetwork := TGTKMenuItem.Create(Self); @@ -899,13 +898,13 @@ begin mnuNetwork.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miOpenConnection := TGTKMenuItem.CreateTyped(Self, itImageText); miOpenConnection.Caption := LANGmiOpenConnectionCaption; - miOpenConnection.OnClick := miOpenConnectionClick; + miOpenConnection.OnClick := @miOpenConnectionClick; miOpenConnection.StockIcon := 'gtk-connect'; miOpenConnection.ShortCuts.AddName('F'); mnuNetwork.Add(miOpenConnection); miQuickConnect := TGTKMenuItem.CreateTyped(Self, itImageText); miQuickConnect.Caption := LANGmiQuickConnectCaption; - miQuickConnect.OnClick := miQuickConnectClick; + miQuickConnect.OnClick := @miQuickConnectClick; miQuickConnect.ShortCuts.AddName('N'); mnuNetwork.Add(miQuickConnect); mnuNetwork.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); @@ -914,7 +913,7 @@ begin miDisconnect.Enabled := False; miDisconnect.ShortCuts.AddName('F'); miDisconnect.StockIcon := 'gtk-disconnect'; - miDisconnect.OnClick := miDisconnectClick; + miDisconnect.OnClick := @miDisconnectClick; mnuNetwork.Add(miDisconnect); mnuPlugins := TGTKMenuItem.Create(Self); @@ -923,7 +922,7 @@ begin // mnuPlugins.Add(TGTKMenuItem.CreateTyped(Self, itTearOff)); miTestPlugin := TGTKMenuItem.CreateTyped(Self, itImageText); miTestPlugin.Caption := LANGmiTestPluginCaption; - miTestPlugin.OnClick := miTestPluginClick; + miTestPlugin.OnClick := @miTestPluginClick; mnuPlugins.Add(miTestPlugin); mnuPlugins.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); @@ -934,24 +933,24 @@ begin miPreferences := TGTKMenuItem.CreateTyped(Self, itImageText); miPreferences.Caption := LANGmiPreferences_Caption; miPreferences.StockIcon := 'gtk-preferences'; - miPreferences.OnClick := miPreferencesClick; + miPreferences.OnClick := @miPreferencesClick; mnuSettings.Add(miPreferences); miFileTypes := TGTKMenuItem.CreateTyped(Self, itImageText); miFileTypes.Caption := LANGmiFileTypes_Caption; - miFileTypes.OnClick := miFileTypesClick; + miFileTypes.OnClick := @miFileTypesClick; mnuSettings.Add(miFileTypes); miMounterSettings := TGTKMenuItem.CreateTyped(Self, itImageText); miMounterSettings.Caption := LANGmiMounterSettingsCaption; - miMounterSettings.OnClick := miMounterSettingsClick; + miMounterSettings.OnClick := @miMounterSettingsClick; mnuSettings.Add(miMounterSettings); miColumns := TGTKMenuItem.CreateTyped(Self, itImageText); miColumns.Caption := LANGmiColumnsCaption; - miColumns.OnClick := miColumnsClick; + miColumns.OnClick := @miColumnsClick; mnuSettings.Add(miColumns); mnuSettings.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miSavePosition := TGTKMenuItem.CreateTyped(Self, itImageText); miSavePosition.Caption := LANGmiSavePositionCaption; - miSavePosition.OnClick := miSavePositionClick; + miSavePosition.OnClick := @miSavePositionClick; mnuSettings.Add(miSavePosition); mnuHelp := TGTKMenuItem.Create(Self); @@ -961,7 +960,7 @@ begin miAbout := TGTKMenuItem.CreateTyped(Self, itImageText); miAbout.Caption := LANGmiAbout_Caption; miAbout.StockIcon := 'gtk-about'; - miAbout.OnClick := miAboutClick; + miAbout.OnClick := @miAboutClick; mnuHelp.Add(miAbout); // Splitter popup menu @@ -971,52 +970,52 @@ begin Item := TGTKMenuItem.Create(Self); Item.Caption := Format('%d - %d', [i * 10, (10 - i) * 10]); Item.Data := Pointer(i * 10); - Item.OnClick := SplitterPopupMenuClick; + Item.OnClick := @SplitterPopupMenuClick; SplitterPopupMenu.Add(Item); end; // Files popup menu FilePopupMenu := TGTKMenuItem.Create(Self); - FilePopupMenu.OnPopup := FilePopupMenuPopup; + FilePopupMenu.OnPopup := @FilePopupMenuPopup; // Mounter popup menu MounterButtonPopupMenu := TGTKMenuItem.Create(Self); - MounterButtonPopupMenu.OnPopup := MounterButtonPopupMenuPopup; + MounterButtonPopupMenu.OnPopup := @MounterButtonPopupMenuPopup; miMount := TGTKMenuItem.CreateTyped(Self, itImageText); miMount.Caption := LANGmiMountCaption; miMount.StockIcon := 'gtk-connect'; - miMount.OnClick := miMountClick; + miMount.OnClick := @miMountClick; MounterButtonPopupMenu.Add(miMount); miUmount := TGTKMenuItem.CreateTyped(Self, itImageText); miUmount.Caption := LANGmiUmountCaption; miUmount.StockIcon := 'gtk-disconnect'; - miUmount.OnClick := miUmountClick; + miUmount.OnClick := @miUmountClick; MounterButtonPopupMenu.Add(miUmount); miEject := TGTKMenuItem.CreateTyped(Self, itImageText); miEject.Caption := LANGmiEjectCaption; // miEject.StockIcon := 'gtk-cdrom'; - miEject.OnClick := miEjectClick; + miEject.OnClick := @miEjectClick; MounterButtonPopupMenu.Add(miEject); // Tab popup menu TabPopupMenu := TGTKMenuItem.Create(Self); - TabPopupMenu.OnPopup := TabPopupMenuPopup; + TabPopupMenu.OnPopup := @TabPopupMenuPopup; miDuplicateTab := TGTKMenuItem.CreateTyped(Self, itImageText); miDuplicateTab.Caption := LANGmiDuplicateTabCaption; miDuplicateTab.ShortCuts.AddName('T'); - miDuplicateTab.OnClick := miDuplicateTabClick; + miDuplicateTab.OnClick := @miDuplicateTabClick; miDuplicateTab.StockIcon := 'gtk-index'; TabPopupMenu.Add(miDuplicateTab); TabPopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miCloseTab := TGTKMenuItem.CreateTyped(Self, itImageText); miCloseTab.Caption := LANGmiCloseTabCaption; miCloseTab.ShortCuts.AddName('W'); - miCloseTab.OnClick := miCloseTabClick; + miCloseTab.OnClick := @miCloseTabClick; miCloseTab.StockIcon := 'gtk-close'; TabPopupMenu.Add(miCloseTab); miCloseAllTabs := TGTKMenuItem.CreateTyped(Self, itImageText); miCloseAllTabs.Caption := LANGmiCloseAllTabsCaption; - miCloseAllTabs.OnClick := miCloseAllTabsClick; + miCloseAllTabs.OnClick := @miCloseAllTabsClick; TabPopupMenu.Add(miCloseAllTabs); // Path box popup menu @@ -1025,13 +1024,13 @@ begin miPathBoxRefresh.Caption := LANGmiRefresh_Caption; miPathBoxRefresh.StockIcon := 'gtk-refresh'; miPathBoxRefresh.ShortCuts.AddName('R'); - miPathBoxRefresh.OnClick := miRefreshClick; + miPathBoxRefresh.OnClick := @miRefreshClick; PathBoxPopupMenu.Add(miPathBoxRefresh); PathBoxPopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); miPathBoxCopyPath := TGTKMenuItem.CreateTyped(Self, itImageText); miPathBoxCopyPath.Caption := LANGCopyPathToClipboard; miPathBoxCopyPath.StockIcon := 'gtk-copy'; - miPathBoxCopyPath.OnClick := miPathBoxCopyPathClick; + miPathBoxCopyPath.OnClick := @miPathBoxCopyPathClick; PathBoxPopupMenu.Add(miPathBoxCopyPath); end; @@ -1056,10 +1055,10 @@ begin // Apply on the other side if LeftLV then AListView := FMain.RightListView else AListView := FMain.LeftListView; - HandlerID := gulong(g_object_get_data(G_OBJECT(AListView.Columns[i].FColumn), 'Width_Notify_Handler')); - g_signal_handler_block(AListView.Columns[i].FColumn, HandlerID); + HandlerID := gulong(g_object_get_data(PGObject(AListView.Columns[i].FColumn), 'Width_Notify_Handler')); + g_signal_handler_block(PGObject(AListView.Columns[i].FColumn), HandlerID); AListView.Columns[i].FixedWidth := ConfColumnSizes[AListView.Columns[i].Tag]; - g_signal_handler_unblock(AListView.Columns[i].FColumn, HandlerID); + g_signal_handler_unblock(PGObject(AListView.Columns[i].FColumn), HandlerID); break; end; end; @@ -1074,7 +1073,7 @@ begin GetFirstLastPanelColumn(FirstColumn, LastColumn); // Temporarily disable the fixed height mode to be able to add columns the Pascal way - g_object_set(ListView.FWidget, 'fixed_height_mode', 0, nil); + g_object_set(PGObject(ListView.FWidget), 'fixed_height_mode', [0, nil]); for i := 1 to ConstNumPanelColumns do if ConfColumnVisible[i] then begin @@ -1095,7 +1094,7 @@ begin Column.Caption := ConfColumnTitlesShort[ConfColumnIDs[i]]; - g_object_set(G_OBJECT(Column.FColumn), 'sizing', 2, 'fixed-width', ConfColumnSizes[i], nil); + g_object_set(PGObject(Column.FColumn), 'sizing', [2, 'fixed-width', ConfColumnSizes[i], nil]); gtk_tree_view_column_set_spacing(Column.FColumn, 1); // Bug with column spacing? @@ -1105,7 +1104,7 @@ begin Column.SetProperty('ypad', 0); Column.SetProperty('yalign', 0.5); Column.Tag := i; - g_object_set_data(G_OBJECT(Column.FColumn), 'Column_ID', Pointer(i)); + g_object_set_data(PGObject(Column.FColumn), 'Column_ID', Pointer(i)); if ConfRowHeight > 0 then Column.SetProperty('height', ConfRowHeight); Column.SortID := ListView.Columns.Count - 1; ColumnSortIDs[Column.SortID + 1] := ConfColumnIDs[i]; @@ -1113,7 +1112,7 @@ begin { gtk_cell_renderer_text_set_fixed_height_from_font(PGtkCellRendererText(Column.FRenderer), 1); gtk_cell_renderer_set_fixed_size(PGtkCellRenderer(Column.FRenderer), ConfColumnSizes[i], ConfRowHeight); } if ConfColumnIDs[i] < 3 then begin // Filename column - Column.OnEdited := ListViewEdited; + Column.OnEdited := @ListViewEdited; Column.SetProperty('ellipsize', 3); end; if ConfColumnIDs[i] in [4, 8, 9] then begin @@ -1121,9 +1120,9 @@ begin Column.Alignment := 1; end; Column.SetProperty('single-paragraph-mode', 1); - Column.OnClicked := ListViewColumnClicked; - HandlerID := g_signal_connect(Column.FColumn, 'notify::width', G_CALLBACK(@ListViewColumnResized), ListView); - g_object_set_data(G_OBJECT(Column.FColumn), 'Width_Notify_Handler', Pointer(HandlerID)); + Column.OnClicked := @ListViewColumnClicked; + HandlerID := g_signal_connect_data(PGObject(Column.FColumn), 'notify::width', TGCallback(@ListViewColumnResized), ListView, nil, G_CONNECT_DEFAULT); + g_object_set_data(PGObject(Column.FColumn), 'Width_Notify_Handler', Pointer(HandlerID)); end; // Set the list font @@ -1131,7 +1130,7 @@ begin FontDesc := pango_font_description_from_string(PChar(ConfPanelFont)); gtk_widget_modify_font(ListView.FWidget, FontDesc); end else gtk_widget_modify_font(ListView.FWidget, nil); - g_object_set(ListView.FWidget, 'fixed_height_mode', 1, nil); + g_object_set(PGObject(ListView.FWidget), 'fixed_height_mode', [1, nil]); end; procedure TFMain.FormDestroy(Sender: TObject); @@ -1205,7 +1204,7 @@ begin end else while Assigned(LeftTabEngines[i]) and (TPanelEngine(LeftTabEngines[i]) is TVFSEngine) do begin s := TPanelEngine(LeftTabEngines[i]).SavePath; - LeftTabEngines[i] := InternalCloseEngine(LeftTabEngines[i], LeftLocalEngine); + LeftTabEngines[i] := InternalCloseEngine(TPanelEngine(LeftTabEngines[i]), LeftLocalEngine); if s <> '' then LeftPanelTabs[i] := s else LeftPanelTabs[i] := TPanelEngine(LeftTabEngines[i]).Path; end; @@ -1224,7 +1223,7 @@ begin end else while Assigned(RightTabEngines[i]) and (TPanelEngine(RightTabEngines[i]) is TVFSEngine) do begin s := TPanelEngine(RightTabEngines[i]).SavePath; - RightTabEngines[i] := InternalCloseEngine(RightTabEngines[i], RightLocalEngine); + RightTabEngines[i] := InternalCloseEngine(TPanelEngine(RightTabEngines[i]), RightLocalEngine); if s <> '' then RightPanelTabs[i] := s else RightPanelTabs[i] := TPanelEngine(RightTabEngines[i]).Path; end; @@ -1347,8 +1346,8 @@ begin Application.ProcessMessages; // Need to process all messages before unlocking InternalLockInit(False); - LeftListView.OnColumnsChanged := ListViewColumnsChanged; - RightListView.OnColumnsChanged := ListViewColumnsChanged; + LeftListView.OnColumnsChanged := @ListViewColumnsChanged; + RightListView.OnColumnsChanged := @ListViewColumnsChanged; LeftListView.SetFocus; end; @@ -1720,7 +1719,6 @@ var Data: PDataItem; LeftPanel: boolean; DataList: TList; Engine: TPanelEngine; - AListView: TGTKListView; Ext: string; begin if LeftListView.Focused then LeftPanel := True @@ -1729,11 +1727,9 @@ begin if LeftPanel then begin DataList := LeftPanelData; Engine := LeftPanelEngine; - AListView := LeftListView; end else begin DataList := RightPanelData; Engine := RightPanelEngine; - AListView := RightListView; end; DeactivateQuickFind(LeftPanel); Data := DataList[ItemIndex]; @@ -2306,24 +2302,24 @@ begin if Editing and (InplaceEditItem.Data = Data) and (ColumnID < 3) and ((ColumnID = 0) or (ColumnID = 1) or Assigned(tree_column^.editable_widget)) then begin if (ColumnID = 0) or (ColumnID = 1) then s := FDisplayName else s := nil; - g_object_set(cell, 'text', s, 'foreground-gdk', AFGColor, nil); - g_object_set(cell, 'background-gdk', ABGColor, nil); + g_object_set(PGObject(cell), 'text', [s, 'foreground-gdk', AFGColor, nil]); + g_object_set(PGObject(cell), 'background-gdk', [ABGColor, nil]); end else begin // not editing if ConfDirsInBold then begin - if IsDir or UpDir then g_object_set(cell, 'markup', PChar(Format('%s', [QuoteMarkupStr(ColumnData[ColumnID])])), 'foreground-gdk', AFGColor, nil) - else g_object_set(cell, 'markup', PChar(QuoteMarkupStr(ColumnData[ColumnID])), 'foreground-gdk', AFGColor, nil); - end else g_object_set(cell, 'text', ColumnData[ColumnID], 'foreground-gdk', AFGColor, nil); - g_object_set(cell, 'background-gdk', ABGColor, nil); + if IsDir or UpDir then g_object_set(PGObject(cell), 'markup', [PChar(Format('%s', [QuoteMarkupStr(ColumnData[ColumnID])])), 'foreground-gdk', AFGColor, nil]) + else g_object_set(PGObject(cell), 'markup', [PChar(QuoteMarkupStr(ColumnData[ColumnID])), 'foreground-gdk', AFGColor, nil]); + end else g_object_set(PGObject(cell), 'text', [ColumnData[ColumnID], 'foreground-gdk', AFGColor, nil]); + g_object_set(PGObject(cell), 'background-gdk', [ABGColor, nil]); end; end else // this is the image column if ConfUseFileTypeIcons then begin // Assign icons - g_object_set(cell, 'cell-background-gdk', ABGColor, nil); + g_object_set(PGObject(cell), 'cell-background-gdk', [ABGColor, nil]); if Sel and (not (Sender as TGTKView).Focused) then begin if Sender = LeftListView then RedrawLeftInactive := True else RedrawRightInactive := True; end; - if Icon <> nil then g_object_set(cell, 'pixbuf', Icon, nil); + if Icon <> nil then g_object_set(PGObject(cell), 'pixbuf', [Icon, nil]); end; end; end; @@ -3530,7 +3526,7 @@ begin FFileTypeSettings.CleanItems; x := AssocList; AssocList := FFileTypeSettings.IntAssocList; - FFileTypeSettings.IntAssocList := x; + FFileTypeSettings.IntAssocList := TList(x); RecreateIcons(AssocList); DoRefresh(True, True, True); DoRefresh(False, True, True); @@ -4103,7 +4099,7 @@ begin Item.Caption := Format(LANGPopupRunS, [QuoteMarkupStr(StrToUTF8(ShortFName), True)]); Item.StockIcon := 'gtk-execute'; Item.Data := Pointer(1); - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; Item.Enabled := Engine.FileCanRun(FileName); FilePopupMenu.Add(Item); end else begin @@ -4113,7 +4109,7 @@ begin else Item.Caption := Format(LANGPopupOpenS, [QuoteMarkupStr(StrToUTF8(ShortFName), True)]); Item.StockIcon := 'gtk-open'; Item.Data := Pointer(1); - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; FilePopupMenu.Add(Item); // Open directory in background tab @@ -4121,7 +4117,7 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGOpenDirectoryInBackgroundTab; Item.Data := Pointer(3); - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; FilePopupMenu.Add(Item); end; end; @@ -4138,7 +4134,7 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := Format(LANGPopupOpenWithS, [TAssocAction(ActionList[j]).ActionName]); Item.Data := ActionList[j]; - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; FilePopupMenu.Add(Item); end; Break; @@ -4156,7 +4152,7 @@ begin if ((j = 0) and (Assoc.DefaultAction > Assoc.ActionList.Count - 1)) or (j = Assoc.DefaultAction) then Item.Caption := Item.Caption + LANGPopupDefault; Item.Data := Assoc.ActionList[j]; - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; FilePopupMenu.Add(Item); end; end; @@ -4165,7 +4161,7 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGPopupOpenWith; Item.Data := Pointer(2); - Item.OnClick := FilePopupMenuItemClick; + Item.OnClick := @FilePopupMenuItemClick; FilePopupMenu.Add(Item); end; @@ -4176,59 +4172,50 @@ begin Item.Caption := LANGPopupViewFile; Item.StockIcon := 'gtk-find'; Item.Data := Pointer(200); // This number HAVE to be here due to F3F4ButtonClick method using - Item.OnClick := F3F4ButtonClick; + Item.OnClick := @F3F4ButtonClick; FilePopupMenu.Add(Item); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGPopupEditFile; Item.Data := Pointer(201); // Here too - Item.OnClick := F3F4ButtonClick; + Item.OnClick := @F3F4ButtonClick; FilePopupMenu.Add(Item); end; if not DataItem^.IsDir then FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGPopupMakeSymlink; Item.StockIcon := 'gtk-jump-to'; - Item.OnClick := miCreateSymlinkClick; + Item.OnClick := @miCreateSymlinkClick; FilePopupMenu.Add(Item); if DataItem^.IsLnk then begin Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGmiEditSymlink_Caption; - Item.OnClick := miEditSymlinkClick; + Item.OnClick := @miEditSymlinkClick; FilePopupMenu.Add(Item); end; FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGmiChangePermissions_Caption; Item.StockIcon := 'gtk-convert'; - Item.OnClick := miChangePermissionsClick; + Item.OnClick := @miChangePermissionsClick; Item.Enabled := not UpDir; FilePopupMenu.Add(Item); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGmiChangeOwner_Caption; - Item.OnClick := miChangeOwnerClick; + Item.OnClick := @miChangeOwnerClick; Item.Enabled := not UpDir; FilePopupMenu.Add(Item); FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGPopupRename; - Item.OnClick := F6ButtonClick; + Item.OnClick := @F6ButtonClick; Item.Enabled := not UpDir; FilePopupMenu.Add(Item); Item := TGTKMenuItem.CreateTyped(Self, itImageText); Item.Caption := LANGPopupDelete; Item.StockIcon := 'gtk-delete'; - Item.OnClick := F8ButtonClick; + Item.OnClick := @F8ButtonClick; Item.Enabled := not UpDir; FilePopupMenu.Add(Item); -// FilePopupMenu.Add(TGTKMenuItem.CreateTyped(Self, itSeparator)); - Item := TGTKMenuItem.CreateTyped(Self, itImageText); - Item.Caption := LANGFilePopupMenu_Properties; - Item.StockIcon := 'gtk-properties'; - Item.OnClick := miFilePropertiesClick; - Item.Enabled := False; - Item.Visible := False; -// Item.Enabled := not UpDir; - FilePopupMenu.Add(Item); FreeDataItem(DataItem); end; @@ -4363,7 +4350,7 @@ begin end; end; -procedure TFMain.ApplySettings(RebuildListViews, RebuildIcons, Startup: boolean); +procedure TFMain.ApplySettings(RebuildListViews, RebuildIcons, AStartup: boolean); var i: integer; begin ButtonsBox.Visible := ConfShowFuncButtons; @@ -4419,7 +4406,7 @@ begin end; // Refresh the lists - if not Startup then begin + if not AStartup then begin DoRefresh(True, True, True); DoRefresh(False, True, True); if RebuildListViews then begin @@ -4451,8 +4438,8 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itLabel); Item.Caption := Format('_%s %s', [Chr(Ord('a') + i), StrToUTF8(QuoteMarkupStr(Bookmarks[i]))]); Item.Data := Pointer(i); - Item.OnClick := miBookmarkClick; - Item.OnMouseUp := BookmarkItemMouseUp; + Item.OnClick := @miBookmarkClick; + Item.OnMouseUp := @BookmarkItemMouseUp; if i < Length(ShortcutKeys) - 1 then Item.ShortCuts.AddName(Format('%s', [ShortcutKeys[i + 1]])); mnuBookmarks.Add(Item); end; @@ -4602,9 +4589,9 @@ var menu_requisition: TGtkRequisition; max_x, max_y: integer; begin (* Calculate our preferred position. *) - gdk_window_get_origin(PGtkWidget(user_data).Window, x, y); - x^ := x^ + PGtkWidget(user_data).allocation.x + PGtkWidget(user_data).allocation.width; - y^ := y^ + PGtkWidget(user_data).allocation.y + PGtkWidget(user_data).allocation.height; + gdk_window_get_origin(PGtkWidget(user_data)^.Window, x, y); + x^ := x^ + PGtkWidget(user_data)^.allocation.x + PGtkWidget(user_data)^.allocation.width; + y^ := y^ + PGtkWidget(user_data)^.allocation.y + PGtkWidget(user_data)^.allocation.height; (* Now make sure we are on the screen. *) gtk_widget_size_request(PGtkWidget(menu), @menu_requisition); @@ -4621,7 +4608,7 @@ begin miAddBookmark.Visible := True; miEditBookmarks.Visible := False; miBookmarksSeparator.Visible := mnuBookmarks.Count > 3; - gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, menu_position_cb, (Sender as TGTKControl).FWidget, 1, GDK_CURRENT_TIME); + gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, @menu_position_cb, (Sender as TGTKControl).FWidget, 1, GDK_CURRENT_TIME); if (Sender = LeftBookmarkButton) {and (not LeftLastFocused)} then LeftListView.SetFocus else if (Sender = RightBookmarkButton) {and LeftLastFocused} then RightListView.SetFocus; end; @@ -4667,7 +4654,7 @@ begin if LeftPanel then AListView := LeftListView else AListView := RightListView; FilePopupMenuPopup(AListView); - gtk_menu_popup(PGtkMenu(FilePopupMenu.FMenu), nil, nil, file_popup_position_cb, AListView, 0, gtk_get_current_event_time()); + gtk_menu_popup(PGtkMenu(FilePopupMenu.FMenu), nil, nil, @file_popup_position_cb, AListView, 0, gtk_get_current_event_time()); end; (********************************************************************************************************************************) @@ -4782,7 +4769,7 @@ procedure TFMain.FillMounterBar; Button.Tooltip := Format(LANGMountPointDevice, [StrToUTF8(MountPath), StrToUTF8(Device)]); Button.BorderStyle := bsNone; Button.PopupMenu := MounterButtonPopupMenu; - Button.OnMouseDown := MounterButtonMouseDown; + Button.OnMouseDown := @MounterButtonMouseDown; // Check the icon b := FileExists(IconPath); @@ -4806,7 +4793,7 @@ procedure TFMain.FillMounterBar; (Button as TGTKImageToggleButton).Checked := Mounted; end else (Button as TGTKImageButton).Icon := Pixmap; - Button.OnClick := MounterButtonClick; // It has to be here because setting the Checked property causes the signal emitting + Button.OnClick := @MounterButtonClick; // It has to be here because setting the Checked property causes the signal emitting Table.AddControlEx(2*i + 1, 0, 1, 1, Button, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 1); List.Add(Button); @@ -4850,7 +4837,7 @@ var Item: TMounterItem; begin if not (Sender is TGTKButton) then Exit; try - Item := Pointer((Sender as TGTKButton).Tag); + Item := TMounterItem((Sender as TGTKButton).Tag); if (not Assigned(Item)) or (Item.MountPath = '') then DebugMsg(['*** Error in mounter button: incorrect data']) else begin if MounterTableListLeft.IndexOf(Sender) > -1 then LeftPanel := True else if MounterTableListRight.IndexOf(Sender) > -1 then LeftPanel := False else LeftPanel := LeftLastFocused; @@ -4867,7 +4854,7 @@ begin if Pos(Item.MountPath, Engine.Path) = 1 then b := Item.Eject; (Sender as TGTKToggleButton).OnClick := nil; (Sender as TGTKToggleButton).Checked := Item.Mounted; - (Sender as TGTKToggleButton).OnClick := MounterButtonClick; + (Sender as TGTKToggleButton).OnClick := @MounterButtonClick; end else if not b then b := Item.Mount; if b then begin @@ -4929,7 +4916,7 @@ begin if ConfMounterPushDown then begin (LastMounterButton as TGTKToggleButton).OnClick := nil; (LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted; - (LastMounterButton as TGTKToggleButton).OnClick := MounterButtonClick; + (LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick; end; end; @@ -4941,7 +4928,7 @@ begin if ConfMounterPushDown then begin (LastMounterButton as TGTKToggleButton).OnClick := nil; (LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted; - (LastMounterButton as TGTKToggleButton).OnClick := MounterButtonClick; + (LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick; end; end; @@ -4953,7 +4940,7 @@ begin if ConfMounterPushDown then begin (LastMounterButton as TGTKToggleButton).OnClick := nil; (LastMounterButton as TGTKToggleButton).Checked := TMounterItem(LastMounterButton.Tag).Mounted; - (LastMounterButton as TGTKToggleButton).OnClick := MounterButtonClick; + (LastMounterButton as TGTKToggleButton).OnClick := @MounterButtonClick; end; end; @@ -5060,7 +5047,7 @@ begin gtk_tree_view_set_headers_visible(PGtkTreeView(SourceListView.FWidget), True); end; -procedure TFMain.RebuildListViews(DoRefresh: boolean); +procedure TFMain.RebuildListViews(ADoRefresh: boolean); begin LeftListView.OnColumnsChanged := nil; RightListView.OnColumnsChanged := nil; @@ -5074,23 +5061,23 @@ begin RightListView.Columns.Clear; ConstructColumns(LeftListView); ConstructColumns(RightListView); - if DoRefresh then begin + if ADoRefresh then begin Application.ProcessMessages; FMain.DoRefresh(True, True, True); FMain.DoRefresh(False, True, True); LeftListView.SetSortInfo(ConfMainWindowLeftSortColumn, TGTKTreeViewSortOrder(ConfMainWindowLeftSortType)); RightListView.SetSortInfo(ConfMainWindowRightSortColumn, TGTKTreeViewSortOrder(ConfMainWindowRightSortType)); end; - LeftListView.OnColumnsChanged := ListViewColumnsChanged; - RightListView.OnColumnsChanged := ListViewColumnsChanged; + LeftListView.OnColumnsChanged := @ListViewColumnsChanged; + RightListView.OnColumnsChanged := @ListViewColumnsChanged; end; procedure TFMain.RebuildListViewsTimerTimer(Sender: TObject); begin RebuildListViewsTimer.Enabled := False; RebuildListViews(True); - LeftListView.OnMouseUp := ListViewMouseUp; - RightListView.OnMouseUp := ListViewMouseUp; + LeftListView.OnMouseUp := @ListViewMouseUp; + RightListView.OnMouseUp := @ListViewMouseUp; end; (********************************************************************************************************************************) @@ -5111,7 +5098,7 @@ begin MenuItem2 := TGTKMenuItem.CreateTyped(Self, itImageText); MenuItem2.Caption := LANGPluginAbout; MenuItem2.Tag := i; - MenuItem2.OnClick := miPluginAboutClick; + MenuItem2.OnClick := @miPluginAboutClick; mnuPlugins.Add(MenuItem1); MenuItem1.Add(MenuItem2); end; @@ -5125,7 +5112,7 @@ begin InternalLock; FTestPlugin := TFTestPlugin.Create(Self); if (FTestPlugin.Run = mbOK) and (PluginList.Count > 0) then begin - Engine := TVFSEngine.Create(PluginList[FTestPlugin.PluginOptionMenu.ItemIndex]); + Engine := TVFSEngine.Create(TVFSPlugin(PluginList[FTestPlugin.PluginOptionMenu.ItemIndex])); if not Engine.VFSOpenURI(FTestPlugin.CommandEntry.Text, nil, nil, nil, nil, nil) then begin Application.MessageBox(LANGCouldntOpenURI, [mbOK], mbError, mbOK, mbOK); Exit; @@ -5151,9 +5138,9 @@ const Authors : array[0..1] of PChar = ('', nil); var AboutBox: PGtkWidget; VFSItem: TVFSPlugin; begin - VFSItem := PluginList[(Sender as TGTKMenuItem).Tag]; + VFSItem := TVFSPlugin(PluginList[(Sender as TGTKMenuItem).Tag]); InternalLock; - if (libGnomeUI2Handle = nil) or (@gnome_about_new = nil) then + if (libGnomeUI2Handle = nil) or (gnome_about_new = nil) then Application.MessageBox(Format(LANGPluginAboutInside, [VFSItem.ModuleName, VFSItem.ModuleAbout, VFSItem.ModuleCopyright])) else begin AboutBox := gnome_about_new(PChar(VFSItem.ModuleName), nil, PChar(VFSItem.ModuleCopyright), PChar(VFSItem.ModuleAbout), @Authors, nil, nil, AppIcon64.FPixbuf); @@ -5235,7 +5222,7 @@ begin end; if not DockedToNotebook then begin - ANotebook.InsertPage(0, AVBoxList[0], StrToUTF8(APathSave)); + ANotebook.InsertPage(0, TGTKControl(AVBoxList[0]), StrToUTF8(APathSave)); SetTabLabel(ANotebook, 0, StrToUTF8(APathSave), StrToUTF8(ATabList[0])); end; @@ -5290,7 +5277,7 @@ begin NewTabInternal(LeftPanel, AEngine, APath, NewTabPosition, not SendSelectedDirToBg); end; -procedure TFMain.SwitchTab(TabNo: integer; LeftPanel, SetFocus: boolean); +procedure TFMain.SwitchTab(TabNo: integer; LeftPanel, ASetFocus: boolean); var ANotebook: TEphyNotebook; AListView: TGTKListView; AVBoxList: TList; @@ -5315,7 +5302,7 @@ begin if (AVBoxList.Count < TabNo) or (TabNo < -1) then Exit; // Remove any objects - g_object_ref(AScrolledWindow.FWidget); + g_object_ref(PGObject(AScrolledWindow.FWidget)); if ListBox.ChildrenCount > 0 then ListBox.RemoveControl(AScrolledWindow); if AVBoxList.Count > 0 then for i := 0 to AVBoxList.Count - 1 do @@ -5330,8 +5317,8 @@ begin ListBox.Visible := True; ANotebook.Visible := False; end; - g_object_unref(AScrolledWindow.FWidget); - if SetFocus then AListView.SetFocus; + g_object_unref(PGObject(AScrolledWindow.FWidget)); + if ASetFocus then AListView.SetFocus; end; procedure TFMain.TabNotebookSwitchPage(Sender: TObject; const NewTabNum: integer; const ShouldFocus: boolean); @@ -5361,8 +5348,8 @@ begin AListView := RightListView; end; SwitchTab(NewTabNum, LeftPanel, ShouldFocus); - if LeftPanel then LeftPanelEngine := TabEngines[NewTabNum] - else RightPanelEngine := TabEngines[NewTabNum]; + if LeftPanel then LeftPanelEngine := TPanelEngine(TabEngines[NewTabNum]) + else RightPanelEngine := TPanelEngine(TabEngines[NewTabNum]); ChangingDir(LeftPanel, ATabList[NewTabNum], PathsHighlight[NewTabNum], '', False, True); AListView.SetSortInfo(Integer(TabSortIDs[NewTabNum]), TGTKTreeViewSortOrder(Integer(TabSortTypes[NewTabNum]))); @@ -5435,13 +5422,13 @@ begin end; if TabNo > 0 then begin - Engine := TabEngines[TabNo]; + Engine := TPanelEngine(TabEngines[TabNo]); if (Engine is TVFSEngine) and CloseVFSEngine and (not CheckForUnsavedConnection(Engine as TVFSEngine, True)) then Exit; end; if (ANotebook.ChildrenCount > 2) and (TabNo >= 0) then begin // Close one tab, leave tab bar visible - Engine := TabEngines[TabNo]; + Engine := TPanelEngine(TabEngines[TabNo]); // !!!!!!!! NewPageIndex := ANotebook.PageIndex - Ord((TabNo = ANotebook.PageIndex) and (TabNo = ANotebook.ChildrenCount - 1)) + Ord((TabNo = ANotebook.PageIndex) and (ANotebook.ChildrenCount > TabNo + 1)); @@ -5471,8 +5458,8 @@ begin // Change dir to the opposite if (TabNo >= 0) and (TabNo = ANotebook.PageIndex) then begin // we should not change directory while closing all tabs... i := Ord(not Boolean(ANotebook.PageIndex)); - if LeftPanel then LeftPanelEngine := TabEngines[i] - else RightPanelEngine := TabEngines[i]; + if LeftPanel then LeftPanelEngine := TPanelEngine(TabEngines[i]) + else RightPanelEngine := TPanelEngine(TabEngines[i]); ChangingDir(LeftPanel, ATabList[i], PathsHighlight[i]); AListView.SetSortInfo(Integer(TabSortIDs[i]), TGTKTreeViewSortOrder(Integer(TabSortTypes[i]))); end; @@ -5482,10 +5469,10 @@ begin ATabList.Clear; PathsHighlight.Clear; for i := 0 to TabEngines.Count - 1 do - if (TPanelEngine(TabEngines[i]) is TVFSEngine) and CloseVFSEngine and ((LeftPanel and (LeftPanelEngine <> TabEngines[i])) or - ((not LeftPanel) and (RightPanelEngine <> TabEngines[i]))) + if (TPanelEngine(TabEngines[i]) is TVFSEngine) and CloseVFSEngine and ((LeftPanel and (LeftPanelEngine <> TPanelEngine(TabEngines[i]))) or + ((not LeftPanel) and (RightPanelEngine <> TPanelEngine(TabEngines[i])))) then begin - Engine := TabEngines[i]; + Engine := TPanelEngine(TabEngines[i]); while Engine is TVFSEngine do try if (i <> TabNo) and (not CheckForUnsavedConnection(Engine as TVFSEngine, False)) then Exit; @@ -5569,7 +5556,7 @@ begin TabNotebookSwitchPage(ANotebook, SetTabActive, True); end; -procedure TFMain.SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, Tooltip: string); +procedure TFMain.SetTabLabel(Notebook: TEphyNotebook; PageIndex: integer; ALabel, ATooltip: string); var g: PChar; begin if (ConfTabMaxLength > 0) and (g_utf8_strlen(PChar(ALabel), -1) > ConfTabMaxLength) then begin @@ -5580,7 +5567,7 @@ begin libc_free(g); end; Notebook.SetTabCaption(PageIndex, ALabel); - Notebook.SetTabTooltip(PageIndex, Tooltip); + Notebook.SetTabTooltip(PageIndex, ATooltip); end; procedure TFMain.NotebookReordered(Sender: TObject; const Source, Dest: integer); @@ -5889,7 +5876,7 @@ begin miEditBookmarks.Visible := False; miBookmarksSeparator.Visible := False; - gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, menu_position_cb, SenderControl.FWidget, 1, GDK_CURRENT_TIME); + gtk_menu_popup(PGtkMenu(mnuBookmarks.FMenu), nil, nil, @menu_position_cb, SenderControl.FWidget, 1, GDK_CURRENT_TIME); if LeftPanel then LeftListView.SetFocus else RightListView.SetFocus; end; @@ -6053,105 +6040,6 @@ begin libc_chdir('/'); end; - -(********************************************************************************************************************************) -procedure TFMain.miFilePropertiesClick(Sender: TObject); -var LeftPanel: boolean; - AListView: TGTKListView; - Engine: TPanelEngine; - DataList: TList; - i: integer; - SelCount: longint; - AFile, NextItem1, NextItem2: string; - Stat: PDataItem; -{ AWorkingThread: TWorkerThread; - AFProgress: TFProgress; } -begin - try - InternalLock; - Stat := nil; - if LeftListView.Focused then LeftPanel := True else - if RightListView.Focused then LeftPanel := False else - LeftPanel := LeftLastFocused; - if LeftPanel then begin - AListView := LeftListView; - Engine := LeftPanelEngine; - DataList := LeftPanelData; - end else begin - AListView := RightListView; - Engine := RightPanelEngine; - DataList := RightPanelData; - end; - - SelCount := 0; - if DataList.Count > 0 then - for i := 0 to DataList.Count - 1 do - with PDataItem(DataList[i])^ do - if Selected and (not UpDir) then Inc(SelCount); - if (SelCount = 0) and ((not Assigned(AListView.Selected)) {or PDataItem(AListView.Selected.Data)^.UpDir}) then begin - Application.MessageBox(LANGNoFilesSelected, [mbOK], mbInfo, mbNone, mbOK); - Exit; - end; - - AFile := ''; - if SelCount = 0 then AFile := PDataItem(AListView.Selected.Data)^.FName else - for i := 0 to DataList.Count - 1 do - with PDataItem(DataList[i])^ do - if Selected and (not UpDir) then begin - AFile := FName; - Break; - end; - - if AFile <> '' then - try - FProperties := TFProperties.Create(Self); - Stat := Engine.GetFileInfo(IncludeTrailingPathDelimiter(Engine.Path) + AFile, True, True, nil); - if not Assigned(Stat) then Exit; -// FProperties.AssignMode(Stat^.Mode, AFile, Stat^.UID, Stat^.GID); - FProperties.DisplayFileName := AFile; - if FProperties.Run = mbOK then begin -{ FindNextSelected(AListView, DataList, NextItem1, NextItem2); - - AWorkingThread := TWorkerThread.Create; - AFProgress := TFProgress.Create(Self); - try - AFProgress.SetNumBars(False); - AFProgress.ProgressBar.Value := 0; - AFProgress.Label1.Caption := LANGChownProgress; - AWorkingThread.ProgressForm := AFProgress; - if Assigned(AListView.Selected) then AWorkingThread.SelectedItem := AListView.Selected.Data; - AWorkingThread.ParamBool1 := FChown.RecursiveCheckButton.Checked; - AWorkingThread.ParamCardinal1 := FChown.LastUID; - AWorkingThread.ParamCardinal2 := FChown.LastGID; - AWorkingThread.Engine := Engine; - AWorkingThread.LeftPanel := LeftPanel; - AWorkingThread.DataList := DataList; - AWorkingThread.WorkerProcedure := ChownFilesWorker; - AWorkingThread.Resume; - AFProgress.ParentForm := FMain; - if (SelCount > 1) or FChown.RecursiveCheckButton.Checked then AFProgress.ShowModal; - ProcessProgressThread(AWorkingThread, AFProgress); - AFProgress.Close; - finally - AFProgress.Free; - AWorkingThread.Free; - end; } - - NextItem1 := ''; - NextItem2 := ''; - ChangingDir(LeftPanel, Engine.Path, NextItem1, NextItem2); - DoRefresh(not LeftPanel, True, True); - end; - finally - FreeDataItem(Stat); - FProperties.Free; - end; - finally - Application.ProcessMessages; - InternalLockInit(False); - end; -end; - (********************************************************************************************************************************) procedure TFMain.CopyFilenamesToClipboard(FullPaths, LeftPanel: boolean); var DataList: TList; diff --git a/UMounterPrefs.pas b/UMounterPrefs.pas index 76ababd..7194370 100644 --- a/UMounterPrefs.pas +++ b/UMounterPrefs.pas @@ -22,8 +22,8 @@ unit UMounterPrefs; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, - GTKView, GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, + lazglib2, lazgobject2, gdk2, gtk2, SysUtils, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, + GTKView, GTKDialogs, GTKPixbuf, GTKMenus, UCoreClasses, UGnome; type @@ -122,7 +122,7 @@ begin MounterListTable.BorderWidth := 7; ListView := TGTKListView.CreateTyped(Self, False, [lcText, lcText, lcText, lcPointer, lcPixbuf]); - g_signal_connect(ListView.FWidget, 'drag-end', G_CALLBACK(@TGTKListView_drag_end), nil); + g_signal_connect_data(PGObject(ListView.FWidget), 'drag-end', TGCallback(@TGTKListView_drag_end), nil, nil, G_CONNECT_DEFAULT); gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(ListView.FWidget), GDK_BUTTON1_MASK, @row_targets, 1, GDK_ACTION_MOVE or GDK_ACTION_COPY); gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(ListView.FWidget), @row_targets, 1, GDK_ACTION_MOVE or GDK_ACTION_COPY); ListView.RulesHint := True; @@ -280,21 +280,21 @@ begin - OnDestroy := FormDestroy; - ListView.OnSelectionChanged := ListViewSelectionChanged; - UseFSTabDefaultsCheckBox.OnToggled := UseFSTabDefaultsCheckBoxToggled; - AddItemButton.OnClick := AddItemButtonClick; - RemoveItemButton.OnClick := RemoveItemButtonClick; - MoveUpButton.OnClick := MoveUpDownButtonButtonClick; - MoveDownButton.OnClick := MoveUpDownButtonButtonClick; - DisplayTextEntry.OnChanged := DisplayTextEntryChanged; - MountPointEntry.OnChanged := MountPointEntryChanged; - MountDeviceEntry.OnChanged := MountDeviceEntryChanged; - MountCommandEntry.OnChanged := MountCommandEntryChanged; - UmountCommandEntry.OnChanged := UmountCommandEntryChanged; - DeviceTypeOptionMenu.OnChanged := DeviceTypeOptionMenuChanged; - if FUseGnomeIconEntry then IconEntry.OnIconChanged := IconEntryChanged - else IconEntry2.OnClick := IconEntry2Click; + OnDestroy := @FormDestroy; + ListView.OnSelectionChanged := @ListViewSelectionChanged; + UseFSTabDefaultsCheckBox.OnToggled := @UseFSTabDefaultsCheckBoxToggled; + AddItemButton.OnClick := @AddItemButtonClick; + RemoveItemButton.OnClick := @RemoveItemButtonClick; + MoveUpButton.OnClick := @MoveUpDownButtonButtonClick; + MoveDownButton.OnClick := @MoveUpDownButtonButtonClick; + DisplayTextEntry.OnChanged := @DisplayTextEntryChanged; + MountPointEntry.OnChanged := @MountPointEntryChanged; + MountDeviceEntry.OnChanged := @MountDeviceEntryChanged; + MountCommandEntry.OnChanged := @MountCommandEntryChanged; + UmountCommandEntry.OnChanged := @UmountCommandEntryChanged; + DeviceTypeOptionMenu.OnChanged := @DeviceTypeOptionMenuChanged; + if FUseGnomeIconEntry then IconEntry.OnIconChanged := @IconEntryChanged + else IconEntry2.OnClick := @IconEntry2Click; ListViewSelectionChanged(Self); ListView.SetFocus; @@ -319,7 +319,7 @@ begin if FUseGnomeIconEntry then IconEntry.Filename := ''; Exit; end; - Item := ListView.Selected.AsPointer(3); + Item := TMounterItem(ListView.Selected.AsPointer(3)); DisplayTextEntry.Text := Item.DisplayText; MountPointEntry.Text := StrToUTF8(Item.MountPath); MountDeviceEntry.Text := StrToUTF8(Item.Device); @@ -358,7 +358,7 @@ procedure TFMounterPrefs.RemoveItemButtonClick(Sender: TObject); var Item: TMounterItem; begin if Assigned(ListView.Selected) and Assigned(ListView.Selected.AsPointer(3)) then begin - Item := ListView.Selected.AsPointer(3); + Item := TMounterItem(ListView.Selected.AsPointer(3)); Item.Free; InternalMounterList.Remove(Item); ListView.Items.Delete(ListView.Selected.Index); @@ -449,7 +449,7 @@ var Pixmap: TGDKPixbuf; b: boolean; Data: TMounterItem; begin - Data := InternalMounterList[ItemIndex]; + Data := TMounterItem(InternalMounterList[ItemIndex]); b := FileExists(Data.IconPath); Pixmap := nil; if b then begin diff --git a/UNewDir.pas b/UNewDir.pas index a108fd1..a55f5c3 100644 --- a/UNewDir.pas +++ b/UNewDir.pas @@ -22,7 +22,7 @@ unit UNewDir; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; type TFNewDir = class(TGTKDialog) @@ -63,7 +63,7 @@ begin Box.AddControlEx(Entry, False, False, 0); Box.BorderWidth := 6; ClientArea.AddControlEx(Box, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; Entry.SetFocus; end; diff --git a/UOverwrite.pas b/UOverwrite.pas index 78f057b..e2d7b43 100644 --- a/UOverwrite.pas +++ b/UOverwrite.pas @@ -22,7 +22,7 @@ unit UOverwrite; interface uses - gtk2, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; const OVERWRITE_CANCEL = 0; OVERWRITE_OVERWRITE = 1; @@ -70,28 +70,28 @@ begin ToInfoLabel.XAlign := 0; ToInfoLabel.XPadding := 40; OverwriteButton := TGTKButton.Create(Self); OverwriteButton.Caption := LANGOverwriteButton_Caption; - OverwriteButton.OnClick := ButtonClick; + OverwriteButton.OnClick := @ButtonClick; OverwriteAllButton := TGTKButton.Create(Self); OverwriteAllButton.Caption := LANGOverwriteAllButton_Caption; - OverwriteAllButton.OnClick := ButtonClick; + OverwriteAllButton.OnClick := @ButtonClick; SkipButton := TGTKButton.Create(Self); SkipButton.Caption := LANGSkipButton_Caption; - SkipButton.OnClick := ButtonClick; + SkipButton.OnClick := @ButtonClick; CancelButton := TGTKButton.Create(Self); CancelButton.Caption := LANGCancel; - CancelButton.OnClick := ButtonClick; + CancelButton.OnClick := @ButtonClick; OverwriteAllOlderButton := TGTKButton.Create(Self); OverwriteAllOlderButton.Caption := LANGOverwriteAllOlderButton_Caption; - OverwriteAllOlderButton.OnClick := ButtonClick; + OverwriteAllOlderButton.OnClick := @ButtonClick; SkipAllButton := TGTKButton.Create(Self); SkipAllButton.Caption := LANGSkipAllButton_Caption; - SkipAllButton.OnClick := ButtonClick; + SkipAllButton.OnClick := @ButtonClick; RenameButton := TGTKButton.Create(Self); RenameButton.Caption := LANGRenameButton_Caption; - RenameButton.OnClick := ButtonClick; + RenameButton.OnClick := @ButtonClick; AppendButton := TGTKButton.Create(Self); AppendButton.Caption := LANGAppendButton_Caption; - AppendButton.OnClick := ButtonClick; + AppendButton.OnClick := @ButtonClick; ButtonTable := TGTKTable.Create(Self); ButtonTable.RowCount := 3; ButtonTable.ColCount := 3; @@ -107,7 +107,7 @@ begin ClientArea.AddControlEx(FromVBox, True, True, 5); ClientArea.AddControlEx(ToVBox, True, True, 5); ActionArea.AddControlEx(ButtonTable, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFOverwrite.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); diff --git a/UPreferences.pas b/UPreferences.pas index c65e3db..008ecf5 100644 --- a/UPreferences.pas +++ b/UPreferences.pas @@ -22,9 +22,9 @@ unit UPreferences; interface uses - glib2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, + gtk2, pango, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, ULibc, - UCoreClasses, UGnome; + UGnome; type TFPreferences = class(TGTKDialog) @@ -106,7 +106,7 @@ var implementation -uses ULocale, UFileAssoc, UCoreUtils, UConfig; +uses ULocale, UCoreUtils, UConfig; procedure TFPreferences.FormCreate(Sender: TObject); @@ -203,7 +203,7 @@ begin RowHeightLabel.FocusControl := RowHeightSpinEdit; RowHeightLabel.UseUnderline := True; DefaultRowHeightCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); - DefaultRowHeightCheckBox.OnToggled := DefaultRowHeightCheckBoxToggled; + DefaultRowHeightCheckBox.OnToggled := @DefaultRowHeightCheckBoxToggled; Table2.AddControlEx(1, 5, 1, 1, RowHeightLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); Table2.AddControlEx(2, 5, 1, 1, RowHeightSpinEdit, [taoFill, taoExpand], [taoShrink, taoExpand, taoFill], 10, 2); Table2.AddControlEx(3, 5, 1, 1, DefaultRowHeightCheckBox, [taoFill, taoExpand], [taoShrink, taoExpand, taoFill], 10, 2); @@ -273,14 +273,14 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itLabel); Item.Caption := LANGPreferences_Custom; DateFormatOptionMenu.Items.Add(Item); - DateFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged; + DateFormatOptionMenu.OnChanged := @DateTimeFormatOptionMenuChanged; Table2.AddControlEx(1, 9, 1, 1, DateFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); Table2.AddControlEx(2, 9, 2, 1, DateFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); CustomDateFormatEntry := TGTKEntry.Create(Self); CustomDateFormatEntry.Enabled := False; CustomDateFormatEntry.Tooltip := LANGPreferences_CustomDateFormatEntry_Tooltip; - CustomDateFormatEntry.OnChanged := DateTimeFormatOptionMenuChanged; + CustomDateFormatEntry.OnChanged := @DateTimeFormatOptionMenuChanged; Table2.AddControlEx(2, 10, 2, 1, CustomDateFormatEntry, [taoShrink], [taoShrink], 10, 2); TimeFormatLabel := TGTKLabel.Create(Self); @@ -300,14 +300,14 @@ begin Item := TGTKMenuItem.CreateTyped(Self, itLabel); Item.Caption := LANGPreferences_Custom; TimeFormatOptionMenu.Items.Add(Item); - TimeFormatOptionMenu.OnChanged := DateTimeFormatOptionMenuChanged; + TimeFormatOptionMenu.OnChanged := @DateTimeFormatOptionMenuChanged; Table2.AddControlEx(1, 11, 1, 1, TimeFormatLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 0, 2); Table2.AddControlEx(2, 11, 2, 1, TimeFormatOptionMenu, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 10, 2); CustomTimeFormatEntry := TGTKEntry.Create(Self); CustomTimeFormatEntry.Enabled := False; CustomTimeFormatEntry.Tooltip := LANGPreferences_CustomTimeFormatEntry_Tooltip; - CustomTimeFormatEntry.OnChanged := DateTimeFormatOptionMenuChanged; + CustomTimeFormatEntry.OnChanged := @DateTimeFormatOptionMenuChanged; Table2.AddControlEx(2, 12, 2, 1, CustomTimeFormatEntry, [taoShrink], [taoShrink], 10, 2); DateTimeFormatLabel := TGTKLabel.Create(Self); @@ -436,14 +436,14 @@ begin ViewerCombo.Items.Append(ConfViewersApps[i]); ViewerBrowseButton := TGTKButton.Create(Self); ViewerBrowseButton.Caption := Format(' %s ', [LANGBrowseButton_Caption]); - ViewerBrowseButton.OnClick := ViewerBrowseButtonClick; + ViewerBrowseButton.OnClick := @ViewerBrowseButtonClick; ViewerLabel2 := TGTKLabel.Create(Self); ViewerLabel2.Caption := LANGPreferencesCommandSC; ViewerLabel2.XAlign := 0; ViewerLabel2.FocusControl := ViewerCombo.Entry; ViewerLabel2.UseUnderline := True; UseInternalViewerCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferencesUseInternalViewer); - UseInternalViewerCheckBox.OnToggled := UseInternalViewerCheckBoxToggled; + UseInternalViewerCheckBox.OnToggled := @UseInternalViewerCheckBoxToggled; ViewerOptionMenu := TGTKOptionMenu.Create(Self); miViewerTerminalDetect := TGTKMenuItem.CreateTyped(Self, itLabel); miViewerTerminalDetect.Caption := LANGPreferencesAutodetectXApp; @@ -476,7 +476,7 @@ begin EditorCombo.Items.Append(ConfEditorApps[i]); EditorBrowseButton := TGTKButton.Create(Self); EditorBrowseButton.Caption := Format(' %s ', [LANGBrowseButton_Caption]); - EditorBrowseButton.OnClick := ViewerBrowseButtonClick; + EditorBrowseButton.OnClick := @ViewerBrowseButtonClick; EditorLabel2 := TGTKLabel.Create(Self); EditorLabel2.Caption := LANGPreferencesCommandSC; EditorLabel2.XAlign := 0; @@ -513,7 +513,7 @@ begin TerminalCombo.Items.Append(ConfTerminalApps[i]); TerminalBrowseButton := TGTKButton.Create(Self); TerminalBrowseButton.Caption := Format(' %s ', [LANGBrowseButton_Caption]); - TerminalBrowseButton.OnClick := ViewerBrowseButtonClick; + TerminalBrowseButton.OnClick := @ViewerBrowseButtonClick; TerminalLabel2 := TGTKLabel.Create(Self); TerminalLabel2.Caption := LANGPreferencesCommandSC; TerminalLabel2.XAlign := 0; @@ -569,9 +569,9 @@ begin ListFontFrame.AddControl(ListFontPreview); ChangeFontButton := TGTKButton.Create(Self); ChangeFontButton.Caption := LANGPreferences_Change; - ChangeFontButton.OnClick := ChangeFontButtonClick; + ChangeFontButton.OnClick := @ChangeFontButtonClick; DefaultFontCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_UseDefaultFont); - DefaultFontCheckBox.OnToggled := DefaultFontCheckBoxToggled; + DefaultFontCheckBox.OnToggled := @DefaultFontCheckBoxToggled; Table3.AddControlEx(0, 0, 1, 1, TGTKVBox.Create(Self), [taoShrink], [taoShrink, taoExpand, taoFill], 12, 2); Table3.AddControlEx(1, 0, 1, 1, ListFontLabel, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2); @@ -609,7 +609,7 @@ begin NormalItemBGColorButton.SetSizeRequest(30, -1); NormalItemFGColorDefault := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); NormalItemFGColorDefault.Tooltip := LANGPreferences_SetToDefaultToUseGTKThemeColors; - NormalItemFGColorDefault.OnToggled := ColorButtonDefaultsToggled; + NormalItemFGColorDefault.OnToggled := @ColorButtonDefaultsToggled; Table4.AddControl(0, 1, 1, 1, NormalItemFGColorLabel, 30, 2); Table4.AddControl(2, 1, 1, 1, NormalItemFGColorButton, 5, 2); Table4.AddControl(5, 1, 1, 1, NormalItemBGColorButton, 5, 2); @@ -622,7 +622,7 @@ begin ActiveItemBGColorButton := TGnomeColorButton.Create(Self); ActiveItemFGColorDefault := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); ActiveItemFGColorDefault.Tooltip := LANGPreferences_SetToDefaultToUseGTKThemeColors; - ActiveItemFGColorDefault.OnToggled := ColorButtonDefaultsToggled; + ActiveItemFGColorDefault.OnToggled := @ColorButtonDefaultsToggled; Table4.AddControl(0, 2, 1, 1, ActiveItemFGColorLabel, 30, 2); Table4.AddControl(2, 2, 1, 1, ActiveItemFGColorButton, 5, 2); Table4.AddControl(5, 2, 1, 1, ActiveItemBGColorButton, 5, 2); @@ -635,7 +635,7 @@ begin InactiveItemBGColorButton := TGnomeColorButton.Create(Self); InactiveItemFGColorDefault := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); InactiveItemFGColorDefault.Tooltip := LANGPreferences_SetToDefaultToUseGTKThemeColors; - InactiveItemFGColorDefault.OnToggled := ColorButtonDefaultsToggled; + InactiveItemFGColorDefault.OnToggled := @ColorButtonDefaultsToggled; Table4.AddControl(0, 3, 1, 1, InactiveItemFGColorLabel, 30, 2); Table4.AddControl(2, 3, 1, 1, InactiveItemFGColorButton, 5, 2); Table4.AddControl(5, 3, 1, 1, InactiveItemBGColorButton, 5, 2); @@ -654,7 +654,7 @@ begin LinkItemFGColorButton := TGnomeColorButton.Create(Self); LinkItemFGColorDefault := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); LinkItemFGColorDefault.Tooltip := LANGPreferences_LinkItemHint; - LinkItemFGColorDefault.OnToggled := ColorButtonDefaultsToggled; + LinkItemFGColorDefault.OnToggled := @ColorButtonDefaultsToggled; Table4.AddControl(0, 5, 1, 1, LinkItemFGColorLabel, 30, 2); Table4.AddControl(2, 5, 1, 1, LinkItemFGColorButton, 5, 2); Table4.AddControl(7, 5, 1, 1, LinkItemFGColorDefault, 10, 2); @@ -665,7 +665,7 @@ begin DotFileItemFGColorButton := TGnomeColorButton.Create(Self); DotFileItemFGColorDefault := TGTKCheckButton.CreateWithLabel(Self, LANGPreferences_Default); DotFileItemFGColorDefault.Tooltip := LANGPreferences_DotFileItemHint; - DotFileItemFGColorDefault.OnToggled := ColorButtonDefaultsToggled; + DotFileItemFGColorDefault.OnToggled := @ColorButtonDefaultsToggled; Table4.AddControl(0, 6, 1, 1, DotFileItemFGColorLabel, 30, 2); Table4.AddControl(2, 6, 1, 1, DotFileItemFGColorButton, 5, 2); Table4.AddControl(7, 6, 1, 1, DotFileItemFGColorDefault, 10, 2); @@ -718,8 +718,8 @@ begin // ****************** - OnKeyDown := FormKeyDown; - OnDestroy := FormDestroy; + OnKeyDown := @FormKeyDown; + OnDestroy := @FormDestroy; end; procedure TFPreferences.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); @@ -782,7 +782,7 @@ begin gtk_widget_modify_font(ListFontPreview.FWidget, nil); ListFontPreview.Caption := Format(LANGPreferences_DefaultS, [DefaultGTKFont]); end else begin - FontDesc := pango_font_description_from_string(StringToPgchar(LocalListFont)); + FontDesc := pango_font_description_from_string(PChar(LocalListFont)); gtk_widget_modify_font(ListFontPreview.FWidget, FontDesc); ListFontPreview.Caption := LocalListFont; end; @@ -799,7 +799,7 @@ procedure TFPreferences.ChangeFontButtonClick(Sender: TObject); Dialog.FontName := ToControl.Caption; if Byte(Dialog.Run) = 251 then begin ToControl.Caption := Dialog.FontName; - FontDesc := pango_font_description_from_string(StringToPgchar(Dialog.FontName)); + FontDesc := pango_font_description_from_string(PChar(Dialog.FontName)); gtk_widget_modify_font(ToControl.FWidget, FontDesc); // g_object_unref(FontDesc); // *** - cannot unref, causes SIGSEGV LocalListFont := Dialog.FontName; diff --git a/UProgress.pas b/UProgress.pas index f389328..bc6410b 100644 --- a/UProgress.pas +++ b/UProgress.pas @@ -22,8 +22,7 @@ unit UProgress; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - UEngines; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; type TFProgress = class(TGTKDialog) @@ -89,9 +88,9 @@ begin // ClientArea.AddControlEx(Space, False, False, 0); // ClientArea.AddControlEx(VBox, True, True, 0); // AddControl(VBox); - OnKeyDown := FormKeyDown; - OnCloseQuery := FormCloseQuery; - CancelButton.OnClick := CancelButtonClick; + OnKeyDown := @FormKeyDown; + OnCloseQuery := @FormCloseQuery; + CancelButton.OnClick := @CancelButtonClick; CancelButton.Default := True; end; diff --git a/UProperties.pas b/UProperties.pas deleted file mode 100644 index d951264..0000000 --- a/UProperties.pas +++ /dev/null @@ -1,144 +0,0 @@ -(* - Tux Commander - UProeprties - File properties dialog - Copyright (C) 2006 Tomas Bzatek - Check for updates on tuxcmd.sourceforge.net - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*) -unit UProperties; - -interface - -uses - glib2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, - UCoreClasses, UGnome; - -type - TFProperties = class(TGTKDialog) - TitleFrame, ListFontFrame: TGTKFrame; - TitleLabel: TGTKLabel; - TitleEventBox: TGTKEventBox; - TitleIcon: TGTKImage; - TitleHBox: TGTKHBox; - Notebook: TGTKNotebook; - BasicPage, PermissionsPage, OpenWithPage: TGTKVBox; - - Table2: TGTKTable; - NameLabel: TGTKLabel; - NameEdit: TGTKEntry; - - procedure FormCreate(Sender: TObject); override; - procedure FormDestroy(Sender: TObject); - procedure FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); - public - DisplayFileName: string; - end; - -var - FProperties: TFProperties; - -implementation - -uses ULocale, UFileAssoc, UCoreUtils, UConfig; - - -procedure TFProperties.FormCreate(Sender: TObject); -// var i: integer; -begin - SetDefaultSize(450, 500); - Caption := Format('%s Properties', [DisplayFileName]); - Buttons := [mbOK, mbCancel]; - ShowSeparator := False; - TitleEventBox := TGTKEventBox.Create(Self); - TitleLabel := TGTKLabel.Create(Self); - TitleLabel.Caption := Format('%s', [Format('%s Properties', [DisplayFileName])]); - TitleLabel.UseMarkup := True; - TitleLabel.XAlign := 0; - TitleLabel.XPadding := 0; - TitleLabel.YPadding := 3; - TitleEventBox.ControlState := csPrelight; - TitleFrame := TGTKFrame.CreateWithoutLabel(Self); - TitleFrame.ShadowType := stShadowOut; - TitleIcon := TGTKImage.Create(Self); - TitleIcon.SetFromStock('gtk-properties', isLargeToolbar); - TitleHBox := TGTKHBox.Create(Self); - TitleHBox.Homogeneous := False; - TitleHBox.AddControlEx(TGTKVBox.Create(Self), False, False, 5); - TitleHBox.AddControlEx(TitleIcon, False, False, 0); - TitleHBox.AddControlEx(TitleLabel, True, True, 10); - TitleEventBox.AddControl(TitleHBox); - TitleFrame.AddControl(TitleEventBox); - ClientArea.AddControlEx(TitleFrame, False, True, 0); - - Notebook := TGTKNotebook.Create(Self); - Notebook.BorderWidth := 10; - ClientArea.AddControlEx(Notebook, True, True, 0); - - BasicPage := TGTKVBox.Create(Notebook); - Notebook.AppendPage(BasicPage, 'Basic'); - - PermissionsPage := TGTKVBox.Create(Notebook); - Notebook.AppendPage(PermissionsPage, 'Permissions'); - - OpenWithPage := TGTKVBox.Create(Notebook); - Notebook.AppendPage(OpenWithPage, 'Open With'); - - - // ********* PAGE Basic - - BasicPage.AddControlEx(TGTKVBox.Create(Self), False, False, 5); - Table2 := TGTKTable.Create(Self); - Table2.SetRowColCount(8, 5); - BasicPage.AddControlEx(Table2, False, False, 0); - - NameLabel := TGTKLabel.Create(Self); - NameLabel.Caption := Format('%s', ['_Name:']); - NameLabel.XAlign := 0; - NameLabel.UseMarkup := True; - NameEdit := TGTKEntry.Create(Self); - NameLabel.FocusControl := NameEdit; - NameLabel.UseUnderline := True; - Table2.AddControlEx(0, 0, 1, 1, NameLabel, [taoShrink, taoFill], [taoShrink], 2, 5); - Table2.AddControlEx(1, 0, 1, 1, NameEdit, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 2, 5); - - - - // ********* PAGE Permissions - - - - // ********* PAGE Applications - - - // ****************** - - OnKeyDown := FormKeyDown; - OnDestroy := FormDestroy; -end; - -procedure TFProperties.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); -begin - if Key = GDK_ESCAPE then ModalResult := mbCancel; -end; - -procedure TFProperties.FormDestroy(Sender: TObject); -begin - -end; - -(********************************************************************************************************************************) -end. - diff --git a/UQuickConnect.pas b/UQuickConnect.pas index 903add4..18725fc 100644 --- a/UQuickConnect.pas +++ b/UQuickConnect.pas @@ -22,9 +22,9 @@ unit UQuickConnect; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, - UCore, UCoreClasses, UVFSCore, UEngines, UConnectionManager; + lazglib2, gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, + GTKPixbuf, GTKClasses, GTKMenus, + UCore, UVFSCore, UEngines, UConnectionManager; type TFQuickConnect = class(TGTKDialog) @@ -63,7 +63,7 @@ var implementation -uses ULocale, UCoreUtils, UConfig, UConnectionProperties, UGnome, UError, uVFSprototypes; +uses ULocale, UCoreUtils, UConfig, UConnectionProperties, UGnome, UError; procedure TFQuickConnect.FormCreate(Sender: TObject); @@ -170,14 +170,14 @@ begin Table.AddControlEx(0, 2, 1, 1, Label2, [taoShrink, taoFill], [taoShrink], 10, 5); Table.AddControlEx(1, 2, 1, 1, PluginOptionMenu, [taoExpand, taoFill], [taoShrink], 0, 5); - CloseButton.OnClick := CloseButtonClick; - ConnectButton.OnClick := ConnectButtonClick; - StopButton.OnClick := StopButtonClick; - OnKeyDown := FormKeyDown; - OnClose := FormClose; - OnResponse := FormResponse; - URIComboBox.Entry.OnKeyDown := ComboBoxKeyDown; - URIComboBox.Entry.OnChanged := ComboBoxChanged; + CloseButton.OnClick := @CloseButtonClick; + ConnectButton.OnClick := @ConnectButtonClick; + StopButton.OnClick := @StopButtonClick; + OnKeyDown := @FormKeyDown; + OnClose := @FormClose; + OnResponse := @FormResponse; + URIComboBox.Entry.OnKeyDown := @ComboBoxKeyDown; + URIComboBox.Entry.OnChanged := @ComboBoxChanged; ComboBoxChanged(Sender); end; @@ -286,7 +286,7 @@ begin // Find VFS module to use for this connection VFSPlugin := nil; if (PluginOptionMenu.ItemIndex <> 0) and (PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data <> nil) then begin - VFSPlugin := PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data; + VFSPlugin := TVFSPlugin(PluginOptionMenu.Items[PluginOptionMenu.ItemIndex].Data); ConfQuickConnectPluginID := VFSPlugin.ModuleID; end else ConfQuickConnectPluginID := ''; if VFSPlugin = nil then begin @@ -297,12 +297,12 @@ begin if Length(TVFSPlugin(PluginList[i]).Services) > 0 then for j := 0 to Length(TVFSPlugin(PluginList[i]).Services) - 1 do if WideCompareText(TVFSPlugin(PluginList[i]).Services[j], Scheme) = 0 then begin - VFSPlugin := PluginList[i]; + VFSPlugin := TVFSPlugin(PluginList[i]); Break; end; if VFSPlugin <> nil then Break; end; - if VFSPlugin = nil then VFSPlugin := PluginList[0]; // Fallback in hope some other plugin can handle it + if VFSPlugin = nil then VFSPlugin := TVFSPlugin(PluginList[0]); // Fallback in hope some other plugin can handle it end; if (SourcePanelEngine is TVFSEngine) and ConfReplaceConnectionWarning then begin diff --git a/URemoteWait.pas b/URemoteWait.pas index e4a2c13..c3802d1 100644 --- a/URemoteWait.pas +++ b/URemoteWait.pas @@ -22,8 +22,7 @@ unit URemoteWait; interface uses - glib2, gdk2, gtk2, pango, - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; type TFRemoteWait = class(TGTKDialog) @@ -78,9 +77,9 @@ begin CancelButton := TGTKButton.CreateFromStock(Self, 'gtk-cancel'); CancelButton.Default := True; ActionArea.AddControlEndEx(CancelButton, False, False, 2); - OnKeyDown := FormKeyDown; - OnCloseQuery := FormCloseQuery; - CancelButton.OnClick := CancelButtonClick; + OnKeyDown := @FormKeyDown; + OnCloseQuery := @FormCloseQuery; + CancelButton.OnClick := @CancelButtonClick; Cancelled := False; end; diff --git a/URunFromVFS.pas b/URunFromVFS.pas index a1309ff..4710a33 100644 --- a/URunFromVFS.pas +++ b/URunFromVFS.pas @@ -22,8 +22,8 @@ unit URunFromVFS; interface uses - glib2, gtk2, pango, SysUtils, Types, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, UCoreClasses; + gtk2, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, + GTKPixbuf, UCoreClasses; type TFRunFromVFS = class(TGTKDialog) @@ -56,7 +56,7 @@ var implementation -uses ULocale, UConfig; +uses ULocale; procedure TFRunFromVFS.FormCreate(Sender: TObject); @@ -89,7 +89,7 @@ begin CloseButton := TGTKButton.CreateFromStock(Self, GTK_STOCK_CLOSE); // CloseButton.Default := True; // Default := CloseButton; - CloseButton.OnClick := CloseButtonClick; + CloseButton.OnClick := @CloseButtonClick; ButtonBox := TGTKHButtonBox.Create(Self); ButtonBox.Layout := blEnd; ButtonBox.Spacing := 0; @@ -173,11 +173,11 @@ begin ExecuteButton := TGTKImageButton.Create(Self); ExecuteButton.SetFromStock('gtk-execute', isButton); ExecuteButton.Caption := LANGFRunFromVFS_ExecuteButton; - ExecuteButton.OnClick := ExecuteButtonClick; + ExecuteButton.OnClick := @ExecuteButtonClick; ExecuteButton.Spacing := 7; ExecuteAllButton := TGTKImageButton.Create(Self); ExecuteAllButton.Caption := LANGFRunFromVFS_ExecuteAllButton; - ExecuteAllButton.OnClick := ExecuteAllButtonClick; + ExecuteAllButton.OnClick := @ExecuteAllButtonClick; ExecuteAllButton.Spacing := 7; @@ -216,7 +216,7 @@ begin ActionArea.AddControlEx(HBox2, False, False, 0); CloseButton.SetFocus; - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFRunFromVFS.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); diff --git a/USearch.pas b/USearch.pas index 3ae35f9..1a9b527 100644 --- a/USearch.pas +++ b/USearch.pas @@ -22,7 +22,7 @@ unit USearch; interface uses - glib2, gdk2, gtk2, SyncObjs, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, + lazglib2, gtk2, SyncObjs, SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKMenus, UEngines, UGnome, ULibc; @@ -84,6 +84,7 @@ type FRootEngine: TPanelEngine; Wilds: array of string; GUIMutex: TCriticalSection; + FFinished: boolean; procedure DoRecurse(StartDir: string); function FindText(FileName: string): boolean; protected @@ -95,7 +96,7 @@ type FList: TList; procedure Execute; override; public - Finished, CancelIt: boolean; + CancelIt: boolean; CurrentDir: string; constructor Create(Engine: TPanelEngine); destructor Destroy; override; @@ -106,7 +107,7 @@ var implementation -uses Math, UMain, ULocale, UCoreUtils, UCore, DateUtils, UViewer, UConfig, UVFSCore, UFileAssoc; +uses Math, UMain, ULocale, UCoreUtils, UCore, DateUtils, UConfig, UVFSCore, UFileAssoc; var SizeUnits: array[0..2] of string; DayUnits: array[0..3] of string; @@ -137,7 +138,7 @@ begin Caption := LANGSearch_Caption; Buttons := []; ShowSeparator := False; - FUseGnomeWidgets := Assigned(@gnome_date_edit_new) and Assigned(@gnome_date_edit_set_time) and Assigned(@gnome_date_edit_get_time); + FUseGnomeWidgets := False; Notebook := TGTKNotebook.Create(Self); Notebook.BorderWidth := 10; @@ -167,7 +168,7 @@ begin Label1.Caption := Format('%s', [LANGSearch_SearchFor]); FileMaskEntry := TGTKCombo.Create(Self); FileMaskEntry.Tooltip := LANGSearch_FileMaskEntryTooltip; - FileMaskEntry.Entry.OnKeyDown := FileMaskEntryKeyDown; + FileMaskEntry.Entry.OnKeyDown := @FileMaskEntryKeyDown; if SearchHistory.Count > 0 then for i := 0 to SearchHistory.Count - 1 do FileMaskEntry.Items.Append(SearchHistory[i]); @@ -191,7 +192,7 @@ begin Label3.Caption := LANGSearch_FindText; FindTextEntry := TGTKCombo.Create(Self); FindTextEntry.Tooltip := LANGSearch_FindTextEntryTooltip; - FindTextEntry.Entry.OnKeyDown := FindTextEntryKeyDown; + FindTextEntry.Entry.OnKeyDown := @FindTextEntryKeyDown; if SearchTextHistory.Count > 0 then for i := 0 to SearchTextHistory.Count - 1 do FindTextEntry.Items.Append(SearchTextHistory[i]); @@ -390,24 +391,24 @@ begin ActionArea.AddControlEx(ButtonBox, False, False, 0); - OnKeyDown := FormKeyDown; - OnCloseQuery := FormCloseQuery; - OnResponse := FormResponse; - OnDestroy := FormDestroy; - FileList.OnSelectionChanged := FileListSelectionChanged; - FindButton.OnClick := FindButtonClick; - StopButton.OnClick := StopButtonClick; - CloseButton.OnClick := CloseButtonClick; - BiggerThanCheckButton.OnToggled := BiggerThanCheckButtonToggled; - SmallerThanCheckButton.OnToggled := BiggerThanCheckButtonToggled; - ModifiedBetweenRadioButton.OnToggled := BiggerThanCheckButtonToggled; - NotModifiedAfterRadioButton.OnToggled := BiggerThanCheckButtonToggled; - ModifiedLastRadioButton.OnToggled := BiggerThanCheckButtonToggled; - ModifiedNotLastRadionButton.OnToggled := BiggerThanCheckButtonToggled; - NewSearchButton.OnClick := NewSearchButtonClick; - ViewButton.OnClick := ViewButtonClick; - GoToFileButton.OnClick := GoToFileButtonClick; - FileList.OnDblClick := FileListDblClick; + OnKeyDown := @FormKeyDown; + OnCloseQuery := @FormCloseQuery; + OnResponse := @FormResponse; + OnDestroy := @FormDestroy; + FileList.OnSelectionChanged := @FileListSelectionChanged; + FindButton.OnClick := @FindButtonClick; + StopButton.OnClick := @StopButtonClick; + CloseButton.OnClick := @CloseButtonClick; + BiggerThanCheckButton.OnToggled := @BiggerThanCheckButtonToggled; + SmallerThanCheckButton.OnToggled := @BiggerThanCheckButtonToggled; + ModifiedBetweenRadioButton.OnToggled := @BiggerThanCheckButtonToggled; + NotModifiedAfterRadioButton.OnToggled := @BiggerThanCheckButtonToggled; + ModifiedLastRadioButton.OnToggled := @BiggerThanCheckButtonToggled; + ModifiedNotLastRadionButton.OnToggled := @BiggerThanCheckButtonToggled; + NewSearchButton.OnClick := @NewSearchButtonClick; + ViewButton.OnClick := @ViewButtonClick; + GoToFileButton.OnClick := @GoToFileButtonClick; + FileList.OnDblClick := @FileListDblClick; Notebook.PageIndex := 0; FileMaskEntry.Entry.SetFocus; @@ -811,7 +812,7 @@ begin end; FSearchThread.GUIMutex.Release; - until FSearchThread.Finished; + until FSearchThread.FFinished; if not Stop then StatusLabel.Caption := Format('%s (' + LANGSearch_FilesFound + ')', [LANGSearch_SearchFinished, FSearchThread.FList.Count]) @@ -821,7 +822,7 @@ begin // Save the list x := List; List := FSearchThread.FList; - FSearchThread.FList := x; + FSearchThread.FList := TList(x); FSearchThread.Free; finally StopButton.Visible := False; @@ -847,7 +848,7 @@ begin FreeOnTerminate := False; GUIMutex := TCriticalSection.Create; CancelIt := False; - Finished := False; + FFinished := False; CurrentDir := ''; FSearchArchives := False; @@ -894,7 +895,7 @@ begin DoRecurse(ExcludeTrailingPathDelimiter(FStartPath)); SetLength(Wilds, 0); finally - Finished := True; + FFinished := True; end; end; diff --git a/USelect.pas b/USelect.pas index f9edccf..5fcc8cc 100644 --- a/USelect.pas +++ b/USelect.pas @@ -22,9 +22,8 @@ unit USelect; interface uses - glib2, gtk2, pango, SysUtils, Types, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses; - + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts, GTKClasses; + type TFSelect = class(TGTKDialog) { TitleFrame, ListFontFrame: TGTKFrame; @@ -92,13 +91,13 @@ begin for i := 0 to SelectHistory.Count - 1 do ComboBox.Items.Append(SelectHistory[i]); ComboBox.Entry.Text := '*.*'; - ComboBox.Entry.OnKeyDown := ComboBoxKeyDown; + ComboBox.Entry.OnKeyDown := @ComboBoxKeyDown; Label1.FocusControl := ComboBox.Entry; Box.AddControlEx(Label1, False, False, 0); Box.AddControlEx(ComboBox, False, False, 3); Box.BorderWidth := 12; ClientArea.AddControlEx(Box, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; ComboBox.SetFocus; end; diff --git a/USplitFile.pas b/USplitFile.pas index 6ba6065..39e9505 100644 --- a/USplitFile.pas +++ b/USplitFile.pas @@ -22,7 +22,7 @@ unit USplitFile; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKConsts; type TFSplitFile = class(TGTKDialog) @@ -98,7 +98,7 @@ begin Box.AddControlEx(SizeBox, False, False, 0); DeleteTargetCheckBox := TGTKCheckButton.CreateWithLabel(Self, LANGDeleteFilesOnTargetDisk); Box.AddControlEx(DeleteTargetCheckBox, False, False, 3); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; Entry.SetFocus; end; diff --git a/USymlink.pas b/USymlink.pas index b98c2ab..40a7cd6 100644 --- a/USymlink.pas +++ b/USymlink.pas @@ -22,7 +22,7 @@ unit USymlink; interface uses - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts; type TFSymlink = class(TGTKDialog) @@ -68,7 +68,7 @@ begin ToEntry := TGTKEntry.Create(Self); Label2.FocusControl := ToEntry; RelativeCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGFSymlink_RelativePath); - RelativeCheckButton.OnToggled := RelativeCheckButtonToggled; + RelativeCheckButton.OnToggled := @RelativeCheckButtonToggled; Box.AddControlEx(Label1, False, False, 2); Box.AddControlEx(FromEntry, False, False, 0); Box.AddControlEx(RelativeCheckButton, False, False, 0); @@ -77,7 +77,7 @@ begin Box.AddControlEx(ToEntry, False, False, 0); Box.BorderWidth := 10; ClientArea.AddControlEx(Box, True, True, 0); - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; ToEntry.SetFocus; end; diff --git a/UTestPlugin.pas b/UTestPlugin.pas index 2d92ae2..1673103 100644 --- a/UTestPlugin.pas +++ b/UTestPlugin.pas @@ -22,9 +22,8 @@ unit UTestPlugin; interface uses - glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, - GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKMenus, - UCoreClasses; + SysUtils, Classes, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, + GTKPixbuf, GTKMenus; type TFTestPlugin = class(TGTKDialog) @@ -133,7 +132,7 @@ begin Label4.FocusControl := PasswordEntry; Label4.UseUnderline := True; AnonymousCheckButton := TGTKCheckButton.CreateWithLabel(Self, LANGTestPlugin_AnonymousCheckButton); - AnonymousCheckButton.OnToggled := AnonymousCheckButtonToggled; + AnonymousCheckButton.OnToggled := @AnonymousCheckButtonToggled; AnonymousCheckButton.Checked := True; Table.AddControlEx(0, 4, 2, 1, TGTKEventBox.Create(Self), [taoShrink, taoFill], [taoExpand, taoFill], 5, 4); Table.AddControlEx(0, 5, 1, 1, Label3, [taoShrink, taoFill], [taoShrink, taoExpand, taoFill], 5, 2); @@ -157,7 +156,7 @@ begin PluginOptionMenu.Items.Add(MenuItem); end; - OnKeyDown := FormKeyDown; + OnKeyDown := @FormKeyDown; end; procedure TFTestPlugin.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); diff --git a/UToolTips.pas b/UToolTips.pas index a9ed9fb..6926456 100644 --- a/UToolTips.pas +++ b/UToolTips.pas @@ -22,7 +22,7 @@ unit UToolTips; interface -uses glib2, gdk2, gtk2, pango; +uses lazglib2, lazgobject2, gdk2, gtk2, pango; procedure FileListTipsInstall(ATreeView: PGtkTreeView); procedure FileListTipsEnable; @@ -55,8 +55,8 @@ function tips_button_press_event(widget: PGtkWidget; event: PGdkEventButton; use procedure FileListTipsInstall(ATreeView: PGtkTreeView); begin - g_signal_connect_after(ATreeView, 'event-after', G_CALLBACK(@event_handler), nil); - g_signal_connect(ATreeView, 'leave-notify-event', G_CALLBACK(@on_leave_notify), nil); + g_signal_connect_data(PGObject(ATreeView), 'event-after', TGCallback(@event_handler), nil, nil, [G_CONNECT_AFTER]); + g_signal_connect_data(PGObject(ATreeView), 'leave-notify-event', TGCallback(@on_leave_notify), nil, nil, G_CONNECT_DEFAULT); end; procedure file_list_tips_show_tip(AListView: PGtkTreeView; row: PGtkTreePath; column: PGtkTreeViewColumn); @@ -67,7 +67,7 @@ var Timeout: integer; begin if not tips_enabled then Exit; FileListTipsHide; - g_object_get(G_OBJECT(FMain.FWidget), 'is-active', @is_active, nil); + g_object_get(PGObject(FMain.FWidget), 'is-active', [@is_active, nil]); if not is_active then Exit; if Assigned(data_row) and (data_row <> row) then gtk_tree_path_free(data_row); data_panel := AListView; @@ -79,7 +79,7 @@ begin if (sec < 1) and (ms < ConstFileListTipsDelayNeighbour * 1000) then Timeout := 1; // DebugMsg(['Time elapsed = ', Double(sec), ':', integer(ms div 1000)]); end; - timer_id := gtk_timeout_add(Timeout, show_tip_widget, nil); + timer_id := gtk_timeout_add(Timeout, @show_tip_widget, nil); end; @@ -179,9 +179,9 @@ begin gtk_widget_set_name(GTK_WIDGET(tip_window), 'gtk-tooltips'); gtk_container_set_border_width(GTK_CONTAINER(tip_window), 4); gtk_widget_set_events(GTK_WIDGET(tip_window), GDK_POINTER_MOTION_MASK or GDK_BUTTON_PRESS_MASK or GDK_KEY_PRESS_MASK or GDK_FOCUS_CHANGE_MASK or GDK_SCROLL_MASK); - g_signal_connect(tip_window, 'event', G_CALLBACK(@tip_event_handler), nil); - g_signal_connect(tip_window, 'expose_event', G_CALLBACK(@gtk_tooltips_paint_window), tip_window); - g_signal_connect(tip_window, 'button-press-event', G_CALLBACK(@tips_button_press_event), tip_window); + g_signal_connect_data(PGObject(tip_window), 'event', TGCallback(@tip_event_handler), nil, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(tip_window), 'expose_event', TGCallback(@gtk_tooltips_paint_window), tip_window, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(tip_window), 'button-press-event', TGCallback(@tips_button_press_event), tip_window, nil, G_CONNECT_DEFAULT); tip_label := GTK_LABEL(gtk_label_new(nil)); gtk_misc_set_alignment(GTK_MISC(tip_label), 0, 0.5); @@ -232,7 +232,7 @@ var Text: PChar; pango_layout_set_font_description(Layout, FontDesc); end; pango_layout_get_pixel_size(Layout, @w, @h); - g_object_unref(Layout); + g_object_unref(PGObject(Layout)); Result := ColumnWidth > w; end; diff --git a/UViewer.pas b/UViewer.pas index 6e5fe85..e3eff81 100644 --- a/UViewer.pas +++ b/UViewer.pas @@ -24,8 +24,8 @@ unit UViewer; interface uses - glib2, gdk2, gtk2, pango, - SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKUtils, GTKDialogs, GTKPixbuf, GTKClasses, GTKExtCtrls, GTKConsts, + lazglib2, lazgobject2, gdk2, gtk2, pango, + SysUtils, Classes, GTKControls, GTKForms, GTKExtCtrls, GTKConsts, GTKText; type @@ -67,7 +67,7 @@ var implementation -uses UCoreUtils, UCoreClasses, UConfig, DateUtils, ULibc, UGnome; +uses UCoreUtils, UConfig, DateUtils, ULibc, UGnome; @@ -83,13 +83,13 @@ begin Caption := 'TuxView'; BorderWidth := 5; AThread := nil; - if @gtk_window_set_icon_name <> nil then gtk_window_set_icon_name(PGtkWindow(FWidget), 'text-x-generic'); // accessories-text-editor + gtk_window_set_icon_name(PGtkWindow(FWidget), 'text-x-generic'); // accessories-text-editor ScrolledWindow := TGTKScrolledWindow.Create(Self); ScrolledWindow.HorizScrollBarPolicy := sbAutomatic; ScrolledWindow.VertScrollBarPolicy := sbAutomatic; ScrolledWindow.ShadowType := stShadowIn; - g_signal_connect(G_OBJECT(ScrolledWindow.FWidget), 'scroll-event', G_CALLBACK (@scroll_event_callback), Self); + g_signal_connect_data(PGObject(ScrolledWindow.FWidget), 'scroll-event', TGCallback (@scroll_event_callback), Self, nil, G_CONNECT_DEFAULT); AddControl(ScrolledWindow); // ClientArea.AddControl(ScrolledWindow); @@ -98,8 +98,8 @@ begin FDrawingArea.FWidget := gtk_drawing_area_new; gtk_widget_set_events(FDrawingArea.FWidget, GDK_EXPOSURE_MASK or GDK_BUTTON_PRESS_MASK or GDK_POINTER_MOTION_MASK or GDK_KEY_PRESS_MASK); gtk_widget_set_size_request(FDrawingArea.FWidget, 10000, 40000); - g_signal_connect(G_OBJECT(FDrawingArea.FWidget), 'expose_event', G_CALLBACK (@expose_event_callback), Self); -// g_signal_connect_after(G_OBJECT(FDrawingArea.FWidget), 'key_press_event', G_CALLBACK (@key_press_event_callback), NULL); + g_signal_connect(G_OBJECT(FDrawingArea.FWidget), 'expose_event', TGCallback (@expose_event_callback), Self); +// g_signal_connect_after(G_OBJECT(FDrawingArea.FWidget), 'key_press_event', TGCallback (@key_press_event_callback), NULL); gtk_widget_set(FDrawingArea.FWidget, 'can_focus', TRUE, 0); gtk_widget_set(FDrawingArea.FWidget, 'can_default', TRUE, 0); gtk_widget_show(FDrawingArea.FWidget); @@ -112,7 +112,7 @@ begin TextView := TGTKTextView.Create(Self); TextView.CursorVisible := False; TextView.ReadOnly := True; - TextView.OnKeyDown := TextViewKeyDown; + TextView.OnKeyDown := @TextViewKeyDown; ScrolledWindow.AddControl(TextView); TextView.SetFocus; @@ -120,9 +120,9 @@ begin // ****************** - OnKeyDown := FormKeyDown; - OnDestroy := FormDestroy; - OnClose := FormClose; + OnKeyDown := @FormKeyDown; + OnDestroy := @FormDestroy; + OnClose := @FormClose; end; procedure TFViewer.FormKeyDown(Sender: TObject; Key: Word; Shift: TShiftState; var Accept: boolean); @@ -143,7 +143,7 @@ procedure TFViewer.FormDestroy(Sender: TObject); begin try LineBuffer.Free; - g_object_unref(window_group); + g_object_unref(PGObject(window_group)); except end; end; diff --git a/libgtk_kylix/GTKClasses.pas b/libgtk_kylix/GTKClasses.pas index d668fb0..6071d74 100644 --- a/libgtk_kylix/GTKClasses.pas +++ b/libgtk_kylix/GTKClasses.pas @@ -24,7 +24,7 @@ unit GTKClasses; interface -uses gtk2, gdk2, glib2, Classes, SysUtils; +uses gtk2, lazglib2, Classes, SysUtils; type @@ -73,10 +73,6 @@ type (********************************************************************************************************************************) implementation -uses GTKUtils; - -(********************************************************************************************************************************) -(********************************************************************************************************************************) constructor TGList.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -98,14 +94,14 @@ end; procedure TGList.Append(Data: string); begin - Append(Pointer(StringToPgchar(Data))); + Append(Pointer(PChar(Data))); end; procedure TGList.Delete(Index: integer); -var El: PGSList; +var El: PGList; begin El := g_list_nth_data(FList, Index); - if El <> nil then FList := g_list_remove(FList, El); + if El <> nil then FList := g_list_remove(FList, gpointer(El)); end; function TGList.Count: integer; @@ -158,7 +154,7 @@ end; procedure TGTKTimer.Start; begin if FHandlerID > 0 then Stop; - if FEnabled then FHandlerID := gtk_timeout_add(FInterval, TGTKTimer_Timeout, Self); + if FEnabled then FHandlerID := gtk_timeout_add(FInterval, @TGTKTimer_Timeout, Self); end; procedure TGTKTimer.Stop; diff --git a/libgtk_kylix/GTKConsts.pas b/libgtk_kylix/GTKConsts.pas index 9b4e545..0b18b1c 100644 --- a/libgtk_kylix/GTKConsts.pas +++ b/libgtk_kylix/GTKConsts.pas @@ -24,7 +24,7 @@ unit GTKConsts; interface -uses glib2, gdk2, gtk2; +uses lazglib2, gtk2; const // copied from gdkkeysyms GDK_BackSpace = $FF08; diff --git a/libgtk_kylix/GTKControls.pas b/libgtk_kylix/GTKControls.pas index ceafe18..82de154 100644 --- a/libgtk_kylix/GTKControls.pas +++ b/libgtk_kylix/GTKControls.pas @@ -24,8 +24,7 @@ unit GTKControls; interface -uses gtk2, gdk2, glib2, Classes; - // Quick jump: QForms QControls +uses gtk2, gdk2, lazglib2, lazgobject2, Classes; const @@ -416,7 +415,7 @@ function TGTKControl.GetEnabled: boolean; var b: gboolean; begin b := False; - if not (csDestroying in ComponentState) then g_object_get(FWidget, 'sensitive', @b, nil); + if not (csDestroying in ComponentState) then g_object_get(PGObject(FWidget), 'sensitive', [@b, nil]); Result := b; end; @@ -454,29 +453,27 @@ begin FPopupMenu := Value; if not Assigned(Value) then begin if not Assigned(FOnMouseDown) then begin - g_signal_handler_disconnect(PGtkObject(FWidget), FButtonPressSignalHandler); + g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); FButtonPressSignalHandler := 0; end; end else if FButtonPressSignalHandler = 0 - then FButtonPressSignalHandler := g_signal_connect(PGtkObject(FWidget), 'button-press-event', G_CALLBACK(@TGTKControl_button_press_event), Self) + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) end; end; function TGTKControl.GetTooltip: string; -var TooltipsData : PGtkTooltipsData; - text: PChar; +var text: PChar; begin text := nil; Result := ''; - g_object_get(FWidget, 'tooltip-text', @text, nil); + g_object_get(PGObject(FWidget), 'tooltip-text', [@text, nil]); if text <> nil then Result := string(text); end; procedure TGTKControl.SetTooltip(Value: string); -var FParentForm : TCustomGTKForm; begin - g_object_set(FWidget, 'tooltip-text', PChar(Value), nil) + g_object_set(PGObject(FWidget), 'tooltip-text', [PChar(Value), nil]) end; procedure TGTKControl.SetFocus; @@ -489,7 +486,7 @@ function TGTKControl.GetCanFocus: boolean; var b: gboolean; begin b := False; - if not (csDestroying in ComponentState) then g_object_get(FWidget, 'can-focus', @b, nil); + if not (csDestroying in ComponentState) then g_object_get(PGObject(FWidget), 'can-focus', [@b, nil]); Result := b; end; @@ -497,7 +494,7 @@ procedure TGTKControl.SetCanFocus(Value: boolean); begin { if Value then FWidget^.private_flags := FWidget^.private_flags or GTK_CAN_FOCUS else FWidget^.private_flags := FWidget^.private_flags and (not GTK_CAN_FOCUS); } - g_object_set(G_OBJECT(FWidget), 'can-focus', Ord(Value), nil); + g_object_set(PGObject(FWidget), 'can-focus', [Ord(Value), nil]); end; function TGTKControl.GetFocused: boolean; @@ -507,7 +504,7 @@ begin Result := False; try if (csDestroying in ComponentState) or (FWidget = nil) then Exit; - g_object_get(FWidget, 'has-focus', @b, nil); + g_object_get(PGObject(FWidget), 'has-focus', [@b, nil]); Result := b; except end; end; @@ -549,8 +546,8 @@ begin if @FOnKeyDown <> @Value then begin FOnKeyDown := Value; if Assigned(Value) - then FKeyDownSignalHandler := g_signal_connect(PGtkObject(FWidget), 'key-press-event', G_CALLBACK(@TGTKControl_key_press_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FKeyDownSignalHandler); + then FKeyDownSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-press-event', TGCallback(@TGTKControl_key_press_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FKeyDownSignalHandler); end; end; @@ -559,8 +556,8 @@ begin if @FOnKeyUp <> @Value then begin FOnKeyUp := Value; if Assigned(Value) - then FKeyUpSignalHandler := g_signal_connect(PGtkObject(FWidget), 'key-release-event', G_CALLBACK(@TGTKControl_key_release_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FKeyUpSignalHandler); + then FKeyUpSignalHandler := g_signal_connect_data(PGObject(FWidget), 'key-release-event', TGCallback(@TGTKControl_key_release_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FKeyUpSignalHandler); end; end; @@ -585,8 +582,8 @@ begin if @FOnEnter <> @Value then begin FOnEnter := Value; if Assigned(Value) - then FFocusInSignalHandler := g_signal_connect(PGtkObject(FWidget), 'focus-in-event', G_CALLBACK(@TGTKControl_focus_in_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FFocusInSignalHandler); + then FFocusInSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-in-event', TGCallback(@TGTKControl_focus_in_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FFocusInSignalHandler); end; end; @@ -595,8 +592,8 @@ begin if @FOnExit <> @Value then begin FOnExit := Value; if Assigned(Value) - then FFocusOutSignalHandler := g_signal_connect(PGtkObject(FWidget), 'focus-out-event', G_CALLBACK(@TGTKControl_focus_out_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FFocusOutSignalHandler); + then FFocusOutSignalHandler := g_signal_connect_data(PGObject(FWidget), 'focus-out-event', TGCallback(@TGTKControl_focus_out_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FFocusOutSignalHandler); end; end; @@ -666,12 +663,12 @@ begin FOnMouseDown := Value; if not Assigned(Value) then begin if (not Assigned(FPopupMenu)) and (not Assigned(FOnDblClick)) then begin - g_signal_handler_disconnect(PGtkObject(FWidget), FButtonPressSignalHandler); + g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); FButtonPressSignalHandler := 0; end; end else if FButtonPressSignalHandler = 0 - then FButtonPressSignalHandler := g_signal_connect(PGtkObject(FWidget), 'button-press-event', G_CALLBACK(@TGTKControl_button_press_event), Self) + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) end; end; @@ -681,12 +678,12 @@ begin FOnDblClick := Value; if not Assigned(Value) then begin if (not Assigned(FPopupMenu)) and (not Assigned(FOnMouseDown)) then begin - g_signal_handler_disconnect(PGtkObject(FWidget), FButtonPressSignalHandler); + g_signal_handler_disconnect(PGObject(FWidget), FButtonPressSignalHandler); FButtonPressSignalHandler := 0; end; end else if FButtonPressSignalHandler = 0 - then FButtonPressSignalHandler := g_signal_connect(PGtkObject(FWidget), 'button-press-event', G_CALLBACK(@TGTKControl_button_press_event), Self) + then FButtonPressSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-press-event', TGCallback(@TGTKControl_button_press_event), Self, nil, G_CONNECT_DEFAULT) end; end; @@ -708,8 +705,8 @@ procedure TGTKControl.SetOnMouseUp(Value: TGDKMouseEvent); begin if @FOnMouseUp <> @Value then begin FOnMouseUp := Value; - if Assigned(Value) then FButtonReleaseSignalHandler := g_signal_connect(PGtkObject(FWidget), 'button-release-event', G_CALLBACK(@TGTKControl_button_release_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FButtonReleaseSignalHandler); + if Assigned(Value) then FButtonReleaseSignalHandler := g_signal_connect_data(PGObject(FWidget), 'button-release-event', TGCallback(@TGTKControl_button_release_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FButtonReleaseSignalHandler); end; end; @@ -738,8 +735,8 @@ procedure TGTKControl.SetOnMouseMove(Value: TGDKMouseEvent); begin if @FOnMouseMove <> @Value then begin FOnMouseMove := Value; - if Assigned(Value) then FMotionNotifyHandler := g_signal_connect(PGtkObject(FWidget), 'motion-notify-event', G_CALLBACK(@TGTKControl_motion_notify_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FMotionNotifyHandler); + if Assigned(Value) then FMotionNotifyHandler := g_signal_connect_data(PGObject(FWidget), 'motion-notify-event', TGCallback(@TGTKControl_motion_notify_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FMotionNotifyHandler); end; end; @@ -747,14 +744,14 @@ function TGTKControl.GetDefault: boolean; var b: gboolean; begin b := False; - if not (csDestroying in ComponentState) then g_object_get(FWidget, 'has-default', @b, nil); + if not (csDestroying in ComponentState) then g_object_get(PGObject(FWidget), 'has-default', [@b, nil]); Result := b; end; procedure TGTKControl.SetDefault(Value: boolean); begin if (csDestroying in ComponentState) then Exit; - g_object_set(FWidget, 'can-default', Ord(Value), nil); + g_object_set(PGObject(FWidget), 'can-default', [Ord(Value), nil]); end; procedure TGTKControl.Invalidate; @@ -787,8 +784,8 @@ begin if @FOnExpose <> @Value then begin FOnExpose := Value; if Assigned(Value) - then FExposeSignalHandler := g_signal_connect(PGtkObject(FWidget), 'expose-event', G_CALLBACK(@TGTKControl_expose_event), Self) - else g_signal_handler_disconnect(PGtkObject(FWidget), FExposeSignalHandler); + then FExposeSignalHandler := g_signal_connect_data(PGObject(FWidget), 'expose-event', TGCallback(@TGTKControl_expose_event), Self, nil, G_CONNECT_DEFAULT) + else g_signal_handler_disconnect(PGObject(FWidget), FExposeSignalHandler); end; end; @@ -804,12 +801,12 @@ end; function TGTKControl.GetData(Key: string): Pointer; begin - Result := g_object_get_data(G_OBJECT(FWidget), PChar(Key)); + Result := g_object_get_data(PGObject(FWidget), PChar(Key)); end; procedure TGTKControl.SetData(Key: string; Value: Pointer); begin - g_object_set_data(G_OBJECT(FWidget), PChar(Key), Value); + g_object_set_data(PGObject(FWidget), PChar(Key), Value); end; (********************************************************************************************************************************) @@ -847,7 +844,7 @@ end; function TGTKContainer.GetChildrenCount: integer; var List: PGList; begin - List := gtk_container_get_children(PGtkContainer(FWidget)); + List := LAZGLIB2.PGList(gtk_container_get_children(PGtkContainer(FWidget))); Result := g_list_length(List); g_list_free(List); end; @@ -1020,7 +1017,7 @@ function TGTKTable.GetRowCount: integer; var nrows: guint; begin nrows := 1; - g_object_get(FWidget, 'n-rows', @nrows, nil); + g_object_get(PGObject(FWidget), 'n-rows', [@nrows, nil]); Result := nrows; end; @@ -1033,7 +1030,7 @@ function TGTKTable.GetColCount: integer; var ncols: guint; begin ncols := 1; - g_object_get(FWidget, 'n-columns', @ncols, nil); + g_object_get(PGObject(FWidget), 'n-columns', [@ncols, nil]); Result := ncols; end; diff --git a/libgtk_kylix/GTKDialogs.pas b/libgtk_kylix/GTKDialogs.pas index e6e5c7e..17b32d0 100644 --- a/libgtk_kylix/GTKDialogs.pas +++ b/libgtk_kylix/GTKDialogs.pas @@ -24,7 +24,7 @@ unit GTKDialogs; interface -uses gtk2, gdk2, glib2, Classes, GTKControls, GTKConsts, GTKUtils, GTKClasses, GTKForms; +uses gtk2, gdk2, lazglib2, lazgobject2, Classes, GTKControls, GTKUtils, GTKClasses, GTKForms; type @@ -105,7 +105,7 @@ end; constructor TGTKFileSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); begin inherited Create(AOwner); - FWidget := gtk_file_selection_new(StringToPgchar(Title)); + FWidget := gtk_file_selection_new(PChar(Title)); Show; end; @@ -128,7 +128,7 @@ function TGTKFileSelectionDialog.GetShowFileOpButtons: boolean; var b: Boolean; begin b := False; - g_object_get(FWidget, 'show-fileops', @b, nil); + g_object_get(PGObject(FWidget), 'show-fileops', [@b, nil]); Result := b; end; @@ -160,7 +160,7 @@ end; constructor TGTKColorSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); begin inherited Create(AOwner); - FWidget := gtk_color_selection_dialog_new(StringToPgchar(Title)); + FWidget := gtk_color_selection_dialog_new(PChar(Title)); Show; end; @@ -216,7 +216,7 @@ end; constructor TGTKFontSelectionDialog.CreateWithTitle(AOwner: TComponent; const Title: string); begin inherited Create(AOwner); - FWidget := gtk_font_selection_dialog_new(StringToPgchar(Title)); + FWidget := gtk_font_selection_dialog_new(PChar(Title)); Show; end; @@ -227,22 +227,22 @@ end; function TGTKFontSelectionDialog.GetFontName: string; begin - Result := PgcharToString(gtk_font_selection_dialog_get_font_name(PGtkFontSelectionDialog(FWidget))); + Result := String(gtk_font_selection_dialog_get_font_name(PGtkFontSelectionDialog(FWidget))); end; procedure TGTKFontSelectionDialog.SetFontName(Value: string); begin - gtk_font_selection_dialog_set_font_name(PGtkFontSelectionDialog(FWidget), StringToPgchar(Value)); + gtk_font_selection_dialog_set_font_name(PGtkFontSelectionDialog(FWidget), PChar(Value)); end; function TGTKFontSelectionDialog.GetPreviewText: string; begin - Result := PgcharToString(gtk_font_selection_dialog_get_preview_text(PGtkFontSelectionDialog(FWidget))); + Result := String(gtk_font_selection_dialog_get_preview_text(PGtkFontSelectionDialog(FWidget))); end; procedure TGTKFontSelectionDialog.SetPreviewText(Value: string); begin - gtk_font_selection_dialog_set_preview_text(PGtkFontSelectionDialog(FWidget), StringToPgchar(Value)); + gtk_font_selection_dialog_set_preview_text(PGtkFontSelectionDialog(FWidget), PChar(Value)); end; (********************************************************************************************************************************) diff --git a/libgtk_kylix/GTKExtCtrls.pas b/libgtk_kylix/GTKExtCtrls.pas index 8ae5abc..777f8ed 100644 --- a/libgtk_kylix/GTKExtCtrls.pas +++ b/libgtk_kylix/GTKExtCtrls.pas @@ -24,9 +24,7 @@ unit GTKExtCtrls; interface -uses gtk2, gdk2, glib2, Classes, GTKControls, GTKConsts, GTKStdCtrls, GTKUtils, GTKMenus; - // Quick jump: QForms QControls QStdCtrls QExtCtrls - +uses gtk2, lazglib2, lazgobject2, Classes, GTKControls, GTKStdCtrls, GTKMenus; type @@ -326,12 +324,12 @@ end; function TGTKProgressBar.GetText: string; begin - Result := PgcharToString(gtk_progress_bar_get_text(PGtkProgressBar(FWidget))); + Result := String(gtk_progress_bar_get_text(PGtkProgressBar(FWidget))); end; procedure TGTKProgressBar.SetText(Value: string); begin - gtk_progress_bar_set_text(PGtkProgressbar(FWidget), StringToPgchar(Value)); + gtk_progress_bar_set_text(PGtkProgressbar(FWidget), PChar(Value)); end; function TGTKProgressBar.GetFraction: Double; @@ -398,7 +396,7 @@ end; procedure TGTKPaned.SetChild1(Value: TGTKControl); begin gtk_paned_pack1(PGtkPaned(FWidget), Value.FWidget, True, False); - g_signal_connect(PGtkObject(Value.FWidget), 'size-allocate', G_CALLBACK(@TGTKPaned_resize), Self); + g_signal_connect_data(PGObject(Value.FWidget), 'size-allocate', TGCallback(@TGTKPaned_resize), Self, nil, G_CONNECT_DEFAULT); end; procedure TGTKPaned.SetChild2(Value: TGTKControl); @@ -439,7 +437,7 @@ end; procedure TGTKNotebook_switch_page(notebook: PGtkNotebook; page: PGtkNotebookPage; page_num: guint; user_data: gpointer); cdecl; begin - if Assigned(user_data) and Assigned(TGTKNotebook(user_data).FOnSwitchPage) then TGTKNotebook(user_data).FOnSwitchPage(user_data); + if Assigned(user_data) and Assigned(TGTKNotebook(user_data).FOnSwitchPage) then TGTKNotebook(user_data).FOnSwitchPage(TObject(user_data)); end; constructor TGTKNotebook.Create(AOwner: TComponent); @@ -447,7 +445,7 @@ begin inherited Create(AOwner); FWidget := gtk_notebook_new; FOnSwitchPage := nil; - g_signal_connect_after(PGtkObject(FWidget), 'switch-page', G_CALLBACK(@TGTKNotebook_switch_page), Self); + g_signal_connect_data(PGObject(FWidget), 'switch-page', TGCallback(@TGTKNotebook_switch_page), Self, nil, [G_CONNECT_AFTER]); Show; end; @@ -461,17 +459,17 @@ function _gtk_notebook_append_page(notebook:PGtkNotebook; child:PGtkWidget; tab_ function TGTKNotebook.AppendPage(Child: TGTKControl; Caption: string): integer; begin Result := _gtk_notebook_append_page(PGtkNotebook(FWidget), Child.FWidget, nil); - gtk_notebook_set_tab_label_text(PGtkNotebook(FWidget), Child.FWidget, StringToPgchar(Caption)); + gtk_notebook_set_tab_label_text(PGtkNotebook(FWidget), Child.FWidget, PChar(Caption)); end; function TGTKNotebook.GetCaption(PageNo: integer): string; begin - Result := PgcharToString(gtk_notebook_get_tab_label_text(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo))); + Result := String(gtk_notebook_get_tab_label_text(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo))); end; procedure TGTKNotebook.SetCaption(PageNo: integer; Caption: string); begin - gtk_notebook_set_tab_label_text(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo), StringToPgchar(Caption)); + gtk_notebook_set_tab_label_text(PGtkNotebook(FWidget), gtk_notebook_get_nth_page(PGtkNotebook(FWidget), PageNo), PChar(Caption)); end; procedure TGTKNotebook.RemovePage(PageNo: integer); @@ -584,11 +582,11 @@ begin inherited Create(AOwner); FOnChanged := nil; FWidget := gtk_option_menu_new; - g_signal_connect(PGtkObject(FWidget), 'changed', G_CALLBACK(@TGTKOptionMenu_changed), Self); + g_signal_connect_data(PGObject(FWidget), 'changed', TGCallback(@TGTKOptionMenu_changed), Self, nil, G_CONNECT_DEFAULT); Show; FItems := TGTKMenuItem.Create(Self); FItems.FParentMenu := Self; - FItems.Notify := ItemsChanged; + FItems.Notify := @ItemsChanged; end; destructor TGTKOptionMenu.Destroy; diff --git a/libgtk_kylix/GTKForms.pas b/libgtk_kylix/GTKForms.pas index 0224825..a3572b6 100644 --- a/libgtk_kylix/GTKForms.pas +++ b/libgtk_kylix/GTKForms.pas @@ -24,8 +24,7 @@ unit GTKForms; interface -uses gtk2, gdk2, glib2, Classes, SysUtils, GTKControls, GTKConsts; - +uses gtk2, gdk2, lazglib2, lazgobject2, Classes, SysUtils, GTKControls, GTKConsts; type // Some basic types PCharArray = array[0..0] of PChar; @@ -118,7 +117,7 @@ type // Some basic types procedure ShowModal; virtual; function CloseQuery: Boolean; virtual; procedure SetDefaultSize(DefaultWidth, DefaultHeight: integer); - procedure SetTransientFor(Parent: TCustomGTKForm); + procedure SetTransientFor(AParent: TCustomGTKForm); procedure Maximize; procedure Unmaximize; procedure Minimize; @@ -225,10 +224,6 @@ function GetParentForm(Control: TGTKControl): TCustomGTKForm; (********************************************************************************************************************************) implementation -uses GTKUtils; - -(********************************************************************************************************************************) -(********************************************************************************************************************************) constructor TGDKScreen.Create(AOwner: TComponent); begin inherited Create(AOwner); @@ -249,7 +244,7 @@ end; function TGDKScreen.GetForm(Index: Integer): TCustomGTKForm; begin - Result := FForms[Index]; + Result := TCustomGTKForm(FForms[Index]); end; function TGDKScreen.GetFormCount: Integer; @@ -370,7 +365,7 @@ function TCustomGTKForm.GetWindowPosition: TWindowPosition; var pos: TGtkWindowPosition; begin pos := GTK_WIN_POS_NONE; - g_object_get(FWidget, 'window-position', @pos, nil); + g_object_get(PGObject(FWidget), 'window-position', [@pos, nil]); Result := TWindowPosition(pos); end; @@ -394,10 +389,10 @@ begin gtk_window_set_default_size(PGtkWindow(FWidget), DefaultWidth, DefaultHeight); end; -procedure TCustomGTKForm.SetTransientFor(Parent: TCustomGTKForm); +procedure TCustomGTKForm.SetTransientFor(AParent: TCustomGTKForm); begin - if Assigned(Parent) and Assigned(Parent.FWidget) then - gtk_window_set_transient_for(PGtkWindow(FWidget), PGtkWindow(Parent.FWidget)); + if Assigned(AParent) and Assigned(AParent.FWidget) then + gtk_window_set_transient_for(PGtkWindow(FWidget), PGtkWindow(AParent.FWidget)); end; procedure TCustomGTKForm.ShowModal; @@ -527,9 +522,9 @@ begin FMainForm := nil; FMainFormSet := False; if not Assigned(Classes.ApplicationHandleException) then - Classes.ApplicationHandleException := HandleException; + Classes.ApplicationHandleException := @HandleException; if not Assigned(Classes.ApplicationShowException) then - Classes.ApplicationShowException := ShowException; + Classes.ApplicationShowException := @ShowException; CreateHandle; HookSynchronizeWakeup; FThreadID := 0; @@ -578,10 +573,10 @@ var E: TExceptionEvent; begin UnhookSynchronizeWakeup; - P := HandleException; + P := @HandleException; if @P = @Classes.ApplicationHandleException then Classes.ApplicationHandleException := nil; - E := ShowException; + E := @ShowException; if @E = @Classes.ApplicationShowException then Classes.ApplicationShowException := nil; inherited Destroy; @@ -723,12 +718,12 @@ begin Exit; end; Dialog := gtk_message_dialog_new(ParentWindow, GTK_DIALOG_MODAL or GTK_DIALOG_DESTROY_WITH_PARENT, TMessageStyleID[Integer(Style)], - GTK_BUTTONS_NONE, '%s', StringToPgchar(Text)); + GTK_BUTTONS_NONE, '%s', PChar(Text)); for i := 1 to NumMessageButtons do if TMessageButton(i - 1) in Buttons then gtk_dialog_add_button(PGtkDialog(Dialog), MessageButtonID[i], i); - if Escape <> mbNone then g_signal_connect(PGtkObject(Dialog), 'key-press-event', G_CALLBACK(@TGTKApplication_MessageBox_key_press_event), - Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]})); + if Escape <> mbNone then g_signal_connect_data(PGObject(Dialog), 'key-press-event', TGCallback(@TGTKApplication_MessageBox_key_press_event), + Pointer(Ord(Escape) + 1{MessageButtonID[Ord(Escape)]}), nil, G_CONNECT_DEFAULT); if Default <> mbNone then gtk_dialog_set_default_response(PGtkDialog(Dialog), Ord(Default)); Result := TMessageButton(gtk_dialog_run(PGtkDialog(Dialog)) - 1); gtk_widget_destroy(Dialog); @@ -764,9 +759,9 @@ begin inherited Create(AOwner); FWidget := gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_add_accel_group(PGtkWindow(FWidget), FAccelGroup); - g_signal_connect(PGtkObject(FWidget), 'delete-event', G_CALLBACK(@TCustomGTKForm_delete_event), Self); - g_signal_connect(PGtkObject(FWidget), 'size-allocate', G_CALLBACK(@TCustomGTKForm_size_allocate), Self); - g_signal_connect(PGtkObject(FWidget), 'show', G_CALLBACK(@TCustomGTKForm_show), Self); + g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'size-allocate', TGCallback(@TCustomGTKForm_size_allocate), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); Visible := False; SetResizeable(True); FormCreate(Self); @@ -797,9 +792,9 @@ begin if Assigned(AOwner) and (AOwner is TCustomGTKForm) then SetTransientFor(AOwner as TCustomGTKForm); FOnResponse := nil; gtk_window_add_accel_group(PGtkWindow(FWidget), FAccelGroup); - g_signal_connect(PGtkObject(FWidget), 'delete-event', G_CALLBACK(@TCustomGTKForm_delete_event), Self); - g_signal_connect(PGtkObject(FWidget), 'show', G_CALLBACK(@TCustomGTKForm_show), Self); - g_signal_connect(PGtkObject(FWidget), 'response', G_CALLBACK(@TGTKDialog_response_event), Self); + g_signal_connect_data(PGObject(FWidget), 'delete-event', TGCallback(@TCustomGTKForm_delete_event), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'show', TGCallback(@TCustomGTKForm_show), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'response', TGCallback(@TGTKDialog_response_event), Self, nil, G_CONNECT_DEFAULT); ClientArea := TGTKVBox.CreateLinked(Self, PGtkDialog(FWidget)^.vbox); ActionArea := TGTKHBox.CreateLinked(Self, PGtkDialog(FWidget)^.action_area); FButtons := []; @@ -845,7 +840,7 @@ end; procedure TGTKDialog.AddButton(ButtonCaption: string; ButtonID: integer); begin - gtk_dialog_add_button(PGtkDialog(FWidget), StringToPgchar(ButtonCaption), ButtonID); + gtk_dialog_add_button(PGtkDialog(FWidget), PChar(ButtonCaption), ButtonID); end; procedure TGTKDialog.SetResponseSensitive(ButtonID: integer; Sensitive: boolean); diff --git a/libgtk_kylix/GTKMenus.pas b/libgtk_kylix/GTKMenus.pas index bf2c095..ed2bfba 100644 --- a/libgtk_kylix/GTKMenus.pas +++ b/libgtk_kylix/GTKMenus.pas @@ -24,9 +24,7 @@ unit GTKMenus; interface -uses gtk2, gdk2, glib2, Classes, GTKControls, GTKConsts, GTKUtils, GTKPixbuf; - // Quick jump: QForms QControls QMenus - +uses gtk2, gdk2, glib2, lazglib2, lazgobject2, Classes, GTKControls, GTKConsts, GTKPixbuf; type (****************************************** TGDKSHORTCUTS ***********************************************************************) @@ -142,7 +140,7 @@ function MakeGDKShortCut(Key: word; Locked, ModAlt, ModShift, ModCtrl : boolean) (********************************************************************************************************************************) implementation -uses GTKForms, GTKExtCtrls; +uses GTKForms; (********************************************************************************************************************************) (********************************************************************************************************************************) @@ -236,9 +234,9 @@ begin gtk_widget_show(FImageWidget); gtk_image_menu_item_set_image(PGtkImageMenuItem(FWidget), FImageWidget); end; - itRadio: FWidget := gtk_radio_menu_item_new_with_mnemonic(AGroup, Pgchar(SCDefaultMenuItemCaption)); + itRadio: FWidget := gtk_radio_menu_item_new_with_mnemonic(GLIB2.PGSList(AGroup), Pgchar(SCDefaultMenuItemCaption)); end; - g_signal_connect(PGtkObject(FWidget), 'activate', G_CALLBACK(@TGTKMenuItem_activate), Self); + g_signal_connect_data(PGObject(FWidget), 'activate', TGCallback(@TGTKMenuItem_activate), Self, nil, G_CONNECT_DEFAULT); Show; end; @@ -264,7 +262,7 @@ function TGTKMenuItem.GetItem(Index: Integer): TGTKMenuItem; begin Result := nil; if FItems = nil then Exit; - Result := FItems[Index]; + Result := TGTKMenuItem(FItems[Index]); end; procedure TGTKMenuItem.Delete(Index: Integer); @@ -311,20 +309,20 @@ function TGTKMenuItem.GetCaption: string; begin Result := ''; if FItemType in [itSeparator, itTearOff] then Exit; - if Assigned(ChildControl) then Result := PgcharToString(gtk_label_get_text(PGtkLabel(ChildControl))); + if Assigned(ChildControl) then Result := String(gtk_label_get_text(PGtkLabel(ChildControl))); end; procedure TGTKMenuItem.SetCaption(Value: string); begin if FItemType in [itSeparator, itTearOff] then Exit; - gtk_label_set_markup_with_mnemonic(PGtkLabel(ChildControl), StringToPgchar(Value)); + gtk_label_set_markup_with_mnemonic(PGtkLabel(ChildControl), PChar(Value)); if FTearOffTitle = '' then SetTearOffTitle(Value); end; procedure TGTKMenuItem.SetCaptionPlain(Value: string); begin if FItemType in [itSeparator, itTearOff] then Exit; - gtk_label_set_markup(PGtkLabel(ChildControl), StringToPgchar(Value)); + gtk_label_set_markup(PGtkLabel(ChildControl), PChar(Value)); if FTearOffTitle = '' then SetTearOffTitle(Value); end; @@ -333,8 +331,8 @@ begin FTearOffTitle := Value; if FItemType = itTearOff then begin if Assigned(FParentMenu) and (FParentMenu is TGTKMenuItem) and Assigned((FParentMenu as TGTKMenuItem).FMenu) - then gtk_menu_set_title(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), StringToPgchar(FTearOffTitle)) - end else if Assigned(FMenu) then gtk_menu_set_title(PGtkMenu(FMenu), StringToPgchar(FTearOffTitle)); + then gtk_menu_set_title(PGtkMenu((FParentMenu as TGTKMenuItem).FMenu), PChar(FTearOffTitle)) + end else if Assigned(FMenu) then gtk_menu_set_title(PGtkMenu(FMenu), PChar(FTearOffTitle)); end; function TGTKMenuItem.GetRightJustified: boolean; @@ -362,8 +360,8 @@ function TGTKMenuItem.GetTornOff: boolean; var b: gboolean; begin b := False; - if FItemType = itTearOff then g_object_get(FWidget, 'tearoff-state', @b, nil) else - if Assigned(FMenu) and (Count > 0) then g_object_get(FMenu, 'tearoff-state', @b, nil); + if FItemType = itTearOff then g_object_get(PGObject(FWidget), 'tearoff-state', [@b, nil]) else + if Assigned(FMenu) and (Count > 0) then g_object_get(PGObject(FMenu), 'tearoff-state', [@b, nil]); Result := b; end; @@ -421,12 +419,12 @@ end; function TGTKMenuItem.GetGroup: TGTKMenuItemGroup; begin - Result := gtk_radio_menu_item_get_group(PGtkRadioMenuItem(FWidget)); + Result := LAZGLIB2.PGSList(gtk_radio_menu_item_get_group(PGtkRadioMenuItem(FWidget))); end; procedure TGTKMenuItem.SetGroup(Value: TGTKMenuItemGroup); begin - gtk_radio_menu_item_set_group(PGtkRadioMenuItem(FWidget), Value); + gtk_radio_menu_item_set_group(PGtkRadioMenuItem(FWidget), GLIB2.PGSList(Value) ); end; (********************************************************************************************************************************) @@ -457,7 +455,7 @@ end; procedure TGDKShortCuts.AddName(Item: string); var Key, Modifiers: guint; begin - gtk_accelerator_parse(StringToPgchar(Item), @Key, @Modifiers); + gtk_accelerator_parse(PChar(Item), @Key, @Modifiers); if Key <> 0 then Add(MakeGDKShortCut(Key, False, Modifiers and GDK_MOD1_MASK = GDK_MOD1_MASK, Modifiers and GDK_SHIFT_MASK = GDK_SHIFT_MASK, Modifiers and GDK_CONTROL_MASK = GDK_CONTROL_MASK)); end; diff --git a/libgtk_kylix/GTKPixbuf.pas b/libgtk_kylix/GTKPixbuf.pas index a51bef2..c296add 100644 --- a/libgtk_kylix/GTKPixbuf.pas +++ b/libgtk_kylix/GTKPixbuf.pas @@ -24,8 +24,7 @@ unit GTKPixbuf; interface -uses glib2, gdk2, gdk2pixbuf, gtk2, Classes, GTKControls, GTKStdCtrls; - +uses lazglib2, gdk2pixbuf, gtk2, Classes, GTKControls, GTKStdCtrls; type TGTKIconSize = (isInvalid, isMenu, isSmallToolbar, isLargeToolbar, isButton, isDND, isDialog); diff --git a/libgtk_kylix/GTKStdCtrls.pas b/libgtk_kylix/GTKStdCtrls.pas index 8f53f50..33ca7a6 100644 --- a/libgtk_kylix/GTKStdCtrls.pas +++ b/libgtk_kylix/GTKStdCtrls.pas @@ -24,9 +24,7 @@ unit GTKStdCtrls; interface -uses gtk2, gdk2, glib2, Classes, GTKControls, GTKConsts, GTKClasses; - // Quick jump: QForms QControls QStdCtrls - +uses gtk2, glib2, lazglib2, lazgobject2, Classes, GTKControls, GTKConsts, GTKClasses; type @@ -288,10 +286,6 @@ procedure TGTKButton_OnClick(button: PGtkButton; user_data: Pgpointer); cdecl; (********************************************************************************************************************************) implementation -uses GTKUtils; - -(********************************************************************************************************************************) -(********************************************************************************************************************************) procedure TGTKButton_OnClick(button: PGtkButton; user_data: Pgpointer); cdecl; begin if Assigned(TGTKButton(user_data).FOnClick) then TGTKButton(user_data).FOnClick(TGTKButton(user_data)); @@ -302,8 +296,8 @@ begin inherited Create(AOwner); FOnClick := nil; if ClassName = 'TGTKButton' then begin - FWidget := gtk_button_new_with_mnemonic(StringToPgchar(SCDefaultButtonCaption)); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + FWidget := gtk_button_new_with_mnemonic(PChar(SCDefaultButtonCaption)); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -314,7 +308,7 @@ begin FOnClick := nil; if ClassName = 'TGTKButton' then begin FWidget := gtk_button_new_from_stock(StockID); - g_signal_connect(PGtkObject(FWidget), 'clicked', G_CALLBACK(@TGTKButton_OnClick), Self); + g_signal_connect_data(PGObject(FWidget), 'clicked', TGCallback(@TGTKButton_OnClick), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -326,12 +320,12 @@ end; function TGTKButton.GetCaption: string; begin - Result := PgcharToString(gtk_label_get_text(PGtkLabel(ChildControl))); + Result := String(gtk_label_get_text(PGtkLabel(ChildControl))); end; procedure TGTKButton.SetCaption(Value: string); begin - gtk_label_set_text_with_mnemonic(PGtkLabel(ChildControl), StringToPgchar(Value)); + gtk_label_set_text_with_mnemonic(PGtkLabel(ChildControl), PChar(Value)); end; function TGTKButton.GetUseStock: boolean; @@ -385,11 +379,11 @@ procedure _gtk_misc_get_alignment(misc:PGtkMisc; xalign:Pgfloat; yalign:Pgfloat) procedure _gtk_misc_get_padding(misc:PGtkMisc; xpad:Pgint; ypad:Pgint); cdecl; external gtklib name 'gtk_misc_get_padding'; function TGTKMisc.GetXAlign: Single; -var xalign: gfloat; +var axalign: gfloat; begin - xalign := 0.0; - _gtk_misc_get_alignment(PGtkMisc(FWidget), @xalign, nil); - Result := xalign; + axalign := 0.0; + _gtk_misc_get_alignment(PGtkMisc(FWidget), @axalign, nil); + Result := axalign; end; procedure TGTKMisc.SetXAlign(Value: Single); @@ -398,11 +392,11 @@ begin end; function TGTKMisc.GetYAlign: Single; -var yalign: gfloat; +var ayalign: gfloat; begin - yalign := 0.0; - _gtk_misc_get_alignment(PGtkMisc(FWidget), nil, @yalign); - Result := yalign; + ayalign := 0.0; + _gtk_misc_get_alignment(PGtkMisc(FWidget), nil, @ayalign); + Result := ayalign; end; procedure TGTKMisc.SetYAlign(Value: Single); @@ -466,12 +460,12 @@ end; function TGTKLabel.GetCaption: string; begin - Result := PgcharToString(gtk_label_get_text(PGtkLabel(FWidget))); + Result := String(gtk_label_get_text(PGtkLabel(FWidget))); end; procedure TGTKLabel.SetCaption(Value: string); begin - gtk_label_set_text(PGtkLabel(FWidget), StringToPgchar(Value)); + gtk_label_set_text(PGtkLabel(FWidget), PChar(Value)); end; function TGTKLabel.GetAlignment: TGTKAlignment; @@ -546,8 +540,8 @@ begin inherited Create(AOwner); FOnToggled := nil; if ClassName = 'TGTKToggleButton' then begin - FWidget := gtk_toggle_button_new_with_label(StringToPgchar(SCDefaultToggleButtonCaption)); - g_signal_connect(PGtkObject(FWidget), 'toggled', G_CALLBACK(@TGTKToggleButton_OnToggled), Self); + FWidget := gtk_toggle_button_new_with_label(PChar(SCDefaultToggleButtonCaption)); + g_signal_connect_data(PGObject(FWidget), 'toggled', TGCallback(@TGTKToggleButton_OnToggled), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -559,12 +553,12 @@ end; function TGTKToggleButton.GetCaption: string; begin - Result := PgcharToString(gtk_label_get_text(PGtkLabel(ChildControl))); + Result := String(gtk_label_get_text(PGtkLabel(ChildControl))); end; procedure TGTKToggleButton.SetCaption(Value: string); begin - gtk_label_set_text(PGtkLabel(ChildControl), StringToPgchar(Value)); + gtk_label_set_text(PGtkLabel(ChildControl), PChar(Value)); end; function TGTKToggleButton.GetChecked: boolean; @@ -603,8 +597,8 @@ constructor TGTKCheckButton.Create(AOwner: TComponent); begin inherited Create(AOwner); if ClassName = 'TGTKCheckButton' then begin - FWidget := gtk_check_button_new_with_mnemonic(StringToPgchar(SCDefaultCheckButtonCaption)); - g_signal_connect(PGtkObject(FWidget), 'toggled', G_CALLBACK(@TGTKToggleButton_OnToggled), Self); + FWidget := gtk_check_button_new_with_mnemonic(PChar(SCDefaultCheckButtonCaption)); + g_signal_connect_data(PGObject(FWidget), 'toggled', TGCallback(@TGTKToggleButton_OnToggled), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -613,8 +607,8 @@ constructor TGTKCheckButton.CreateWithLabel(AOwner: TComponent; const ALabel: st begin inherited Create(AOwner); if ClassName = 'TGTKCheckButton' then begin - FWidget := gtk_check_button_new_with_mnemonic(StringToPgchar(ALabel)); - g_signal_connect(PGtkObject(FWidget), 'toggled', G_CALLBACK(@TGTKToggleButton_OnToggled), Self); + FWidget := gtk_check_button_new_with_mnemonic(PChar(ALabel)); + g_signal_connect_data(PGObject(FWidget), 'toggled', TGCallback(@TGTKToggleButton_OnToggled), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -630,8 +624,8 @@ constructor TGTKRadioButton.Create(AOwner: TComponent); begin inherited Create(AOwner); if ClassName = 'TGTKRadioButton' then begin - FWidget := gtk_radio_button_new_with_label(nil, StringToPgchar(SCDefaultRadioButtonCaption)); - g_signal_connect(PGtkObject(FWidget), 'toggled', G_CALLBACK(@TGTKToggleButton_OnToggled), Self); + FWidget := gtk_radio_button_new_with_label(nil, PChar(SCDefaultRadioButtonCaption)); + g_signal_connect_data(PGObject(FWidget), 'toggled', TGCallback(@TGTKToggleButton_OnToggled), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -640,8 +634,8 @@ constructor TGTKRadioButton.CreateWithLabel(AOwner: TComponent; const ALabel: st begin inherited Create(AOwner); if ClassName = 'TGTKRadioButton' then begin - FWidget := gtk_radio_button_new_with_mnemonic(nil, StringToPgchar(ALabel)); - g_signal_connect(PGtkObject(FWidget), 'toggled', G_CALLBACK(@TGTKToggleButton_OnToggled), Self); + FWidget := gtk_radio_button_new_with_mnemonic(nil, PChar(ALabel)); + g_signal_connect_data(PGObject(FWidget), 'toggled', TGCallback(@TGTKToggleButton_OnToggled), Self, nil, G_CONNECT_DEFAULT); Show; end; end; @@ -662,7 +656,7 @@ end; constructor TGTKFrame.Create(AOwner: TComponent); begin inherited Create(AOwner); - FWidget := gtk_frame_new(StringToPgchar(SCDefaultFrameCaption)); + FWidget := gtk_frame_new(PChar(SCDefaultFrameCaption)); Show; end; @@ -680,12 +674,12 @@ end; function TGTKFrame.GetCaption: string; begin - Result := PgcharToString(gtk_frame_get_label(PGtkFrame(FWidget))); + Result := String(gtk_frame_get_label(PGtkFrame(FWidget))); end; procedure TGTKFrame.SetCaption(Value: string); begin - gtk_label_set_text(PGtkLabel(gtk_frame_get_label_widget(PGtkFrame(FWidget))), StringToPgchar(Value)); + gtk_label_set_text(PGtkLabel(gtk_frame_get_label_widget(PGtkFrame(FWidget))), PChar(Value)); end; function TGTKFrame.GetShadowType: TGTKShadowType; @@ -750,7 +744,7 @@ procedure TGTKEditable.InsertText(AText: string; Position: integer); var pos: gint; begin pos := Position; - gtk_editable_insert_text(PGtkEditable(FWidget), StringToPgchar(AText), Length(AText), @pos); + gtk_editable_insert_text(PGtkEditable(FWidget), PChar(AText), Length(AText), @pos); end; procedure TGTKEditable.DeleteText(StartPosition, EndPosition: integer); @@ -760,7 +754,7 @@ end; function TGTKEditable.GetChars(StartPosition, EndPosition: integer): string; begin - Result := PgcharToString(gtk_editable_get_chars(PGtkEditable(FWidget), StartPosition, EndPosition)); + Result := String(gtk_editable_get_chars(PGtkEditable(FWidget), StartPosition, EndPosition)); end; procedure TGTKEditable.SelectRegion(StartPosition, EndPosition: integer); @@ -786,7 +780,7 @@ begin FLinked := False; FWidget := gtk_entry_new; Show; - g_signal_connect(PGtkObject(FWidget), 'changed', G_CALLBACK(@TGTKEditable_Changed), Self); + g_signal_connect_data(PGObject(FWidget), 'changed', TGCallback(@TGTKEditable_Changed), Self, nil, G_CONNECT_DEFAULT); end; constructor TGTKEntry.CreateFromWidget(AOwner: TComponent; Widget: PGtkWidget); @@ -794,7 +788,7 @@ begin inherited Create(AOwner); FLinked := True; FWidget := Widget; - g_signal_connect(PGtkObject(FWidget), 'changed', G_CALLBACK(@TGTKEditable_Changed), Self); + g_signal_connect_data(PGObject(FWidget), 'changed', TGCallback(@TGTKEditable_Changed), Self, nil, G_CONNECT_DEFAULT); end; destructor TGTKEntry.Destroy; @@ -804,12 +798,12 @@ end; function TGTKEntry.GetText: string; begin - Result := PgcharToString(gtk_entry_get_text(PGtkEntry(FWidget))); + Result := String(gtk_entry_get_text(PGtkEntry(FWidget))); end; procedure TGTKEntry.SetText(Value: string); begin - gtk_entry_set_text(PGtkEntry(FWidget), StringToPgchar(Value)); + gtk_entry_set_text(PGtkEntry(FWidget), PChar(Value)); end; function TGTKEntry.GetMaxLength: integer; @@ -844,7 +838,7 @@ begin inherited Create(AOwner); FWidget := gtk_combo_new; Items := TGList.Create(Self); - Items.Notify := ItemsChanged; + Items.Notify := @ItemsChanged; Entry := TGTKEntry.CreateFromWidget(Self, PGtkCombo(FWidget)^.entry); Show; end; @@ -857,33 +851,33 @@ end; procedure TGTKCombo.UpdateItems; begin - gtk_combo_set_popdown_strings(PGtkCombo(FWidget), Items.FList); + gtk_combo_set_popdown_strings(PGtkCombo(FWidget), GLIB2.PGList(Items.FList)); end; function TGTKCombo.GetAllowEmpty: boolean; var b: gboolean; begin b := False; - g_object_get(FWidget, 'allow-empty', @b, nil); + g_object_get(PGObject(FWidget), 'allow-empty', [@b, nil]); Result := b; end; procedure TGTKCombo.SetAllowEmpty(Value: boolean); begin - g_object_set(FWidget, 'allow-empty', Ord(Value), nil); + g_object_set(PGObject(FWidget), 'allow-empty', [Ord(Value), nil]); end; function TGTKCombo.GetMatchValue: boolean; var b: gboolean; begin b := False; - g_object_get(FWidget, 'value-in-list', @b, nil); + g_object_get(PGObject(FWidget), 'value-in-list', [@b, nil]); Result := b; end; procedure TGTKCombo.SetMatchValue(Value: boolean); begin - g_object_set(FWidget, 'value-in-list', Ord(Value), nil); + g_object_set(PGObject(FWidget), 'value-in-list', [Ord(Value), nil]); end; procedure TGTKCombo.SetPolicy(MatchValue, AllowEmpty: boolean); @@ -895,7 +889,7 @@ function TGTKCombo.GetCaseSensitive: boolean; var b: gboolean; begin b := False; - g_object_get(FWidget, 'case-sensitive', @b, nil); + g_object_get(PGObject(FWidget), 'case-sensitive', [@b, nil]); Result := b; end; diff --git a/libgtk_kylix/GTKText.pas b/libgtk_kylix/GTKText.pas index 127e399..d3152b1 100644 --- a/libgtk_kylix/GTKText.pas +++ b/libgtk_kylix/GTKText.pas @@ -24,7 +24,7 @@ unit GTKText; interface -uses gtk2, gdk2, glib2, Classes, GTKControls, GTKConsts, GTKUtils, GTKClasses, GTKForms; +uses gtk2, lazgobject2, Classes, GTKControls, GTKForms; type @@ -88,7 +88,7 @@ begin FTextBuffer := TGTKTextBuffer.Create(Self); FWidget := gtk_text_view_new_with_buffer(FTextBuffer.FBuffer); Show; - g_object_unref(FTextBuffer.FBuffer); + g_object_unref(PGObject(FTextBuffer.FBuffer)); end; destructor TGTKTextView.Destroy; diff --git a/libgtk_kylix/GTKUtils.pas b/libgtk_kylix/GTKUtils.pas index acc30ca..f893858 100644 --- a/libgtk_kylix/GTKUtils.pas +++ b/libgtk_kylix/GTKUtils.pas @@ -24,11 +24,9 @@ unit GTKUtils; interface -uses gtk2, gdk2, glib2, SysUtils, GTKControls, GTKClasses; +uses gtk2, gdk2, lazglib2, SysUtils, GTKControls, GTKClasses; (********************************************************************************************************************************) -function PgcharToString(const S: Pgchar): string; -function StringToPgchar(const S: string): Pgchar; function AllocateColor(Widget: PGtkWidget; R, G, B: Word): PGdkColor; overload; function AllocateColor(R, G, B: Word): TGDKColor; overload; function KeyValToUnicode(const Key: word): guint32; @@ -49,18 +47,6 @@ function StringToGDKColor(Str: string; var Color: TGDKColor): boolean; implementation -(********************************************************************************************************************************) -function PgcharToString(const S: Pgchar): string; -begin - Result := string(S); -end; - -(********************************************************************************************************************************) -function StringToPgchar(const S: string): Pgchar; -begin - Result := PChar(S); -end; - (********************************************************************************************************************************) function AllocateColor(Widget: PGtkWidget; R, G, B: Word): PGdkColor; begin @@ -178,10 +164,10 @@ end; (********************************************************************************************************************************) function PGdkColorToGDKColor(Color: PGdkColor): TGDKColor; begin - Result.pixel := Color.pixel; - Result.red := Color.red; - Result.green := Color.green; - Result.blue := Color.blue; + Result.pixel := Color^.pixel; + Result.red := Color^.red; + Result.green := Color^.green; + Result.blue := Color^.blue; end; (********************************************************************************************************************************) diff --git a/libgtk_kylix/GTKView.pas b/libgtk_kylix/GTKView.pas index 3b46fad..3cd00dc 100644 --- a/libgtk_kylix/GTKView.pas +++ b/libgtk_kylix/GTKView.pas @@ -21,13 +21,10 @@ *) unit GTKView; -{$O+} // Optimization needs to be enabled for this unit due to bug in compiler (fixed columns doesn't work) interface -uses gtk2, gdk2, gdk2pixbuf, glib2, Classes, GTKControls, GTKConsts, GTKUtils, GTKClasses, GTKForms, GTKPixbuf; - // Quick jump: QForms QControls QStdCtrls QComCtrls - +uses gtk2, gdk2, gdk2pixbuf, glib2, lazglib2, lazgobject2, Classes, GTKControls, GTKForms; type TGTKListItem = class; @@ -439,10 +436,9 @@ end; function TGTKView.ConvertToSorted(Index: integer): integer; var Path: PGtkTreePath; - Iter: TGtkTreeIter; begin Result := Index; - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(Index))); if not Assigned(Path) then Exit; if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_child_path_to_path(FTreeModelSort, Path); if not Assigned(Path) then Exit; @@ -452,10 +448,9 @@ end; function TGTKView.ConvertFromSorted(Index: integer): integer; var Path: PGtkTreePath; - Iter: TGtkTreeIter; begin Result := Index; - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Index))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(Index))); if not Assigned(Path) then Exit; if Assigned(FTreeModelSort) then Path := gtk_tree_model_sort_convert_path_to_child_path(FTreeModelSort, Path); if not Assigned(Path) then Exit; @@ -520,9 +515,9 @@ begin FWidget := gtk_tree_view_new_with_model(FTreeModelSort); end; FSelection := gtk_tree_view_get_selection(PGtkTreeView(FWidget)); - g_signal_connect(FSelection, 'changed', G_CALLBACK(@TGTKListView_changed), Self); - g_signal_connect(FWidget, 'row-activated', G_CALLBACK(@TGTKListView_row_activated), Self); - g_signal_connect_after(FWidget, 'columns-changed', G_CALLBACK(@TGTKListView_columns_changed), Self); + g_signal_connect_data(PGObject(FSelection), 'changed', TGCallback(@TGTKListView_changed), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'row-activated', TGCallback(@TGTKListView_row_activated), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FWidget), 'columns-changed', TGCallback(@TGTKListView_columns_changed), Self, nil, [G_CONNECT_AFTER]); FTreeModel := gtk_tree_view_get_model(PGtkTreeView(FWidget)); Show; end; @@ -540,7 +535,6 @@ function TGTKListView.GetSelected: TGTKListItem; var Iter: TGtkTreeIter; Path: PGtkTreePath; AIndex: integer; - i: integer; begin Result := nil; Path := nil; @@ -560,7 +554,7 @@ end; procedure TGTKListView.SetSelected(Value: TGTKListItem); var Path: PGtkTreePath; begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(Value.FIndex))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(Value.FIndex))); ConvertChildToPath(Path); gtk_tree_selection_select_path(FSelection, Path); gtk_tree_path_free(Path); @@ -596,6 +590,8 @@ var Path: PGtkTreePath; AIndex: integer; begin Result := nil; + Path := nil; + Column := nil; if gtk_tree_view_get_path_at_pos(PGtkTreeView(FWidget), X, Y, Path, Column, nil, nil) then begin if not Assigned(Path) then Exit; ConvertPathToChild(Path); @@ -698,7 +694,7 @@ var x: pointer; Iter: TGtkTreeIter; begin x := FList[Index]; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel(FStore), @Iter, StringToPgchar(IntToStr(Index))) then begin + if gtk_tree_model_get_iter_from_string(PGtkTreeModel(FStore), @Iter, PChar(IntToStr(Index))) then begin // (FOwner as TGTKView).CovertSortableIter(Iter); gtk_list_store_remove(FStore, @Iter); end; @@ -839,12 +835,12 @@ end; function TGTKTreeViewColumn.GetCaption: string; begin - Result := PgcharToString(gtk_tree_view_column_get_title(FColumn)); + Result := String(gtk_tree_view_column_get_title(FColumn)); end; procedure TGTKTreeViewColumn.SetCaption(Value: string); begin - gtk_tree_view_column_set_title(FColumn, StringToPgchar(Value)); + gtk_tree_view_column_set_title(FColumn, PChar(Value)); end; function TGTKTreeViewColumn.GetVisible: boolean; @@ -979,7 +975,7 @@ var NewText: string; Path: PGtkTreePath; begin if Assigned(TGTKTreeViewColumn(data).FOnEdited) then begin - NewText := PgcharToString(new_text); + NewText := String(new_text); AllowChange := True; DataColumn := TGTKTreeViewColumn(data).FIndex; Path := gtk_tree_path_new_from_string(path_string); @@ -1027,19 +1023,19 @@ begin end; if Value = ctImageText then gtk_tree_view_column_pack_start(FColumn, FPixbufRenderer, False); gtk_tree_view_column_pack_start(FColumn, FRenderer, True); - if (Value = ctImageText) or (Value = ctText) then g_signal_connect(FRenderer, 'edited', G_CALLBACK(@TGTKTreeViewColumn_edited), Self); - if Value = ctToggle then g_signal_connect(FRenderer, 'toggled', G_CALLBACK(@TGTKTreeViewColumn_toggled), Self); - g_signal_connect_after(FColumn, 'clicked', G_CALLBACK(@TGTKTreeViewColumn_clicked), Self); + if (Value = ctImageText) or (Value = ctText) then g_signal_connect_data(PGObject(FRenderer), 'edited', TGCallback(@TGTKTreeViewColumn_edited), Self, nil, G_CONNECT_DEFAULT); + if Value = ctToggle then g_signal_connect_data(PGObject(FRenderer), 'toggled', TGCallback(@TGTKTreeViewColumn_toggled), Self, nil, G_CONNECT_DEFAULT); + g_signal_connect_data(PGObject(FColumn), 'clicked', TGCallback(@TGTKTreeViewColumn_clicked), Self, nil, [G_CONNECT_AFTER]); end; procedure TGTKTreeViewColumn.AddAttribute(Attribute: string; Value: integer); begin - gtk_tree_view_column_add_attribute(FColumn, FRenderer, StringToPgchar(Attribute), Value); + gtk_tree_view_column_add_attribute(FColumn, FRenderer, PChar(Attribute), Value); end; procedure TGTKTreeViewColumn.AddImageAttribute(Attribute: string; Value: integer); begin - gtk_tree_view_column_add_attribute(FColumn, FPixbufRenderer, StringToPgchar(Attribute), Value); + gtk_tree_view_column_add_attribute(FColumn, FPixbufRenderer, PChar(Attribute), Value); end; procedure TGTKTreeViewColumn.ClearAttributes; @@ -1052,15 +1048,15 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_LONG; AValue.data[0].v_long := Value; - g_object_set_property(PGObject(FRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetProperty(AProperty: string; Value: string); var AValue: TGValue; begin AValue.g_type := G_TYPE_STRING; - AValue.data[0].v_pointer := StringToPgchar(Value); - g_object_set_property(PGObject(FRenderer), StringToPgchar(AProperty), @AValue); + AValue.data[0].v_pointer := PChar(Value); + g_object_set_property(PGObject(FRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetProperty(AProperty: string; Value: Double); @@ -1068,7 +1064,7 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_DOUBLE; AValue.data[0].v_double := Value; - g_object_set_property(PGObject(FRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetProperty(AProperty: string; Value: pointer); @@ -1076,7 +1072,7 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_POINTER; AValue.data[0].v_pointer := Value; - g_object_set_property(PGObject(FRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetImageProperty(AProperty: string; Value: integer); @@ -1084,15 +1080,15 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_LONG; AValue.data[0].v_long := Value; - g_object_set_property(PGObject(FPixbufRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FPixbufRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetImageProperty(AProperty: string; Value: string); var AValue: TGValue; begin AValue.g_type := G_TYPE_STRING; - AValue.data[0].v_pointer := StringToPgchar(Value); - g_object_set_property(PGObject(FPixbufRenderer), StringToPgchar(AProperty), @AValue); + AValue.data[0].v_pointer := PChar(Value); + g_object_set_property(PGObject(FPixbufRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetImageProperty(AProperty: string; Value: Double); @@ -1100,7 +1096,7 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_DOUBLE; AValue.data[0].v_double := Value; - g_object_set_property(PGObject(FPixbufRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FPixbufRenderer), PChar(AProperty), @AValue); end; procedure TGTKTreeViewColumn.SetImageProperty(AProperty: string; Value: pointer); @@ -1108,7 +1104,7 @@ var AValue: TGValue; begin AValue.g_type := G_TYPE_POINTER; AValue.data[0].v_pointer := Value; - g_object_set_property(PGObject(FPixbufRenderer), StringToPgchar(AProperty), @AValue); + g_object_set_property(PGObject(FPixbufRenderer), PChar(AProperty), @AValue); end; (********************************************************************************************************************************) @@ -1130,11 +1126,11 @@ var Iter: TGtkTreeIter; AValue: TGValue; begin Result := ''; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin AValue.g_type := 0; gtk_tree_model_get_value(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, @AValue); - Result := PgcharToString(AValue.data[0].v_pointer); + Result := String(AValue.data[0].v_pointer); end; end; @@ -1143,7 +1139,7 @@ var Iter: TGtkTreeIter; AValue: TGValue; begin Result := 0; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin AValue.g_type := 0; gtk_tree_model_get_value(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, @AValue); @@ -1156,7 +1152,7 @@ var Iter: TGtkTreeIter; AValue: TGValue; begin Result := nil; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin AValue.g_type := 0; gtk_tree_model_get_value(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, @AValue); @@ -1169,7 +1165,7 @@ var Iter: TGtkTreeIter; AValue: TGValue; begin Result := False; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin AValue.g_type := 0; gtk_tree_model_get_value(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, @AValue); @@ -1180,28 +1176,28 @@ end; procedure TGTKListItem.SetValue(Index: longint; Value: string); var Iter: TGtkTreeIter; begin - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) - then gtk_list_store_set(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, StringToPgchar(Value), -1); + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) + then gtk_list_store_set(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, PChar(Value), -1); end; procedure TGTKListItem.SetValue(Index: longint; Value: integer); var Iter: TGtkTreeIter; begin - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then gtk_list_store_set(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, Value, -1); end; procedure TGTKListItem.SetValue(Index: longint; Value: pointer); var Iter: TGtkTreeIter; begin - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then gtk_list_store_set(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, Value, -1); end; procedure TGTKListItem.SetValue(Index: longint; Value: boolean); var Iter: TGtkTreeIter; begin - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then gtk_list_store_set(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, Index, Value, -1); end; @@ -1209,7 +1205,7 @@ function TGTKListItem.GetSelected: boolean; var Iter: TGtkTreeIter; begin Result := False; - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then begin + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin // ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertSortableIter(Iter); Result := gtk_tree_selection_iter_is_selected(((FOwner as TGTKListItems).FOwner as TGTKView).FSelection, @Iter); end; @@ -1217,10 +1213,9 @@ end; procedure TGTKListItem.SetSelected(Value: boolean); var Iter, NewIter: TGtkTreeIter; - Path: PGtkTreePath; begin try - if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, StringToPgchar(IntToStr(FIndex))) then begin + if gtk_tree_model_get_iter_from_string(PGtkTreeModel((FOwner as TGTKListItems).FStore), @Iter, PChar(IntToStr(FIndex))) then begin if Assigned(((FOwner as TGTKListItems).FOwner as TGTKView).FTreeModelSort) then begin gtk_tree_model_sort_convert_child_iter_to_iter(((FOwner as TGTKListItems).FOwner as TGTKView).FTreeModelSort, @NewIter, @Iter); Iter := NewIter; @@ -1237,7 +1232,7 @@ var Path: PGtkTreePath; // Renderer: PGtkCellRenderer; i : integer; begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(FIndex))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(FIndex))); if not Assigned(Path) then Exit; ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertChildToPath(Path); if not Assigned(Path) then Exit; @@ -1260,7 +1255,7 @@ var CellEditable: PGtkCellEditable; Column: PGtkTreeViewColumn; BackgroundRect, CellRect: TGdkRectangle; begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(FIndex))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(FIndex))); if not Assigned(Path) then Exit; ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertChildToPath(Path); if not Assigned(Path) then Exit; @@ -1270,7 +1265,7 @@ begin gtk_tree_view_column_focus_cell(Column, ((FOwner as TGTKListItems).FOwner as TGTKView).Columns[ColumnNo].FRenderer); CellEditable := gtk_cell_renderer_start_editing(((FOwner as TGTKListItems).FOwner as TGTKView).Columns[ColumnNo].FRenderer, - nil, ((FOwner as TGTKListItems).FOwner as TGTKView).FWidget, PChar(StringToPgchar(IntToStr(FIndex))), + nil, ((FOwner as TGTKListItems).FOwner as TGTKView).FWidget, PChar(PChar(IntToStr(FIndex))), @BackgroundRect, @CellRect, {GTK_CELL_RENDERER_SELECTED or GTK_CELL_RENDERER_SORTED} 0); gtk_widget_show(CellEditable); // gtk_cell_editable_start_editing(CellEditable, nil); @@ -1284,7 +1279,7 @@ var Rect, BackgroundRect: TGdkRectangle; Path: PGtkTreePath; Column: PGtkTreeViewColumn; begin - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(FIndex))); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(FIndex))); if not Assigned(Path) then Exit; ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertChildToPath(Path); if not Assigned(Path) then Exit; @@ -1306,8 +1301,8 @@ var CellRect, VisibleRect: TGdkRectangle; begin Result := False; gtk_tree_view_get_visible_rect(PGtkTreeView(((FOwner as TGTKListItems).FOwner as TGTKView).FWidget), @VisibleRect); + Path := gtk_tree_path_new_from_string(PChar(IntToStr(FIndex))); if not Assigned(Path) then Exit; - Path := gtk_tree_path_new_from_string(StringToPgchar(IntToStr(FIndex))); ((FOwner as TGTKListItems).FOwner as TGTKView).ConvertChildToPath(Path); if not Assigned(Path) then Exit; gtk_tree_view_get_background_area(PGtkTreeView(((FOwner as TGTKListItems).FOwner as TGTKView).FWidget), Path, nil, @CellRect); diff --git a/tuxcmd.dpr b/tuxcmd.dpr index edc437b..86d3ba4 100644 --- a/tuxcmd.dpr +++ b/tuxcmd.dpr @@ -21,69 +21,12 @@ program tuxcmd; uses - {$IFDEF FPC} cthreads, cwstring, - {$ENDIF} GTKForms, UConfig in 'UConfig.pas', - UGnome in 'UGnome.pas', UMain in 'UMain.pas' {FMain}, - UCore in 'UCore.pas', - UEngines in 'UEngines.pas', - USelect in 'USelect.pas' {FSelect}, - URemoteWait in 'URemoteWait.pas' {FRemoteWait}, - UDirDelete in 'UDirDelete.pas' {FDirDelete}, - UProgress in 'UProgress.pas' {FProgress}, - UCopyMove in 'UCopyMove.pas' {FCopyMove}, - UOverwrite in 'UOverwrite.pas' {FOverwrite}, - UCoreUtils in 'UCoreUtils.pas', - ULocale in 'ULocale.pas', - UChecksum in 'UChecksum.pas' {FChecksum}, - UChecksumDruid in 'UChecksumDruid.pas' {FChecksumDruid}, - USplitFile in 'USplitFile.pas' {FSplitFile}, - UFileAssoc in 'UFileAssoc.pas', - UFileTypeSettings in 'UFileTypeSettings.pas' {FFileTypeSettings}, - UChmod in 'UChmod.pas' {FChmod}, - UChown in 'UChown.pas' {FChown}, - UCoreClasses in 'UCoreClasses.pas', - USymlink in 'USymlink.pas' {FSymlink}, - UPreferences in 'UPreferences.pas' {FPreferences}, - UViewer in 'UViewer.pas' {FViewer}, - UTestPlugin in 'UTestPlugin.pas', - UMounterPrefs in 'UMounterPrefs.pas', - UColumns in 'UColumns.pas', - UVFSCore in 'vfs/UVFSCore.pas', - uVFSprototypes in 'vfs/uVFSprototypes.pas', - UToolTips in 'UToolTips.pas', - UConnectionManager in 'UConnectionManager.pas', - UConnectionProperties in 'UConnectionProperties.pas', - USearch in 'USearch.pas', - URunFromVFS in 'URunFromVFS.pas', - ULibc in 'ULibc.pas', - UQuickConnect in 'UQuickConnect.pas', - UError in 'UError.pas', - UTranslation_EN in 'translations/UTranslation_EN.pas', - UTranslation_CZ in 'translations/UTranslation_CZ.pas', - UTranslation_RU in 'translations/UTranslation_RU.pas', - UTranslation_DE in 'translations/UTranslation_DE.pas', - UTranslation_SV in 'translations/UTranslation_SV.pas', - UTranslation_FR in 'translations/UTranslation_FR.pas', - UTranslation_ES in 'translations/UTranslation_ES.pas', - UTranslation_PL in 'translations/UTranslation_PL.pas', - UTranslation_UA in 'translations/UTranslation_UA.pas', - UTranslation_SR in 'translations/UTranslation_SR.pas', - UTranslation_HU in 'translations/UTranslation_HU.pas', - UTranslation_IT in 'translations/UTranslation_IT.pas', - UTranslation_CHT in 'translations/UTranslation_CHT.pas', - UTranslation_CHS in 'translations/UTranslation_CHS.pas', - UTranslation_SK in 'translations/UTranslation_SK.pas', - UTranslation_PT in 'translations/UTranslation_PT.pas'; - - -{$IFNDEF FPC} - {$R *.res} -{$ENDIF} + UCore in 'UCore.pas'; begin Application.Initialize; diff --git a/vfs/UVFSCore.pas b/vfs/UVFSCore.pas index 5bf185e..b6c516d 100644 --- a/vfs/UVFSCore.pas +++ b/vfs/UVFSCore.pas @@ -21,7 +21,7 @@ unit UVFSCore; interface -uses GTKForms, ULibc, glib2, Classes, uVFSprototypes, UEngines, UCoreUtils; +uses GTKForms, ULibc, lazglib2, Classes, uVFSprototypes, UEngines, UCoreUtils; type @@ -149,7 +149,7 @@ type // VFS additions function VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; - function VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; + function VFSOpenEx(const AFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; function VFSClose(Error: PPGError): boolean; function ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; @@ -208,61 +208,61 @@ begin ModuleHandle := PluginHandle; // Find the symbols - @FVFSNew := dlsym(ModuleHandle, 'VFSNew'); - @FVFSFree := dlsym(ModuleHandle, 'VFSFree'); - @FVFSVersion := dlsym(ModuleHandle, 'VFSVersion'); - @FVFSGetInfo := dlsym(ModuleHandle, 'VFSGetInfo'); - @FVFSOpenArchive := dlsym(ModuleHandle, 'VFSOpenArchive'); - @FVFSOpenURI := dlsym(ModuleHandle, 'VFSOpenURI'); - @FVFSClose := dlsym(ModuleHandle, 'VFSClose'); - @FVFSListFirst := dlsym(ModuleHandle, 'VFSListFirst'); - @FVFSListNext := dlsym(ModuleHandle, 'VFSListNext'); - @FVFSListClose := dlsym(ModuleHandle, 'VFSListClose'); - @FVFSGetPath := dlsym(ModuleHandle, 'VFSGetPath'); - @FVFSGetPathURI := dlsym(ModuleHandle, 'VFSGetPathURI'); - @FVFSChangeDir := dlsym(ModuleHandle, 'VFSChangeDir'); - @FVFSGetFileSystemInfo := dlsym(ModuleHandle, 'VFSGetFileSystemInfo'); - @FVFSFileInfo := dlsym(ModuleHandle, 'VFSFileInfo'); - @FVFSMkDir := dlsym(ModuleHandle, 'VFSMkDir'); - @FVFSRemove := dlsym(ModuleHandle, 'VFSRemove'); - @FVFSRename := dlsym(ModuleHandle, 'VFSRename'); - @FVFSMakeSymLink := dlsym(ModuleHandle, 'VFSMakeSymLink'); - @FVFSChmod := dlsym(ModuleHandle, 'VFSChmod'); - @FVFSChown := dlsym(ModuleHandle, 'VFSChown'); - @FVFSChangeTimes := dlsym(ModuleHandle, 'VFSChangeTimes'); - @FVFSGetDirSize := dlsym(ModuleHandle, 'VFSGetDirSize'); - @FVFSBreakGetDirSize := dlsym(ModuleHandle, 'VFSBreakGetDirSize'); - @FVFSCopyToLocal := dlsym(ModuleHandle, 'VFSCopyToLocal'); - @FVFSCopyFromLocal := dlsym(ModuleHandle, 'VFSCopyFromLocal'); - @FVFSOpenFile := dlsym(ModuleHandle, 'VFSOpenFile'); - @FVFSReadFile := dlsym(ModuleHandle, 'VFSReadFile'); - @FVFSWriteFile := dlsym(ModuleHandle, 'VFSWriteFile'); - @FVFSCloseFile := dlsym(ModuleHandle, 'VFSCloseFile'); - @FVFSFileSeek := dlsym(ModuleHandle, 'VFSFileSeek'); - @FVFSSetBlockSize := dlsym(ModuleHandle, 'VFSSetBlockSize'); - @FVFSIsOnSameFS := dlsym(ModuleHandle, 'VFSIsOnSameFS'); - @FVFSTwoSameFiles := dlsym(ModuleHandle, 'VFSTwoSameFiles'); - @FVFSGetArchiveExts := dlsym(ModuleHandle, 'VFSGetArchiveExts'); - @FVFSGetNetworkServices := dlsym(ModuleHandle, 'VFSGetNetworkServices'); - @FVFSGetPasswordRequired := dlsym(ModuleHandle, 'VFSGetPasswordRequired'); - @FVFSSetCallbacks := dlsym(ModuleHandle, 'VFSSetCallbacks'); - @FVFSResetPassword := dlsym(ModuleHandle, 'VFSResetPassword'); - @FVFSStartCopyOperation := dlsym(ModuleHandle, 'VFSStartCopyOperation'); - @FVFSStopCopyOperation := dlsym(ModuleHandle, 'VFSStopCopyOperation'); - @FVFSGetCapabilities := dlsym(ModuleHandle, 'VFSGetCapabilities'); + FVFSNew := TVFSNew(dlsym(ModuleHandle, 'VFSNew')); + FVFSFree := TVFSFree(dlsym(ModuleHandle, 'VFSFree')); + FVFSVersion := TVFSVersion(dlsym(ModuleHandle, 'VFSVersion')); + FVFSGetInfo := TVFSGetInfo(dlsym(ModuleHandle, 'VFSGetInfo')); + FVFSOpenArchive := TVFSOpenArchive(dlsym(ModuleHandle, 'VFSOpenArchive')); + FVFSOpenURI := TVFSOpenURI(dlsym(ModuleHandle, 'VFSOpenURI')); + FVFSClose := TVFSClose(dlsym(ModuleHandle, 'VFSClose')); + FVFSListFirst := TVFSListFirst(dlsym(ModuleHandle, 'VFSListFirst')); + FVFSListNext := TVFSListNext(dlsym(ModuleHandle, 'VFSListNext')); + FVFSListClose := TVFSListClose(dlsym(ModuleHandle, 'VFSListClose')); + FVFSGetPath := TVFSGetPath(dlsym(ModuleHandle, 'VFSGetPath')); + FVFSGetPathURI := TVFSGetPathURI(dlsym(ModuleHandle, 'VFSGetPathURI')); + FVFSChangeDir := TVFSChangeDir(dlsym(ModuleHandle, 'VFSChangeDir')); + FVFSGetFileSystemInfo := TVFSGetFileSystemInfo(dlsym(ModuleHandle, 'VFSGetFileSystemInfo')); + FVFSFileInfo := TVFSFileInfo(dlsym(ModuleHandle, 'VFSFileInfo')); + FVFSMkDir := TVFSMkDir(dlsym(ModuleHandle, 'VFSMkDir')); + FVFSRemove := TVFSRemove(dlsym(ModuleHandle, 'VFSRemove')); + FVFSRename := TVFSRename(dlsym(ModuleHandle, 'VFSRename')); + FVFSMakeSymLink := TVFSMakeSymLink(dlsym(ModuleHandle, 'VFSMakeSymLink')); + FVFSChmod := TVFSChmod(dlsym(ModuleHandle, 'VFSChmod')); + FVFSChown := TVFSChown(dlsym(ModuleHandle, 'VFSChown')); + FVFSChangeTimes := TVFSChangeTimes(dlsym(ModuleHandle, 'VFSChangeTimes')); + FVFSGetDirSize := TVFSGetDirSize(dlsym(ModuleHandle, 'VFSGetDirSize')); + FVFSBreakGetDirSize := TVFSBreakGetDirSize(dlsym(ModuleHandle, 'VFSBreakGetDirSize')); + FVFSCopyToLocal := TVFSCopyToLocal(dlsym(ModuleHandle, 'VFSCopyToLocal')); + FVFSCopyFromLocal := TVFSCopyFromLocal(dlsym(ModuleHandle, 'VFSCopyFromLocal')); + FVFSOpenFile := TVFSOpenFile(dlsym(ModuleHandle, 'VFSOpenFile')); + FVFSReadFile := TVFSReadFile(dlsym(ModuleHandle, 'VFSReadFile')); + FVFSWriteFile := TVFSWriteFile(dlsym(ModuleHandle, 'VFSWriteFile')); + FVFSCloseFile := TVFSCloseFile(dlsym(ModuleHandle, 'VFSCloseFile')); + FVFSFileSeek := TVFSFileSeek(dlsym(ModuleHandle, 'VFSFileSeek')); + FVFSSetBlockSize := TVFSSetBlockSize(dlsym(ModuleHandle, 'VFSSetBlockSize')); + FVFSIsOnSameFS := TVFSIsOnSameFS(dlsym(ModuleHandle, 'VFSIsOnSameFS')); + FVFSTwoSameFiles := TVFSTwoSameFiles(dlsym(ModuleHandle, 'VFSTwoSameFiles')); + FVFSGetArchiveExts := TVFSGetArchiveExts(dlsym(ModuleHandle, 'VFSGetArchiveExts')); + FVFSGetNetworkServices := TVFSGetNetworkServices(dlsym(ModuleHandle, 'VFSGetNetworkServices')); + FVFSGetPasswordRequired := TVFSGetPasswordRequired(dlsym(ModuleHandle, 'VFSGetPasswordRequired')); + FVFSSetCallbacks := TVFSSetCallbacks(dlsym(ModuleHandle, 'VFSSetCallbacks')); + FVFSResetPassword := TVFSResetPassword(dlsym(ModuleHandle, 'VFSResetPassword')); + FVFSStartCopyOperation := TVFSStartCopyOperation(dlsym(ModuleHandle, 'VFSStartCopyOperation')); + FVFSStopCopyOperation := TVFSStopCopyOperation(dlsym(ModuleHandle, 'VFSStopCopyOperation')); + FVFSGetCapabilities := TVFSGetCapabilities(dlsym(ModuleHandle, 'VFSGetCapabilities')); // Initialize the extensions list SetLength(Extensions, 0); SetLength(Services, 0); - if (@FVFSGetArchiveExts <> nil) and (@FVFSOpenArchive <> nil) then begin - s := FVFSGetArchiveExts; + if (FVFSGetArchiveExts <> nil) and (FVFSOpenArchive <> nil) then begin + s := FVFSGetArchiveExts(); if s <> nil then begin ParseString(String(s), ';', Extensions); real_libc_free(s); end; end; - if (@FVFSGetNetworkServices <> nil) and (@FVFSOpenURI <> nil) then begin - s := FVFSGetNetworkServices; + if (FVFSGetNetworkServices <> nil) and (FVFSOpenURI <> nil) then begin + s := FVFSGetNetworkServices(); if s <> nil then begin ParseString(String(s), ';', Services); real_libc_free(s); @@ -281,8 +281,8 @@ end; (********************************************************************************************************************************) function TVFSPlugin.VFSVersion: integer; begin - if @FVFSVersion <> nil then Result := FVFSVersion - else Result := -1; + if FVFSVersion <> nil then Result := FVFSVersion() + else Result := -1; end; procedure _free_PVFSInfo(Info: PVFSInfo); @@ -298,9 +298,9 @@ end; function TVFSPlugin.ModuleID: string; var Info: PVFSInfo; begin - if @FVFSGetInfo <> nil then begin - Info := FVFSGetInfo; - Result := String(Info.ID); + if FVFSGetInfo <> nil then begin + Info := FVFSGetInfo(); + Result := String(Info^.ID); _free_PVFSInfo(Info); end else Result := ''; end; @@ -308,9 +308,9 @@ end; function TVFSPlugin.ModuleName: string; var Info: PVFSInfo; begin - if @FVFSGetInfo <> nil then begin - Info := FVFSGetInfo; - Result := String(Info.Name); + if FVFSGetInfo <> nil then begin + Info := FVFSGetInfo(); + Result := String(Info^.Name); _free_PVFSInfo(Info); end else Result := ''; end; @@ -318,9 +318,9 @@ end; function TVFSPlugin.ModuleAbout: string; var Info: PVFSInfo; begin - if @FVFSGetInfo <> nil then begin - Info := FVFSGetInfo; - Result := String(Info.About); + if FVFSGetInfo <> nil then begin + Info := FVFSGetInfo(); + Result := String(Info^.About); _free_PVFSInfo(Info); end else Result := ''; end; @@ -328,21 +328,21 @@ end; function TVFSPlugin.ModuleCopyright: string; var Info: PVFSInfo; begin - if @FVFSGetInfo <> nil then begin - Info := FVFSGetInfo; - Result := String(Info.Copyright); + if FVFSGetInfo <> nil then begin + Info := FVFSGetInfo(); + Result := String(Info^.Copyright); _free_PVFSInfo(Info); end else Result := ''; end; function TVFSPlugin.GetHandlesArchives: boolean; begin - Result := (Length(Extensions) > 0) and (@FVFSOpenArchive <> nil); + Result := (Length(Extensions) > 0) and (FVFSOpenArchive <> nil); end; function TVFSPlugin.GetHandlesNetwork: boolean; begin - Result := (Length(Services) > 0) and (@FVFSOpenURI <> nil); + Result := (Length(Services) > 0) and (FVFSOpenURI <> nil); end; (********************************************************************************************************************************) @@ -364,13 +364,13 @@ begin FCopyProgressCallback := nil; FCopyCallbackData := nil; - if @FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(@VFSLogFunc); + if FSourcePlugin.FVFSNew <> nil then FGlobs := FSourcePlugin.FVFSNew(PVFSLogFunc(@VFSLogFunc)); end; destructor TVFSEngine.Destroy; begin try - if @FSourcePlugin.FVFSFree <> nil then FSourcePlugin.FVFSFree(FGlobs); + if FSourcePlugin.FVFSFree <> nil then FSourcePlugin.FVFSFree(FGlobs); if Length(Trim(RemoveFileOnClose)) > 0 then if unlink(PChar(RemoveFileOnClose)) <> 0 then DebugMsg(['(EE) TVFSEngine.Destroy: error while removing ''', RemoveFileOnClose, ''': ', strerror(errno)]); @@ -383,13 +383,13 @@ function TVFSEngine.VFSOpenURI(const URI: string; AskQuestionCallback: PVFSAskQu begin Result := False; try - if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenURI <> nil) then begin - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if (FGlobs <> nil) and (FSourcePlugin.FVFSOpenURI <> nil) then begin + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); Result := FSourcePlugin.FVFSOpenURI(FGlobs, PChar(URI), Error); FArchiveMode := False; FArchivePath := ''; - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; except @@ -400,18 +400,18 @@ begin end; end; -function TVFSEngine.VFSOpenEx(const OpenFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; +function TVFSEngine.VFSOpenEx(const AFile: string; AskQuestionCallback: PVFSAskQuestionCallback; AskPasswordCallback: PVFSAskPasswordCallback; ProgressCallback: PVFSProgressCallback; CallbackData: Pointer; Error: PPGError): boolean; begin Result := False; try - if (FGlobs <> nil) and (@FSourcePlugin.FVFSOpenArchive <> nil) then begin - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if (FGlobs <> nil) and (FSourcePlugin.FVFSOpenArchive <> nil) then begin + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); - Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(OpenFile), Error); + Result := FSourcePlugin.FVFSOpenArchive(FGlobs, PChar(AFile), Error); FArchiveMode := True; - if Result then FArchivePath := OpenFile + if Result then FArchivePath := AFile else FArchivePath := ''; - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; except @@ -426,7 +426,7 @@ end; function TVFSEngine.VFSClose(Error: PPGError): boolean; begin Result := False; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSClose <> nil) then + if (FGlobs <> nil) and (FSourcePlugin.FVFSClose <> nil) then Result := FSourcePlugin.FVFSClose(FGlobs, Error); end; @@ -469,8 +469,8 @@ begin DebugMsg(['^^VFS (II): GetListing begin']); Result := False; try - if (@FSourcePlugin.FVFSListFirst = nil) or (@FSourcePlugin.FVFSListNext = nil) or (@FSourcePlugin.FVFSListClose = nil) then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'File listing not supported by the VFS module.'); + if (FSourcePlugin.FVFSListFirst = nil) or (FSourcePlugin.FVFSListNext = nil) or (FSourcePlugin.FVFSListClose = nil) then begin + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'File listing not supported by the VFS module.'); Exit; end; P := FSourcePlugin.FVFSListFirst(FGlobs, PChar(APath), FollowSymlinks, AddFullPath, Error); @@ -493,7 +493,7 @@ begin if Error^ <> nil then g_error_free(Error^); Error^ := nil; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED), '%s', 'The operation has been cancelled.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_CANCELLED), 'The operation has been cancelled.'); Result := False; end; real_libc_free(P); @@ -515,8 +515,8 @@ begin DebugMsg(['^^VFS (II): GetFileInfo begin']); Result := nil; - if @FSourcePlugin.FVFSFileInfo = nil then begin - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Querying file info is not supported by the VFS module.'); + if FSourcePlugin.FVFSFileInfo = nil then begin + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Querying file info is not supported by the VFS module.'); Exit; end; try @@ -547,7 +547,7 @@ begin FSSize := -1; FSFree := -1; FSName := 'plugin'; - if @FSourcePlugin.FVFSGetFileSystemInfo <> nil then begin + if FSourcePlugin.FVFSGetFileSystemInfo <> nil then begin AFSSize := -1; AFSFree := -1; AFSName := nil; @@ -578,7 +578,7 @@ function TVFSEngine.GetPath: string; var s: PChar; begin Result := '/'; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetPath <> nil) then begin + if (FGlobs <> nil) and (FSourcePlugin.FVFSGetPath <> nil) then begin s := FSourcePlugin.FVFSGetPath(FGlobs); if s <> nil then begin Result := String(s); @@ -591,7 +591,7 @@ function TVFSEngine.GetPathURI: string; var s: PChar; begin Result := ''; - if (FGlobs <> nil) and (@FSourcePlugin.FVFSGetPathURI <> nil) then begin + if (FGlobs <> nil) and (FSourcePlugin.FVFSGetPathURI <> nil) then begin s := FSourcePlugin.FVFSGetPathURI(FGlobs); if s <> nil then begin Result := String(s); @@ -619,12 +619,12 @@ function TVFSEngine.ChangeDirEx(const NewPath: string; AskQuestionCallback: PVFS begin Result := False; try - if (FGlobs <> nil) and (@FSourcePlugin.FVFSChangeDir <> nil) then begin - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if (FGlobs <> nil) and (FSourcePlugin.FVFSChangeDir <> nil) then begin + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); Result := ChangeDir(NewPath, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_CHDIR); - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); end; except @@ -645,7 +645,7 @@ function TVFSEngine.FileExists(const FileName: string; FollowSymlinks: boolean): var P: PVFSItem; begin Result := False; - if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then + if (FGlobs = nil) or (FSourcePlugin.FVFSFileInfo = nil) then Exit; try P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil); @@ -661,7 +661,7 @@ function TVFSEngine.DirectoryExists(const FileName: string; FollowSymlinks: bool var P: PVFSItem; begin Result := False; - if (FGlobs = nil) or (@FSourcePlugin.FVFSFileInfo = nil) then + if (FGlobs = nil) or (FSourcePlugin.FVFSFileInfo = nil) then Exit; try P := FSourcePlugin.FVFSFileInfo(FGlobs, PChar(FileName), FollowSymlinks, False, nil); @@ -675,91 +675,91 @@ end; function TVFSEngine.MakeDir(const NewDir: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSMkDir <> nil then begin + if FSourcePlugin.FVFSMkDir <> nil then begin Result := FSourcePlugin.FVFSMkDir(FGlobs, PChar(NewDir), Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_MKDIR); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Creating directories is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Creating directories is not supported by the VFS module.'); end; end; function TVFSEngine.Remove(const APath: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSRemove <> nil then begin + if FSourcePlugin.FVFSRemove <> nil then begin Result := FSourcePlugin.FVFSRemove(FGlobs, PChar(APath), Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_REMOVE); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Removing files is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Removing files is not supported by the VFS module.'); end; end; function TVFSEngine.RenameFile(const SourceFile, DestFile: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSRename <> nil then begin + if FSourcePlugin.FVFSRename <> nil then begin Result := FSourcePlugin.FVFSRename(FGlobs, PChar(SourceFile), PChar(DestFile), Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_RENAME); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Renaming files is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Renaming files is not supported by the VFS module.'); end; end; function TVFSEngine.MakeSymLink(const NewFileName, PointTo: string; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSMakeSymLink <> nil then begin + if FSourcePlugin.FVFSMakeSymLink <> nil then begin Result := FSourcePlugin.FVFSMakeSymLink(FGlobs, PChar(NewFileName), PChar(PointTo), Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_SYMLINK); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Creating symbolic links is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Creating symbolic links is not supported by the VFS module.'); end; end; function TVFSEngine.Chmod(const FileName: string; Mode: cuLong; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChmod <> nil then begin + if FSourcePlugin.FVFSChmod <> nil then begin Result := FSourcePlugin.FVFSChmod(FGlobs, PChar(FileName), Mode, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_CHMOD); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Chmod is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Chmod is not supported by the VFS module.'); end; end; function TVFSEngine.Chown(const FileName: string; UID, GID: cuLong; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChown <> nil then begin + if FSourcePlugin.FVFSChown <> nil then begin Result := FSourcePlugin.FVFSChown(FGlobs, PChar(FileName), UID, GID, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_CHOWN); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Chown is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Chown is not supported by the VFS module.'); end; end; function TVFSEngine.ChangeTimes(const APath: string; mtime, atime: time_t; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSChangeTimes <> nil then begin + if FSourcePlugin.FVFSChangeTimes <> nil then begin Result := FSourcePlugin.FVFSChangeTimes(FGlobs, PChar(APath), mtime, atime, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_TIMESTAMPS); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Changing timestamps is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Changing timestamps is not supported by the VFS module.'); end; end; function TVFSEngine.GetDirSize(const APath: string): Int64; begin - if @FSourcePlugin.FVFSGetDirSize <> nil then Result := FSourcePlugin.FVFSGetDirSize(FGlobs, PChar(APath)) + if FSourcePlugin.FVFSGetDirSize <> nil then Result := FSourcePlugin.FVFSGetDirSize(FGlobs, PChar(APath)) else Result := 0; end; procedure TVFSEngine.BreakProcessing(ProcessingKind: integer); begin case ProcessingKind of - 1: if @FSourcePlugin.FVFSBreakGetDirSize <> nil then FSourcePlugin.FVFSBreakGetDirSize(FGlobs); + 1: if FSourcePlugin.FVFSBreakGetDirSize <> nil then FSourcePlugin.FVFSBreakGetDirSize(FGlobs); end; end; @@ -770,7 +770,7 @@ end; procedure TVFSEngine.SetBlockSize(Value: Cardinal); begin - if (FGlobs <> nil) and (@FSourcePlugin.FVFSSetBlockSize <> nil) + if (FGlobs <> nil) and (FSourcePlugin.FVFSSetBlockSize <> nil) then FSourcePlugin.FVFSSetBlockSize(FGlobs, Value); end; @@ -779,69 +779,69 @@ end; (********************************************************************************************************************************) function TVFSEngine.IsOnSameFS(const Path1, Path2: string; FollowSymlinks: boolean): boolean; begin - if @FSourcePlugin.FVFSIsOnSameFS <> nil + if FSourcePlugin.FVFSIsOnSameFS <> nil then Result := FSourcePlugin.FVFSIsOnSameFS(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks) else Result := True; end; function TVFSEngine.OpenFile(const APath: string; Mode: integer; Error: PPGError): TEngineFileDes; begin - if @FSourcePlugin.FVFSOpenFile <> nil then begin + if FSourcePlugin.FVFSOpenFile <> nil then begin Result := FSourcePlugin.FVFSOpenFile(FGlobs, PChar(APath), Mode, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_OPEN_FILE); end else begin Result := nil; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual opening files is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual opening files is not supported by the VFS module.'); end; end; function TVFSEngine.ReadFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; ABlockSize: integer; Error: PPGError): integer; begin - if @FSourcePlugin.FVFSReadFile <> nil then begin + if FSourcePlugin.FVFSReadFile <> nil then begin Result := FSourcePlugin.FVFSReadFile(FGlobs, FileDescriptor, Buffer, ABlockSize, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_READ_FILE); end else begin Result := -1; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual read is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual read is not supported by the VFS module.'); end; end; function TVFSEngine.WriteFile(const FileDescriptor: TEngineFileDes; Buffer: Pointer; BytesCount: integer; Error: PPGError): integer; begin - if @FSourcePlugin.FVFSWriteFile <> nil then begin + if FSourcePlugin.FVFSWriteFile <> nil then begin Result := FSourcePlugin.FVFSWriteFile(FGlobs, FileDescriptor, Buffer, BytesCount, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_WRITE_FILE); end else begin Result := -1; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual write is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual write is not supported by the VFS module.'); end; end; function TVFSEngine.CloseFile(const FileDescriptor: TEngineFileDes; Error: PPGError): boolean; begin - if @FSourcePlugin.FVFSCloseFile <> nil then begin + if FSourcePlugin.FVFSCloseFile <> nil then begin Result := FSourcePlugin.FVFSCloseFile(FGlobs, FileDescriptor, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_CLOSE_FILE); end else begin Result := False; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual closing files is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual closing files is not supported by the VFS module.'); end; end; function TVFSEngine.FileSeek(const FileDescriptor: TEngineFileDes; const AbsoluteOffset: Int64; Error: PPGError): Int64; begin - if @FSourcePlugin.FVFSFileSeek <> nil then begin + if FSourcePlugin.FVFSFileSeek <> nil then begin Result := FSourcePlugin.FVFSFileSeek(FGlobs, FileDescriptor, AbsoluteOffset, Error); VFSToTuxcmdError(Error, TUXCMD_ERROR_SEEK); end else begin Result := -1; - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'Manual seek is not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'Manual seek is not supported by the VFS module.'); end; end; function TVFSEngine.TwoSameFiles(const Path1, Path2: string; FollowSymlinks: boolean): boolean; begin - if @FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks) + if FSourcePlugin.FVFSTwoSameFiles <> nil then Result := FSourcePlugin.FVFSTwoSameFiles(FGlobs, PChar(Path1), PChar(Path2), FollowSymlinks) else Result := False; end; @@ -865,23 +865,20 @@ begin end; function TVFSEngine.CopyFileOutEx(const SourceFile, DestFile: string; Append: boolean; Error: PPGError): boolean; -var ACopyProgressCallback: TVFSProgressCallback; begin Result := False; try - if @FSourcePlugin.FVFSCopyToLocal <> nil then + if FSourcePlugin.FVFSCopyToLocal <> nil then try Result := FSourcePlugin.FVFSCopyToLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, Error) except on E: Exception do tuxcmd_set_error_from_exception(Error, E); end else - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyToLocal not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSCopyToLocal not supported by the VFS module.'); if Error^ <> nil then begin - if FCopyProgressCallback <> nil then begin - @ACopyProgressCallback := FCopyProgressCallback; - Result := ACopyProgressCallback(0, Error^, FCopyCallbackData); - end; + if FCopyProgressCallback <> nil then + Result := TVFSProgressCallback(FCopyProgressCallback)(0, Error^, FCopyCallbackData); end; except on E: Exception do begin @@ -893,23 +890,20 @@ begin end; function TVFSEngine.CopyFileInEx(const SourceFile, DestFile: string; Append: boolean; Error: PPGError): boolean; -var ACopyProgressCallback: TVFSProgressCallback; begin Result := False; try - if @FSourcePlugin.FVFSCopyFromLocal <> nil then + if FSourcePlugin.FVFSCopyFromLocal <> nil then try Result := FSourcePlugin.FVFSCopyFromLocal(FGlobs, PChar(SourceFile), PChar(DestFile), Append, Error) except on E: Exception do tuxcmd_set_error_from_exception(Error, E); end else - g_set_error(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSCopyFromLocal not supported by the VFS module.'); + g_set_error_literal(Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSCopyFromLocal not supported by the VFS module.'); if Error <> nil then begin - if FCopyProgressCallback <> nil then begin - @ACopyProgressCallback := FCopyProgressCallback; - Result := ACopyProgressCallback(0, Error^, FCopyCallbackData); - end; + if FCopyProgressCallback <> nil then + Result := TVFSProgressCallback(FCopyProgressCallback)(0, Error^, FCopyCallbackData); end; except on E: Exception do begin @@ -925,20 +919,20 @@ var Error: PGError; begin Result := not ArchiveMode; try - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, AskQuestionCallback, AskPasswordCallback, ProgressCallback, CallbackData); FCopyProgressCallback := ProgressCallback; FCopyCallbackData := CallbackData; if ArchiveMode then begin Error := nil; - if @FSourcePlugin.FVFSStartCopyOperation <> nil then + if FSourcePlugin.FVFSStartCopyOperation <> nil then try Result := FSourcePlugin.FVFSStartCopyOperation(FGlobs, @Error) except on E: Exception do tuxcmd_set_error_from_exception(@Error, E); end else - g_set_error(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSStartCopyOperation not supported by the VFS module.'); + g_set_error_literal(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSStartCopyOperation not supported by the VFS module.'); if Error <> nil then begin if ProgressCallback <> nil then Result := ProgressCallback^(0, Error, CallbackData); @@ -955,18 +949,18 @@ var Error: PGError; begin Result := not ArchiveMode; try - if @FSourcePlugin.FVFSSetCallbacks <> nil then + if FSourcePlugin.FVFSSetCallbacks <> nil then FSourcePlugin.FVFSSetCallbacks(FGlobs, nil, nil, nil, nil); if ArchiveMode then begin Error := nil; - if @FSourcePlugin.FVFSStopCopyOperation <> nil then + if FSourcePlugin.FVFSStopCopyOperation <> nil then try Result := FSourcePlugin.FVFSStopCopyOperation(FGlobs, @Error) except on E: Exception do tuxcmd_set_error_from_exception(@Error, E); end else - g_set_error(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), '%s', 'VFSStopCopyOperation not supported by the VFS module.'); + g_set_error_literal(@Error, TUXCMD_ERROR, gint(TUXCMD_ERROR_NOT_SUPPORTED), 'VFSStopCopyOperation not supported by the VFS module.'); if Error <> nil then begin if ProgressCallback <> nil then Result := ProgressCallback^(0, Error, CallbackData); @@ -985,13 +979,13 @@ end; (********************************************************************************************************************************) function TVFSEngine.GetPasswordRequired: boolean; begin - if @FSourcePlugin.FVFSGetPasswordRequired <> nil then Result := FSourcePlugin.FVFSGetPasswordRequired(FGlobs) + if FSourcePlugin.FVFSGetPasswordRequired <> nil then Result := FSourcePlugin.FVFSGetPasswordRequired(FGlobs) else Result := False; end; procedure TVFSEngine.ResetPassword; begin - if @FSourcePlugin.FVFSResetPassword <> nil then + if FSourcePlugin.FVFSResetPassword <> nil then FSourcePlugin.FVFSResetPassword(FGlobs); end; @@ -1006,7 +1000,7 @@ end; function TVFSEngine.GetArchiveStreamingType: boolean; begin Result := False; - if (@FSourcePlugin.FVFSGetCapabilities <> nil) then + if (FSourcePlugin.FVFSGetCapabilities <> nil) then Result := (FSourcePlugin.FVFSGetCapabilities() and VFS_CAP_ARCHIVE_STREAMING) = VFS_CAP_ARCHIVE_STREAMING; end; @@ -1101,8 +1095,8 @@ begin ModuleHandler := dlopen(PChar(IncludeTrailingPathDelimiter(s) + Buf), RTLD_NOW); if ModuleHandler = nil then DebugMsg([' XXX Error loading module: ', dlerror]) else try - @VFSVersionFunc := dlsym(ModuleHandler, 'VFSVersion'); - if (@VFSVersionFunc <> nil) and (VFSVersionFunc = ConstVFSVersionRequired) then begin + VFSVersionFunc := TVFSVersion(dlsym(ModuleHandler, 'VFSVersion')); + if (VFSVersionFunc <> nil) and (VFSVersionFunc() = ConstVFSVersionRequired) then begin PluginItem := TVFSPlugin.Create(ModuleHandler); PluginItem.FullModulePath := IncludeTrailingPathDelimiter(s) + Buf; PluginList.Add(PluginItem); diff --git a/vfs/uVFSprototypes.pas b/vfs/uVFSprototypes.pas index 6fbe65d..3a4b205 100644 --- a/vfs/uVFSprototypes.pas +++ b/vfs/uVFSprototypes.pas @@ -27,11 +27,9 @@ unit uVFSprototypes; interface -uses glib2; +uses lazglib2; -{$IFDEF FPC} - {$PACKRECORDS C} -{$ENDIF} +{$PACKRECORDS C} const cVFSVersion = 5; // current version of the VFS API -- cgit v1.2.3