06-25-2018, 11:02 AM
Add a status indicator to the deskbar tray.
Code:
#!yab
doc Place a description of your
doc program here.
doc
doc Author, date, license
// set DEBUG = 1 to print out all messages on the console
DEBUG = 1
dir$=attribute get$ "",""
dir$=dir$+"/"
OpenWindow()
// Main Message Loop
dim msg$(1)
while(not leavingLoop)
nCommands = token(message$, msg$(), "|")
for everyCommand = 1 to nCommands
if(DEBUG and msg$(everyCommand)<>"") print msg$(everyCommand)
switch(msg$(everyCommand))
case "_QuitRequested"
case "MainWindow:_QuitRequested"
leavingLoop = true
break
case "on/off"
if off=1 then
off=0
OPTION SET "on/off", "Label", "Stop"
system("copyattr -n BEOS:ICON "+dir$+"Color_12_Green "+dir$+"On-Off")
if link=1 then
system("desklink --remove=On-Off")
system("desklink \"cmd=Remove replicant:desklink --remove=On-Off\" "+dir$+"On-Off")
endif
else
OPTION SET "on/off", "Label", "Run"
system("copyattr -n BEOS:ICON "+dir$+"Color_06_Red "+dir$+"On-Off")
off=1
if link=1 then
system("desklink --remove=On-Off")
system("desklink \"cmd=Remove replicant:desklink --remove=On-Off\" "+dir$+"On-Off")
endif
endif
break
case "link"
if link=0 then
system("desklink \"cmd=Remove replicant:desklink --remove=On-Off\" "+dir$+"On-Off")
OPTION SET "link", "Label", "Remove"
link=1
else
system("desklink --remove=On-Off")
link=0
OPTION SET "link", "Label", "DeskLink"
endif
break
default
end switch
next everyCommand
wend
CloseWindow()
end
// Setup the main window here
sub OpenWindow()
window open 100,100 to 600,500, "MainWindow", "On-Off"
off=1
link=0
button 30,30 to 80,50, "on/off", "Run", "MainWindow"
button 30,100 to 120,120, "link", "DeskLink", "MainWindow"
return
end sub
// Close down the main window
sub CloseWindow()
system("copyattr -n BEOS:ICON "+dir$+"Color_06_Red "+dir$+"On-Off")
system("desklink --remove=On-Off")
window close "MainWindow"
return
end sub