mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
Allow getting the printer's hard margins
Adds a way to get the unprintable area of the printer. Bug #468989.
This commit is contained in:
parent
e81dacb8e3
commit
efa90e4182
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
@ -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 *
|
||||
|
@ -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 */
|
||||
|
@ -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: */
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user