About Make Invisible 2.1 Source

Class MainWindow
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance

// Event implementations
Sub DropObject(obj As DragItem, action As Integer)
do
if obj.FolderItemAvailable then
app.Process obj.FolderItem
end if
loop until not obj.NextItem
End Sub
Sub Open()
me.AcceptFileDrop "special/application"

End Sub
End Class

Class App
Inherits Application
// Event implementations
Sub EnableMenuItems()
FileOpen.Enable
AppleAboutMakeInvisible.Enable
End Sub
Sub OpenDocument(item As FolderItem)
Process item
End Sub
Sub Open()
RegisterPlugins
End Sub

// Methods
Sub Process(f as folderItem)
if f.Directory then
ProcessPackage f
else
ProcessRes f
end if

call f.FinderUpdateMBS
End Sub
Protected Sub ProcessRes(f as folderitem)
dim r as ResourceFork
dim s as string
dim o as CFObjectMBS
dim d as CFDictionaryMBS
dim e as CFMutableDictionaryMBS
dim b as CFBinaryDataMBS
dim key,value as CFStringMBS
dim name as string

if f.MacType="APPL" then
// only applications

r=f.OpenResourceFork
if r=nil then
MsgBox "Failed to open resource fork of file "+f.DisplayName+"."
else
s=r.GetResource("plst",0)

if s="" then
MsgBox "No plst resource in file "+f.DisplayName+"."
else
b=NewCFBinaryDataMBSStr(s)
o=NewCFObjectMBSFromXML(b)

if o isa CFDictionaryMBS then
d=CFDictionaryMBS(o)
e=d.Edit

// key=NewCFStringMBS("LSBackgroundOnly") ' something different

key=NewCFStringMBS("NSUIElement")
value=NewCFStringMBS("true")

e.Add key,value

// Make XML from CFMutableDictionary
b=e.XML

// Make RB String
s=b.Str

// save
r.AddResource s,"plst",0,""

end if
end if
end if
end if
End Sub
Protected Sub ProcessPackage(f as folderitem)
dim r as BinaryStream
dim s as string
dim o as CFObjectMBS
dim d as CFDictionaryMBS
dim e as CFMutableDictionaryMBS
dim b as CFBinaryDataMBS
dim key,value as CFStringMBS
dim name as string
dim g as FolderItem

g=f.TrueChild("Contents")
if g<>nil and g.Exists then
g=g.TrueChild("Info.plist")

if g<>nil and g.Exists then
// only applications

r=g.OpenAsBinaryFile(true)
if r=nil then
MsgBox "Failed to open info.plist file."
else
s=r.Read(r.Length)

if s="" then
MsgBox "No plst resource in file "+f.DisplayName+"."
else
b=NewCFBinaryDataMBSStr(s)
o=NewCFObjectMBSFromXML(b)

if o isa CFDictionaryMBS then
d=CFDictionaryMBS(o)
e=d.Edit

// key=NewCFStringMBS("LSBackgroundOnly") ' something different

key=NewCFStringMBS("NSUIElement")
value=NewCFStringMBS("true")

e.Add key,value

// Make XML from CFMutableDictionary
b=e.XML

// Make RB String
s=b.Str

// save
r.Position=0
r.Write s
r.Length=r.Position // cut away rest of file

end if
end if
end if
end if
end if
End Sub
End Class





Links
MBS Xojo Plugins