Use izzylib.enum and default webview settings change
This commit is contained in:
parent
139151fddc
commit
27ab565bb9
|
@ -3,6 +3,8 @@ from .. import (
|
|||
__version__ as version
|
||||
)
|
||||
|
||||
from ..enums import WebviewAccelPolicy
|
||||
|
||||
|
||||
default_settings = {
|
||||
'allow-file-access-from-file-urls': {
|
||||
|
@ -11,7 +13,7 @@ default_settings = {
|
|||
'description': 'Allow requests in local html files access other local files'
|
||||
},
|
||||
'allow-modal-dialogs': {
|
||||
'default': False,
|
||||
'default': True,
|
||||
'name': 'Javascript modal dialogs',
|
||||
'description': 'Allow the window.showModalDialog javascript function to be executed'
|
||||
},
|
||||
|
@ -226,7 +228,7 @@ default_settings = {
|
|||
'description': 'Allow GPU rendering of pages'
|
||||
},
|
||||
'javascript-can-access-clipboard': {
|
||||
'default': False,
|
||||
'default': True,
|
||||
'name': 'Javascript clipboard access',
|
||||
'description': 'Allow Javascript to access the clipboard'
|
||||
},
|
||||
|
@ -251,7 +253,7 @@ default_settings = {
|
|||
'description': 'Allow media to play without being fullscreened'
|
||||
},
|
||||
'media-playback-requires-user-gesture': {
|
||||
'default': False,
|
||||
'default': True,
|
||||
'name': 'Prevent media autoplay',
|
||||
'description': 'Prevent media from playing without user interaction'
|
||||
},
|
||||
|
@ -298,13 +300,6 @@ default_settings = {
|
|||
}
|
||||
|
||||
|
||||
accel_policy = dict(
|
||||
demand = 0,
|
||||
always = 1,
|
||||
never = 2
|
||||
)
|
||||
|
||||
|
||||
class WebSettings(WebKit2.Settings):
|
||||
def __init__(self, tab):
|
||||
super().__init__()
|
||||
|
@ -333,7 +328,7 @@ class WebSettings(WebKit2.Settings):
|
|||
return
|
||||
|
||||
if key == 'hardware-acceleration-policy':
|
||||
value = accel_policy.get(value.lower(), value)
|
||||
value = WebviewAccelPolicy.parse(value)
|
||||
|
||||
self.set_property(key, value)
|
||||
|
||||
|
@ -348,6 +343,8 @@ class WebSettings(WebKit2.Settings):
|
|||
except AttributeError:
|
||||
logging.warning('Tried to apply settings before webview setup')
|
||||
|
||||
logging.debug(f'Applied settings for tab: {self.tab.id}')
|
||||
|
||||
|
||||
def set(self, key, value):
|
||||
if key not in default_settings.keys():
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from enum import Enum, IntEnum
|
||||
from izzylib.enum import IntEnum, StrEnum
|
||||
|
||||
|
||||
__all__ = []
|
||||
|
@ -32,7 +32,7 @@ class BitwardenLoginType(IntEnum):
|
|||
|
||||
|
||||
@register
|
||||
class BitwardenTemplateType(Enum):
|
||||
class BitwardenTemplateType(StrEnum):
|
||||
ITEM = 'item'
|
||||
FIELD = 'item.field'
|
||||
LOGIN = 'item.login'
|
||||
|
@ -72,7 +72,7 @@ class BitwardenUrlMatchType(IntEnum):
|
|||
|
||||
|
||||
@register
|
||||
class EditAction(Enum):
|
||||
class EditAction(StrEnum):
|
||||
COPY = WebKit2.EDITING_COMMAND_COPY
|
||||
LINK = WebKit2.EDITING_COMMAND_CREATE_LINK
|
||||
CUT = WebKit2.EDITING_COMMAND_CUT
|
||||
|
@ -106,7 +106,7 @@ class FileChooserResponse(IntEnum):
|
|||
|
||||
|
||||
@register
|
||||
class Javascript(Enum):
|
||||
class Javascript(StrEnum):
|
||||
SELECTION = 'window.getSelection().toString()'
|
||||
EXEC = 'window.execCommand("{}")'
|
||||
PRINT = 'window.print()'
|
||||
|
@ -115,7 +115,7 @@ class Javascript(Enum):
|
|||
|
||||
|
||||
@register
|
||||
class LibraryPage(Enum):
|
||||
class LibraryPage(StrEnum):
|
||||
HOME = ''
|
||||
BOOKMARKS = 'bookmarks'
|
||||
DOWNLOADS = 'downloads'
|
||||
|
@ -128,6 +128,7 @@ class LibraryPage(Enum):
|
|||
HELP = 'help'
|
||||
|
||||
|
||||
@register
|
||||
class StylePriority(IntEnum):
|
||||
FALLBACK = Gtk.STYLE_PROVIDER_PRIORITY_FALLBACK #1
|
||||
THEME = Gtk.STYLE_PROVIDER_PRIORITY_THEME #200
|
||||
|
@ -137,7 +138,14 @@ class StylePriority(IntEnum):
|
|||
|
||||
|
||||
@register
|
||||
class WebviewContextActions(Enum):
|
||||
class WebviewAccelPolicy(IntEnum):
|
||||
DEMAND = WebKit2.HardwareAccelerationPolicy.ON_DEMAND
|
||||
ALWAYS = WebKit2.HardwareAccelerationPolicy.ALWAYS
|
||||
NEVER = WebKit2.HardwareAccelerationPolicy.NEVER
|
||||
|
||||
|
||||
@register
|
||||
class WebviewContextActions(IntEnum):
|
||||
AUDIO_COPY = WebKit2.ContextMenuAction.COPY_AUDIO_LINK_TO_CLIPBOARD
|
||||
AUDIO_DOWNLOAD = WebKit2.ContextMenuAction.DOWNLOAD_AUDIO_TO_DISK
|
||||
FRAME_OPEN = WebKit2.ContextMenuAction.OPEN_FRAME_IN_NEW_WINDOW
|
||||
|
|
Reference in a new issue