Press a to save screenshot of mind map.

master
Andy Stewart 6 years ago
parent bcfee716ca
commit 26d6922bd7
  1. 4
      app/mindmap/buffer.py
  2. 5
      app/mindmap/index.html
  3. 16
      core/browser.py
  4. 1
      eaf.el

@ -33,12 +33,12 @@ class AppBuffer(BrowserBuffer):
for method_name in ["zoom_in", "zoom_out", "zoom_reset", "add_sub_node", "remove_node",
"select_up_node", "select_down_node", "select_left_node", "select_right_node",
"toggle_node"]:
"toggle_node", "save_screenshot"]:
self.build_js_method(method_name)
for method_name in ["zoom_in", "zoom_out", "zoom_reset", "remove_node", "update_node_topic", "refresh_page",
"select_up_node", "select_down_node", "select_left_node", "select_right_node",
"toggle_node"]:
"toggle_node", "save_screenshot"]:
self.build_insert_or_do(method_name)
def build_js_method(self, method_name):

@ -158,6 +158,11 @@
_jm.toggle_node(selected_node);
}
}
function save_screenshot() {
"use strict";
_jm.screenshot.shootDownload();
}
</script>
</body>
</html>

@ -31,6 +31,7 @@ import os
import base64
import subprocess
import re
import base64
MOUSE_BACK_BUTTON = 8
MOUSE_FORWARD_BUTTON = 16
@ -424,10 +425,19 @@ class BrowserBuffer(Buffer):
def handle_download_request(self, download_item):
self.try_start_aria2_daemon()
with open(os.devnull, "w") as null_file:
subprocess.Popen(["aria2p", "add", download_item.url().toString()], stdout=null_file)
download_data = download_item.url().toString()
if download_data.startswith("data:image/png;base64,"):
image_path = os.path.join(os.path.expanduser(str(self.emacs_var_dict["eaf-browser-download-path"])),
os.path.splitext(os.path.basename(self.buffer_widget.url().toString()))[0] + ".png")
with open(image_path, "wb") as f:
f.write(base64.decodestring(download_data.split("data:image/png;base64,")[1].encode("utf-8")))
self.message_to_emacs.emit("Save image: " + image_path)
else:
with open(os.devnull, "w") as null_file:
subprocess.Popen(["aria2p", "add", download_data], stdout=null_file)
self.message_to_emacs.emit("Start download: " + download_item.url().toString())
self.message_to_emacs.emit("Start download: " + download_data)
def handle_destroy(self):
self.close_page.emit(self.buffer_widget.url().toString())

@ -440,6 +440,7 @@ Try not to modify this alist directly. Use `eaf-setq' to modify instead."
("d" . "insert_or_remove_node")
("f" . "insert_or_update_node_topic")
("t" . "insert_or_toggle_node")
("a" . "insert_or_save_screenshot")
)
"The keybinding of EAF Mindmap."
:type 'cons)

Loading…
Cancel
Save