Changeset 1083:a5f219c25f2a for src
- Timestamp:
- 03/15/23 19:01:30 (21 months ago)
- Branch:
- python3
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/acars.py
r996 r1083 27 27 super(ACARS, self).__init__() 28 28 self._gui = gui 29 self._browser = None 29 30 30 31 def start(self): … … 34 35 self.pack_start(container, True, True, 0) 35 36 36 cef.startInContainer(container, ACARS.URL) 37 self._browser = cef.startInContainer(container, ACARS.URL) 38 39 def stop(self): 40 """Close the browser.""" 41 if self._browser is not None: 42 self._browser.CloseBrowser(False) 43 self._browser = None -
src/mlx/gui/cef.py
r997 r1083 92 92 self._browser.SetFocus(True) 93 93 self._browser.SetClientCallback("OnLoadEnd", self._onLoadEnd) 94 95 bindings = cefpython.JavascriptBindings(bindToFrames=True, 96 bindToPopups=True) 97 bindings.SetFunction("briefingData", self._briefingDataAvailable) 98 bindings.SetFunction("formFilled", self._formFilled) 99 self._browser.SetJavascriptBindings(bindings) 94 self._browser.SetClientCallback("OnLoadError", self._onLoadError) 95 self._browser.SetClientCallback("OnBeforeBrowse", 96 lambda browser, frame, request, 97 user_gesture, is_redirect: False) 100 98 101 99 def call(self, plan, getCredentials, updateProgress, htmlFilePath): … … 112 110 self._updateProgress(SIMBRIEF_PROGRESS_LOADING_FORM, 113 111 SIMBRIEF_RESULT_NONE, None) 112 113 def finalize(self): 114 """Close the browser and release it.""" 115 self._browser.CloseBrowser() 116 self._browser = None 114 117 115 118 def _onLoadEnd(self, browser, frame, http_code): … … 182 185 SIMBRIEF_RESULT_ERROR_OTHER, None) 183 186 184 def _resultsAvailable(self, flightInfo): 185 """Called from the result retrieval thread when the result is 186 available. 187 188 It checks for the plan being not None, as we may time out.""" 189 if self._plan is not None: 190 self._updateProgress(SIMBRIEF_PROGRESS_DONE, 191 SIMBRIEF_RESULT_OK, flightInfo) 187 def _onLoadError(self, browser, frame, error_code, error_text_out, 188 failed_url): 189 """Called when loading of an URL fails.""" 190 print("gui.cef.SimBriefHandler._onLoadError", browser, frame, error_code, error_text_out, failed_url) 191 self._updateProgress(self._lastProgress, 192 SIMBRIEF_RESULT_ERROR_OTHER, None) 192 193 193 194 def _updateProgress(self, progress, results, flightInfo): … … 281 282 "browser_subprocess_path": "%s/%s" % \ 282 283 (cefpython.GetModuleDirectory(), "subprocess"), 284 "windowless_rendering_enabled": True, 285 "cache_path": os.path.join(GLib.get_user_cache_dir(), 286 "mlxcef") 283 287 } 284 288 … … 307 311 """Get a container object suitable for running a browser instance 308 312 within.""" 309 if os.name=="nt": 310 container = Gtk.DrawingArea() 311 container.set_property("can-focus", True) 312 container.connect("size-allocate", _handleSizeAllocate) 313 else: 314 container = Gtk.DrawingArea() 315 313 container = Gtk.DrawingArea() 314 container.set_property("can-focus", True) 315 container.connect("size-allocate", _handleSizeAllocate) 316 316 container.show() 317 317 … … 333 333 container.windowID = windowID 334 334 Gdk.threads_leave() 335 windowRect = [0, 0, 1, 1] 335 336 else: 336 337 container.set_visual(container.get_screen().lookup_visual(0x21)) 337 338 windowID = container.get_window().get_xid() 339 windowRect = None 338 340 339 341 windowInfo = cefpython.WindowInfo() 340 342 if windowID is not None: 341 windowInfo.SetAsChild(windowID) 342 343 return cefpython.CreateBrowserSync(windowInfo, 344 browserSettings = browserSettings, 345 navigateUrl = url) 343 windowInfo.SetAsChild(windowID, windowRect = windowRect) 344 345 browser = cefpython.CreateBrowserSync(windowInfo, 346 browserSettings = browserSettings, 347 navigateUrl = url) 348 container.browser = browser 349 350 return browser 346 351 347 352 #------------------------------------------------------------------------------ … … 350 355 def GetRootScreenRect(self, browser, rect_out): 351 356 #print "GetRootScreenRect" 352 rect_out += [0, 0, 800, 600]357 rect_out += [0, 0, 1920, 1080] 353 358 return True 354 359 355 360 def GetViewRect(self, browser, rect_out): 356 361 #print "GetViewRect" 357 rect_out += [0, 0, 800, 600]362 rect_out += [0, 40, 1920, 1040] 358 363 return True 359 364 … … 387 392 pass 388 393 389 def OnBeforePopup(self, browser, frame, targetURL, targetFrameName, 390 popupFeatures, windowInfo, client, browserSettings, 391 noJavascriptAccess): 394 def OnBeforePopup(self, browser, frame, target_url, target_frame_name, 395 target_disposition, user_gesture, 396 popup_features, window_info_out, client, 397 browser_settings_out, no_javascript_access_out, 398 **kwargs): 392 399 wInfo = cefpython.WindowInfo() 393 400 wInfo.SetAsOffscreen(int(0)) 394 401 395 window Info.append(wInfo)402 window_info_out.append(wInfo) 396 403 397 404 return False … … 417 424 global _toQuit 418 425 _toQuit = True 426 427 _simBriefHandler.finalize() 428 419 429 cefpython.Shutdown() 420 430 … … 433 443 def _handleSizeAllocate(widget, sizeAlloc): 434 444 """Handle the size-allocate event on Windows.""" 435 if widget is not None: 436 cefpython.WindowUtils.OnSize(widget.windowID, 0, 0, 0) 445 if os.name=="nt": 446 if widget is not None and hasattr(widget, "windowID"): 447 cefpython.WindowUtils.OnSize(widget.windowID, 0, 0, 0) 448 else: 449 if widget is not None and hasattr(widget, "browser") and \ 450 widget.browser is not None: 451 widget.browser.SetBounds(sizeAlloc.x, sizeAlloc.y, 452 sizeAlloc.width, sizeAlloc.height) -
src/mlx/gui/common.py
r1002 r1083 35 35 from gi.repository import Pango 36 36 from gi.repository import PangoCairo 37 from gi.repository import GLib 37 38 38 39 import codecs -
src/mlx/gui/gui.py
r1081 r1083 484 484 singleton.raiseCallback = None 485 485 486 self._acars.stop() 487 486 488 cef.finalize() 487 489
Note:
See TracChangeset
for help on using the changeset viewer.