You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 lines
2.2 KiB

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018 Andy Stewart
#
# Author: Andy Stewart <lazycat.manatee@gmail.com>
# Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from core.browser import BrowserView, webview_scroll
from core.buffer import Buffer
class BrowserBuffer(Buffer):
def __init__(self, buffer_id, url, arguments, fit_to_view, background_color):
Buffer.__init__(self, buffer_id, url, arguments, fit_to_view, background_color)
self.add_widget(BrowserView())
self.buffer_widget.loadStarted.connect(self.start_progress)
self.buffer_widget.loadProgress.connect(self.update_progress)
self.buffer_widget.loadFinished.connect(self.stop_progress)
self.buffer_widget.web_page.windowCloseRequested.connect(self.request_close_buffer)
def get_key_event_widgets(self):
# We need send key event to QWebEngineView's focusProxy widget, not QWebEngineView.
return [self.buffer_widget.focusProxy()]
def scroll(self, scroll_direction, scroll_type):
webview_scroll(self, scroll_direction, scroll_type)
def send_keystroke(self, keystroke):
if keystroke == "M-f":
self.buffer_widget.forward()
elif keystroke == "M-b":
self.buffer_widget.back()
elif keystroke == "M-q":
self.buffer_widget.clean_cookie()
self.message_to_emacs.emit("Clean all cookie")
elif keystroke == "C--":
self.buffer_widget.zoom_out()
elif keystroke == "C-=":
self.buffer_widget.zoom_in()
elif keystroke == "C-0":
self.buffer_widget.zoom_reset()