summaryrefslogtreecommitdiff
path: root/gtk/gtkprintcontext.c
diff options
context:
space:
mode:
authorecyrbe <ecyrbe@gmail.com>2009-12-05 13:23:44 +0100
committerCarlos Garcia Campos <carlosgc@gnome.org>2009-12-05 13:23:44 +0100
commitbe686e2badb5cdfdaed7df2cac9ff3b3fb793056 (patch)
tree17f253943781f07cfd0531770330178dc084eca0 /gtk/gtkprintcontext.c
parentdb30c79dac4d72c267d7cc74da2c38018aa50f9f (diff)
downloadgtk+-be686e2badb5cdfdaed7df2cac9ff3b3fb793056.tar.gz
Bring GtkPrintContext hard margin aware
See bug #468989.
Diffstat (limited to 'gtk/gtkprintcontext.c')
-rw-r--r--gtk/gtkprintcontext.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/gtk/gtkprintcontext.c b/gtk/gtkprintcontext.c
index 80eac79fa7..cdf04d7c2f 100644
--- a/gtk/gtkprintcontext.c
+++ b/gtk/gtkprintcontext.c
@@ -44,6 +44,13 @@ struct _GtkPrintContext
gdouble pixels_per_unit_x;
gdouble pixels_per_unit_y;
+
+ gboolean has_hard_margins;
+ gdouble hard_margin_top;
+ gdouble hard_margin_bottom;
+ gdouble hard_margin_left;
+ gdouble hard_margin_right;
+
};
struct _GtkPrintContextClass
@@ -90,6 +97,7 @@ _gtk_print_context_new (GtkPrintOperation *op)
context->op = op;
context->cr = NULL;
+ context->has_hard_margins = FALSE;
return context;
}
@@ -374,6 +382,62 @@ gtk_print_context_get_dpi_y (GtkPrintContext *context)
}
/**
+ * gtk_print_context_get_hard_margins:
+ * @context: a #GtkPrintContext
+ * @top: top hardware printer margin
+ * @bottom: bottom hardware printer margin
+ * @left: left hardware printer margin
+ * @right: right hardware printer margin
+ *
+ * Obtains the hardware printer margins of the #GtkPrintContext, in units.
+ *
+ * Return value: %TRUE if the hard margins were retrieved
+ *
+ * Since: 2.20
+ */
+gboolean
+gtk_print_context_get_hard_margins (GtkPrintContext *context,
+ gdouble *top,
+ gdouble *bottom,
+ gdouble *left,
+ gdouble *right)
+{
+ if (context->has_hard_margins)
+ {
+ *top = context->hard_margin_top / context->pixels_per_unit_y;
+ *bottom = context->hard_margin_bottom / context->pixels_per_unit_y;
+ *left = context->hard_margin_left / context->pixels_per_unit_x;
+ *right = context->hard_margin_right / context->pixels_per_unit_x;
+ }
+
+ return context->has_hard_margins;
+}
+
+/**
+ * gtk_print_context_set_hard_margins:
+ * @context: a #GtkPrintContext
+ * @top: top hardware printer margin
+ * @bottom: bottom hardware printer margin
+ * @left: left hardware printer margin
+ * @right: right hardware printer margin
+ *
+ * set the hard margins in pixel coordinates
+ */
+void
+_gtk_print_context_set_hard_margins (GtkPrintContext *context,
+ gdouble top,
+ gdouble bottom,
+ gdouble left,
+ gdouble right)
+{
+ context->hard_margin_top = top;
+ context->hard_margin_bottom = bottom;
+ context->hard_margin_left = left;
+ context->hard_margin_right = right;
+ context->has_hard_margins = TRUE;
+}
+
+/**
* gtk_print_context_get_pango_fontmap:
* @context: a #GtkPrintContext
*