Implement File > Send

This doesn't work in Gmail, Thunderbird, or elementary OS's Mail.
What DOES it work in? Jeez.
This commit is contained in:
Isaiah Odhner 2023-07-22 02:19:12 -04:00
parent 925b0a1372
commit 4cdce54a39
2 changed files with 14 additions and 4 deletions

View File

@ -59,7 +59,7 @@ This is a TUI (Text User Interface) image editor, inspired by MS Paint, built wi
- [x] **Attributes** (resize canvas; in the future may change color/text modes, maybe text encoding)
- [x] **Edit Colors**
- [x] **Set As Wallpaper** (tiled or centered)
- Every command is implemented, other than **Print** and **Send** (as fax / email), and a few toggles: **Draw Opaque** (pending tool options), **Show Thumbnail** (pending [sixel support in Textual](https://textual.textualize.io/roadmap/#widgets)), and **Text Toolbar** (which could show FIGlet fonts, but that would complicate the text area implementation, and could show bold/italic/underline, but that would complicate the document model. Both interesting, but not for a first release!)
- Every command is implemented, other than printing options, and a few toggles: **Draw Opaque** (pending tool options), **Show Thumbnail** (pending [sixel support in Textual](https://textual.textualize.io/roadmap/#widgets)), and **Text Toolbar** (which could show FIGlet fonts, but that would complicate the text area implementation, and could show bold/italic/underline, but that would complicate the document model. Both interesting, but not for a first release!)
- [x] Color palette
- [x] Efficient screen updates and undo/redo history, by tracking regions affected by each action
- You could totally use this program over SSH! Haha, this "what if" project could actually be useful. Of course, it should be mentioned that you can also run graphical programs over SSH, but this might be more responsive, or just fit your vibe better.

View File

@ -3631,8 +3631,18 @@ Columns: {len(palette) // 2}
self.message_box(_("Paint"), "Not implemented.", "ok")
def action_print(self) -> None:
self.message_box(_("Paint"), "Not implemented.", "ok")
def action_send(self) -> None:
self.message_box(_("Paint"), "Not implemented.", "ok")
"""Send the image as an email attachment."""
import subprocess
import tempfile
file_path = tempfile.mktemp(suffix=".svg")
svg = self.image.get_svg()
self.write_file_path(file_path, svg.encode("utf-8"), _("Send"))
body = _("Textual Paint image attached.")
subprocess.run(["xdg-email", "--utf8", "--attach", file_path, "--body", body, "Someone <test@example.com>"])
# Don't remove the file.
# Some e-mail applications require the file to remain present after xdg-email returns.
def action_set_as_wallpaper_tiled(self) -> None:
"""Tile the image as the wallpaper."""
@ -4425,7 +4435,7 @@ Columns: {len(palette) // 2}
MenuItem(_("Page Se&tup..."), self.action_page_setup, 57605, grayed=True, description=_("Changes the page layout.")),
MenuItem(_("&Print...\tCtrl+P"), self.action_print, 57607, grayed=True, description=_("Prints the active document and sets printing options.")),
Separator(),
MenuItem(_("S&end..."), self.action_send, 37662, grayed=True, description=_("Sends a picture by using mail or fax.")),
MenuItem(_("S&end..."), self.action_send, 37662, description=_("Sends a picture by using mail or fax.")),
Separator(),
MenuItem(_("Set As &Wallpaper (Tiled)"), self.action_set_as_wallpaper_tiled, 57677, description=_("Tiles this bitmap as the desktop wallpaper.")),
MenuItem(_("Set As Wa&llpaper (Centered)"), self.action_set_as_wallpaper_centered, 57675, description=_("Centers this bitmap as the desktop wallpaper.")),