def __on_search_words_activate(self, action, selection): """ Open link in a new page @param action as Gtk.Action @param selection as str """ search = Search() uri = search.get_search_uri(selection) self._window.container.add_webview(uri, Gdk.WindowType.CHILD)
def __on_search_words_activate(self, action, variant, selection): """ Open link in a new page @param action as Gio.SimpleAction @param variant as GLib.Variant @param selection as str """ search = Search() uri = search.get_search_uri(selection) self._window.container.add_webview(uri, LoadingType.FOREGROUND)
def run(self): """ Run dialog """ self.__populate() self.__dialog.run() # Save engines engines = {} for child in self.__listbox.get_children(): if child.is_valid: name = child.item.get_property("name") uri = child.item.get_property("uri") search = child.item.get_property("search") keyword = child.item.get_property("keyword") encoding = child.item.get_property("encoding") bang = child.item.get_property("bang") if name and search: engines[name] = [uri, search, keyword, encoding, bang] content = json.dumps(engines) f = Gio.File.new_for_path(EOLIE_LOCAL_PATH + "/search_engines.json") f.replace_contents(content.encode("utf-8"), None, False, Gio.FileCreateFlags.REPLACE_DESTINATION, None) self.__dialog.destroy() # Update application search engines El().search = Search()
def init(self): """ Init main application """ self.__is_fs = False if Gtk.get_minor_version() > 18: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Eolie/application.css') else: cssProviderFile = Gio.File.new_for_uri( 'resource:///org/gnome/Eolie/application-legacy.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.bookmarks.import_firefox() adblock = DatabaseAdblock() adblock.update() self.art = Art() self.search = Search() self.downloads_manager = DownloadsManager() 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("app.shortcut::uri", ["<Control>l"]) self.set_accels_for_action("app.shortcut::new_page", ["<Control>t"]) self.set_accels_for_action("app.shortcut::close_page", ["<Control>w"]) # Set some WebKit defaults context = WebKit2.WebContext.get_default() 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( WebKit2.CookieAcceptPolicy.NO_THIRD_PARTY) cookie_manager.set_persistent_storage( self.__COOKIES_PATH, WebKit2.CookiePersistentStorage.SQLITE)
def __populate(self): """ Populate the view with engines """ search = Search() engines = search.engines try: # First load static engines for key in engines.keys(): item = Item() item.set_property("name", key) item.set_property("uri", engines[key][0]) item.set_property("search", engines[key][1]) item.set_property("keyword", engines[key][2]) item.set_property("encoding", engines[key][3]) item.set_property("bang", engines[key][4]) child = Row(item) child.show() self.__listbox.add(child) except Exception as e: print("DialogSearchEngine::__populate():", e)
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 """ self.__is_fs = False self.__setup_app_menu() self.set_app_menu(self.__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) 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 self.adblock = DatabaseAdblock() self.adblock.update() self.art = Art() self.search = Search() self.download_manager = DownloadManager() 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::uri", ["<Control>l"]) self.set_accels_for_action("win.shortcut::new_page", ["<Control>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::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::settings", ["<Control>e"]) self.set_accels_for_action("win.shortcut::backward", ["<Alt>Left"]) self.set_accels_for_action("win.shortcut::forward", ["<Alt>Right"]) self.set_accels_for_action("win.shortcut::next", ["<Control>Tab"]) self.set_accels_for_action("win.shortcut::previous", ["<Control><Shift>Tab"]) # Set some WebKit defaults context = WebKit2.WebContext.get_default() 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(self.__on_extension_signal, None)
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)
def __init(self): """ Init main application """ self.settings = Settings.new() # Init extensions GLib.setenv("PYTHONPATH", self.__extension_dir, True) # Create favicon path if not GLib.file_test(self.__FAVICONS_PATH, GLib.FileTest.IS_DIR): GLib.mkdir_with_parents(self.__FAVICONS_PATH, 0o0750) # Add a global DBus helper self.helper = DBusHelper() # First init sync worker from eolie.mozilla_sync import SyncWorker if SyncWorker.check_modules(): 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) else: 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") # Do not remove this! self.update_default_style_sheet() self.popup_exceptions = DatabaseExceptions("popups") self.image_exceptions = DatabaseExceptions("images") 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() # Check MOZ_PLUGIN_PATH if self.settings.get_value('enable-plugins') and\ not GLib.getenv("MOZ_PLUGIN_PATH"): print("You need to set MOZ_PLUGIN_PATH to use plugins") # https://wiki.ubuntu.com/Unity/LauncherAPI self.__unity = None if is_unity(): try: gi.require_version('Unity', '7.0') from gi.repository import Unity self.__unity = Unity.LauncherEntry.get_for_desktop_id( "org.gnome.Eolie.desktop") except: pass # Init profiles self.set_profiles() 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><Shift>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::home", ["<Control>Home"]) 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>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::next_site", ["<Control>twosuperior"]) self.set_accels_for_action("win.shortcut::previous_site", ["<Control><Shift>twosuperior"]) 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"])