#!/usr/bin/env python3 import gi, os, json, shutil, hashlib, time, threading gi.require_version('Gtk', '3.0') gi.require_version("WebKit2", "4.1") from gi.repository import GObject, Gtk, Gdk, WebKit2, GLib, Gio, GdkPixbuf def create_same_window(origin, req): w, h = origin.window.get_size() win = Gtk.Window() win.set_default_size(w, h) web = WebKit2.WebView.new_with_related_view(origin) web.load_request(req) win.add(web) win.show_all() return web def create_custom_window(origin, options): WebEngine = type(origin) _w, _h = origin.window.get_size() w = options.get('width') or _w h = options.get('height') or _h win = Gtk.Window() win.set_default_size(w, h) wmclass = options.get('wmclass') or 'WebEngine Window' win.set_wmclass(wmclass, 'WebEngine') win.set_title(options.get('title') or 'WebEngine') if options.get('frame') == False: win.set_decorated(False) if options.get('x') is not None and options.get('y') is not None: win.move(options.get('x'), options.get('y')) if options.get('always_on_top') == True: win.set_keep_above(options['always_on_top']) if options.get('resizable') == False: win.set_resizable(False) web = WebEngine(win) # web = WebEngine(win, origin) # web = WebKit2.WebView.new_with_related_view(origin) # web = WebEngine.new_with(win, origin) # web.window = win web.set_root(origin.root, True) web.set_zoom_level(origin.get_zoom_level()) web.set_settings(origin.get_settings()) web.load(options.get('url')) win.add(web) win.show_all() return web