Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browser: Support duplicating current page in new tab #401

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/browser/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, buffer_id, url, config_dir, arguments, emacs_var_dict, module
self.buffer_widget.translate_selected_text.connect(self.translate_text)

self.buffer_widget.open_url_in_new_tab.connect(self.open_url_in_new_tab)
self.buffer_widget.duplicate_page_in_new_tab.connect(self.duplicate_page_in_new_tab)
self.buffer_widget.open_url_in_background_tab.connect(self.open_url_in_background_tab)

self.buffer_widget.urlChanged.connect(self.set_adblocker)
Expand Down
5 changes: 5 additions & 0 deletions core/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
class BrowserView(QWebEngineView):

open_url_in_new_tab = QtCore.pyqtSignal(str)
duplicate_page_in_new_tab = QtCore.pyqtSignal(str)
open_url_in_background_tab = QtCore.pyqtSignal(str)
translate_selected_text = QtCore.pyqtSignal(str)
trigger_focus_event = QtCore.pyqtSignal(str)
Expand Down Expand Up @@ -1348,6 +1349,10 @@ def recover_prev_close_page(self):
else:
self.message_to_emacs.emit("No page need recovery.")

@interactive(insert_or_do=True)
def duplicate_page(self):
self.buffer_widget.duplicate_page_in_new_tab.emit(self.current_url)

@interactive(insert_or_do=True)
def open_browser(self):
''' Open browser.'''
Expand Down
1 change: 1 addition & 0 deletions core/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class Buffer(QGraphicsScene):

update_buffer_details = QtCore.pyqtSignal(str, str, str)
open_url_in_new_tab = QtCore.pyqtSignal(str)
duplicate_page_in_new_tab = QtCore.pyqtSignal(str)
open_url_in_background_tab = QtCore.pyqtSignal(str)
translate_text = QtCore.pyqtSignal(str)
input_message = QtCore.pyqtSignal(str, str, str, str, str)
Expand Down
11 changes: 11 additions & 0 deletions eaf.el
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
("M-v" . "scroll_down_page")
("M-<" . "scroll_to_begin")
("M->" . "scroll_to_bottom")
("M-p" . "duplicate_page")
("M-t" . "new_blank_page")
("SPC" . "insert_or_scroll_up_page")
("J" . "insert_or_select_left_tab")
Expand Down Expand Up @@ -388,6 +389,7 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
("y" . "insert_or_download_youtube_video")
("Y" . "insert_or_download_youtube_audio")
("p" . "insert_or_toggle_device")
("P" . "insert_or_duplicate_page")
("1" . "insert_or_save_as_pdf")
("2" . "insert_or_save_as_single_file")
("v" . "insert_or_view_source")
Expand Down Expand Up @@ -1676,6 +1678,15 @@ In that way the corresponding function will be called to retrieve the HTML
(interactive "M[EAF/browser] URL: ")
(eaf-open (eaf-wrap-url url) "browser" args))

(dbus-register-signal
:session "com.lazycat.eaf" "/com/lazycat/eaf"
"com.lazycat.eaf" "duplicate_page_in_new_tab"
#'eaf-browser--duplicate-page-in-new-tab)

(defun eaf-browser--duplicate-page-in-new-tab (url)
"Duplicate a new tab for the dedicated URL."
(eaf-open (eaf-wrap-url url) "browser" nil t))

(defun eaf-is-valid-url (url)
"Return the same URL if it is valid."
(when (and
Expand Down
5 changes: 5 additions & 0 deletions eaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def create_buffer(self, buffer_id, url, module_path, arguments):
app_buffer.update_buffer_details.connect(self.update_buffer_details)
app_buffer.translate_text.connect(self.translate_text)
app_buffer.open_url_in_new_tab.connect(self.open_url_in_new_tab)
app_buffer.duplicate_page_in_new_tab.connect(self.duplicate_page_in_new_tab)
app_buffer.open_url_in_background_tab.connect(self.open_url_in_background_tab)
app_buffer.goto_left_tab.connect(self.goto_left_tab)
app_buffer.goto_right_tab.connect(self.goto_right_tab)
Expand Down Expand Up @@ -469,6 +470,10 @@ def update_buffer_details(self, buffer_id, title, url):
def open_url_in_new_tab(self, url):
pass

@dbus.service.signal(EAF_DBUS_NAME)
def duplicate_page_in_new_tab(self, url):
pass

@dbus.service.signal(EAF_DBUS_NAME)
def open_dev_tools_page(self):
pass
Expand Down