:right-sidebar: True UserContentFilterStore =================================================================== .. currentmodule:: gi.repository.WebKit .. versionadded:: 2.24 .. class:: UserContentFilterStore(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Handles storage of user content filters on disk. The WebKitUserContentFilterStore provides the means to import and save `JSON rule sets `__\, which can be loaded later in an efficient manner. Once filters are stored, the :obj:`~gi.repository.WebKit.UserContentFilter` objects which represent them can be added to a :obj:`~gi.repository.WebKit.UserContentManager` with :func:`~gi.repository.WebKit.UserContentManager.add_filter`. JSON rule sets are imported using :func:`~gi.repository.WebKit.UserContentFilterStore.save` and stored on disk in an implementation defined format. The contents of a filter store must be managed using the :obj:`~gi.repository.WebKit.UserContentFilterStore`\: a list of all the stored filters can be obtained with :func:`~gi.repository.WebKit.UserContentFilterStore.fetch_identifiers`, :func:`~gi.repository.WebKit.UserContentFilterStore.load` can be used to retrieve a previously saved filter, and removed from the store with :func:`~gi.repository.WebKit.UserContentFilterStore.remove`. Constructors ------------ .. rst-class:: interim-class .. class:: UserContentFilterStore :no-index: .. classmethod:: new(storage_path: str) -> ~gi.repository.WebKit.UserContentFilterStore Create a new :obj:`~gi.repository.WebKit.UserContentFilterStore` to manipulate filters stored at ``storage_path``\. The path must point to a local filesystem, and will be created if needed. .. versionadded:: 2.24 :param storage_path: path where data for filters will be stored on disk Methods ------- .. rst-class:: interim-class .. class:: UserContentFilterStore :no-index: .. method:: fetch_identifiers(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously retrieve a list of the identifiers for all the stored filters. When the operation is finished, ``callback`` will be invoked, which then can use :func:`~gi.repository.WebKit.UserContentFilterStore.fetch_identifiers_finish` to obtain the list of filter identifiers. .. versionadded:: 2.24 :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the removal is completed :param user_data: the data to pass to the callback function .. method:: fetch_identifiers_finish(result: ~gi.repository.Gio.AsyncResult) -> list[str] Finishes an asynchronous fetch of the list of stored filters. Finishes an asynchronous fetch of the list of identifiers for the stored filters previously started with :func:`~gi.repository.WebKit.UserContentFilterStore.fetch_identifiers`. .. versionadded:: 2.24 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_path() -> str Gets the storage path for user content filters. .. versionadded:: 2.24 .. method:: load(identifier: str, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously load a content filter given its ``identifier``\. The filter must have been previously stored using :func:`~gi.repository.WebKit.UserContentFilterStore.save`. When the operation is finished, ``callback`` will be invoked, which then can use :func:`~gi.repository.WebKit.UserContentFilterStore.load_finish` to obtain the resulting filter. .. versionadded:: 2.24 :param identifier: a filter identifier :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the load is completed :param user_data: the data to pass to the callback function .. method:: load_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.WebKit.UserContentFilter Finishes an asynchronous filter load previously started with :func:`~gi.repository.WebKit.UserContentFilterStore.load`. .. versionadded:: 2.24 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: remove(identifier: str, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously remove a content filter given its ``identifier``\. When the operation is finished, ``callback`` will be invoked, which then can use :func:`~gi.repository.WebKit.UserContentFilterStore.remove_finish` to check whether the removal was successful. .. versionadded:: 2.24 :param identifier: a filter identifier :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the removal is completed :param user_data: the data to pass to the callback function .. method:: remove_finish(result: ~gi.repository.Gio.AsyncResult) -> bool Finishes an asynchronous filter removal previously started with :func:`~gi.repository.WebKit.UserContentFilterStore.remove`. .. versionadded:: 2.24 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: save(identifier: str, source: ~gi.repository.GLib.Bytes, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously save a content filter from a set source rule. Asynchronously save a content filter from a source rule set in the `WebKit content extesions JSON format `__\. The ``identifier`` can be used afterwards to refer to the filter when using :func:`~gi.repository.WebKit.UserContentFilterStore.remove` and :func:`~gi.repository.WebKit.UserContentFilterStore.load`. When the ``identifier`` has been used in the past, the new filter source will replace the one saved beforehand for the same identifier. When the operation is finished, ``callback`` will be invoked, which then can use :func:`~gi.repository.WebKit.UserContentFilterStore.save_finish` to obtain the resulting filter. .. versionadded:: 2.24 :param identifier: a string used to identify the saved filter :param source: :obj:`~gi.repository.GLib.Bytes` containing the rule set in JSON format :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when saving is completed :param user_data: the data to pass to the callback function .. method:: save_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.WebKit.UserContentFilter Finishes an asynchronous filter save previously started with :func:`~gi.repository.WebKit.UserContentFilterStore.save`. .. versionadded:: 2.24 :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: save_from_file(identifier: str, file: ~gi.repository.Gio.File, cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously save a content filter from the contents of a file. Asynchronously save a content filter from the contents of a file, which must be native to the platform, as checked by :func:`~gi.repository.Gio.File.is_native`. See :func:`~gi.repository.WebKit.UserContentFilterStore.save` for more details. When the operation is finished, ``callback`` will be invoked, which then can use :func:`~gi.repository.WebKit.UserContentFilterStore.save_finish` to obtain the resulting filter. .. versionadded:: 2.24 :param identifier: a string used to identify the saved filter :param file: a :obj:`~gi.repository.Gio.File` containing the rule set in JSON format :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when saving is completed :param user_data: the data to pass to the callback function .. method:: save_from_file_finish(result: ~gi.repository.Gio.AsyncResult) -> ~gi.repository.WebKit.UserContentFilter Finishes and asynchronous filter save previously started with :func:`~gi.repository.WebKit.UserContentFilterStore.save_from_file`. .. versionadded:: 2.24 :param result: a :obj:`~gi.repository.Gio.AsyncResult` Properties ---------- .. rst-class:: interim-class .. class:: UserContentFilterStore :no-index: .. attribute:: props.path :type: str The type of the None singleton. .. versionadded:: 2.24