summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/reference/gtk/gtk-sections.txt1
-rw-r--r--gtk/gtk.symbols1
-rw-r--r--gtk/gtkcustompaperunixdialog.c3
-rw-r--r--gtk/gtkprintbackend.c14
-rw-r--r--gtk/gtkprintbackend.h10
-rw-r--r--gtk/gtkprinter-private.h5
-rw-r--r--gtk/gtkprinter.c38
-rw-r--r--gtk/gtkprinter.h5
-rw-r--r--modules/printbackends/cups/gtkprintbackendcups.c16
9 files changed, 59 insertions, 34 deletions
diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt
index 1672e5f3d6..93ec24e73f 100644
--- a/docs/reference/gtk/gtk-sections.txt
+++ b/docs/reference/gtk/gtk-sections.txt
@@ -6864,6 +6864,7 @@ gtk_printer_has_details
gtk_printer_request_details
gtk_printer_get_capabilities
gtk_printer_get_default_page_size
+gtk_printer_get_hard_margins
GtkPrinterFunc
gtk_enumerate_printers
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index 05e20fea64..40f3261c66 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2945,6 +2945,7 @@ gtk_printer_compare
gtk_printer_has_details
gtk_printer_request_details
gtk_printer_get_capabilities
+gtk_printer_get_hard_margins
gtk_enumerate_printers
gtk_print_capabilities_get_type G_GNUC_CONST
#endif
diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c
index 9006eaba23..a5c9bc9152 100644
--- a/gtk/gtkcustompaperunixdialog.c
+++ b/gtk/gtkcustompaperunixdialog.c
@@ -802,7 +802,8 @@ set_margins_from_printer (GtkCustomPaperUnixDialog *dialog,
gdouble top, bottom, left, right;
top = bottom = left = right = 0;
- _gtk_printer_get_hard_margins (printer, &top, &bottom, &left, &right);
+ if (!gtk_printer_get_hard_margins (printer, &top, &bottom, &left, &right))
+ return;
priv->non_user_change = TRUE;
unit_widget_set (priv->top_widget, _gtk_print_convert_to_mm (top, GTK_UNIT_POINTS));
diff --git a/gtk/gtkprintbackend.c b/gtk/gtkprintbackend.c
index 3c64823ebe..4b8b0dedf3 100644
--- a/gtk/gtkprintbackend.c
+++ b/gtk/gtkprintbackend.c
@@ -349,11 +349,11 @@ G_DEFINE_TYPE (GtkPrintBackend, gtk_print_backend, G_TYPE_OBJECT)
static void fallback_printer_request_details (GtkPrinter *printer);
static gboolean fallback_printer_mark_conflicts (GtkPrinter *printer,
GtkPrinterOptionSet *options);
-static void fallback_printer_get_hard_margins (GtkPrinter *printer,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right);
+static gboolean fallback_printer_get_hard_margins (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right);
static GList * fallback_printer_list_papers (GtkPrinter *printer);
static GtkPageSetup * fallback_printer_get_default_page_size (GtkPrinter *printer);
static GtkPrintCapabilities fallback_printer_get_capabilities (GtkPrinter *printer);
@@ -494,7 +494,7 @@ fallback_printer_mark_conflicts (GtkPrinter *printer,
return FALSE;
}
-static void
+static gboolean
fallback_printer_get_hard_margins (GtkPrinter *printer,
gdouble *top,
gdouble *bottom,
@@ -505,6 +505,8 @@ fallback_printer_get_hard_margins (GtkPrinter *printer,
*bottom = 0;
*left = 0;
*right = 0;
+
+ return TRUE;
}
static GList *
diff --git a/gtk/gtkprintbackend.h b/gtk/gtkprintbackend.h
index c4b43b10d2..e19193ffdd 100644
--- a/gtk/gtkprintbackend.h
+++ b/gtk/gtkprintbackend.h
@@ -104,11 +104,11 @@ struct _GtkPrintBackendClass
GtkPageSetup *page_setup);
GList * (*printer_list_papers) (GtkPrinter *printer);
GtkPageSetup * (*printer_get_default_page_size) (GtkPrinter *printer);
- void (*printer_get_hard_margins) (GtkPrinter *printer,
- double *top,
- double *bottom,
- double *left,
- double *right);
+ gboolean (*printer_get_hard_margins) (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right);
GtkPrintCapabilities (*printer_get_capabilities) (GtkPrinter *printer);
/* Signals */
diff --git a/gtk/gtkprinter-private.h b/gtk/gtkprinter-private.h
index 39165bd9b5..a5786d0162 100644
--- a/gtk/gtkprinter-private.h
+++ b/gtk/gtkprinter-private.h
@@ -45,11 +45,6 @@ cairo_surface_t * _gtk_printer_create_cairo_surface (GtkPrinter
gdouble width,
gdouble height,
GIOChannel *cache_io);
-void _gtk_printer_get_hard_margins (GtkPrinter *printer,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right);
GHashTable * _gtk_printer_get_custom_widgets (GtkPrinter *printer);
/* GtkPrintJob private methods: */
diff --git a/gtk/gtkprinter.c b/gtk/gtkprinter.c
index 0e9fd77fc8..20cbfe2d25 100644
--- a/gtk/gtkprinter.c
+++ b/gtk/gtkprinter.c
@@ -951,12 +951,12 @@ gtk_printer_list_papers (GtkPrinter *printer)
/**
* gtk_printer_get_default_page_size:
* @printer: a #GtkPrinter
- *
+ *
* Returns default page size of @printer.
*
* Return value: a newly allocated #GtkPageSetup with default page size of the printer.
*
- * Since: 2.13
+ * Since: 2.14
*/
GtkPageSetup *
gtk_printer_get_default_page_size (GtkPrinter *printer)
@@ -969,16 +969,34 @@ gtk_printer_get_default_page_size (GtkPrinter *printer)
return backend_class->printer_get_default_page_size (printer);
}
-void
-_gtk_printer_get_hard_margins (GtkPrinter *printer,
- gdouble *top,
- gdouble *bottom,
- gdouble *left,
- gdouble *right)
+/**
+ * gtk_printer_get_hard_margins:
+ * @printer: a #GtkPrinter
+ * @top: a location to store the top margin in
+ * @bottom: a location to store the bottom margin in
+ * @left: a location to store the left margin in
+ * @right: a location to store the right margin in
+ *
+ * Retrieve the hard margins of @printer, i.e. the margins that define
+ * the area at the borders of the paper that the printer cannot print to.
+ *
+ * Note: This will not succeed unless the printer's details are available,
+ * see gtk_printer_has_details() and gtk_printer_request_details().
+ *
+ * Return value: %TRUE iff the hard margins were retrieved
+ *
+ * Since: 2.18
+ */
+gboolean
+gtk_printer_get_hard_margins (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right)
{
GtkPrintBackendClass *backend_class = GTK_PRINT_BACKEND_GET_CLASS (printer->priv->backend);
- backend_class->printer_get_hard_margins (printer, top, bottom, left, right);
+ return backend_class->printer_get_hard_margins (printer, top, bottom, left, right);
}
/**
@@ -993,7 +1011,7 @@ _gtk_printer_get_hard_margins (GtkPrinter *printer,
*
* This will return 0 unless the printer's details are available, see
* gtk_printer_has_details() and gtk_printer_request_details().
- * *
+ *
* Return value: the printer's capabilities
*
* Since: 2.12
diff --git a/gtk/gtkprinter.h b/gtk/gtkprinter.h
index a61cfc3fde..527582c95d 100644
--- a/gtk/gtkprinter.h
+++ b/gtk/gtkprinter.h
@@ -113,6 +113,11 @@ gint gtk_printer_compare (GtkPrinter *a,
gboolean gtk_printer_has_details (GtkPrinter *printer);
void gtk_printer_request_details (GtkPrinter *printer);
GtkPrintCapabilities gtk_printer_get_capabilities (GtkPrinter *printer);
+gboolean gtk_printer_get_hard_margins (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right);
typedef gboolean (*GtkPrinterFunc) (GtkPrinter *printer,
gpointer data);
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index 0bae98fac2..f98364aca9 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -158,11 +158,11 @@ static GtkPageSetup * cups_printer_get_default_page_size (GtkPrinter
static void cups_printer_request_details (GtkPrinter *printer);
static gboolean cups_request_default_printer (GtkPrintBackendCups *print_backend);
static gboolean cups_request_ppd (GtkPrinter *printer);
-static void cups_printer_get_hard_margins (GtkPrinter *printer,
- double *top,
- double *bottom,
- double *left,
- double *right);
+static gboolean cups_printer_get_hard_margins (GtkPrinter *printer,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right);
static GtkPrintCapabilities cups_printer_get_capabilities (GtkPrinter *printer);
static void set_option_from_settings (GtkPrinterOption *option,
GtkPrintSettings *setting);
@@ -4428,7 +4428,7 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
return create_page_setup (ppd_file, size);
}
-static void
+static gboolean
cups_printer_get_hard_margins (GtkPrinter *printer,
gdouble *top,
gdouble *bottom,
@@ -4439,12 +4439,14 @@ cups_printer_get_hard_margins (GtkPrinter *printer,
ppd_file = gtk_printer_cups_get_ppd (GTK_PRINTER_CUPS (printer));
if (ppd_file == NULL)
- return;
+ return FALSE;
*left = ppd_file->custom_margins[0];
*bottom = ppd_file->custom_margins[1];
*right = ppd_file->custom_margins[2];
*top = ppd_file->custom_margins[3];
+
+ return TRUE;
}
static GtkPrintCapabilities