def __init__(self, com_pipe: object, com_dict: object): """ Initialize the process. """ from gi.repository import Soup as libsoup from gi.repository import WebKit as libwebkit from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GLib as glib self._icon_db = libwebkit.get_favicon_database() # proxy_uri = libsoup.URI.new(os.getenv('http_proxy')) # session = libwebkit.get_default_session() # session.set_property('proxy-uri', proxy_uri) self._gtk = gtk self._gdk = gdk self._glib = glib self._libwebkit = libwebkit self._pid = multiprocessing.current_process().pid # self._plugs = dict((self._create_window(com_dict, com_pipe),)) # self._plugs = {} self._windows = [self._create_window(com_dict, com_pipe)]
def __init__(self, com_pipe: object, com_dict: object): """ Initialize the process. """ self._protocol_pat = re.compile( r'^(about:|http://|https://|ftp://|javascript:|mailto:|file://)', re.I) from gi.repository import Soup as libsoup from gi.repository import WebKit as libwebkit from gi.repository import Gtk as gtk from gi.repository import Gdk as gdk from gi.repository import GLib as glib from gi.repository import Pango as pango from gi.repository import Gio as gio from gi.repository import GdkPixbuf as gdkpixbuf self._gtk = gtk self._gdk = gdk self._glib = glib self._pango = pango self._webkit = libwebkit self._gio = gio self._gdkpixbuf = gdkpixbuf self._icon_db = libwebkit.get_favicon_database() self._accels = self._gtk.AccelGroup() accel_dict = { ('<Ctrl>t',): self._new_tab, ('<Ctrl>w',): self._close_tab, ('<Ctrl>l',): self._focus_address_entry, } for accel_tup, func in accel_dict.items(): for accel in accel_tup: keyval, modifier = self._gtk.accelerator_parse(accel) self._accels.connect(keyval, modifier, self._gtk.AccelFlags.VISIBLE, func) for i in range(9): self._accels.connect(self._gdk.keyval_from_name(str(i)), self._gdk.ModifierType.MOD1_MASK, self._gtk.AccelFlags.VISIBLE, self._switch_tab) self._window = self._gtk.Window() self._window.add_accel_group(self._accels) self._window.set_default_size(1024, 768) self._window.set_resizable(True) self._window.set_icon_name('web-browser') self._window.connect_after('delete-event', self._quit) self._tabs = self._gtk.Notebook() self._tabs.connect('page-reordered', self._tab_reordered) self._tabs.set_scrollable(True) self._tabs.set_show_tabs(True) self._window.add(self._tabs) self._window.show_all() self._pipe = com_pipe self._dict = com_dict self._windows = {} self._glib.io_add_watch(self._pipe.fileno(), self._glib.IO_IN, self._recieve)