diff options
| author | Eric Williams | 2019-09-06 17:56:19 +0000 |
|---|---|---|
| committer | Eric Williams | 2019-09-11 18:12:44 +0000 |
| commit | a323d29b464742ac12e5cb42948bc0d6f843f3c7 (patch) | |
| tree | 4eb812f7af872a7b61859a55d876c2c4a692fa71 | |
| parent | 3c0e74f1ed5a447b60eb0a783979cf9144e65960 (diff) | |
| download | eclipse.platform.swt-a323d29b464742ac12e5cb42948bc0d6f843f3c7.tar.gz eclipse.platform.swt-a323d29b464742ac12e5cb42948bc0d6f843f3c7.tar.xz eclipse.platform.swt-a323d29b464742ac12e5cb42948bc0d6f843f3c7.zip | |
Bug 299550: [GTK] Make "Print Selection" work
Implement selection printing on GTK. Note that the
selection option is always available, even if no text
is selected. In this case, a blank page will be printed.
Tested on GTK3.24 with X11. Printing in the IDE works for
all supported cases as expected.
Change-Id: I540c0fe7ff5d5d5517ee1dc249c91bf9b83d4a1e
Signed-off-by: Eric Williams <ericwill@redhat.com>
5 files changed, 54 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c index 000161b36f..df4e97d791 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c @@ -8409,6 +8409,16 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1print_1unix_1dialog_1set_1embed_1page_1 } #endif +#ifndef NO__1gtk_1print_1unix_1dialog_1set_1has_1selection +JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1print_1unix_1dialog_1set_1has_1selection) + (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) +{ + GTK_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1has_1selection_FUNC); + gtk_print_unix_dialog_set_has_selection((GtkPrintUnixDialog *)arg0, arg1); + GTK_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1has_1selection_FUNC); +} +#endif + #ifndef NO__1gtk_1print_1unix_1dialog_1set_1manual_1capabilities JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1print_1unix_1dialog_1set_1manual_1capabilities) (JNIEnv *env, jclass that, jlong arg0, jlong arg1) @@ -8439,6 +8449,16 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1print_1unix_1dialog_1set_1settings) } #endif +#ifndef NO__1gtk_1print_1unix_1dialog_1set_1support_1selection +JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1print_1unix_1dialog_1set_1support_1selection) + (JNIEnv *env, jclass that, jlong arg0, jboolean arg1) +{ + GTK_NATIVE_ENTER(env, that, _1gtk_1print_1unix_1dialog_1set_1support_1selection_FUNC); + gtk_print_unix_dialog_set_support_selection((GtkPrintUnixDialog *)arg0, arg1); + GTK_NATIVE_EXIT(env, that, _1gtk_1print_1unix_1dialog_1set_1support_1selection_FUNC); +} +#endif + #ifndef NO__1gtk_1printer_1get_1backend JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1printer_1get_1backend) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c index 4828ccc0e9..c72ea32f92 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c @@ -676,9 +676,11 @@ char * GTK_nativeFunctionNames[] = { "_1gtk_1print_1unix_1dialog_1new", "_1gtk_1print_1unix_1dialog_1set_1current_1page", "_1gtk_1print_1unix_1dialog_1set_1embed_1page_1setup", + "_1gtk_1print_1unix_1dialog_1set_1has_1selection", "_1gtk_1print_1unix_1dialog_1set_1manual_1capabilities", "_1gtk_1print_1unix_1dialog_1set_1page_1setup", "_1gtk_1print_1unix_1dialog_1set_1settings", + "_1gtk_1print_1unix_1dialog_1set_1support_1selection", "_1gtk_1printer_1get_1backend", "_1gtk_1printer_1get_1name", "_1gtk_1printer_1is_1default", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h index 71bbc4ecac..77ffdee96d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h @@ -674,9 +674,11 @@ typedef enum { _1gtk_1print_1unix_1dialog_1new_FUNC, _1gtk_1print_1unix_1dialog_1set_1current_1page_FUNC, _1gtk_1print_1unix_1dialog_1set_1embed_1page_1setup_FUNC, + _1gtk_1print_1unix_1dialog_1set_1has_1selection_FUNC, _1gtk_1print_1unix_1dialog_1set_1manual_1capabilities_FUNC, _1gtk_1print_1unix_1dialog_1set_1page_1setup_FUNC, _1gtk_1print_1unix_1dialog_1set_1settings_FUNC, + _1gtk_1print_1unix_1dialog_1set_1support_1selection_FUNC, _1gtk_1printer_1get_1backend_FUNC, _1gtk_1printer_1get_1name_FUNC, _1gtk_1printer_1is_1default_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java index 5b811b8691..500aafea2d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java @@ -87,6 +87,7 @@ public class GTK extends OS { public static final int GTK_PRINT_PAGES_ALL = 0; public static final int GTK_PRINT_PAGES_CURRENT = 1; public static final int GTK_PRINT_PAGES_RANGES = 2; + public static final int GTK_PRINT_PAGES_SELECTION = 3; public static final int GTK_PRINT_DUPLEX_SIMPLEX = 0; public static final int GTK_PRINT_DUPLEX_HORIZONTAL = 1; public static final int GTK_PRINT_DUPLEX_VERTICAL = 2; @@ -5339,6 +5340,30 @@ public class GTK extends OS { lock.unlock(); } } + /** + * @param dialog cast=(GtkPrintUnixDialog *) + */ + public static final native void _gtk_print_unix_dialog_set_support_selection(long dialog, boolean support_selection); + public static final void gtk_print_unix_dialog_set_support_selection(long dialog, boolean support_selection) { + lock.lock(); + try { + _gtk_print_unix_dialog_set_support_selection(dialog, support_selection); + } finally { + lock.unlock(); + } + } + /** + * @param dialog cast=(GtkPrintUnixDialog *) + */ + public static final native void _gtk_print_unix_dialog_set_has_selection(long dialog, boolean has_selection); + public static final void gtk_print_unix_dialog_set_has_selection(long dialog, boolean has_selection) { + lock.lock(); + try { + _gtk_print_unix_dialog_set_has_selection(dialog, has_selection); + } finally { + lock.unlock(); + } + } public static final native long _gtk_progress_bar_new(); public static final long gtk_progress_bar_new() { lock.lock(); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java index c42f9ca2df..a7ebaeac2c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java @@ -299,8 +299,8 @@ public PrinterData open() { } handle = GTK.gtk_print_unix_dialog_new(titleBytes, topHandle); - //TODO: Not currently implemented. May need new API. For now, disable 'Current' in the dialog. (see gtk bug 344519) - GTK.gtk_print_unix_dialog_set_current_page(handle, -1); + GTK.gtk_print_unix_dialog_set_support_selection(handle, true); + GTK.gtk_print_unix_dialog_set_has_selection(handle, true); GTK.gtk_print_unix_dialog_set_manual_capabilities(handle, GTK.GTK_PRINT_CAPABILITY_COLLATE | GTK.GTK_PRINT_CAPABILITY_COPIES | GTK.GTK_PRINT_CAPABILITY_PAGE_SET); @@ -340,10 +340,6 @@ public PrinterData open() { pageRange[1] = printerData.endPage - 1; GTK.gtk_print_settings_set_page_ranges(settings, pageRange, 1); break; - case PrinterData.SELECTION: - //TODO: Not correctly implemented. May need new API. For now, set to ALL. (see gtk bug 344519) - GTK.gtk_print_settings_set_print_pages(settings, GTK.GTK_PRINT_PAGES_ALL); - break; } if ((printerData.printToFile || Printer.GTK_FILE_BACKEND.equals(printerData.driver)) && printerData.fileName != null) { // TODO: GTK_FILE_BACKEND is not GTK API (see gtk bug 345590) @@ -440,10 +436,12 @@ public PrinterData open() { data.endPage = max == 0 ? 1 : max; break; case GTK.GTK_PRINT_PAGES_CURRENT: - //TODO: Disabled in dialog (see above). This code will not run. (see gtk bug 344519) data.scope = PrinterData.SELECTION; data.startPage = data.endPage = GTK.gtk_print_unix_dialog_get_current_page(handle); break; + case GTK.GTK_PRINT_PAGES_SELECTION: + data.scope = PrinterData.SELECTION; + break; } data.printToFile = Printer.GTK_FILE_BACKEND.equals(data.driver); // TODO: GTK_FILE_BACKEND is not GTK API (see gtk bug 345590) |
