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. --- UChecksumDruid.pas | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'UChecksumDruid.pas') 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 -- cgit v1.2.3