def new_ephemeral(): """ New ephemeral webview """ from eolie.context import Context context = WebKit2.WebContext.new_ephemeral() Context(context) view = WebKit2.WebView.new_with_context(context) view.__class__ = WebViewMeta view.__init() return view
def new_ephemeral(window): """ New ephemeral webview @param window as Window """ from eolie.context import Context context = WebKit2.WebContext.new_ephemeral() Context(context) view = WebKit2.WebView.new_with_context(context) view.__class__ = WebViewMeta view.__init(None, window) return view
def new_ephemeral(window, view): """ New ephemeral webview @param window as Window @param view as View """ context = WebKit2.WebContext.new_ephemeral() Context(context) webview = WebKit2.WebView.new_with_context(context) webview.__class__ = WebViewMeta content_manager = webview.get_property("user-content-manager") webview.__init(None, context, content_manager, window, view) return webview
def new(window): """ New webview @param window as Window """ data_manager = WebKit2.WebsiteDataManager() context = WebKit2.WebContext.new_with_website_data_manager( data_manager) Context(context) view = WebKit2.WebView.new_with_context(context) view.__class__ = WebViewMeta view.__init(None, window) return view
def __init(self): """ Init main application """ self.settings = Settings.new() # Init extensions GLib.setenv('PYTHONPATH', self.__extension_dir, True) # Create favicon path d = Gio.File.new_for_path(self.__FAVICONS_PATH) if not d.query_exists(): d.make_directory_with_parents() # Setup default context context = WebKit2.WebContext.get_default() Context(context) # Setup ephemeral context self.__ephemeral_context = WebKit2.WebContext.new_ephemeral() Context(self.__ephemeral_context) # Add a global DBus helper self.helper = DBusHelper() # First init sync worker try: from eolie.mozilla_sync import SyncWorker self.sync_worker = SyncWorker() # Run a first sync in 10 seconds, speed up app start GLib.timeout_add_seconds(10, self.sync_worker.sync, False) # Then run a sync every hour GLib.timeout_add_seconds(3600, self.sync_worker.sync, True) except Exception as e: print("Application::init():", e) self.sync_worker = None if self.prefers_app_menu(): menu = self.get_app_menu() self.set_app_menu(menu) cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Eolie/application.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.history = DatabaseHistory() self.bookmarks = DatabaseBookmarks() # We store cursors for main thread SqlCursor.add(self.history) SqlCursor.add(self.bookmarks) self.websettings = DatabaseSettings() self.adblock = DatabaseAdblock() self.adblock.update() self.phishing = DatabasePhishing() self.adblock_exceptions = DatabaseExceptions("adblock") self.popup_exceptions = DatabaseExceptions("popup") self.image_exceptions = DatabaseExceptions("image") if self.settings.get_user_value("jsblock") is not None: self.js_exceptions = DatabaseExceptions("js") else: self.js_exceptions = None self.phishing.update() self.art = Art() self.search = Search() self.download_manager = DownloadManager() self.pages_menu = PagesMenu() shortcut_action = Gio.SimpleAction.new('shortcut', GLib.VariantType.new('s')) shortcut_action.connect('activate', self.__on_shortcut_action) self.add_action(shortcut_action) self.set_accels_for_action("win.shortcut::expose", ["<Alt>e"]) self.set_accels_for_action("win.exceptions::site", ["<Control>e"]) self.set_accels_for_action("win.shortcut::show_left_panel", ["F9"]) self.set_accels_for_action("win.shortcut::uri", ["<Control>l", "<Control>b"]) self.set_accels_for_action("win.shortcut::new_page", ["<Control>t"]) self.set_accels_for_action("win.shortcut::last_page", ["<Control><Shift>t"]) self.set_accels_for_action("app.shortcut::new_window", ["<Control>n"]) self.set_accels_for_action("win.shortcut::private", ["<Control><Shift>p"]) self.set_accels_for_action("win.shortcut::close_page", ["<Control>w"]) self.set_accels_for_action("win.shortcut::quit", ["<Control>q"]) self.set_accels_for_action("win.shortcut::save", ["<Control>s"]) self.set_accels_for_action("win.shortcut::filter", ["<Control>i"]) self.set_accels_for_action("win.shortcut::reload", ["<Control>r", "F5"]) self.set_accels_for_action("win.shortcut::find", ["<Control>f"]) self.set_accels_for_action("win.shortcut::print", ["<Control>p"]) self.set_accels_for_action("win.shortcut::source", ["<Control><Shift>c"]) self.set_accels_for_action("win.shortcut::history", ["<Control>h"]) self.set_accels_for_action("win.shortcut::search", ["<Control>k"]) self.set_accels_for_action("win.shortcut::fullscreen", ["F11"]) self.set_accels_for_action("app.settings", ["<Control><Shift>s"]) self.set_accels_for_action("win.shortcut::backward", ["<Alt>Left", "XF86Back"]) self.set_accels_for_action("win.shortcut::forward", ["<Alt>Right", "XF86Forward"]) self.set_accels_for_action("win.shortcut::next", ["<Control>Tab", "<Control>Page_Down"]) self.set_accels_for_action("win.shortcut::previous", ["<Control><Shift>Tab", "<Control>Page_Up"]) self.set_accels_for_action("win.shortcut::zoom_in", ["<Control>KP_Add", "<Control>plus", "<Control>equal"]) self.set_accels_for_action("win.shortcut::zoom_out", ["<Control>KP_Subtract", "<Control>minus"]) self.set_accels_for_action("win.shortcut::zoom_default", ["<Control>KP_0", "<Control>0"])
def __init(self): """ Init main application """ # First init sync worker try: from eolie.mozilla_sync import SyncWorker self.sync_worker = SyncWorker() self.sync_worker.sync() GLib.timeout_add_seconds(3600, self.sync_worker.sync) except Exception as e: print("Application::init():", e) self.sync_worker = None if self.prefers_app_menu(): menu = self.get_app_menu() self.set_app_menu(menu) cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Eolie/application.css') cssProvider = Gtk.CssProvider() cssProvider.load_from_file(cssProviderFile) screen = Gdk.Screen.get_default() styleContext = Gtk.StyleContext() styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER) self.settings = Settings.new() self.history = DatabaseHistory() self.bookmarks = DatabaseBookmarks() # We store cursors for main thread SqlCursor.add(self.history) SqlCursor.add(self.bookmarks) self.adblock = DatabaseAdblock() self.adblock.update() self.phishing = DatabasePhishing() self.adblock_exceptions = DatabaseExceptions("adblock") self.popup_exceptions = DatabaseExceptions("popup") self.image_exceptions = DatabaseExceptions("image") self.phishing.update() self.art = Art() self.search = Search() self.download_manager = DownloadManager() self.pages_menu = PagesMenu(self) # Db upgrade db_version = self.settings.get_value("db-version").get_int32() upgrade = DatabaseUpgrade(db_version) db_version = upgrade.do_db_upgrade() self.settings.set_value("db-version", GLib.Variant("i", db_version)) shortcut_action = Gio.SimpleAction.new('shortcut', GLib.VariantType.new('s')) shortcut_action.connect('activate', self.__on_shortcut_action) self.add_action(shortcut_action) self.set_accels_for_action("win.exceptions::site", ["<Control>e"]) self.set_accels_for_action("win.shortcut::uri", ["<Control>l"]) self.set_accels_for_action("win.shortcut::new_page", ["<Control>t"]) self.set_accels_for_action("win.shortcut::last_page", ["<Control><Shift>t"]) self.set_accels_for_action("app.shortcut::new_window", ["<Control>n"]) self.set_accels_for_action("win.shortcut::private", ["<Control><Shift>p"]) self.set_accels_for_action("win.shortcut::close_page", ["<Control>w"]) self.set_accels_for_action("win.shortcut::quit", ["<Control>q"]) self.set_accels_for_action("win.shortcut::save", ["<Control>s"]) self.set_accels_for_action("win.shortcut::filter", ["<Control>i"]) self.set_accels_for_action("win.shortcut::reload", ["<Control>r"]) self.set_accels_for_action("win.shortcut::find", ["<Control>f"]) self.set_accels_for_action("win.shortcut::print", ["<Control>p"]) self.set_accels_for_action("win.shortcut::source", ["<Control><Shift>c"]) self.set_accels_for_action("win.shortcut::fullscreen", ["F11"]) self.set_accels_for_action("app.settings", ["<Control><Shift>s"]) self.set_accels_for_action("win.shortcut::backward", ["<Alt>Left", "XF86Back"]) self.set_accels_for_action("win.shortcut::forward", ["<Alt>Right", "XF86Forward"]) self.set_accels_for_action("win.shortcut::next", ["<Control>Tab"]) self.set_accels_for_action("win.shortcut::previous", ["<Control><Shift>Tab"]) self.set_accels_for_action("win.shortcut::zoom_in", ["<Control>KP_Add", "<Control>plus"]) self.set_accels_for_action("win.shortcut::zoom_out", ["<Control>KP_Subtract", "<Control>minus"]) self.set_accels_for_action("win.panel_mode(0)", ["<Control><Alt>0", "<Control><Alt>KP_0"]) self.set_accels_for_action("win.panel_mode(1)", ["<Control><Alt>1", "<Control><Alt>KP_1"]) self.set_accels_for_action("win.panel_mode(2)", ["<Control><Alt>2", "<Control><Alt>KP_2"]) # Set some WebKit defaults context = WebKit2.WebContext.get_default() Context(context) GLib.setenv('PYTHONPATH', self.__extension_dir, True) context.set_web_extensions_directory(self.__extension_dir) data_manager = WebKit2.WebsiteDataManager() context.new_with_website_data_manager(data_manager) context.set_process_model( WebKit2.ProcessModel.MULTIPLE_SECONDARY_PROCESSES) context.set_cache_model(WebKit2.CacheModel.WEB_BROWSER) d = Gio.File.new_for_path(self.__FAVICONS_PATH) if not d.query_exists(): d.make_directory_with_parents() context.set_favicon_database_directory(self.__FAVICONS_PATH) cookie_manager = context.get_cookie_manager() cookie_manager.set_accept_policy( self.settings.get_enum("cookie-storage")) cookie_manager.set_persistent_storage( self.__COOKIES_PATH, WebKit2.CookiePersistentStorage.SQLITE) helper = DBusHelper() helper.connect("UnsecureFormFocused", self.__on_extension_signal)