Merge pull request #10 from philipdexter/master
Add the ability to rearrange modules
This commit is contained in:
commit
1457f0ab17
@ -23,7 +23,9 @@ class Status:
|
||||
"""Register a new module."""
|
||||
|
||||
if module:
|
||||
self.modules.append(module, *args, **kwargs)
|
||||
return self.modules.append(module, *args, **kwargs)
|
||||
else:
|
||||
return None
|
||||
|
||||
def run_command_endpoint(self):
|
||||
for command in io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull,"w")), skiplines=1).read():
|
||||
|
@ -3,6 +3,7 @@ import time
|
||||
|
||||
from .settings import SettingsBase
|
||||
from .threading import Manager
|
||||
from .util import convert_position
|
||||
|
||||
__all__ = [
|
||||
"Module", "AsyncModule", "IntervalModule",
|
||||
@ -10,6 +11,7 @@ __all__ = [
|
||||
|
||||
class Module(SettingsBase):
|
||||
output = None
|
||||
position = 0
|
||||
|
||||
def registered(self, status_handler):
|
||||
"""Called when this module is registered with a status handler"""
|
||||
@ -19,7 +21,7 @@ class Module(SettingsBase):
|
||||
if "name" not in self.output:
|
||||
self.output["name"] = self.__name__
|
||||
self.output["instance"] = str(id(self))
|
||||
json.insert(0, self.output)
|
||||
json.insert(convert_position(self.position, json), self.output)
|
||||
|
||||
def on_click(self, button):
|
||||
if button == 1: # Left mouse button
|
||||
@ -27,6 +29,9 @@ class Module(SettingsBase):
|
||||
elif button == 3: # Right mouse button
|
||||
self.on_rightclick()
|
||||
|
||||
def move(self, position):
|
||||
self.position = position
|
||||
|
||||
def on_leftclick(self):
|
||||
pass
|
||||
|
||||
|
@ -46,6 +46,7 @@ class ModuleList(collections.UserList):
|
||||
module = self.finder.instanciate_class_from_module(module, *args, **kwargs)
|
||||
module.registered(self.status_handler)
|
||||
super().append(module)
|
||||
return module
|
||||
|
||||
def get_by_id(self, find_id):
|
||||
find_id = int(find_id)
|
||||
@ -94,3 +95,8 @@ class KeyConstraintDict(collections.UserDict):
|
||||
|
||||
def missing(self):
|
||||
return self.required_keys - (self.seen_keys & self.required_keys)
|
||||
|
||||
def convert_position(pos, json):
|
||||
if pos < 0:
|
||||
pos = len(json) + (pos+1)
|
||||
return pos
|
||||
|
@ -21,7 +21,7 @@ class IMAP(Backend):
|
||||
required = ("host", "username", "password")
|
||||
|
||||
port = 993
|
||||
ssl = False
|
||||
ssl = True
|
||||
|
||||
imap_class = imaplib.IMAP4
|
||||
connection = None
|
||||
@ -51,3 +51,5 @@ class IMAP(Backend):
|
||||
conn = self.get_connection()
|
||||
if conn:
|
||||
return len(conn.search(None,"UnSeen")[1][0].split())
|
||||
else:
|
||||
sys.stderr.write("no connection")
|
||||
|
Loading…
Reference in New Issue
Block a user