[gtk/deprecate-render: 38/48] printunixdialog: Stop using gtk_style_context_save_to_node




commit 88ea33cc7eca9f9c127fae4929d566c8ca98f237
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 8 23:25:39 2022 -0400

    printunixdialog: Stop using gtk_style_context_save_to_node

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]