Skip to content

Add print-native@pzim-devdata - #771

Draft
pzim-devdata wants to merge 6 commits into
linuxmint:masterfrom
pzim-devdata:print-native
Draft

pzim-devdata wants to merge 6 commits into
linuxmint:masterfrom
pzim-devdata:print-native

Conversation

@pzim-devdata

Copy link
Copy Markdown
Contributor

Open native GTK print dialog from Nemo

  • Native GTK print dialog (same as File > Print in applications)
  • Uses GTK PrintOperation API
  • Full CUPS integration with all printing options
  • Works with text files, PDFs, images, and more
  • No external dependencies (python3-gi pre-installed)
  • Includes 21 language translations

Open native GTK print dialog from Nemo

- Native GTK print dialog (same as File > Print in applications)
- Uses GTK PrintOperation API
- Full CUPS integration with all printing options
- Works with text files, PDFs, images, and more
- No external dependencies (python3-gi pre-installed)
- Includes 21 language translations
@pzim-devdata

pzim-devdata commented Jan 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Description

Open the native GTK print dialog directly from Nemo's context menu, providing the same printing experience as clicking File > Print in any GNOME application.

Features

  • Native GTK print dialog: Uses GTK.PrintOperation API, the same API used by gedit, evince, and all GNOME applications
  • Full CUPS integration: Access to all printer options (printer selection, duplex, quality, color, copies, etc.)
  • Universal file support: Works with text files, PDFs, images, office documents, and more
  • No custom UI: Uses the system's native print dialog - familiar to all users
  • No external dependencies: Only requires python3-gi which is pre-installed on all GNOME-based systems
  • 21 language translations

Why this action is useful

Instead of opening a file in an application just to access the print dialog, users can directly open the print dialog from the file manager with a simple right-click. This provides a consistent printing experience across all file types.

Technical Details

  • Uses Python's gi.repository.Gtk.PrintOperation API
  • Communicates with CUPS via D-Bus (same as native applications)
  • Renders file content using Cairo and Pango
  • Compatible with any CUPS-supported printer
  • Properly handles file paths with spaces

Dependencies

  • python3-gi (GTK bindings for Python, pre-installed on Cinnamon/GNOME systems)

Supported File Types

Text files, PDFs, PostScript, images (JPEG, PNG, GIF, BMP, TIFF, SVG), office documents (ODT, DOC, DOCX, XLS, XLSX, PPT, PPTX), HTML, Markdown, and more.

Testing

Tested on Debian Cinnamon with multiple file types and printers. Print dialog appears identical to File > Print in gedit and other GNOME applications.

Screenshot

screenshot-auto_1769726396

Thank you to the Linux Mint team!

@pzim-devdata

Copy link
Copy Markdown
Contributor Author

fix: robust MIME detection for extension-less files

Replace mimetypes.guess_type() with a cascading detection:

  1. mimetypes (by extension)
  2. file --mime-type (by content, handles missing extension)
  3. UTF-8 decode attempt (text fallback)

Fixes a bug where a text file without extension would fall back
to xdg-open instead of opening the print dialog.

Add gi.require_version('PangoCairo', '1.0') to the script

Also cleaned up the Mimetypes field in the .nemo_action:
removed invalid entries (/tiff) and duplicates
(image/svg+xml, text/html, text/markdown).

@pzim-devdata
pzim-devdata marked this pull request as draft March 16, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant