ocarina/src/extra/sgtk.py

111 lines
2.0 KiB
Python

# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Jan 13, 2010 12:02:58 AM$"
global name, app, type, path, opt
name = "sgtk"
app = "scion"
type = "extra"
path = ""
opt = []
from bt.message import write
from manager import manager
import settings
from guiGTK import *
import gtk
global win
global vbox
global bar
def test(button, name):
write("Test!")
def hide(item,event):
item.hide()
def pluginWindow(item):
write("Creating plugin window!",True)
plugins = window.Window("Plugin Manager")
hbox = box.HBox(True)
plugins.add(hbox)
manager.run("enable","lsmod")
enabled = list.List(gtk.ListStore(str), ["Enabled"])
enabledMods = manager.run("lsmod","enabled")
for mod in enabledMods:
enabled.insert([mod])
disabled = list.List(gtk.ListStore(str), ["Disabled"])
disabledMods = manager.run("lsmod","disabled")
for mod in disabledMods:
disabled.insert([mod])
enable = button.Button("button",test,None,"<<")
hbox.pack(enabled, True, True)
hbox.pack(enable)
hbox.pack(disabled, True, True)
plugins.quit(hide)
def loop():
global vbox,bar,win
manager.run("disable",["cli"])
win = window.Window(settings.get("appname").title())
vbox = box.VBox()
win.add(vbox)
bar = menu.Bar()
vbox.pack(bar)
plugins = menu.Item("Plugins",pluginWindow)
tools = menu.Item("Tools",None,[plugins])
bar.append(tools)
but = button.Button("button",test,None,"I'm a button!")
vbox.pack(but)
lab = label.Label("Hello, World!")
vbox.pack(lab)
settings.set("guirunning",True)
gtk.main()
# Called every time the plugin is enabled
def open():
settings.init("guirunning",False)
if settings.get("guirunning") == True:
settings.set("loop",loop)
pass
# Called every time the plugin is stopped
def close():
gtk.main_quit()
pass
# Called when the plugin needs to perform some action
def run(args=None):
global win,box
if args == None:
loop()
elif args[0] == "getwin":
return win
elif args[0] == "getbox":
return box