Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EventGhost] - Enhancement - Several, Adds EventGhostEnduringEvent class and icon #318

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions eg/Classes/EventGhostEnduringEvent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
#
# This file is part of EventGhost.
# Copyright © 2005-2016 EventGhost Project <http://www.eventghost.org/>
#
# EventGhost is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 2 of the License, or (at your option)
# any later version.
#
# EventGhost is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with EventGhost. If not, see <http://www.gnu.org/licenses/>.

# Local imports
import eg


class EventGhostEnduringEvent(eg.EventGhostEvent):
icon = eg.Icons.ENDURING_EVENT_ICON

def __init__(self, suffix="", payload=None, prefix="Main", source=eg):
eventString = prefix + "." + suffix

if eventString in eg.eventTable:
for item in eg.eventTable[eventString]:
if item.icon == eg.Icons.EVENT_ICON:
item.icon = eg.Icons.ENDURING_EVENT_ICON
item.Refresh()

eg.EventGhostEvent.__init__(self, suffix, payload, prefix, source)
1 change: 1 addition & 0 deletions eg/Classes/EventGhostEvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class EventGhostEvent(object):

"""
skipEvent = False
icon = eg.Icons.EVENT_ICON

def __init__(self, suffix="", payload=None, prefix="Main", source=eg):
self.string = prefix + "." + suffix
Expand Down
42 changes: 42 additions & 0 deletions eg/Classes/EventItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

# Local imports
import eg
from TreeLink import TreeLink
from TreeItem import HINT_MOVE_AFTER, HINT_MOVE_BEFORE_OR_AFTER, TreeItem

class Text(eg.TranslatableStrings):
Expand All @@ -41,7 +42,13 @@ class EventItem(TreeItem):
}

def __init__(self, parent, node):
if (
'EventType' in node.attrib and
node.attrib['EventType'] == 'Enduring'
):
self.icon = eg.Icons.ENDURING_EVENT_ICON
TreeItem.__init__(self, parent, node)

self.RegisterEvent(self.name)

def Configure(self, name):
Expand Down Expand Up @@ -75,6 +82,30 @@ def GetBasePath(self):
# so we also have no base path
return ""

def GetData(self):
"""
This method returns the needed data to construct its XML
representation.

The return values should be:
1. a list of (name, value) tuples of the attributes
2. the text of the node
"""
attr = []
if self.name:
attr.append(('Name', self.name))
if self.dependants or TreeLink.inUndo:
attr.append(('id', self.xmlId))
if not self.isEnabled:
attr.append(('Enabled', 'False'))
if self.icon == eg.Icons.ENDURING_EVENT_ICON:
attr.append(('EventType', 'Enduring'))
else:
attr.append(('EventType', 'Event'))

attr.append(('XML_Guid', str(self.guid)))
return attr, None

def GetDescription(self):
return ""

Expand All @@ -87,6 +118,17 @@ def RegisterEvent(self, eventString):
eventTable[eventString] = []
eventTable[eventString].append(self)

if (
self.icon != eg.Icons.ENDURING_EVENT_ICON and
'?' not in self.name and
'*' not in self.name
):
for item in eventTable[eventString][:-1]:
if item.icon == eg.Icons.ENDURING_EVENT_ICON:
self.icon = eg.Icons.ENDURING_EVENT_ICON
self.Refresh()
break

@eg.AssertInActionThread
def RenameTo(self, newName):
self.UnRegisterEvent(self.name)
Expand Down
3 changes: 2 additions & 1 deletion eg/Classes/EventThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

# some shortcuts
EventGhostEvent = eg.EventGhostEvent
EventGhostEnduringEvent = eg.EventGhostEnduringEvent
actionThread = eg.actionThread
ActionThreadCall = actionThread.Call

Expand Down Expand Up @@ -90,7 +91,7 @@ def TriggerEnduringEvent(
prefix="Main",
source=eg
):
event = EventGhostEvent(suffix, payload, prefix, source)
event = EventGhostEnduringEvent(suffix, payload, prefix, source)
if event.source in self.filters:
for filterFunc in self.filters[event.source]:
if filterFunc(event) is True:
Expand Down
2 changes: 1 addition & 1 deletion eg/Classes/Log.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def LogEvent(self, event):
mesg = eventstring + ' ' + repr(payload)
else:
mesg = eventstring
self.Write(mesg + "\n", eg.EventItem.icon, eventstring)
self.Write(mesg + "\n", event.icon, eventstring)

def NativeLogOn(self, value):
self.NativeLog = value
Expand Down
1 change: 1 addition & 0 deletions eg/Icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def PilToBitmap(pil):
DISABLED_ICON = PathIcon(join(IMAGES_PATH, "disabled.png"))
PLUGIN_ICON = PathIcon(join(IMAGES_PATH, "plugin.png"))
EVENT_ICON = PathIcon(join(IMAGES_PATH, "event.png"))
ENDURING_EVENT_ICON = PathIcon(join(IMAGES_PATH, "enduring_event.png"))
ACTION_ICON = PathIcon(join(IMAGES_PATH, "action.png"))
MACRO_ICON = PathIcon(join(IMAGES_PATH, "macro.png"))
ADD_ICON = PathIcon(join(IMAGES_PATH, 'add.png'))
Expand Down
Binary file added images/enduring_event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.