Changed how plugins are started after loading. GUI is still broken
This commit is contained in:
parent
18873e6e75
commit
5a69cd165a
|
@ -24,14 +24,6 @@ class Manager:
|
|||
for plugin in plugins:
|
||||
write("Adding plugin: " + str(plugin), True)
|
||||
self.disabled[plugin.name] = plugin
|
||||
# If we are adding a core plugin, activate it right away
|
||||
try:
|
||||
if plugin.type=="core":
|
||||
self.enablePlugin(plugin.name)
|
||||
elif (plugin.name in self.restored)==True:
|
||||
self.enablePlugin(plugin.name)
|
||||
except:
|
||||
error("Error adding plugin: "+plugin.name)
|
||||
|
||||
|
||||
# Move plugin from old[name] to new[name]
|
||||
|
@ -91,6 +83,17 @@ class Manager:
|
|||
settings.save(self.findsession())
|
||||
|
||||
|
||||
def startup(self):
|
||||
if len(self.restored) == 0:
|
||||
for key in self.disabled.keys():
|
||||
if self.disabled[key].type == "core":
|
||||
self.enablePlugin(key)
|
||||
return
|
||||
|
||||
for name in self.restored:
|
||||
self.enablePlugin(name)
|
||||
|
||||
|
||||
def run(self,name,args=None):
|
||||
name = name.strip()
|
||||
if (name in self.enabled)==True:
|
||||
|
@ -128,14 +131,6 @@ class Manager:
|
|||
return
|
||||
for line in file:
|
||||
self.restored+=[line.strip()]
|
||||
# Add this in to disable plugins that were enabled
|
||||
# By an earlier call to restore session
|
||||
for key in self.enabled.keys():
|
||||
if (key in self.restored) == False:
|
||||
self.disablePlugin(key)
|
||||
for key in self.disabled.keys():
|
||||
if (key in self.restored) == True:
|
||||
self.enablePlugin(key)
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ def main():
|
|||
loadPluginPath(path)
|
||||
|
||||
manager.manager.restoresession()
|
||||
manager.manager.startup()
|
||||
settings.pop("loop")()
|
||||
|
||||
|
||||
|
|
|
@ -29,7 +29,10 @@ def open():
|
|||
|
||||
# Called every time the plugin is stopped
|
||||
def close():
|
||||
settings.pop("loop")
|
||||
settings.pop("loopquit")()
|
||||
write("CLI has been stopped", True)
|
||||
#cline.loop.quit()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ from addch import addch
|
|||
from message import *
|
||||
|
||||
global halt
|
||||
halt = False
|
||||
halt = True
|
||||
|
||||
|
||||
|
||||
|
@ -44,6 +44,10 @@ def init():
|
|||
def quit():
|
||||
# Halt our loop
|
||||
global halt
|
||||
|
||||
if halt == True:
|
||||
return
|
||||
|
||||
halt = True
|
||||
|
||||
# Undo ncurses initialization
|
||||
|
@ -71,6 +75,8 @@ def quit():
|
|||
def loop():
|
||||
global halt
|
||||
|
||||
halt = False
|
||||
|
||||
init()
|
||||
|
||||
stdscr = settings.get("stdscr")
|
||||
|
|
|
@ -22,34 +22,33 @@ running = False
|
|||
from manager import manager
|
||||
|
||||
|
||||
def register(name, object):
|
||||
gui = settings.get("gui")
|
||||
gui[name] = object
|
||||
def register(name=None, object=None):
|
||||
#gui = settings.get("gui")
|
||||
#gui[name] = object
|
||||
return
|
||||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
def run(args=None):
|
||||
if args == None:
|
||||
running = settings.get("guirunning")
|
||||
#if args == None:
|
||||
#running = settings.get("guirunning")
|
||||
|
||||
# Main window
|
||||
win = window.Window("Scion", "gui")
|
||||
|
||||
# Horizontal box
|
||||
box = HBox("MainBox")
|
||||
win.add(box)
|
||||
# Main window
|
||||
#win = window.Window("Scion", "gui")
|
||||
|
||||
# Horizontal box
|
||||
#box = HBox("MainBox")
|
||||
#win.add(box)
|
||||
|
||||
|
||||
# Start gtk main
|
||||
if running == False:
|
||||
manager.run("disable", ["cli"] )
|
||||
settings.set("guirunning",True)
|
||||
#if settings.has("loop") == False:
|
||||
gtk.main()
|
||||
else:
|
||||
if len(args) == 2:
|
||||
register(args[0],args[1])
|
||||
# Start gtk main
|
||||
#if running == False:
|
||||
manager.run("disable", ["cli"] )
|
||||
#settings.set("guirunning",True)
|
||||
#if settings.has("loop") == False:
|
||||
#gtk.main()
|
||||
#else:
|
||||
# if len(args) == 2:
|
||||
# register(args[0],args[1])
|
||||
|
||||
|
||||
def loop():
|
||||
|
@ -62,16 +61,6 @@ def loop():
|
|||
settings.pop("loop")()
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
settings.init("guirunning",False)
|
||||
settings.set("loop",loop)
|
||||
settings.init("gui",dict())
|
||||
#if settings.get("guirunning") == True:
|
||||
# run()
|
||||
# settings.set("loop",gtk.main)
|
||||
|
||||
|
||||
# Called every time the plugin is stopped
|
||||
def close():
|
||||
running = settings.get("guirunning")
|
||||
|
@ -80,6 +69,20 @@ def close():
|
|||
settings.delete("gui")
|
||||
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
settings.init("guirunning",False)
|
||||
settings.set("loop",loop)
|
||||
settings.set("loopquit", close)
|
||||
settings.init("gui",dict())
|
||||
#if settings.get("guirunning") == True:
|
||||
# run()
|
||||
# settings.set("loop",gtk.main)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#print loop
|
||||
#settings.set("loop",loop)
|
||||
|
||||
|
|
Loading…
Reference in New Issue