Format file sizes with no more than three digits. FileView: Use the directory cache instead of Stat() when drawing the items.
[GB.FORM] * NEW: Format file sizes with no more than three digits. * BUG: Stock: Don't duplicate 'Gambas' and 'Gambas-Mono' icon themes in Stock.Themes property. * OPT: FileView: Use the directory cache instead of Stat() when drawing the items.
This commit is contained in:
parent
1474d6cef0
commit
d9aa4e194c
8 changed files with 78 additions and 199 deletions
|
@ -1,163 +0,0 @@
|
||||||
access apps/preferences-desktop-accessibility
|
|
||||||
add actions/list-add
|
|
||||||
apply actions/dialog-apply
|
|
||||||
archive mimes/package-x-generic
|
|
||||||
attach status/mail-attachment
|
|
||||||
audio mimes/audio-x-generic
|
|
||||||
battery devices/battery
|
|
||||||
book apps/accessories-dictionary
|
|
||||||
bookmark places/user-bookmarks
|
|
||||||
bottom actions/go-bottom
|
|
||||||
calculator apps/accessories-calculator
|
|
||||||
calendar apps/calendar
|
|
||||||
camera devices/camera-photo
|
|
||||||
cancel actions/dialog-cancel
|
|
||||||
cdrom devices/media-optical
|
|
||||||
clear actions/edit-clear-symbolic
|
|
||||||
clock apps/clock
|
|
||||||
close actions/window-close
|
|
||||||
color categories/applications-graphics
|
|
||||||
color-picker actions/color-picker
|
|
||||||
component categories/applications-utilities
|
|
||||||
computer devices/computer
|
|
||||||
connect actions/network-connect
|
|
||||||
copy actions/edit-copy
|
|
||||||
cut actions/edit-cut
|
|
||||||
delete actions/edit-delete
|
|
||||||
desktop places/user-desktop
|
|
||||||
directory places/folder
|
|
||||||
disconnect actions/network-disconnect
|
|
||||||
down actions/go-down
|
|
||||||
earth categories/applications-internet
|
|
||||||
edit apps/accessories-text-editor
|
|
||||||
eject actions/media-eject
|
|
||||||
end actions/media-skip-forward
|
|
||||||
erase actions/draw-eraser
|
|
||||||
error status/dialog-error
|
|
||||||
exec actions/system-run
|
|
||||||
file mimes/empty;mimes/empty;mimes/application-x-zerosize;mimes/application-x-zerosize
|
|
||||||
file-manager apps/system-file-manager
|
|
||||||
fill actions/fill-color
|
|
||||||
filter actions/view-filter
|
|
||||||
find actions/edit-find
|
|
||||||
first actions/go-first
|
|
||||||
flag
|
|
||||||
flip-h actions/object-flip-horizontal
|
|
||||||
flip-v actions/object-flip-vertical
|
|
||||||
floppy devices/media-floppy
|
|
||||||
font apps/preferences-desktop-font
|
|
||||||
forward actions/media-seek-forward
|
|
||||||
fullscreen actions/view-fullscreen
|
|
||||||
gambas
|
|
||||||
game categories/applications-games
|
|
||||||
grid
|
|
||||||
halt actions/process-stop
|
|
||||||
harddisk devices/drive-harddisk
|
|
||||||
;hardware devices/audio-card
|
|
||||||
;heart emblems/emblem-favorite
|
|
||||||
help apps/help-browser
|
|
||||||
home actions/go-home
|
|
||||||
html mimes/text-html
|
|
||||||
image mimes/image-x-generic
|
|
||||||
important emblems/emblem-important
|
|
||||||
indent actions/format-indent-more
|
|
||||||
info status/dialog-information
|
|
||||||
insert-image actions/insert-image
|
|
||||||
insert-link actions/insert-link
|
|
||||||
insert-text actions/insert-text
|
|
||||||
jump actions/go-jump
|
|
||||||
;lamp status/dialog-information
|
|
||||||
language apps/preferences-desktop-locale
|
|
||||||
last actions/go-last
|
|
||||||
left actions/go-previous
|
|
||||||
;linux apps/tux
|
|
||||||
;lock status/locked
|
|
||||||
mail apps/evolution-mail
|
|
||||||
;make actions/arrow-down
|
|
||||||
;make-all actions/arrow-down-double
|
|
||||||
media-player devices/multimedia-player
|
|
||||||
menu apps/alacarte
|
|
||||||
microphone devices/audio-input-microphone
|
|
||||||
mouse devices/input-mouse
|
|
||||||
network places/network-workgroup
|
|
||||||
new actions/document-new
|
|
||||||
new-dir actions/folder-new
|
|
||||||
new-window actions/window-new
|
|
||||||
next actions/go-next
|
|
||||||
ok actions/dialog-ok
|
|
||||||
open actions/document-open
|
|
||||||
open-recent actions/document-open-recent
|
|
||||||
options categories/preferences-system
|
|
||||||
package apps/system-software-install
|
|
||||||
pause actions/media-playback-pause
|
|
||||||
paste actions/edit-paste
|
|
||||||
pda devices/pda
|
|
||||||
pdf mimes/application-pdf
|
|
||||||
pen actions/gtk-edit
|
|
||||||
people apps/system-users
|
|
||||||
phone devices/phone
|
|
||||||
play actions/media-playback-start
|
|
||||||
previous actions/go-previous
|
|
||||||
print actions/document-print
|
|
||||||
printer devices/printer
|
|
||||||
properties actions/document-properties
|
|
||||||
question status/dialog-question
|
|
||||||
quit actions/application-exit
|
|
||||||
recent actions/document-open-recent
|
|
||||||
record actions/media-record
|
|
||||||
redo actions/edit-redo
|
|
||||||
refresh actions/view-refresh
|
|
||||||
remove actions/list-remove
|
|
||||||
replace actions/edit-find-replace
|
|
||||||
revert actions/document-revert
|
|
||||||
rewind actions/media-seek-backward
|
|
||||||
right actions/go-next
|
|
||||||
rotate-left actions/object-rotate-left
|
|
||||||
rotate-right actions/object-rotate-right
|
|
||||||
save actions/document-save
|
|
||||||
save-as actions/document-save-as
|
|
||||||
science categories/applications-science
|
|
||||||
screen devices/video-display
|
|
||||||
;security status/security-medium
|
|
||||||
select actions/select-rectangular
|
|
||||||
select-all actions/edit-select-all
|
|
||||||
server places/network-server
|
|
||||||
shortcut apps/preferences-desktop-keyboard
|
|
||||||
sort-ascent actions/view-sort-ascending
|
|
||||||
sort-descent actions/view-sort-descending
|
|
||||||
spell-check actions/tools-check-spelling
|
|
||||||
start actions/media-skip-backward
|
|
||||||
stop actions/media-playback-stop
|
|
||||||
sun status/weather-clear
|
|
||||||
system devices/computer
|
|
||||||
terminal apps/utilities-terminal
|
|
||||||
text mimes/text-x-generic;mimes/text-x-generic
|
|
||||||
text-bold actions/format-text-bold
|
|
||||||
text-left actions/format-justify-left
|
|
||||||
text-center actions/format-justify-center
|
|
||||||
text-italic actions/format-text-italic
|
|
||||||
text-fill actions/format-justify-fill
|
|
||||||
text-right actions/format-justify-right
|
|
||||||
text-strike actions/format-text-strikethrough
|
|
||||||
text-underline actions/format-text-underline
|
|
||||||
tools categories/preferences-system
|
|
||||||
top actions/go-top
|
|
||||||
trash places/user-trash
|
|
||||||
undo actions/edit-undo
|
|
||||||
unindent actions/format-indent-less
|
|
||||||
;unlock status/changes-allow
|
|
||||||
up actions/go-up
|
|
||||||
video mimes/video-x-generic
|
|
||||||
;view-detail actions/view-list-details
|
|
||||||
;view-icon actions/view-list-icons
|
|
||||||
;view-normal actions/view-close
|
|
||||||
;view-split-h actions/view-split-left-right
|
|
||||||
;view-split-v actions/view-split-top-bottom
|
|
||||||
volume status/audio-volume-high
|
|
||||||
warning status/dialog-warning
|
|
||||||
watch apps/strigi
|
|
||||||
wizard actions/tools-wizard
|
|
||||||
zoom-fit actions/zoom-fit-best
|
|
||||||
zoom-in actions/zoom-in
|
|
||||||
zoom-normal actions/zoom-original
|
|
||||||
zoom-out actions/zoom-out
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Gambas Project File 3.0
|
# Gambas Project File 3.0
|
||||||
Title=More controls for graphical components
|
Title=More controls for graphical components
|
||||||
Startup=FMain
|
Startup=FTestFileView
|
||||||
Icon=.hidden/icon.png
|
Icon=.hidden/icon.png
|
||||||
Version=3.16.90
|
Version=3.16.90
|
||||||
VersionFile=1
|
VersionFile=1
|
||||||
|
|
|
@ -482,7 +482,7 @@ Private Sub RefreshView()
|
||||||
GoSub ADD_PREVIEW
|
GoSub ADD_PREVIEW
|
||||||
Endif
|
Endif
|
||||||
Endif
|
Endif
|
||||||
$hColumnView[sKey][1] = " " & Main.GetFileSize(.Size)
|
$hColumnView[sKey][1] = " " & Main.FormatSize(.Size)
|
||||||
$hColumnView[sKey][2] = " " & Str(.Time)
|
$hColumnView[sKey][2] = " " & Str(.Time)
|
||||||
If bRichText Then $hColumnView[sPrefix & sFile].RichText = sText
|
If bRichText Then $hColumnView[sPrefix & sFile].RichText = sText
|
||||||
Else
|
Else
|
||||||
|
@ -1252,9 +1252,11 @@ Public Sub View_Draw(X As Integer, Y As Integer, Width As Integer, Height As Int
|
||||||
|
|
||||||
If $iIconSize < (H * 4) Then Return
|
If $iIconSize < (H * 4) Then Return
|
||||||
|
|
||||||
Try hStat = Stat($sDir &/ Mid$(Key, 2))
|
Try hStat = DirCache[$sDir].GetInfo(Mid$(Key, 2))
|
||||||
|
'Try hStat = Stat($sDir &/ Mid$(Key, 2))
|
||||||
If Error Then Return
|
If Error Then Return
|
||||||
|
|
||||||
|
|
||||||
Paint.Background = Color.Merge(Style.ForegroundOf(Last), Style.BackgroundOf(Last), 0.3)
|
Paint.Background = Color.Merge(Style.ForegroundOf(Last), Style.BackgroundOf(Last), 0.3)
|
||||||
|
|
||||||
If System.RightToLeft Then
|
If System.RightToLeft Then
|
||||||
|
@ -1266,7 +1268,7 @@ Public Sub View_Draw(X As Integer, Y As Integer, Width As Integer, Height As Int
|
||||||
Paint.Font = $hInfoFont
|
Paint.Font = $hInfoFont
|
||||||
|
|
||||||
Y += Desktop.Scale
|
Y += Desktop.Scale
|
||||||
Paint.DrawText(Main.GetFileSize(hStat.Size), X, Y, Width, Height, Align.TopNormal)
|
Paint.DrawText(Main.FormatSize(hStat.Size), X, Y, Width, Height, Align.TopNormal)
|
||||||
|
|
||||||
If $iIconSize < (H * 5) Then Return
|
If $iIconSize < (H * 5) Then Return
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ Private Sub UpdateSize(Optional sDirSize As String)
|
||||||
Try nDir = CInt(aDirSize[2])
|
Try nDir = CInt(aDirSize[2])
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
sSize = Main.GetFileSize($iSize)
|
sSize = Main.FormatSize($iSize)
|
||||||
If $iSize >= 1000 Then sSize &= " (" & Subst(("&1 B"), Format($iSize, "#,###")) & ")"
|
If $iSize >= 1000 Then sSize &= " (" & Subst(("&1 B"), Format($iSize, "#,###")) & ")"
|
||||||
|
|
||||||
If sDirSize Then
|
If sDirSize Then
|
||||||
|
|
|
@ -42,36 +42,36 @@ Public Sub GetArrow(iType As Integer, iSize As Integer) As Image
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Public Sub GetFileSize(iSize As Long) As String
|
' Public Sub GetFileSize(iSize As Long) As String
|
||||||
|
'
|
||||||
Dim fSize As Float
|
' Dim fSize As Float
|
||||||
|
'
|
||||||
If iSize < 1024 Then
|
' If iSize < 1024 Then
|
||||||
Return Subst(("&1 B"), CStr(iSize))
|
' Return Subst(("&1 B"), CStr(iSize))
|
||||||
Else If iSize < 1048576 Then
|
' Else If iSize < 1048576 Then
|
||||||
fSize = iSize / 1024
|
' fSize = iSize / 1024
|
||||||
If fSize < 20 Then
|
' If fSize < 20 Then
|
||||||
Return Subst(("&1 KiB"), Format(iSize / 1024, "0.#"))
|
' Return Subst(("&1 KiB"), Format(iSize / 1024, "0.#"))
|
||||||
Else
|
' Else
|
||||||
Return Subst(("&1 KiB"), Format(iSize / 1024, "0"))
|
' Return Subst(("&1 KiB"), Format(iSize / 1024, "0"))
|
||||||
Endif
|
' Endif
|
||||||
Else If iSize < 1073741824 Then
|
' Else If iSize < 1073741824 Then
|
||||||
fSize = iSize / 1048576
|
' fSize = iSize / 1048576
|
||||||
If fSize < 20 Then
|
' If fSize < 20 Then
|
||||||
Return Subst(("&1 MiB"), Format(iSize / 1048576, "0.#"))
|
' Return Subst(("&1 MiB"), Format(iSize / 1048576, "0.#"))
|
||||||
Else
|
' Else
|
||||||
Return Subst(("&1 MiB"), Format(iSize / 1048576, "0"))
|
' Return Subst(("&1 MiB"), Format(iSize / 1048576, "0"))
|
||||||
Endif
|
' Endif
|
||||||
Else
|
' Else
|
||||||
fSize = iSize / 1073741824
|
' fSize = iSize / 1073741824
|
||||||
If fSize < 20 Then
|
' If fSize < 20 Then
|
||||||
Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0.#"))
|
' Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0.#"))
|
||||||
Else
|
' Else
|
||||||
Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0"))
|
' Return Subst(("&1 GiB"), Format(iSize / 1073741824, "0"))
|
||||||
Endif
|
' Endif
|
||||||
Endif
|
' Endif
|
||||||
|
'
|
||||||
End
|
' End
|
||||||
|
|
||||||
Private Sub FindMenuChild(hMenu As Menu, sMenu As String) As Menu
|
Private Sub FindMenuChild(hMenu As Menu, sMenu As String) As Menu
|
||||||
|
|
||||||
|
@ -286,3 +286,42 @@ Public Sub UseGTK() As Boolean
|
||||||
Return $bUseGTK
|
Return $bUseGTK
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Private Sub FormatNumber(fNum As Float) As String
|
||||||
|
|
||||||
|
Dim sStr As String
|
||||||
|
|
||||||
|
sStr = Format(fNum, "0.##")
|
||||||
|
If String.Len(sStr) > 4 Then
|
||||||
|
sStr = String.Left(sStr, 4)
|
||||||
|
If Not IsDigit(Right(sStr)) Then sStr = Left(sStr, -1)
|
||||||
|
Endif
|
||||||
|
Return sStr
|
||||||
|
|
||||||
|
End
|
||||||
|
|
||||||
|
Public Sub FormatSize(Size As Long) As String
|
||||||
|
|
||||||
|
'If {Binary} Then
|
||||||
|
If Size < 1000 Then
|
||||||
|
Return Subst(("&1 B"), CStr(Size))
|
||||||
|
Else If Size < 1024000 Then
|
||||||
|
Return Subst(("&1 KiB"), FormatNumber(Size / 1024))
|
||||||
|
Else If Size < 1048576000 Then
|
||||||
|
Return Subst(("&1 MiB"), FormatNumber(Size / 1048576))
|
||||||
|
Else
|
||||||
|
Return Subst(("&1 GiB"), FormatNumber(Size / 1073741824))
|
||||||
|
Endif
|
||||||
|
' Else
|
||||||
|
' If Size < 1000 Then
|
||||||
|
' Return Subst(("&1 B"), CStr(Size))
|
||||||
|
' Else If Size < 1000000 Then
|
||||||
|
' Return Subst(("&1 KB"), FormatNumber(Size / 1000))
|
||||||
|
' Else If Size < 1000000000 Then
|
||||||
|
' Return Subst(("&1 MB"), FormatNumber(Size / 1000000))
|
||||||
|
' Else
|
||||||
|
' Return Subst(("&1 GB"), FormatNumber(Size / 1000000000))
|
||||||
|
' Endif
|
||||||
|
' Endif
|
||||||
|
|
||||||
|
End
|
||||||
|
|
|
@ -816,7 +816,8 @@ Static Private Function Themes_Read() As String[]
|
||||||
Next
|
Next
|
||||||
Next
|
Next
|
||||||
|
|
||||||
aTheme.Insert(["Gambas", "Gambas-Mono"])
|
If Not aTheme.Exist("Gambas") Then aTheme.Add("Gambas")
|
||||||
|
If Not aTheme.Exist("Gambas-Mono") Then aTheme.Add("Gambas-Mono")
|
||||||
aTheme.Sort(gb.IgnoreCase)
|
aTheme.Sort(gb.IgnoreCase)
|
||||||
Return aTheme
|
Return aTheme
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue