printunixdialog: Stop using gtk_style_context_save_to_node

This commit is contained in:
Matthias Clasen 2022-10-08 23:25:39 -04:00
parent bf9f362597
commit 50ab2386ec

View File

@ -53,8 +53,8 @@
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtktypebuiltins.h" #include "gtktypebuiltins.h"
#include "gtkdialogprivate.h" #include "gtkdialogprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkwidgetprivate.h" #include "gtkwidgetprivate.h"
#include "gtkcsscolorvalueprivate.h"
/** /**
@ -1952,7 +1952,7 @@ paint_page (GtkPrintUnixDialog *dialog,
const char *text, const char *text,
int text_x) int text_x)
{ {
GtkStyleContext *context; GtkCssStyle *style;
int width, height; int width, height;
int text_y; int text_y;
GdkRGBA color; GdkRGBA color;
@ -1964,13 +1964,10 @@ paint_page (GtkPrintUnixDialog *dialog,
height = 26; height = 26;
text_y = 21; text_y = 21;
context = gtk_widget_get_style_context (widget); style = gtk_css_node_get_style (dialog->collate_paper_node);
gtk_style_context_save_to_node (context, dialog->collate_paper_node);
snapshot = gtk_snapshot_new (); snapshot = gtk_snapshot_new ();
gtk_css_boxes_init_border_box (&boxes, gtk_css_boxes_init_border_box (&boxes, style, x, y, width, height);
gtk_style_context_lookup_style (context),
x, y, width, height);
gtk_css_style_snapshot_background (&boxes, snapshot); gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot); gtk_css_style_snapshot_border (&boxes, snapshot);
@ -1981,8 +1978,8 @@ paint_page (GtkPrintUnixDialog *dialog,
gsk_render_node_unref (node); gsk_render_node_unref (node);
} }
gtk_style_context_get_color (context, &color); color = *gtk_css_color_value_get_rgba (style->core->color);
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); gdk_cairo_set_source_rgba (cr, &color);
cairo_select_font_face (cr, "Sans", cairo_select_font_face (cr, "Sans",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_SLANT_NORMAL,
@ -1990,8 +1987,6 @@ paint_page (GtkPrintUnixDialog *dialog,
cairo_set_font_size (cr, 9); cairo_set_font_size (cr, 9);
cairo_move_to (cr, x + text_x, y + text_y); cairo_move_to (cr, x + text_x, y + text_y);
cairo_show_text (cr, text); cairo_show_text (cr, text);
gtk_style_context_restore (context);
} }
static void static void
@ -2389,7 +2384,7 @@ draw_page (GtkDrawingArea *da,
{ {
GtkWidget *widget = GTK_WIDGET (da); GtkWidget *widget = GTK_WIDGET (da);
GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (data); GtkPrintUnixDialog *dialog = GTK_PRINT_UNIX_DIALOG (data);
GtkStyleContext *context; GtkCssStyle *style;
double ratio; double ratio;
int w, h, tmp; int w, h, tmp;
int pages_x, pages_y, i, x, y, layout_w, layout_h; int pages_x, pages_y, i, x, y, layout_w, layout_h;
@ -2498,18 +2493,15 @@ draw_page (GtkDrawingArea *da,
pages_y = tmp; pages_y = tmp;
} }
context = gtk_widget_get_style_context (widget); style = gtk_css_node_get_style (dialog->page_layout_paper_node);
gtk_style_context_save_to_node (context, dialog->page_layout_paper_node); color = *gtk_css_color_value_get_rgba (style->core->color);
gtk_style_context_get_color (context, &color);
pos_x = (width - w) / 2; pos_x = (width - w) / 2;
pos_y = (height - h) / 2 - 10; pos_y = (height - h) / 2 - 10;
cairo_translate (cr, pos_x, pos_y); cairo_translate (cr, pos_x, pos_y);
snapshot = gtk_snapshot_new (); snapshot = gtk_snapshot_new ();
gtk_css_boxes_init_border_box (&boxes, gtk_css_boxes_init_border_box (&boxes, style, 1, 1, w, h);
gtk_style_context_lookup_style (context),
1, 1, w, h);
gtk_css_style_snapshot_background (&boxes, snapshot); gtk_css_style_snapshot_background (&boxes, snapshot);
gtk_css_style_snapshot_border (&boxes, snapshot); gtk_css_style_snapshot_border (&boxes, snapshot);
@ -2620,7 +2612,7 @@ draw_page (GtkDrawingArea *da,
break; break;
} }
cairo_set_source_rgba (cr, color.red, color.green, color.blue, color.alpha); gdk_cairo_set_source_rgba (cr, &color);
if (horizontal) if (horizontal)
for (y = start_y; y != end_y + dy; y += dy) for (y = start_y; y != end_y + dy; y += dy)
{ {
@ -2660,9 +2652,8 @@ draw_page (GtkDrawingArea *da,
g_object_unref (layout); g_object_unref (layout);
gtk_style_context_restore (context); style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
color = *gtk_css_color_value_get_rgba (style->core->color);
gtk_style_context_get_color (context, &color);
if (page_setup != NULL) if (page_setup != NULL)
{ {