[gtk/print-dialog-fixes: 1/4] print dialog: Fix up page drawing
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/print-dialog-fixes: 1/4] print dialog: Fix up page drawing
- Date: Tue, 24 Dec 2019 17:34:58 +0000 (UTC)
commit 28539ba8388ec46dcca8aa93a247498ef4e4ad8d
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 24 12:28:00 2019 -0500
print dialog: Fix up page drawing
This fixes up page drawing enough to appear properly
with the builtin themes.
gtk/gtkprintunixdialog.c | 50 +++++++++++++++++++++++-------------------------
1 file changed, 24 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index f59e85afae..4028aedde5 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -2237,6 +2237,7 @@ paint_page (GtkWidget *widget,
GtkStyleContext *context;
gint width, height;
gint text_y;
+ GdkRGBA color;
width = 20;
height = 26;
@@ -2248,6 +2249,9 @@ paint_page (GtkWidget *widget,
gtk_render_background (context, cr, x, y, width, height);
gtk_render_frame (context, cr, x, y, width, height);
+ gtk_style_context_get_color (context, &color);
+ cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha);
+
cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
@@ -2703,7 +2707,7 @@ draw_page (GtkDrawingArea *da,
GtkPrintUnixDialogPrivate *priv = gtk_print_unix_dialog_get_instance_private (dialog);
GtkStyleContext *context;
gdouble ratio;
- gint w, h, tmp, shadow_offset;
+ gint w, h, tmp;
gint pages_x, pages_y, i, x, y, layout_w, layout_h;
gdouble page_width, page_height;
GtkPageOrientation orientation;
@@ -2815,18 +2819,10 @@ draw_page (GtkDrawingArea *da,
pos_y = (height - h) / 2 - 10;
cairo_translate (cr, pos_x, pos_y);
- shadow_offset = 3;
-
- cairo_set_source_rgba (cr, color.red, color.green, color.blue, 0.5);
- cairo_rectangle (cr, shadow_offset + 1, shadow_offset + 1, w, h);
- cairo_fill (cr);
-
gtk_render_background (context, cr, 1, 1, w, h);
+ gtk_render_frame (context, cr, 1, 1, w, h);
cairo_set_line_width (cr, 1.0);
- cairo_rectangle (cr, 0.5, 0.5, w + 1, h + 1);
- gdk_cairo_set_source_rgba (cr, &color);
- cairo_stroke (cr);
i = 1;
@@ -2965,6 +2961,10 @@ draw_page (GtkDrawingArea *da,
g_object_unref (layout);
+ gtk_style_context_restore (context);
+
+ gtk_style_context_get_color (context, &color);
+
if (page_setup != NULL)
{
PangoContext *pango_c = NULL;
@@ -3023,7 +3023,7 @@ draw_page (GtkDrawingArea *da,
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,
+ cairo_translate (cr, pos_x + w + 2 * RULER_DISTANCE,
(height - layout_h / PANGO_SCALE) / 2);
gdk_cairo_set_source_rgba (cr, &color);
@@ -3042,7 +3042,7 @@ draw_page (GtkDrawingArea *da,
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);
+ pos_y + h + 2 * RULER_DISTANCE);
gdk_cairo_set_source_rgba (cr, &color);
pango_cairo_show_layout (cr, layout);
@@ -3071,33 +3071,31 @@ draw_page (GtkDrawingArea *da,
}
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_move_to (cr, pos_x + w + RULER_DISTANCE, pos_y);
+ cairo_line_to (cr, pos_x + w + 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_move_to (cr, pos_x + w + RULER_DISTANCE - RULER_RADIUS, pos_y - 0.5);
+ cairo_line_to (cr, pos_x + w + 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_move_to (cr, pos_x + w + RULER_DISTANCE - RULER_RADIUS, pos_y + h + 0.5);
+ cairo_line_to (cr, pos_x + w + 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_move_to (cr, pos_x, pos_y + h + RULER_DISTANCE);
+ cairo_line_to (cr, pos_x + w, pos_y + h + 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_move_to (cr, pos_x - 0.5, pos_y + h + RULER_DISTANCE - RULER_RADIUS);
+ cairo_line_to (cr, pos_x - 0.5, pos_y + h + 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_move_to (cr, pos_x + w + 0.5, pos_y + h + RULER_DISTANCE - RULER_RADIUS);
+ cairo_line_to (cr, pos_x + w + 0.5, pos_y + h + RULER_DISTANCE + RULER_RADIUS);
cairo_stroke (cr);
}
-
- gtk_style_context_restore (context);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]