def run(self): Instance.record("view", JWebView(self.config)) if self.config['window']["transparent"]: from JAK.Utils import JavaScript JavaScript.css( "body, html {background-color:transparent !important;background-image:none !important;}", "JAK") if self.config['webview']["addCSS"]: from JAK.Utils import JavaScript JavaScript.css(self.config['webview']["addCSS"], "user") print("Custom CSS detected") if self.config['webview']["runJavaScript"]: from JAK.Utils import JavaScript JavaScript.send(self.config['webview']["runJavaScript"]) print("Custom JavaScript detected") win = Instance.auto("win", JWindow(self.config)) if self.config['window']["fullScreen"]: screen = getScreenGeometry() win.resize(screen.width(), screen.height()) else: win.resize(win.default_size("width"), win.default_size("height")) win.setFocusPolicy(Qt.WheelFocus) win.show() win.setFocus() win.window_original_position = win.frameGeometry() result = self.exec_() sys.exit(result)
def event(view, event): #TODO manage sound and video pass data = event.mimeData() ext = (".mp4", ".ogv", ".webm") if str(data.text().endswith(ext)): video = str(data.text()) js = f"desktop.playVideo(`{video}`)" JavaScript.send(js)
def package_sync_callback(*args): print(args) window = Instance.retrieve("win") msg = f"Would you like to update your software and operating system from {self.branch_lock['branch']} branch now?" Dialog.question(window, " ", msg, update) self.branch_lock["branch"] = "" JavaScript.send(f""" desktop.elem(`#{self.branch_lock["branch"]}-btn`).checked = true """)
def setBranch(self, desired_branch): current_branch = Desktop.getBranch() if current_branch != desired_branch: if self.branch_lock["branch"] == "": self.branch_lock["branch"] = desired_branch.upper() notify( f"Setting branch to {desired_branch.upper()} and synchronising mirrors.", "Might take a while.") def update(): run(["pamac-manager", "--updates"]) def package_sync_callback(*args): print(args) window = Instance.retrieve("win") msg = f"Would you like to update your software and operating system from {self.branch_lock['branch']} branch now?" Dialog.question(window, " ", msg, update) self.branch_lock["branch"] = "" JavaScript.send(f""" desktop.elem(`#{self.branch_lock["branch"]}-btn`).checked = true """) def branch_sync_callback(sucprocess: Gio.Subprocess, result: Gio.AsyncResult, data): proc1.communicate_utf8_finish(result) notify("Mirrors done, Synchronising packages", "") proc2 = Gio.Subprocess.new( ['pkexec', 'pacman', '-Sy'], Gio.SubprocessFlags.STDIN_PIPE | Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE) proc2.communicate_utf8_async('package sync', None, package_sync_callback, None) cmd = [ 'pkexec', 'pacman-mirrors', '--fasttrack', '--api', '--set-branch', f'{desired_branch}' ] proc1 = Gio.Subprocess.new( cmd, Gio.SubprocessFlags.STDIN_PIPE | Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE) proc1.communicate_utf8_async('mirrors sync', None, branch_sync_callback, None) else: notify( f"Hold on, still changing to {self.branch_lock['branch']}.", "") JavaScript.send(f""" desktop.elem(`#{current_branch}-btn`).checked = true """)
def callback(sucprocess: Gio.Subprocess, result: Gio.AsyncResult, data): proc.communicate_utf8_finish(result) current_branch = Desktop.getBranch() if current_branch != desired_branch: JavaScript.send(f""" desktop.elem(`#{current_branch}-btn`).checked = true """) notify("Something went wrong", "") else: from JAK.Widgets import JCancelConfirmDialog window = Instance.retrieve("win") msg = f"All Done, would you like to update your software and operating system from {current_branch.upper()} branch now?" JCancelConfirmDialog(window, " ", msg, update)
def _page_load_finish(self) -> None: result = time.localtime(time.time()) print(f"Document Ready in: {result.tm_sec} seconds") try: if self.custom_css: print("Custom CSS loaded") JavaScript.css(self, self.custom_css) except AttributeError: pass try: if self.custom_js: print("Custom JavaScript loaded") JavaScript.send(self, self.custom_js) except AttributeError: pass
def run(self): Instance.record("view", JWebView(self.config)) if self.config["add_CSS"]: from JAK.Utils import JavaScript JavaScript.css(self.config["add_CSS"]) print("Custom CSS detected") if self.config["run_JavaScript"]: from JAK.Utils import JavaScript JavaScript.send(self.config["run_JavaScript"]) print("Custom JavaScript detected") win = Instance.auto("win", JWindow(self.config)) win.resize(win.default_size("width"), win.default_size("height")) win.show() win.window_original_position = win.frameGeometry() result = self.exec_() sys.exit(result)
def toggleLauncher(): JavaScript.send("desktop.toggleLauncher();")
def toggleSettings(): JavaScript.send("desktop.toggleSettings();")
def updateMenu(): menu = Menu.Get().items() JavaScript.send(f"Jade.menu = { json.dumps( menu ) }")
def toggleSearch(): JavaScript.send("desktop.toggleSearch();")
def show(): JavaScript.send("desktop.closeSettings();desktop.closeApplications();") Desktop.showScreen()
def update(self, *args): from JAK.Utils import JavaScript JavaScript.send(f"Jade.menu = { json.dumps( self.menu() ) }")