Adds a way to get the unprintable area of the printer. Bug #468989.
gtk_printer_request_details
gtk_printer_get_capabilities
gtk_printer_get_default_page_size
+gtk_printer_get_hard_margins
GtkPrinterFunc
gtk_enumerate_printers
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
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));
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);
return FALSE;
}
-static void
+static gboolean
fallback_printer_get_hard_margins (GtkPrinter *printer,
gdouble *top,
gdouble *bottom,
*bottom = 0;
*left = 0;
*right = 0;
+
+ return TRUE;
}
static GList *
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 */
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: */
/**
* 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)
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);
}
/**
*
* 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
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);
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);
return create_page_setup (ppd_file, size);
}
-static void
+static gboolean
cups_printer_get_hard_margins (GtkPrinter *printer,
gdouble *top,
gdouble *bottom,
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