diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-07 20:40:48 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2008-06-07 20:40:48 +0200 |
| commit | a0f1e0e9db4b0edee45018c47a08761916af0ce6 (patch) | |
| tree | dc9d05f5772442f61ec913631540b24cf67d5e8a /UChecksum.pas | |
| parent | ecde167da74c86bc047aaf84c5e548cf65a5da98 (diff) | |
| download | tuxcmd-a0f1e0e9db4b0edee45018c47a08761916af0ce6.tar.xz | |
Revised UTF-8 filenames supportv0.6.38
Diffstat (limited to 'UChecksum.pas')
| -rw-r--r-- | UChecksum.pas | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/UChecksum.pas b/UChecksum.pas index 895f7ec..5f0e4db 100644 --- a/UChecksum.pas +++ b/UChecksum.pas @@ -1,28 +1,28 @@ (* Tux Commander - UChecksum - Checksum dialog - Copyright (C) 2004 Tomas Bzatek <tbzatek@users.sourceforge.net>
- 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
+ Copyright (C) 2004 Tomas Bzatek <tbzatek@users.sourceforge.net> + 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 UChecksum; interface uses - glib2, gdk2, gtk2, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKText, + glib2, gdk2, gtk2, pango, SysUtils, Types, Classes, Variants, GTKControls, GTKForms, GTKStdCtrls, GTKExtCtrls, GTKConsts, GTKView, GTKText, UEngines; type @@ -154,6 +154,7 @@ begin CommentTextView := TGTKTextView.Create(Self); CommentTextView.ReadOnly := True; CommentTextView.CursorVisible := True; + gtk_widget_modify_font(CommentTextView.FWidget, pango_font_description_from_string('Monospace')) end; procedure TFChecksum.FormDestroy(Sender: TObject); @@ -205,10 +206,10 @@ begin Result := False; Stat := Engine.GetFileInfoSL(FileName); if (Stat.Size > 128*1024) then begin - i := integer(Application.MessageBox(Format(LANGTheFileSYouAreTryingToOpenIsQuiteBig, [ANSIToUTF8(ExtractFileName(FileName))]), [mbYes, mbNo], mbWarning, mbNone, mbNo)); + i := integer(Application.MessageBox(Format(LANGTheFileSYouAreTryingToOpenIsQuiteBig, [StrToUTF8(ExtractFileName(FileName))]), [mbYes, mbNo], mbWarning, mbNone, mbNo)); if (i = integer(mbNo)) or (i = 251) then Exit; end; - IsMD5 := (Pos('MD5', ANSIUpperCase(FileName)) > 0) or ((Pos('SFV', ANSIUpperCase(FileName)) = 0) and (Pos('SUM', ANSIUpperCase(FileName)) > 0)); + IsMD5 := (Pos('MD5', WideUpperCase(FileName)) > 0) or ((Pos('SFV', WideUpperCase(FileName)) = 0) and (Pos('SUM', WideUpperCase(FileName)) > 0)); if IsMD5 then MD5Present := True else SFVPresent := True; if MD5Present and SFVPresent then FileList.Columns[1].Caption := 'CRC32/MD5' @@ -222,9 +223,10 @@ begin Application.MessageBox(LANGAnErrorOccuredWhileInitializingMemoryBlock, [mbOK], mbError, mbNone, mbOK); Exit; end; + Error := 0; FD := Engine.OpenFile(FileName, omRead, Error); if Error <> 0 then begin - Application.MessageBox(Format(LANGAnErrorOccuredWhileOpeningFileSS, [ANSIToUTF8(ExtractFileName(FileName)), ANSIToUTF8(GetErrorString(Error))]), [mbOK], mbError, mbNone, mbOK); + Application.MessageBox(Format(LANGAnErrorOccuredWhileOpeningFileSS, [StrToUTF8(ExtractFileName(FileName)), GetErrorString(Error)]), [mbOK], mbError, mbNone, mbOK); Libc.free(Buffer); Exit; end; @@ -233,7 +235,7 @@ begin repeat Count := Engine.ReadFile(FD, Buffer, ChksumBlockSize, Error); if Error <> 0 then begin - Application.MessageBox(Format(LANGAnErrorOccuredWhileReadingFileSS, [ANSIToUTF8(ExtractFileName(FileName)), ANSIToUTF8(GetErrorString(Error))]), [mbOK], mbError, mbNone, mbOK); + Application.MessageBox(Format(LANGAnErrorOccuredWhileReadingFileSS, [StrToUTF8(ExtractFileName(FileName)), GetErrorString(Error)]), [mbOK], mbError, mbNone, mbOK); Engine.CloseFile(FD); Libc.free(Buffer); Exit; @@ -275,10 +277,10 @@ begin if CommentTextView.TextBuffer.LineCount > 1 then begin s1 := ''; for i := 1 to 50 do s1 := s1 + Chr($2212); - CommentTextView.TextBuffer.InsertText(s1 + #13); + CommentTextView.TextBuffer.InsertText(StrToUTF8(s1 + #13)); end; end; - CommentTextView.TextBuffer.InsertText(ANSIToUTF8(Copy(s, 2, Length(s) - 1) + #13)); + CommentTextView.TextBuffer.InsertText(StrToUTF8(Copy(s, 2, Length(s) - 1) + #13)); end else begin Trim(s); if Pos(' ', s) = 0 then Exit; @@ -326,13 +328,13 @@ begin if not Application.GTKVersion_2_0_5_Up then gtk_tree_model_get(tree_model, iter, 0, @Data, -1) else 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)^];
- gtk_tree_path_free(Path);
- end;
+ if not Assigned(Path) then Exit; + (Sender as TGTKListView).ConvertPathToChild(Path); + Data := List[gtk_tree_path_get_indices(Path)^]; + gtk_tree_path_free(Path); + end; case gtk_tree_view_column_get_sort_column_id(tree_column) of - 0: g_object_set(cell, 'text', PChar(Format('[%s] %s', [StatusStr[Data.Status], ANSIToUTF8(Data.Name)])), nil); + 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); end; @@ -348,12 +350,12 @@ begin gtk_tree_model_get(model, b, 0, @Data2, -1); end else begin Path := gtk_tree_model_get_path(model, a); - if not Assigned(Path) then Exit;
- Data1 := List[gtk_tree_path_get_indices(Path)^];
+ if not Assigned(Path) then Exit; + Data1 := 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)^];
+ if not Assigned(Path) then Exit; + Data2 := List[gtk_tree_path_get_indices(Path)^]; gtk_tree_path_free(Path); end; if (Sender as TGTKView).SortColumnID = 0 then Result := CompareTextsEx(PChar(Data1.Name), PChar(Data2.Name)); @@ -411,6 +413,7 @@ begin CRC := $FFFFFFFF; MD5Hash := nil; if Data.IsMD5 then MD5Hash := THash_MD5.Create; + Error := 0; FD := Engine.OpenFile(Data.FullPath, omRead, Error); if Error <> 0 then begin Data.Status := 3; @@ -464,7 +467,7 @@ begin if DataList.Count > 0 then for i := 0 to DataList.Count - 1 do if (not PDataItem(DataList[i])^.IsDir) and (not PDataItem(DataList[i])^.UpDir) and - (AnsiCompareText(Trim(PDataItem(DataList[i])^.AName), ExtractFileName(FileName)) = 0) then + (WideCompareText(Trim(PDataItem(DataList[i])^.FDisplayName), ExtractFileName(FileName)) = 0) then begin PDataItem(DataList[i])^.Selected := True; AListView.Items[i].RedrawRow; |
