Changed event method sub names

This commit is contained in:
itdominator 2022-02-01 00:03:04 -06:00
parent 53ff1417af
commit b4564c2540
3 changed files with 22 additions and 13 deletions

View File

@ -20,7 +20,7 @@ class Builtins(IPCServerMixin):
# data is the method parameters to give # data is the method parameters to give
# Where data may be any kind of data # Where data may be any kind of data
self._gui_events = [] self._gui_events = []
self._fm_events = [] self._module_events = []
self.is_ipc_alive = False self.is_ipc_alive = False
self.ipc_authkey = b'app-ipc' self.ipc_authkey = b'app-ipc'
self.ipc_address = '127.0.0.1' self.ipc_address = '127.0.0.1'
@ -33,9 +33,9 @@ class Builtins(IPCServerMixin):
return self._gui_events.pop(0) return self._gui_events.pop(0)
return None return None
def _pop_fm_event(self): def _pop_module_event(self):
if len(self._fm_events) > 0: if len(self._module_events) > 0:
return self._fm_events.pop(0) return self._module_events.pop(0)
return None return None
@ -46,9 +46,9 @@ class Builtins(IPCServerMixin):
raise Exception("Invald event format! Please do: [type, target, data]") raise Exception("Invald event format! Please do: [type, target, data]")
def push_fm_event(self, event): def push_module_event(self, event):
if len(event) == 3: if len(event) == 3:
self._fm_events.append(event) self._module_events.append(event)
return None return None
raise Exception("Invald event format! Please do: [type, target, data]") raise Exception("Invald event format! Please do: [type, target, data]")
@ -56,14 +56,14 @@ class Builtins(IPCServerMixin):
def read_gui_event(self): def read_gui_event(self):
return self._gui_events[0] return self._gui_events[0]
def read_fm_event(self): def read_module_event(self):
return self._fm_events[0] return self._module_events[0]
def consume_gui_event(self): def consume_gui_event(self):
return self._pop_gui_event() return self._pop_gui_event()
def consume_fm_event(self): def consume_module_event(self):
return self._pop_fm_event() return self._pop_module_event()

View File

@ -42,11 +42,20 @@ class Controller(DummyMixin, Controller_Data):
if event: if event:
try: try:
type, target, data = event type, target, data = event
method = getattr(self.__class__, target) if not type:
GLib.idle_add(method, *(self, data,)) method = getattr(self.__class__, target)
GLib.idle_add(method, *(self, *data,))
else:
method = getattr(self.__class__, "hadle_gui_event_and_call_back")
GLib.idle_add(method, *(self, type, target, data))
except Exception as e: except Exception as e:
print(repr(e)) print(repr(e))
def hadle_gui_event_and_call_back(self, type, target, parameters):
method = getattr(self.__class__, target)
data = method(*(self, *parameters))
event_system.push_module_event([type, None, (data,)])
def handle_file_from_ipc(self, path): def handle_file_from_ipc(self, path):

View File

@ -34,7 +34,7 @@ class IPCServerMixin:
if "FILE|" in msg: if "FILE|" in msg:
file = msg.split("FILE|")[1].strip() file = msg.split("FILE|")[1].strip()
if file: if file:
event_system.push_gui_event([None, "handle_file_from_ipc", file]) event_system.push_gui_event([None, "handle_file_from_ipc", (file,)])
conn.close() conn.close()
break break