Example #1
0
    def __init__(self, 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()
        cookiejar = libsoup.CookieJar()
        cookiejar.set_accept_policy(
            libsoup.CookieJarAcceptPolicy.NO_THIRD_PARTY)
        session = libwebkit.get_default_session()
        print("SESSION: ", session)
        session.add_feature(cookiejar)
        session.set_property('ssl-use-system-ca-file', True)
        session.set_property('ssl-strict', True)
        print("SESSION PROP", session.get_property('tls-database'))
        # session.connect('connection-created', self._soup_connection)
        # proxy_uri = libsoup.URI.new(os.getenv('http_proxy'))
        # session.set_property('proxy-uri', proxy_uri)

        self._libsoup = libsoup
        self._gtk = gtk
        self._gdk = gdk
        self._glib = glib
        self._libwebkit = libwebkit

        self._dict = com_dict
        self._coms = []

        self._pid = multiprocessing.current_process().pid

        self._windows = []

        for socket_id, com_pipe in self._dict.items():
            print("CREATING: ", socket_id, com_pipe)
            try:
                com_pipe.send(('pid', self._pid))
            except BrokenPipeError as err:
                print("BROKEN PIPE: ", err, ' on PIPE ', com_pipe)
                continue
            self._windows.append(self._create_window(socket_id, com_pipe))
Example #2
0
    def __init__(self, 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()
        cookiejar = libsoup.CookieJar()
        cookiejar.set_accept_policy(libsoup.CookieJarAcceptPolicy.NO_THIRD_PARTY)
        session = libwebkit.get_default_session()
        print("SESSION: ", session)
        session.add_feature(cookiejar)
        session.set_property('ssl-use-system-ca-file', True)
        session.set_property('ssl-strict', True)
        print("SESSION PROP", session.get_property('tls-database'))
        # session.connect('connection-created', self._soup_connection)
        # proxy_uri = libsoup.URI.new(os.getenv('http_proxy'))
        # session.set_property('proxy-uri', proxy_uri)

        self._libsoup = libsoup
        self._gtk = gtk
        self._gdk = gdk
        self._glib = glib
        self._libwebkit = libwebkit

        self._dict = com_dict
        self._coms = []

        self._pid = multiprocessing.current_process().pid

        self._windows = []

        for socket_id, com_pipe in self._dict.items():
            print("CREATING: ", socket_id, com_pipe)
            try:
                com_pipe.send(('pid', self._pid))
            except BrokenPipeError as err:
                print("BROKEN PIPE: ", err, ' on PIPE ', com_pipe)
                continue
            self._windows.append(self._create_window(socket_id, com_pipe))
Example #3
0
    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
        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._revived = []

        self._icon_db = libwebkit.get_favicon_database()

        self._accels = self._gtk.AccelGroup()

        accel_dict = {
            ('<Ctrl>t', '<Ctrl><Shift>t'): self._new_tab,
            ('<Ctrl>w', ): self._close_tab,
            ('<Ctrl><Alt>r', ): lambda *a: com_pipe.send(('refresh', True)),
            ('<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('delete-event', self._quit)
        self._window.connect('destroy', self._quit)
        self._tabs = self._gtk.Notebook()
        self._tabs.connect('page-reordered', self._tab_reordered)
        self._tabs.connect('page-removed', self._tab_removed)
        self._tabs.connect('switch-page', self._tab_switched)
        self._tabs.set_scrollable(True)
        self._tabs.set_show_tabs(True)

        self._statusbar = self._gtk.Statusbar()
        self._status_context = self._statusbar.get_context_id('hover-link')

        vbox = self._gtk.VBox()
        vbox.pack_start(self._tabs, True, True, 0)
        vbox.pack_end(self._statusbar, False, False, 0)

        self._window.add(vbox)
        self._window.show_all()

        self._pipe = com_pipe
        self._dict = com_dict

        self._windows = {}
        self._closed = {}

        self._glib.io_add_watch(self._pipe.fileno(), self._glib.IO_IN,
                                self._recieve)

        self._pipe.send(('new-proc', self._make_tab()))
Example #4
0
    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
        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._revived = []

        self._icon_db = libwebkit.get_favicon_database()

        self._accels = self._gtk.AccelGroup()

        accel_dict = {
                ('<Ctrl>t', '<Ctrl><Shift>t'): self._new_tab,
                ('<Ctrl>w',): self._close_tab,
                ('<Ctrl><Alt>r',): lambda *a: com_pipe.send(('refresh', True)),
                ('<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('delete-event', self._quit)
        self._window.connect('destroy', self._quit)
        self._tabs = self._gtk.Notebook()
        self._tabs.connect('page-reordered', self._tab_reordered)
        self._tabs.connect('page-removed', self._tab_removed)
        self._tabs.connect('switch-page', self._tab_switched)
        self._tabs.set_scrollable(True)
        self._tabs.set_show_tabs(True)

        self._statusbar = self._gtk.Statusbar()
        self._status_context = self._statusbar.get_context_id('hover-link')

        vbox = self._gtk.VBox()
        vbox.pack_start(self._tabs, True, True, 0)
        vbox.pack_end(self._statusbar, False, False, 0)

        self._window.add(vbox)
        self._window.show_all()

        self._pipe = com_pipe
        self._dict = com_dict

        self._windows = {}
        self._closed = {}

        self._glib.io_add_watch(self._pipe.fileno(), self._glib.IO_IN,
                                self._recieve)

        self._pipe.send(('new-proc', self._make_tab()))