Simple events system built into __builtins__
This commit is contained in:
		
							
								
								
									
										34
									
								
								src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/versions/pyfm-0.0.1/PyFM/new/pyfm/__builtins__.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
				
			|||||||
 | 
					import builtins
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Builtins:
 | 
				
			||||||
 | 
					    # Makeshift "events" type system FIFO
 | 
				
			||||||
 | 
					    def push_gui_event(event):
 | 
				
			||||||
 | 
					        gui_events.append(event)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def push_fm_event(event):
 | 
				
			||||||
 | 
					        fm_events.append(event)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def pop_gui_event():
 | 
				
			||||||
 | 
					        gui_events.pop(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def pop_fm_event():
 | 
				
			||||||
 | 
					        fm_events.pop(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def read_gui_event():
 | 
				
			||||||
 | 
					        return gui_events[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def read_fm_event():
 | 
				
			||||||
 | 
					        return fm_events[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    builtins.gui_events = []
 | 
				
			||||||
 | 
					    builtins.fm_events  = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # NOTE: Just reminding myself we can add to builtins two different ways...
 | 
				
			||||||
 | 
					    __builtins__.update({"push_gui_event": push_gui_event})
 | 
				
			||||||
 | 
					    __builtins__.update({"push_fm_event": push_fm_event})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    builtins.pop_gui_event  = pop_gui_event
 | 
				
			||||||
 | 
					    builtins.pop_fm_event   = pop_fm_event
 | 
				
			||||||
 | 
					    builtins.read_gui_event = read_gui_event
 | 
				
			||||||
 | 
					    builtins.read_fm_event  = read_fm_event
 | 
				
			||||||
@@ -8,9 +8,10 @@ import inspect
 | 
				
			|||||||
# Application imports
 | 
					# Application imports
 | 
				
			||||||
from utils import Settings
 | 
					from utils import Settings
 | 
				
			||||||
from signal_classes import Signals
 | 
					from signal_classes import Signals
 | 
				
			||||||
 | 
					from __builtins__ import Builtins
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Main:
 | 
					class Main(Builtins):
 | 
				
			||||||
    def __init__(self, args):
 | 
					    def __init__(self, args):
 | 
				
			||||||
        settings = Settings()
 | 
					        settings = Settings()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,7 @@ class Signals(WindowMixin, PaneMixin):
 | 
				
			|||||||
        self.window.show()
 | 
					        self.window.show()
 | 
				
			||||||
        self.generate_windows(self.state)
 | 
					        self.generate_windows(self.state)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def generate_windows(self, data = None):
 | 
					    def generate_windows(self, data = None):
 | 
				
			||||||
        if data:
 | 
					        if data:
 | 
				
			||||||
            for j, value in enumerate(data):
 | 
					            for j, value in enumerate(data):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -37,6 +37,9 @@ class TabMixin(WidgetMixin):
 | 
				
			|||||||
        notebook.show_all()
 | 
					        notebook.show_all()
 | 
				
			||||||
        notebook.set_current_page(index)
 | 
					        notebook.set_current_page(index)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        # FIXME: set_tab_reorderable doesn't seem to work...
 | 
				
			||||||
 | 
					        # notebook.set_tab_reorderable(tab, True)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def close_tab(self, widget, eve):
 | 
					    def close_tab(self, widget, eve):
 | 
				
			||||||
        notebook      = widget.get_parent().get_parent()
 | 
					        notebook      = widget.get_parent().get_parent()
 | 
				
			||||||
        page          = notebook.get_current_page()
 | 
					        page          = notebook.get_current_page()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user