Skip to content

Commit

Permalink
Show error message when trying to print in the Discord Activity
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed May 1, 2024
1 parent cbfc9ca commit c1357a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 10 additions & 1 deletion src/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,15 @@ function file_save_as(maybe_saved_callback = () => { }, update_from_saved = true
});
}

function file_print() {
if (is_discord_embed) {
// closest localized string: "Could not start print job."
show_error_message(localize("Printing is not supported in the Discord Activity."));
return;
}
print();
}

/**
* Prompts the user to save changes to the document.
* @param {(info?: { canvas_modified_while_loading?: boolean }) => void} action
Expand Down Expand Up @@ -4167,7 +4176,7 @@ function show_multi_user_setup_dialog(from_current_document) {
export {
$this_version_news,
apply_file_format_and_palette_info, are_you_sure, cancel, change_some_url_params, change_url_param, choose_file_to_paste, cleanup_bitmap_view, clear, confirm_overwrite_capability, delete_selection, deselect, detect_monochrome,
edit_copy, edit_cut, edit_paste, exit_fullscreen_if_ios, file_load_from_url, file_new, file_open, file_save,
edit_copy, edit_cut, edit_paste, exit_fullscreen_if_ios, file_load_from_url, file_new, file_open, file_print, file_save,
file_save_as, getSelectionText, get_all_url_params, get_history_ancestors, get_tool_by_id, get_uris, get_url_param, go_to_history_node, handle_keyshortcuts, has_any_transparency, image_attributes, image_flip_and_rotate, image_invert_colors, image_stretch_and_skew, load_image_from_uri, load_theme_from_text, make_history_node, make_monochrome_palette, make_monochrome_pattern, make_opaque, make_or_update_undoable, make_stripe_pattern, meld_selection_into_canvas,
meld_textbox_into_canvas, open_from_file, open_from_image_info, paste, paste_image_from_file, please_enter_a_number, read_image_file, redo, render_canvas_view, render_history_as_gif, reset_canvas_and_history, reset_file, reset_selected_colors, resize_canvas_and_save_dimensions, resize_canvas_without_saving_dimensions, sanity_check_blob, save_as_prompt, save_selection_to_file, select_all, select_tool, select_tools, set_all_url_params, set_magnification, show_about_paint, show_convert_to_black_and_white, show_custom_zoom_window, show_document_history, show_error_message, show_file_format_errors, show_multi_user_setup_dialog, show_news, show_resource_load_error_message, switch_to_polychrome_palette, toggle_grid,
toggle_thumbnail, try_exec_command, undo, undoable, update_canvas_rect, update_css_classes_for_conditional_messages, update_disable_aa, update_from_saved_file, update_helper_layer,
Expand Down
8 changes: 4 additions & 4 deletions src/menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// import { available_languages, get_iso_language_name, get_language, get_language_emoji, get_language_endonym, localize, set_language } from "./app-localization.js";
import { show_edit_colors_window } from "./edit-colors.js";
import { palette_formats } from "./file-format-data.js";
import { are_you_sure, change_url_param, choose_file_to_paste, clear, delete_selection, deselect, edit_copy, edit_cut, edit_paste, file_load_from_url, file_new, file_open, file_save, file_save_as, image_attributes, image_flip_and_rotate, image_invert_colors, image_stretch_and_skew, redo, render_history_as_gif, sanity_check_blob, save_selection_to_file, select_all, set_magnification, show_about_paint, show_custom_zoom_window, show_document_history, show_file_format_errors, show_multi_user_setup_dialog, show_news, toggle_grid, toggle_thumbnail, undo, view_bitmap } from "./functions.js";
import { are_you_sure, change_url_param, choose_file_to_paste, clear, delete_selection, deselect, edit_copy, edit_cut, edit_paste, file_load_from_url, file_new, file_open, file_print, file_save, file_save_as, image_attributes, image_flip_and_rotate, image_invert_colors, image_stretch_and_skew, redo, render_history_as_gif, sanity_check_blob, save_selection_to_file, select_all, set_magnification, show_about_paint, show_custom_zoom_window, show_document_history, show_file_format_errors, show_multi_user_setup_dialog, show_news, toggle_grid, toggle_thumbnail, undo, view_bitmap } from "./functions.js";
import { show_help } from "./help.js";
import { $G, get_rgba_from_color, is_discord_embed } from "./helpers.js";
import { show_imgur_uploader } from "./imgur.js";
Expand Down Expand Up @@ -150,7 +150,7 @@ const menus = {
"preview print", "print preview", "show print preview", "show preview of print",
],
action: () => {
print();
file_print();
},
description: localize("Prints the active document and sets printing options."),
//description: localize("Displays full pages."),
Expand All @@ -162,7 +162,7 @@ const menus = {
"page setup", "printing setup", "page set-up", "printing set-up", "page set up", "printing set up",
],
action: () => {
print();
file_print();
},
description: localize("Prints the active document and sets printing options."),
//description: localize("Changes the page layout."),
Expand All @@ -182,7 +182,7 @@ const menus = {
"send the page to printer", "send the image to printer", "send the picture to printer", "send the drawing to printer",
],
action: () => {
print();
file_print();
},
description: localize("Prints the active document and sets printing options."),
},
Expand Down

0 comments on commit c1357a8

Please sign in to comment.