-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_populate-1.tm
More file actions
88 lines (83 loc) · 3.32 KB
/
app_populate-1.tm
File metadata and controls
88 lines (83 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright © 2025 Mark Summerfield. All rights reserved.
package require util
oo::define App method populate_history_menu {} {
.menu.history delete 0 end
.menu.history add command -command [callback on_history_remove] \
-label "Remove Current" -compound left \
-image [ui::icon history-remove.svg $::MENU_ICON_SIZE]
.menu.history add separator
set MAX [expr {1 + [scan Z %c]}]
set i [scan A %c]
foreach tuple [$Pldb history] {
lassign $tuple lid tid filename name
set label [format "%c. %s" $i [humanize_trackname $filename $name]]
.menu.history add command -label $label -underline 0 \
-command [callback play_saved_track $lid $tid $filename 1 1]
incr i
if {$i == $MAX} { break }
}
}
oo::define App method populate_bookmarks_menu {} {
.menu.bookmarks delete 0 end
.menu.bookmarks add command -command [callback on_bookmarks_insert] \
-label "Add Current" -accelerator Ctrl+A -compound left \
-image [ui::icon bookmark-add.svg $::MENU_ICON_SIZE]
.menu.bookmarks add command -command [callback on_bookmarks_remove] \
-label "Remove Current" -compound left \
-image [ui::icon bookmark-remove.svg $::MENU_ICON_SIZE]
.menu.bookmarks add separator
set MAX [expr {1 + [scan Z %c]}]
set i [scan A %c]
foreach tuple [$Pldb bookmarks] {
lassign $tuple lid tid filename name
set label [format "%c. %s" $i [humanize_trackname $filename $name]]
.menu.bookmarks add command -label $label -underline 0 \
-command [callback play_saved_track $lid $tid $filename 1 0]
incr i
if {$i == $MAX} { break }
}
}
oo::define App method populate_listtree {{sel_lid 0}} {
$ListTree delete [$ListTree children {}]
foreach cid [$Pldb cids] {
lassign [$Pldb category_info $cid] name n
lassign [util::n_s $n] n s
if {[set secs [$Pldb category_secs $cid]]} {
set secs " · [humanize_secs $secs]"
} else {
set secs ""
}
$ListTree insert {} end -id C$cid -text "$name · $n list$s$secs"
}
foreach row [$Pldb lists] {
lassign $row cid lid name
lassign [$Pldb list_tracks_info $lid] n secs
set secs [expr {$secs ? " · [humanize_secs $secs]" : ""}]
lassign [util::n_s $n] n s
if {!$sel_lid} { set sel_lid $lid }
$ListTree insert C$cid end -id L$lid \
-text "$name · $n track$s$secs"
}
if {$ListTreeExpanded} { my on_category_expand_all }
select_tree_item $ListTree L$sel_lid
}
oo::define App method populate_tracktree {lid {sel_tid 0}} {
$TrackTree delete [$TrackTree children {}]
set n 0
foreach row [$Pldb tracks_for_lid $lid] {
lassign $row tid filename name artist stars secs
set secs [expr {$secs ? [humanize_secs $secs] : ""}]
incr n
set i [expr {$n < 10 ? "\u2004\u2004${n}" : $n}]
if {$artist ne ""} { set artist " · $artist" }
set txt "$i. [humanize_trackname $filename $name]$artist · $secs"
if {[$Pldb circled $lid $tid]} { set stars ${stars}c }
$TrackTree insert {} end -id $lid:$tid -text $txt -tags $stars
if {!$sel_tid} { set sel_tid $tid }
}
if {$n} {
select_tree_item $TrackTree $lid:$sel_tid
} else {
focus $ListTree
}
}