diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2024-12-23 23:59:45 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2025-11-27 19:36:10 +0100 |
| commit | b9703b29819b619037cc282d719c187e51bacd30 (patch) | |
| tree | bd6d73e5fb6bcb6eb307844103b3dff185f2ac9a /UChecksum.pas | |
| parent | a9634b933f71a9045e61d29c486f2d51d39fd1e2 (diff) | |
| download | tuxcmd-b9703b29819b619037cc282d719c187e51bacd30.tar.xz | |
Port to g-i generated glib2 bindings
Includes switch to FPC -Mobjfpc and related pointer style fixes.
Diffstat (limited to 'UChecksum.pas')
| -rw-r--r-- | UChecksum.pas | 38 |
1 files changed, 18 insertions, 20 deletions
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; |
