+
+ if (page_setup != NULL)
+ {
+ pos_x += 1;
+ pos_y += 1;
+
+ if (pages_per_sheet == 2 || pages_per_sheet == 6)
+ {
+ paper_width = gtk_page_setup_get_paper_height (page_setup, _gtk_print_get_default_user_units ());
+ paper_height = gtk_page_setup_get_paper_width (page_setup, _gtk_print_get_default_user_units ());
+ }
+ else
+ {
+ paper_width = gtk_page_setup_get_paper_width (page_setup, _gtk_print_get_default_user_units ());
+ paper_height = gtk_page_setup_get_paper_height (page_setup, _gtk_print_get_default_user_units ());
+ }
+
+ cairo_restore (cr);
+ cairo_save (cr);
+
+ layout = pango_cairo_create_layout (cr);
+
+ font = pango_font_description_new ();
+ pango_font_description_set_family (font, "sans");
+
+ PangoContext *pango_c = NULL;
+ PangoFontDescription *pango_f = NULL;
+ gint font_size = 12 * PANGO_SCALE;
+
+ pango_c = gtk_widget_get_pango_context (widget);
+ if (pango_c != NULL)
+ {
+ pango_f = pango_context_get_font_description (pango_c);
+ if (pango_f != NULL)
+ font_size = pango_font_description_get_size (pango_f);
+ }
+
+ pango_font_description_set_size (font, font_size);
+ pango_layout_set_font_description (layout, font);
+ pango_font_description_free (font);
+
+ pango_layout_set_width (layout, -1);
+ pango_layout_set_alignment (layout, PANGO_ALIGN_CENTER);
+
+ if (_gtk_print_get_default_user_units () == GTK_UNIT_MM)
+ text = g_strdup_printf ("%.1f mm", paper_height);
+ else
+ text = g_strdup_printf ("%.2f inch", paper_height);
+
+ pango_layout_set_text (layout, text, -1);
+ g_free (text);
+ pango_layout_get_size (layout, &layout_w, &layout_h);
+
+ ltr = gtk_widget_get_direction (GTK_WIDGET (dialog)) == GTK_TEXT_DIR_LTR;
+
+ if (ltr)
+ cairo_translate (cr, pos_x - layout_w / PANGO_SCALE - 2 * RULER_DISTANCE,
+ (height - layout_h / PANGO_SCALE) / 2);
+ else
+ cairo_translate (cr, pos_x + w + shadow_offset + 2 * RULER_DISTANCE,
+ (height - layout_h / PANGO_SCALE) / 2);
+
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_restore (cr);
+ cairo_save (cr);
+
+ if (_gtk_print_get_default_user_units () == GTK_UNIT_MM)
+ text = g_strdup_printf ("%.1f mm", paper_width);
+ else
+ text = g_strdup_printf ("%.2f inch", paper_width);
+
+ pango_layout_set_text (layout, text, -1);
+ g_free (text);
+ pango_layout_get_size (layout, &layout_w, &layout_h);
+
+ cairo_translate (cr, (width - layout_w / PANGO_SCALE) / 2,
+ pos_y + h + shadow_offset + 2 * RULER_DISTANCE);
+
+ pango_cairo_show_layout (cr, layout);
+
+ g_object_unref (layout);
+
+ cairo_restore (cr);
+
+ cairo_set_line_width (cr, 1);
+
+ if (ltr)
+ {
+ cairo_move_to (cr, pos_x - RULER_DISTANCE, pos_y);
+ cairo_line_to (cr, pos_x - RULER_DISTANCE, pos_y + h);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x - RULER_DISTANCE - RULER_RADIUS, pos_y - 0.5);
+ cairo_line_to (cr, pos_x - RULER_DISTANCE + RULER_RADIUS, pos_y - 0.5);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x - RULER_DISTANCE - RULER_RADIUS, pos_y + h + 0.5);
+ cairo_line_to (cr, pos_x - RULER_DISTANCE + RULER_RADIUS, pos_y + h + 0.5);
+ cairo_stroke (cr);
+ }
+ else
+ {
+ cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE, pos_y);
+ cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE, pos_y + h);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE - RULER_RADIUS, pos_y - 0.5);
+ cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE + RULER_RADIUS, pos_y - 0.5);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE - RULER_RADIUS, pos_y + h + 0.5);
+ cairo_line_to (cr, pos_x + w + shadow_offset + RULER_DISTANCE + RULER_RADIUS, pos_y + h + 0.5);
+ cairo_stroke (cr);
+ }
+
+ cairo_move_to (cr, pos_x, pos_y + h + shadow_offset + RULER_DISTANCE);
+ cairo_line_to (cr, pos_x + w, pos_y + h + shadow_offset + RULER_DISTANCE);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x - 0.5, pos_y + h + shadow_offset + RULER_DISTANCE - RULER_RADIUS);
+ cairo_line_to (cr, pos_x - 0.5, pos_y + h + shadow_offset + RULER_DISTANCE + RULER_RADIUS);
+ cairo_stroke (cr);
+
+ cairo_move_to (cr, pos_x + w + 0.5, pos_y + h + shadow_offset + RULER_DISTANCE - RULER_RADIUS);
+ cairo_line_to (cr, pos_x + w + 0.5, pos_y + h + shadow_offset + RULER_DISTANCE + RULER_RADIUS);
+ cairo_stroke (cr);
+ }
+
+ gtk_style_context_restore (context);