[evince/wip/gpoo/gtk4-rebase-port: 5/89] libgd: Port GdTwoLinesRenderer to gtk4
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/gtk4-rebase-port: 5/89] libgd: Port GdTwoLinesRenderer to gtk4
- Date: Mon, 21 Mar 2022 01:11:28 +0000 (UTC)
commit bba22056eedf7b5859956cc4d3843131674707a3
Author: Germán Poo-Caamaño <gpoo gnome org>
Date: Sun Mar 20 21:57:22 2022 -0300
libgd: Port GdTwoLinesRenderer to gtk4
Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>
cut-n-paste/libgd/gd-two-lines-renderer.c | 34 +++++++++++++++++--------------
1 file changed, 19 insertions(+), 15 deletions(-)
---
diff --git a/cut-n-paste/libgd/gd-two-lines-renderer.c b/cut-n-paste/libgd/gd-two-lines-renderer.c
index f5e1ce53a..9c70b1c1a 100644
--- a/cut-n-paste/libgd/gd-two-lines-renderer.c
+++ b/cut-n-paste/libgd/gd-two-lines-renderer.c
@@ -92,6 +92,7 @@ apply_subtitle_style_to_layout (GtkStyleContext *context,
PangoAttrList *layout_attr;
PangoAttribute *attr_alpha;
+#if 0
gtk_style_context_save (context);
gtk_style_context_set_state (context, flags);
gtk_style_context_get (context, gtk_style_context_get_state (context),
@@ -104,6 +105,7 @@ apply_subtitle_style_to_layout (GtkStyleContext *context,
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
+#endif
/* Set the font alpha */
layout_attr = pango_attr_list_new ();
attr_alpha = pango_attr_foreground_alpha_new (SUBTITLE_DIM_PERCENTAGE * 65535);
@@ -275,12 +277,12 @@ gd_two_lines_renderer_get_size (GtkCellRenderer *cell,
}
static void
-gd_two_lines_renderer_render (GtkCellRenderer *cell,
- cairo_t *cr,
- GtkWidget *widget,
- const GdkRectangle *background_area,
- const GdkRectangle *cell_area,
- GtkCellRendererState flags)
+gd_two_lines_renderer_snapshot (GtkCellRenderer *cell,
+ GtkSnapshot *snapshot,
+ GtkWidget *widget,
+ const GdkRectangle *background_area,
+ const GdkRectangle *cell_area,
+ GtkCellRendererState flags)
{
GdTwoLinesRenderer *self = GD_TWO_LINES_RENDERER (cell);
GtkStyleContext *context;
@@ -312,10 +314,10 @@ gd_two_lines_renderer_render (GtkCellRenderer *cell,
render_area.x += x_offset_1 - layout_rect.x;
render_area.y += y_offset;
- gtk_render_layout (context, cr,
- render_area.x,
- render_area.y,
- layout_one);
+ gtk_snapshot_render_layout (snapshot, context,
+ render_area.x,
+ render_area.y,
+ layout_one);
/* render the second layout */
if (layout_two != NULL)
@@ -336,10 +338,10 @@ gd_two_lines_renderer_render (GtkCellRenderer *cell,
render_area.x += x_offset_2 - layout_rect.x;
render_area.y += y_offset + line_one_height;
- gtk_render_layout (context, cr,
- render_area.x,
- render_area.y,
- layout_two);
+ gtk_snapshot_render_layout (snapshot, context,
+ render_area.x,
+ render_area.y,
+ layout_two);
gtk_style_context_restore (context);
}
@@ -378,6 +380,7 @@ gd_two_lines_renderer_get_preferred_width (GtkCellRenderer *cell,
/* Fetch the average size of a character */
context = gtk_widget_get_pango_context (widget);
+#if 0
gtk_style_context_save (style_context);
gtk_style_context_set_state (style_context, 0);
gtk_style_context_get (style_context, gtk_style_context_get_state (style_context),
@@ -390,6 +393,7 @@ gd_two_lines_renderer_get_preferred_width (GtkCellRenderer *cell,
pango_font_metrics_unref (metrics);
pango_font_description_free (font_desc);
+#endif
/* enforce minimum width for ellipsized labels at ~3 chars */
ellipsize_chars = 3;
@@ -593,7 +597,7 @@ gd_two_lines_renderer_class_init (GdTwoLinesRendererClass *klass)
GtkCellRendererClass *cclass = GTK_CELL_RENDERER_CLASS (klass);
GObjectClass *oclass = G_OBJECT_CLASS (klass);
- cclass->render = gd_two_lines_renderer_render;
+ cclass->snapshot = gd_two_lines_renderer_snapshot;
cclass->get_preferred_width = gd_two_lines_renderer_get_preferred_width;
cclass->get_preferred_height = gd_two_lines_renderer_get_preferred_height;
cclass->get_preferred_height_for_width = gd_two_lines_renderer_get_preferred_height_for_width;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]