Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status bar #39

Merged
merged 4 commits into from
Jun 16, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions deken-plugin.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ namespace eval ::deken:: {
variable platform
variable architecture_substitutes
variable installpath
variable statustext
variable statustimer
}

set ::deken::statustimer ""
set ::deken::installpath [ lindex $::sys_staticpath 0 ]

# console message to let them know we're loaded
Expand Down Expand Up @@ -59,6 +61,18 @@ set ::deken::architecture_substitutes(i586) [list "i386"]
set ::deken::architecture_substitutes(armv6l) [list "armv6" "arm"]
set ::deken::architecture_substitutes(armv7l) [list "armv7" "armv6l" "armv6" "arm"]

proc ::deken::status {msg} {
#variable mytoplevelref
#$mytoplevelref.results insert end "$msg\n"
#$mytoplevelref.status.label -text "$msg"
after cancel $::deken::statustimer
if {"" ne $msg} {
set ::deken::statustext "STATUS: $msg"
set ::deken::statustimer [after 5000 [list set ::deken::statustext ""]]
} {
set ::deken::statustext ""
}
}
# this function gets called when the menu is clicked
proc ::deken::open_searchui {mytoplevel} {
if {[winfo exists $mytoplevel]} {
Expand Down Expand Up @@ -98,6 +112,11 @@ proc ::deken::create_dialog {mytoplevel} {
label $mytoplevel.warning.label -text "Only install externals uploaded by people you trust."
pack $mytoplevel.warning.label -side left -padx 6

frame $mytoplevel.status
pack $mytoplevel.status -side bottom -fill x
label $mytoplevel.status.label -textvariable ::deken::statustext
pack $mytoplevel.status.label -side left -padx 6

button $mytoplevel.searchbit.button -text [_ "Search"] -default active -width 9 -command "::deken::initiate_search $mytoplevel"
pack $mytoplevel.searchbit.button -side right -padx 6 -pady 3

Expand All @@ -112,7 +131,12 @@ proc ::deken::initiate_search {mytoplevel} {
$mytoplevel.results delete 1.0 end
$mytoplevel.results insert end "Searching for externals...\n"
# make the ajax call
set results [search_for [$mytoplevel.searchbit.entry get]]
if { [ catch {
set results [search_for [$mytoplevel.searchbit.entry get]]
} ] } {
puts "online?"
::deken::status "Unable to perform search. Are you online?"
} else {
# delete all text in the results
$mytoplevel.results delete 1.0 end
if {[llength $results] != 0} {
Expand All @@ -130,7 +154,7 @@ proc ::deken::initiate_search {mytoplevel} {
set tag ch$counter
set readable_date [regsub -all {[TZ]} $date { }]
$mytoplevel.results insert end "$title\n\tUploaded by $creator $readable_date\n\n" $tag
$mytoplevel.results tag bind $tag <Enter> "$mytoplevel.results tag configure $tag -foreground blue"
$mytoplevel.results tag bind $tag <Enter> "$mytoplevel.results tag configure $tag -foreground blue; ::deken::status $URL"
if {[::deken::architecture_match $filename]} {
$mytoplevel.results tag bind $tag <Leave> "$mytoplevel.results tag configure $tag -foreground black"
$mytoplevel.results tag configure $tag -foreground black
Expand All @@ -146,7 +170,7 @@ proc ::deken::initiate_search {mytoplevel} {
} else {
$mytoplevel.results insert end "No matching externals found. Try using the full name e.g. 'freeverb'.\n"
}
}
}}

# handle a clicked link
proc ::deken::clicked_link {mytoplevel URL filename} {
Expand Down Expand Up @@ -237,6 +261,8 @@ proc ::deken::architecture_match {title} {
# make a remote HTTP call and parse and display the results
proc ::deken::search_for {term} {
set searchresults [list]
::deken::status "searching for '$term'"

#set token [http::geturl "http://puredata.info/search_rss?SearchableText=$term+externals.zip&portal_type%3Alist=IAEMFile&portal_type%3Alist=PSCfile"]
set token [http::geturl "http://puredata.info/dekenpackages?name=$term"]
set contents [http::data $token]
Expand Down