def Update(self): self.TaskList.UpdateOffsetToWindow(self) self.TopOptionsBar.Update() self.TopOptionsBar.UpdateOffsetToWindow(self) if self.TopOptionsBar.LastInteractionID == 0: self.UpdateProcessList() if self.TopOptionsBar.LastInteractionID == 1: if self.SelectedTaskPID != -1: CoreAccess.SendSigKillToProcessByPID(self.SelectedTaskPID) self.SelectedTaskPID = -1 self.SelectedTask = "" self.TaskList.ResetSelectedItem() self.UpdateProcessList() self.UpdateSelectedTaskTitle() if self.TaskList.LastItemIndex is not None: self.SelectedTask = self.TaskList.LastItemClicked self.SelectedTaskPID = self.TaskList.ItemProperties[ self.TaskList.LastItemIndex] if not self.FirstCycleRefresh: self.FirstCycleRefresh = True self.UpdateProcessList()
def CloseSelectedProcess(self): if self.WindowList.LastItemIndex is not None: try: ProcessPID = self.WindowList.ItemProperties[ self.WindowList.LastItemIndex] CoreAccess.KillProcessByPID(ProcessPID) self.DefaultContent.PlaySound("/click.wav", UI.SystemSoundsVolume) except IndexError: self.WindowList.ResetSelectedItem() except Exception: Core.MAIN.SystemFault_Trigger = True Core.MAIN.SystemFault_Traceback = traceback.format_exc() Core.MAIN.SystemFault_ProcessObject = None WmControl.WindowManagerSignal(None, 4) print( "AppSeletorModeInstance : Process Error Detected\nin Process PID(unknow)" ) print("Traceback:\n" + Core.MAIN.SystemFault_Traceback) # Generate the Crash Log Core.MAIN.GenerateCrashLog() self.RootObj.SetMode(1) self.RootObj.Toggle()
def Update(): global UnatachedDialogOpened global Enabled global OtherProcessPID if not Enabled: return # Open Dialog Process if not UnatachedDialogOpened: UnatachedDialogOpened = True Main.var.DisableControls = True Main.var.AwaysUpdate = True OtherProcessPID = CoreAccess.CreateProcess( "OneTrack/UnatachedDialog", "OneTrack File Operation", (var.ProcessReference, "OPEN")) # Operation has been completed if not OtherProcessPID in CoreAccess.ProcessAccess_PID: var.AwaysUpdate = False var.DisableControls = False Enabled = False UnatachedDialogOpened = False CoreWMControl.WindowManagerSignal(var.ProcessReference, 0)
def ProcessError(self): print("The process {0} has failed.".format(self.NAME)) print(traceback.format_exc()) CoreAccess.CreateProcess("System{0}SystemApps{0}crash_dialog".format(CorePaths.TaiyouPath_CorrectSlash), "application_crash", (self.TITLEBAR_TEXT, self.NAME, self.PID)) self.KillProcess(False)
def WindowManagerSignal(self, Signal, Args=None): """ Sends a signal to the TaskBar's Window Manager :param self:Process Object :param Signal:Signal Table: SignalID Description\n ######## #############\n 0 Force Focus on Window\n 1 Kill Process\n 2 Play Notify Sound on Task Bar Graphical Interface\n 3 Disable GUI Task Manager\n 4 Enable GUI Task Manager\n 5 Disable Intro Sound Trigger\n :return: """ global TaskBarUIProcessID try: if TaskBarUIProcessID == -1: raise Exception( "Cant send signal to TaskBarGUI because it is not running.") print("WindowManagerManager : TaskBAR ProcessID {0}".format( TaskBarUIProcessID)) if Signal == 0: OriginalDragValue = self.WINDOW_DRAG_ENABLED for process in CoreAccess.ProcessAccess: process.APPLICATION_HAS_FOCUS = False process.WINDOW_DRAG_ENABLED = False # Make this application focused again self.APPLICATION_HAS_FOCUS = True self.WINDOW_DRAG_ENABLED = OriginalDragValue return elif Signal == 1: CoreAccess.KillProcessByPID(self.PID) return elif Signal == 2: CoreAccess.ProcessAccess[TaskBarUIProcessID].PlayNotifySound = True return elif Signal == 3: CoreAccess.ProcessAccess[ TaskBarUIProcessID].GUI_ALLOW_TASKMANAGER = False return elif Signal == 4: CoreAccess.ProcessAccess[ TaskBarUIProcessID].GUI_ALLOW_TASKMANAGER = True return except: print("Error while processing Window Manager Request") print(traceback.format_exc())
def EventUpdate(self, event): if self.ApplicationSeletor: self.ApplicationSelectorObj.EventUpdate(event) if event.type == pygame.KEYUP and event.key == pygame.K_RETURN: if not self.ApplicationSelectorObj.SelectedItemIndex == -1: try: # Create the Application Process CoreAccess.CreateProcess( self.ApplicationSelectorObj.SelectedItemModulePath, self.ApplicationSelectorObj.SelectedItemModulePath) # Allow Window Manager do receive request WmControl.WindowManagerSignal(None, 4) # Kills the Bootloader process CoreAccess.KillProcessByPID(self.PID) except Exception as e: Traceback = traceback.format_exc() self.GenerateCrashLog( Traceback, self.ApplicationSelectorObj.SelectedItemModulePath) print(Traceback) self.FatalErrorScreen = True self.ApplicationSeletor = True self.APPLICATION_HAS_FOCUS = True else: if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE and self.Progress < 3: self.LoadingComplete = True self.LoadingBarProgress = 0 self.Progress = 0 self.ProgressAddDelay = 0 self.ProgressProgression = False self.ApplicationSeletor = True if self.FatalErrorScreen: if event.type == pygame.KEYUP and event.key == pygame.K_ESCAPE: self.FatalErrorScreen = False self.ApplicationSeletor = True
def OpenSelectedApp(self): self.DisableInput = True print("OpenApp : " + self.ApplicationSelector.SelectedItemTitle) try: # Create the Application Process CoreAccess.CreateProcess( self.ApplicationSelector.SelectedItemModulePath, self.ApplicationSelector.SelectedItemModulePath) self.RootObj.Toggle() except: print("Error while opening application in TaiyouUI Dashboard.") print(traceback.format_exc()) CoreAccess.CreateProcess( "System{0}SystemApps{0}crash_dialog".format( CorePaths.TaiyouPath_CorrectSlash), "application_crash", (self.ApplicationSelector.SelectedItemTitle, None, None, 1)) self.RootObj.Toggle() """
def __init__(self, pPID, pProcessName, pROOT_MODULE, pInitArgs, pProcessIndex): """ A TaiyouProcess Object :param pPID:Process PID :param pProcessName:Process Name :param pROOT_MODULE:Root Module :param pInitArgs:Initialization Arguments :param pProcessIndex:Process Index """ self.PID = pPID self.NAME = pProcessName self.ROOT_MODULE = pROOT_MODULE self.ProcessIndex = pProcessIndex self.INIT_ARGS = pInitArgs self.ICON = None self.IS_GRAPHICAL = False self.DISPLAY = pygame.Surface((320, 240), pygame.HWACCEL | pygame.HWSURFACE) self.LAST_SURFACE = self.DISPLAY.copy() self.APPLICATION_HAS_FOCUS = True self.POSITION = (0, 0) self.FULLSCREEN = False self.Running = True self.TITLEBAR_TEXT = "Untitled Window" self.TITLEBAR_RECTANGLE = pygame.Rect(0, 0, 320, 15) self.WINDOW_DRAG_ENABLED = False self.THIS_THREAD = None self.WINDOW_SURFACE = None self.WINDOW_SURFACE_LAST_DRAG_STATE = None self.WINDOW_SURFACE_LAST_DRAG_STATE_BORDER_UPDATE_NEXT_FRAME = False self.WINDOW_SURFACE_LAST_DRAG_STATE_LAST_GEOMETRY = None self.CURSOR = None self.FRAMELESS = False self.PROCESS_KILL = False self.LAST_TITLEBAR_TEXT = False self.UpdateClock = pygame.time.Clock() self.SetCursor(0) self.UpdateFPS = 100 try: self.Initialize() except: self.ProcessError() return if self.IS_GRAPHICAL: self.StartDrawThread() CoreAccess.RegisterToCoreAccess(self)
def Update(self): if self.DeleteInstanceOnFirstCycle and self.DialogPID not in CoreAccess.ProcessList_PID: CoreAccess.KillProcessByPID(self.PID) if not self.APPLICATION_HAS_FOCUS and var.AwaysUpdate is False: return self.CurrentScreenToUpdate.Update() LagIndicator.Update() if var.PlayMode: self.UpdateFPS = 60 else: self.UpdateFPS = 100 self.CalcFPS = self.UpdateClock.get_fps()
def KillProcess(self, WhenKilled=True): """ This function is called when the processing is being closed by Taiyou [Unsafe to Override] :return: """ print("Process [{0}] has received kill request.".format(self.TITLEBAR_TEXT)) CoreAccess.RemoveFromCoreAccess(self) if self.IS_GRAPHICAL: self.KillDrawThread() self.Running = False if WhenKilled: self.WhenKilled() del self UTILS.GarbageCollector_Collect()
def LoadingSteps(self, CurrentProgres): print("Taiyou.Bootloader.LoadingSteps : Running Step {0}.".format( CurrentProgres)) # Load default UI Resources if CurrentProgres == 0: # Load the default Theme File UI.ThemesManager_LoadTheme( UI.SystemResources, UI.SystemResources.Get_RegKey("UI/selected_theme")) if CurrentProgres == 1: # Start the SystemUI CoreAccess.CreateProcess( "System{0}SystemApps{0}TaiyouUI".format( CorePaths.TaiyouPath_CorrectSlash), "system_ui") self.InterruptDrawing = False if CurrentProgres >= self.ProgressMax: # Finish the Loading self.FinishLoadingScreen()
def Update(self): if self.ApplicationSeletor: self.ApplicationSeletorAnimatorStart.Update() if self.ApplicationSeletorAnimatorStart.Value <= 10 and not self.FatalErrorScreen: self.ApplicationSeletorAnimatorStart.Enabled = True if not self.ApplicationSeletorWelcomeSound and not self.FatalErrorScreen: self.ApplicationSeletorWelcomeSound = True self.DefaultContent.PlaySound("/intro.wav") return if self.ProgressProgression and not self.LoadingComplete: self.ProgressAddDelay += 1 if self.ProgressAddDelay == 5: self.ProgressAddDelay = 0 self.Progress += 1 if self.ProgressAddDelay == 1: self.LoadingSteps(self.Progress) if self.Progress >= self.ProgressMax and not self.LoadingComplete: self.LoadingComplete = True print("Taiyou.Bootloader : Loading Complete") # Start the Default Application CreatedProcessPID = 0 try: print( "Taiyou.Bootloader : Loading has been completed\nStarting user selected applicaton..." ) # Create the Application Process CreatedProcessPID = CoreAccess.CreateProcess( Core.GetUserSelectedApplication(), Core.GetUserSelectedApplication()) # Allow Window Manager to receive request WmControl.WindowManagerSignal(None, 4) # Kills the Bootloader process self.KillProcess(False) except Exception: print( "Taiyou.Bootloader : Fatal Error : Error while creating the process to the Auto-Start Application." ) Traceback = traceback.format_exc() print(Traceback) CoreAccess.KillProcessByPID(CreatedProcessPID) # Check if SelectedFile wax exists try: UserSelectedApplication = Core.GetUserSelectedApplication( ) self.GenerateCrashLog(Traceback, UserSelectedApplication) print( "Something bad happened while creating the process for the default application." ) self.FatalErrorScreen = True self.ApplicationSeletor = True self.APPLICATION_HAS_FOCUS = True except: print("Selected application file is not readable.") self.ApplicationSeletor = True self.APPLICATION_HAS_FOCUS = True
def GreyDialog(self, Title, Text, Icon="none"): var.AwaysUpdate = False return CoreAccess.CreateProcess( "OneTrack/UnatachedDialog", "OneTrack Dialog", (var.ProcessReference, "DIALOG_OK", "{0};{1}".format( Title, Text), "icon:{0},".format(Icon)))
def DropDownButtonsActions_SettingsButton(): DropDownFileMenu.SelectedItem = "" var.FileMenuEnabled = False CoreAccess.CreateProcess("OneTrack/UnatachedDialog", "OneTrack Dialog", (var.ProcessReference, "DIALOG_SETTINGS"))