summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov <akurtako@redhat.com>2013-07-12 17:13:43 +0300
committerAlexander Kurtakov <akurtako@redhat.com>2013-07-12 17:13:43 +0300
commit7d865938b30c1ae03ba599023ba96f0087c84faf (patch)
treebd657d67236b1ed9f6d43d07aa29f980979eea49
parentd2e5c07029c231cf71046f566a084417747c40b0 (diff)
downloadeclipse.platform.swt-7d865938b30c1ae03ba599023ba96f0087c84faf.tar.gz
eclipse.platform.swt-7d865938b30c1ae03ba599023ba96f0087c84faf.tar.xz
eclipse.platform.swt-7d865938b30c1ae03ba599023ba96f0087c84faf.zip
org.eclipse.swt.printing - Clean pre-2.8 GTK checks.
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/PrintDialog.java394
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java6
2 files changed, 198 insertions, 202 deletions
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 4f0f888c92..76d002864d 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
@@ -288,214 +288,210 @@ public void setPrintToFile(boolean printToFile) {
* </ul>
*/
public PrinterData open() {
- if (OS.GTK_VERSION < OS.VERSION (2, 10, 0)) {
- return Printer.getDefaultPrinterData();
- } else {
- byte [] titleBytes = Converter.wcsToMbcs (null, getText(), true);
- long /*int*/ topHandle = getParent().handle;
- while (topHandle != 0 && !OS.GTK_IS_WINDOW(topHandle)) {
- topHandle = OS.gtk_widget_get_parent(topHandle);
+ byte [] titleBytes = Converter.wcsToMbcs (null, getText(), true);
+ long /*int*/ topHandle = getParent().handle;
+ while (topHandle != 0 && !OS.GTK_IS_WINDOW(topHandle)) {
+ topHandle = OS.gtk_widget_get_parent(topHandle);
+ }
+ handle = OS.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)
+ OS.gtk_print_unix_dialog_set_current_page(handle, -1);
+
+ OS.gtk_print_unix_dialog_set_manual_capabilities(handle,
+ OS.GTK_PRINT_CAPABILITY_COLLATE | OS.GTK_PRINT_CAPABILITY_COPIES | OS.GTK_PRINT_CAPABILITY_PAGE_SET);
+
+ /* Set state into print dialog settings. */
+ long /*int*/ settings = OS.gtk_print_settings_new();
+ long /*int*/ page_setup = OS.gtk_page_setup_new();
+
+ if (printerData.otherData != null) {
+ Printer.restore(printerData.otherData, settings, page_setup);
+ }
+
+ /* Set values of print_settings and page_setup from PrinterData. */
+ String printerName = printerData.name;
+ if (printerName == null && printerData.printToFile) {
+ /* Find the printer name corresponding to the file backend. */
+ long /*int*/ printer = Printer.gtkPrinterFromPrinterData(printerData);
+ if (printer != 0) {
+ PrinterData data = Printer.printerDataFromGtkPrinter(printer);
+ printerName = data.name;
+ OS.g_object_unref(printer);
}
- handle = OS.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)
- OS.gtk_print_unix_dialog_set_current_page(handle, -1);
-
- OS.gtk_print_unix_dialog_set_manual_capabilities(handle,
- OS.GTK_PRINT_CAPABILITY_COLLATE | OS.GTK_PRINT_CAPABILITY_COPIES | OS.GTK_PRINT_CAPABILITY_PAGE_SET);
-
- /* Set state into print dialog settings. */
- long /*int*/ settings = OS.gtk_print_settings_new();
- long /*int*/ page_setup = OS.gtk_page_setup_new();
-
- if (printerData.otherData != null) {
- Printer.restore(printerData.otherData, settings, page_setup);
+ }
+ if (printerName != null) {
+ byte [] nameBytes = Converter.wcsToMbcs (null, printerName, true);
+ OS.gtk_print_settings_set_printer(settings, nameBytes);
+ }
+
+ switch (printerData.scope) {
+ case PrinterData.ALL_PAGES:
+ OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_ALL);
+ break;
+ case PrinterData.PAGE_RANGE:
+ OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_RANGES);
+ int [] pageRange = new int[2];
+ pageRange[0] = printerData.startPage - 1;
+ pageRange[1] = printerData.endPage - 1;
+ OS.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)
+ OS.gtk_print_settings_set_print_pages(settings, OS.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)
+ byte [] uri = Printer.uriFromFilename(printerData.fileName);
+ if (uri != null) {
+ OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, uri);
}
-
- /* Set values of print_settings and page_setup from PrinterData. */
- String printerName = printerData.name;
- if (printerName == null && printerData.printToFile) {
- /* Find the printer name corresponding to the file backend. */
- long /*int*/ printer = Printer.gtkPrinterFromPrinterData(printerData);
- if (printer != 0) {
- PrinterData data = Printer.printerDataFromGtkPrinter(printer);
- printerName = data.name;
- OS.g_object_unref(printer);
+ }
+ OS.gtk_print_settings_set_n_copies(settings, printerData.copyCount);
+ OS.gtk_print_settings_set_collate(settings, printerData.collate);
+ /*
+ * Bug in GTK. The unix dialog gives priority to the value of the non-API
+ * field cups-Duplex in the print_settings (which we preserve in otherData).
+ * The fix is to manually clear cups-Duplex before setting the duplex field.
+ */
+ byte [] keyBuffer = Converter.wcsToMbcs (null, "cups-Duplex", true);
+ OS.gtk_print_settings_set(settings, keyBuffer, (byte[]) null);
+ if (printerData.duplex != SWT.DEFAULT) {
+ int duplex = printerData.duplex == PrinterData.DUPLEX_LONG_EDGE ? OS.GTK_PRINT_DUPLEX_HORIZONTAL
+ : printerData.duplex == PrinterData.DUPLEX_SHORT_EDGE ? OS.GTK_PRINT_DUPLEX_VERTICAL
+ : OS.GTK_PRINT_DUPLEX_SIMPLEX;
+ OS.gtk_print_settings_set_duplex (settings, duplex);
+ }
+ int orientation = printerData.orientation == PrinterData.LANDSCAPE ? OS.GTK_PAGE_ORIENTATION_LANDSCAPE : OS.GTK_PAGE_ORIENTATION_PORTRAIT;
+ OS.gtk_print_settings_set_orientation(settings, orientation);
+ OS.gtk_page_setup_set_orientation(page_setup, orientation);
+
+ OS.gtk_print_unix_dialog_set_settings(handle, settings);
+ OS.gtk_print_unix_dialog_set_page_setup(handle, page_setup);
+ if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
+ OS.gtk_print_unix_dialog_set_embed_page_setup(handle, true);
+ }
+ OS.g_object_unref(settings);
+ OS.g_object_unref(page_setup);
+ long /*int*/ group = OS.gtk_window_get_group(0);
+ OS.gtk_window_group_add_window (group, handle);
+ OS.gtk_window_set_modal(handle, true);
+ PrinterData data = null;
+ //TODO: Handle 'Print Preview' (GTK_RESPONSE_APPLY).
+ Display display = getParent() != null ? getParent().getDisplay (): Display.getCurrent ();
+
+ int signalId = 0;
+ long /*int*/ hookId = 0;
+ if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
+ signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
+ hookId = OS.g_signal_add_emission_hook (signalId, 0, ((LONG) display.getData (GET_EMISSION_PROC_KEY)).value, handle, 0);
+ }
+ display.setData (ADD_IDLE_PROC_KEY, null);
+ Object oldModal = null;
+ if (OS.gtk_window_get_modal (handle)) {
+ oldModal = display.getData (GET_MODAL_DIALOG);
+ display.setData (SET_MODAL_DIALOG, this);
+ }
+ int response = OS.gtk_dialog_run (handle);
+ /*
+ * This call to gdk_threads_leave() is a temporary work around
+ * to avoid deadlocks when gdk_threads_init() is called by native
+ * code outside of SWT (i.e AWT, etc). It ensures that the current
+ * thread leaves the GTK lock acquired by the function above.
+ */
+ OS.gdk_threads_leave();
+ if (OS.gtk_window_get_modal (handle)) {
+ display.setData (SET_MODAL_DIALOG, oldModal);
+ }
+ if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
+ OS.g_signal_remove_emission_hook (signalId, hookId);
+ }
+ if (response == OS.GTK_RESPONSE_OK) {
+ long /*int*/ printer = OS.gtk_print_unix_dialog_get_selected_printer(handle);
+ if (printer != 0) {
+ /* Get state from print dialog. */
+ settings = OS.gtk_print_unix_dialog_get_settings(handle); // must unref
+ page_setup = OS.gtk_print_unix_dialog_get_page_setup(handle); // do not unref
+ data = Printer.printerDataFromGtkPrinter(printer);
+ int print_pages = OS.gtk_print_settings_get_print_pages(settings);
+ switch (print_pages) {
+ case OS.GTK_PRINT_PAGES_ALL:
+ data.scope = PrinterData.ALL_PAGES;
+ break;
+ case OS.GTK_PRINT_PAGES_RANGES:
+ data.scope = PrinterData.PAGE_RANGE;
+ int[] num_ranges = new int[1];
+ long /*int*/ page_ranges = OS.gtk_print_settings_get_page_ranges(settings, num_ranges);
+ int [] pageRange = new int[2];
+ int length = num_ranges[0];
+ int min = Integer.MAX_VALUE, max = 0;
+ for (int i = 0; i < length; i++) {
+ OS.memmove(pageRange, page_ranges + i * pageRange.length * 4, pageRange.length * 4);
+ min = Math.min(min, pageRange[0] + 1);
+ max = Math.max(max, pageRange[1] + 1);
+ }
+ OS.g_free(page_ranges);
+ data.startPage = min == Integer.MAX_VALUE ? 1 : min;
+ data.endPage = max == 0 ? 1 : max;
+ break;
+ case OS.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 = OS.gtk_print_unix_dialog_get_current_page(handle);
+ break;
}
- }
- if (printerName != null) {
- byte [] nameBytes = Converter.wcsToMbcs (null, printerName, true);
- OS.gtk_print_settings_set_printer(settings, nameBytes);
- }
-
- switch (printerData.scope) {
- case PrinterData.ALL_PAGES:
- OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_ALL);
- break;
- case PrinterData.PAGE_RANGE:
- OS.gtk_print_settings_set_print_pages(settings, OS.GTK_PRINT_PAGES_RANGES);
- int [] pageRange = new int[2];
- pageRange[0] = printerData.startPage - 1;
- pageRange[1] = printerData.endPage - 1;
- OS.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)
- OS.gtk_print_settings_set_print_pages(settings, OS.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)
- byte [] uri = Printer.uriFromFilename(printerData.fileName);
- if (uri != null) {
- OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI, uri);
+
+ data.printToFile = Printer.GTK_FILE_BACKEND.equals(data.driver); // TODO: GTK_FILE_BACKEND is not GTK API (see gtk bug 345590)
+ if (data.printToFile) {
+ long /*int*/ address = OS.gtk_print_settings_get(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ data.fileName = new String (Converter.mbcsToWcs (null, buffer));
}
- }
- OS.gtk_print_settings_set_n_copies(settings, printerData.copyCount);
- OS.gtk_print_settings_set_collate(settings, printerData.collate);
- /*
- * Bug in GTK. The unix dialog gives priority to the value of the non-API
- * field cups-Duplex in the print_settings (which we preserve in otherData).
- * The fix is to manually clear cups-Duplex before setting the duplex field.
- */
- byte [] keyBuffer = Converter.wcsToMbcs (null, "cups-Duplex", true);
- OS.gtk_print_settings_set(settings, keyBuffer, (byte[]) null);
- if (printerData.duplex != SWT.DEFAULT) {
- int duplex = printerData.duplex == PrinterData.DUPLEX_LONG_EDGE ? OS.GTK_PRINT_DUPLEX_HORIZONTAL
- : printerData.duplex == PrinterData.DUPLEX_SHORT_EDGE ? OS.GTK_PRINT_DUPLEX_VERTICAL
- : OS.GTK_PRINT_DUPLEX_SIMPLEX;
- OS.gtk_print_settings_set_duplex (settings, duplex);
- }
- int orientation = printerData.orientation == PrinterData.LANDSCAPE ? OS.GTK_PAGE_ORIENTATION_LANDSCAPE : OS.GTK_PAGE_ORIENTATION_PORTRAIT;
- OS.gtk_print_settings_set_orientation(settings, orientation);
- OS.gtk_page_setup_set_orientation(page_setup, orientation);
-
- OS.gtk_print_unix_dialog_set_settings(handle, settings);
- OS.gtk_print_unix_dialog_set_page_setup(handle, page_setup);
- if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) {
- OS.gtk_print_unix_dialog_set_embed_page_setup(handle, true);
- }
- OS.g_object_unref(settings);
- OS.g_object_unref(page_setup);
- long /*int*/ group = OS.gtk_window_get_group(0);
- OS.gtk_window_group_add_window (group, handle);
- OS.gtk_window_set_modal(handle, true);
- PrinterData data = null;
- //TODO: Handle 'Print Preview' (GTK_RESPONSE_APPLY).
- Display display = getParent() != null ? getParent().getDisplay (): Display.getCurrent ();
-
- int signalId = 0;
- long /*int*/ hookId = 0;
- if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
- signalId = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET());
- hookId = OS.g_signal_add_emission_hook (signalId, 0, ((LONG) display.getData (GET_EMISSION_PROC_KEY)).value, handle, 0);
- }
- display.setData (ADD_IDLE_PROC_KEY, null);
- Object oldModal = null;
- if (OS.gtk_window_get_modal (handle)) {
- oldModal = display.getData (GET_MODAL_DIALOG);
- display.setData (SET_MODAL_DIALOG, this);
- }
- int response = OS.gtk_dialog_run (handle);
- /*
- * This call to gdk_threads_leave() is a temporary work around
- * to avoid deadlocks when gdk_threads_init() is called by native
- * code outside of SWT (i.e AWT, etc). It ensures that the current
- * thread leaves the GTK lock acquired by the function above.
- */
- OS.gdk_threads_leave();
- if (OS.gtk_window_get_modal (handle)) {
- display.setData (SET_MODAL_DIALOG, oldModal);
- }
- if ((getStyle () & SWT.RIGHT_TO_LEFT) != 0) {
- OS.g_signal_remove_emission_hook (signalId, hookId);
- }
- if (response == OS.GTK_RESPONSE_OK) {
- long /*int*/ printer = OS.gtk_print_unix_dialog_get_selected_printer(handle);
- if (printer != 0) {
- /* Get state from print dialog. */
- settings = OS.gtk_print_unix_dialog_get_settings(handle); // must unref
- page_setup = OS.gtk_print_unix_dialog_get_page_setup(handle); // do not unref
- data = Printer.printerDataFromGtkPrinter(printer);
- int print_pages = OS.gtk_print_settings_get_print_pages(settings);
- switch (print_pages) {
- case OS.GTK_PRINT_PAGES_ALL:
- data.scope = PrinterData.ALL_PAGES;
- break;
- case OS.GTK_PRINT_PAGES_RANGES:
- data.scope = PrinterData.PAGE_RANGE;
- int[] num_ranges = new int[1];
- long /*int*/ page_ranges = OS.gtk_print_settings_get_page_ranges(settings, num_ranges);
- int [] pageRange = new int[2];
- int length = num_ranges[0];
- int min = Integer.MAX_VALUE, max = 0;
- for (int i = 0; i < length; i++) {
- OS.memmove(pageRange, page_ranges + i * pageRange.length * 4, pageRange.length * 4);
- min = Math.min(min, pageRange[0] + 1);
- max = Math.max(max, pageRange[1] + 1);
- }
- OS.g_free(page_ranges);
- data.startPage = min == Integer.MAX_VALUE ? 1 : min;
- data.endPage = max == 0 ? 1 : max;
- break;
- case OS.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 = OS.gtk_print_unix_dialog_get_current_page(handle);
- break;
- }
-
- data.printToFile = Printer.GTK_FILE_BACKEND.equals(data.driver); // TODO: GTK_FILE_BACKEND is not GTK API (see gtk bug 345590)
- if (data.printToFile) {
- long /*int*/ address = OS.gtk_print_settings_get(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI);
- int length = OS.strlen (address);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, address, length);
- data.fileName = new String (Converter.mbcsToWcs (null, buffer));
- }
- data.copyCount = OS.gtk_print_settings_get_n_copies(settings);
- data.collate = OS.gtk_print_settings_get_collate(settings);
- int duplex = OS.gtk_print_settings_get_duplex(settings);
- data.duplex = duplex == OS.GTK_PRINT_DUPLEX_HORIZONTAL ? PrinterData.DUPLEX_LONG_EDGE
- : duplex == OS.GTK_PRINT_DUPLEX_VERTICAL ? PrinterData.DUPLEX_SHORT_EDGE
- : PrinterData.DUPLEX_NONE;
- data.orientation = OS.gtk_page_setup_get_orientation(page_setup) == OS.GTK_PAGE_ORIENTATION_LANDSCAPE ? PrinterData.LANDSCAPE : PrinterData.PORTRAIT;
+ data.copyCount = OS.gtk_print_settings_get_n_copies(settings);
+ data.collate = OS.gtk_print_settings_get_collate(settings);
+ int duplex = OS.gtk_print_settings_get_duplex(settings);
+ data.duplex = duplex == OS.GTK_PRINT_DUPLEX_HORIZONTAL ? PrinterData.DUPLEX_LONG_EDGE
+ : duplex == OS.GTK_PRINT_DUPLEX_VERTICAL ? PrinterData.DUPLEX_SHORT_EDGE
+ : PrinterData.DUPLEX_NONE;
+ data.orientation = OS.gtk_page_setup_get_orientation(page_setup) == OS.GTK_PAGE_ORIENTATION_LANDSCAPE ? PrinterData.LANDSCAPE : PrinterData.PORTRAIT;
- /* Save other print_settings data as key/value pairs in otherData. */
- Callback printSettingsCallback = new Callback(this, "GtkPrintSettingsFunc", 3); //$NON-NLS-1$
- long /*int*/ GtkPrintSettingsFunc = printSettingsCallback.getAddress();
- if (GtkPrintSettingsFunc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
- index = 0;
- settingsData = new byte[1024];
- OS.gtk_print_settings_foreach (settings, GtkPrintSettingsFunc, 0);
- printSettingsCallback.dispose ();
- index++; // extra null terminator after print_settings and before page_setup
+ /* Save other print_settings data as key/value pairs in otherData. */
+ Callback printSettingsCallback = new Callback(this, "GtkPrintSettingsFunc", 3); //$NON-NLS-1$
+ long /*int*/ GtkPrintSettingsFunc = printSettingsCallback.getAddress();
+ if (GtkPrintSettingsFunc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ index = 0;
+ settingsData = new byte[1024];
+ OS.gtk_print_settings_foreach (settings, GtkPrintSettingsFunc, 0);
+ printSettingsCallback.dispose ();
+ index++; // extra null terminator after print_settings and before page_setup
- /* Save page_setup data as key/value pairs in otherData.
- * Note that page_setup properties must be stored and restored in the same order.
- */
- store("orientation", OS.gtk_page_setup_get_orientation(page_setup)); //$NON-NLS-1$
- store("top_margin", OS.gtk_page_setup_get_top_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- store("bottom_margin", OS.gtk_page_setup_get_bottom_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- store("left_margin", OS.gtk_page_setup_get_left_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- store("right_margin", OS.gtk_page_setup_get_right_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- long /*int*/ paper_size = OS.gtk_page_setup_get_paper_size(page_setup); //$NON-NLS-1$
- storeBytes("paper_size_name", OS.gtk_paper_size_get_name(paper_size)); //$NON-NLS-1$
- storeBytes("paper_size_display_name", OS.gtk_paper_size_get_display_name(paper_size)); //$NON-NLS-1$
- storeBytes("paper_size_ppd_name", OS.gtk_paper_size_get_ppd_name(paper_size)); //$NON-NLS-1$
- store("paper_size_width", OS.gtk_paper_size_get_width(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- store("paper_size_height", OS.gtk_paper_size_get_height(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
- store("paper_size_is_custom", OS.gtk_paper_size_is_custom(paper_size)); //$NON-NLS-1$
- data.otherData = settingsData;
- OS.g_object_unref(settings);
- printerData = data;
- }
+ /* Save page_setup data as key/value pairs in otherData.
+ * Note that page_setup properties must be stored and restored in the same order.
+ */
+ store("orientation", OS.gtk_page_setup_get_orientation(page_setup)); //$NON-NLS-1$
+ store("top_margin", OS.gtk_page_setup_get_top_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ store("bottom_margin", OS.gtk_page_setup_get_bottom_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ store("left_margin", OS.gtk_page_setup_get_left_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ store("right_margin", OS.gtk_page_setup_get_right_margin(page_setup, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ long /*int*/ paper_size = OS.gtk_page_setup_get_paper_size(page_setup); //$NON-NLS-1$
+ storeBytes("paper_size_name", OS.gtk_paper_size_get_name(paper_size)); //$NON-NLS-1$
+ storeBytes("paper_size_display_name", OS.gtk_paper_size_get_display_name(paper_size)); //$NON-NLS-1$
+ storeBytes("paper_size_ppd_name", OS.gtk_paper_size_get_ppd_name(paper_size)); //$NON-NLS-1$
+ store("paper_size_width", OS.gtk_paper_size_get_width(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ store("paper_size_height", OS.gtk_paper_size_get_height(paper_size, OS.GTK_UNIT_MM)); //$NON-NLS-1$
+ store("paper_size_is_custom", OS.gtk_paper_size_is_custom(paper_size)); //$NON-NLS-1$
+ data.otherData = settingsData;
+ OS.g_object_unref(settings);
+ printerData = data;
}
- display.setData (REMOVE_IDLE_PROC_KEY, null);
- OS.gtk_widget_destroy (handle);
- return data;
}
+ display.setData (REMOVE_IDLE_PROC_KEY, null);
+ OS.gtk_widget_destroy (handle);
+ return data;
}
long /*int*/ GtkPrintSettingsFunc (long /*int*/ key, long /*int*/ value, long /*int*/ data) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
index 13dcf09f96..258d7eaa03 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/gtk/org/eclipse/swt/printing/Printer.java
@@ -91,7 +91,7 @@ static void gtk_init() {
*/
public static PrinterData[] getPrinterList() {
printerList = new PrinterData [0];
- if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) {
+ if (disablePrinting) {
return printerList;
}
gtk_init();
@@ -139,7 +139,7 @@ static long /*int*/ GtkPrinterFunc_List (long /*int*/ printer, long /*int*/ user
*/
public static PrinterData getDefaultPrinterData() {
findData = null;
- if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) {
+ if (disablePrinting) {
return null;
}
gtk_init();
@@ -748,7 +748,7 @@ public Rectangle computeTrim(int x, int y, int width, int height) {
*/
protected void create(DeviceData deviceData) {
this.data = (PrinterData)deviceData;
- if (OS.GTK_VERSION < OS.VERSION (2, 10, 0) || disablePrinting) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (disablePrinting) SWT.error(SWT.ERROR_NO_HANDLES);
printer = gtkPrinterFromPrinterData(data);
if (printer == 0) SWT.error(SWT.ERROR_NO_HANDLES);
}