label: Stop using gtk_snapshot_render api
authorMatthias Clasen <mclasen@redhat.com>
Sat, 8 Oct 2022 19:30:29 +0000 (15:30 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 12 Oct 2022 19:35:00 +0000 (15:35 -0400)
The gtk_snapshot_render api is deprecated, so avoid using it.

gtk/gtklabel.c

index 586aad8cd989ae1fb122a0e9eca17f4512553c1e..cd548b096007c7dd11f0791c4ad1a0f1654ed3a4 100644 (file)
 #include "gtkshortcutcontroller.h"
 #include "gtkshortcuttrigger.h"
 #include "gtkshow.h"
-#include "deprecated/gtkrender.h"
+#include "gtksnapshot.h"
+#include "gtkrenderbackgroundprivate.h"
+#include "gtkrenderborderprivate.h"
+#include "gtkrenderlayoutprivate.h"
 #include "gtkstylecontextprivate.h"
 #include "gtktextutilprivate.h"
 #include "gtktooltip.h"
@@ -1381,8 +1384,8 @@ gtk_label_snapshot (GtkWidget   *widget,
   GtkStyleContext *context;
   int lx, ly;
   int width, height;
+  GtkCssBoxes boxes;
 
-G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   if (!self->text || (*self->text == '\0'))
     return;
 
@@ -1391,7 +1394,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   context = _gtk_widget_get_style_context (widget);
   get_layout_location (self, &lx, &ly);
 
-  gtk_snapshot_render_layout (snapshot, context, lx, ly, self->layout);
+  gtk_css_boxes_init (&boxes, widget);
+  gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
 
   info = self->select_info;
   if (!info)
@@ -1412,14 +1416,18 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
       gtk_style_context_save_to_node (context, info->selection_node);
 
+      gtk_css_boxes_init_border_box (&boxes,
+                                     gtk_style_context_lookup_style (context),
+                                     0, 0, width, height);
+
       range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
       for (i = 0; i < cairo_region_num_rectangles (range_clip); i++)
         {
           cairo_region_get_rectangle (range_clip, i, &clip_rect);
 
           gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_FROM_RECT (&clip_rect));
-          gtk_snapshot_render_background (snapshot, context, 0, 0, width, height);
-          gtk_snapshot_render_layout (snapshot, context, lx, ly, self->layout);
+          gtk_css_style_snapshot_background (&boxes, snapshot);
+          gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
           gtk_snapshot_pop (snapshot);
         }
 
@@ -1444,10 +1452,12 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
           PangoDirection cursor_direction;
 
           cursor_direction = get_cursor_direction (self);
-          gtk_snapshot_render_insertion_cursor (snapshot, context,
-                                                lx, ly,
-                                                self->layout, self->select_info->selection_end,
-                                                cursor_direction);
+          gtk_css_style_snapshot_caret (&boxes, gtk_widget_get_display (widget),
+                                        snapshot,
+                                        lx, ly,
+                                        self->layout,
+                                        self->select_info->selection_end,
+                                        cursor_direction);
         }
 
       focus_link = gtk_label_get_focus_link (self, NULL);
@@ -1460,14 +1470,18 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
           gtk_style_context_save_to_node (context, active_link->cssnode);
 
+          gtk_css_boxes_init_border_box (&boxes,
+                                         gtk_style_context_lookup_style (context),
+                                         0, 0, width, height);
+
           range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
           for (i = 0; i < cairo_region_num_rectangles (range_clip); i++)
             {
               cairo_region_get_rectangle (range_clip, i, &clip_rect);
 
               gtk_snapshot_push_clip (snapshot, &GRAPHENE_RECT_FROM_RECT (&clip_rect));
-              gtk_snapshot_render_background (snapshot, context, 0, 0, width, height);
-              gtk_snapshot_render_layout (snapshot, context, lx, ly, self->layout);
+              gtk_css_style_snapshot_background (&boxes, snapshot);
+              gtk_css_style_snapshot_layout (&boxes, snapshot, lx, ly, self->layout);
               gtk_snapshot_pop (snapshot);
             }
 
@@ -1486,14 +1500,16 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
           range_clip = gdk_pango_layout_get_clip_region (self->layout, lx, ly, range, 1);
           cairo_region_get_extents (range_clip, &rect);
 
-          gtk_snapshot_render_focus (snapshot, context, rect.x, rect.y, rect.width, rect.height);
+          gtk_css_boxes_init_border_box (&boxes,
+                                         gtk_style_context_lookup_style (context),
+                                         rect.x, rect.y, rect.width, rect.height);
+          gtk_css_style_snapshot_outline (&boxes, snapshot);
 
           cairo_region_destroy (range_clip);
 
           gtk_style_context_restore (context);
         }
     }
-G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static GtkSizeRequestMode