diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-10-08 15:30:29 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-10-12 15:35:00 -0400 |
commit | 381f863a183976c53873200ac911adbafad2d5a2 (patch) | |
tree | 410628918811b5508f40cb74dff3387c969d82cd /gtk/gtklabel.c | |
parent | 57c63d9ce78ccd249f3cb0e313e7607a0fb316d8 (diff) | |
download | gtk+-381f863a183976c53873200ac911adbafad2d5a2.tar.gz |
label: Stop using gtk_snapshot_render api
The gtk_snapshot_render api is deprecated, so avoid using it.
Diffstat (limited to 'gtk/gtklabel.c')
-rw-r--r-- | gtk/gtklabel.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 586aad8cd9..cd548b0960 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -41,7 +41,10 @@ #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 |