[evince/wip/gpoo/gtk4-rebase-port: 54/65] ev-view: remove the children field of EvView
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/gtk4-rebase-port: 54/65] ev-view: remove the children field of EvView
- Date: Mon, 21 Mar 2022 02:57:03 +0000 (UTC)
commit 0a9a8461bee77269601a4d080d06137395969e4c
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date: Fri Aug 27 12:23:48 2021 +0800
ev-view: remove the children field of EvView
Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>
libview/ev-view-private.h | 3 ---
libview/ev-view.c | 57 +++++++++++++++++++++++++++--------------------
2 files changed, 33 insertions(+), 27 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 89fb79b14..a47147456 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -147,9 +147,6 @@ typedef struct {
struct _EvView {
GtkWidget parent;
- /* Container */
- GList *children;
-
EvDocument *document;
/* Find */
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 29fca5e16..6b9a37dd7 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -92,8 +92,6 @@ typedef enum {
} EvViewFindDirection;
typedef struct {
- GtkWidget *widget;
-
/* View coords */
gint x;
gint y;
@@ -1719,6 +1717,12 @@ ev_view_get_area_from_mapping (EvView *view,
area->y -= view->scroll_y;
}
+static void
+ev_child_free (EvViewChild *child)
+{
+ g_slice_free (EvViewChild, child);
+}
+
static void
ev_view_put (EvView *view,
GtkWidget *child_widget,
@@ -1731,14 +1735,15 @@ ev_view_put (EvView *view,
child = g_slice_new (EvViewChild);
- child->widget = child_widget;
child->x = x;
child->y = y;
child->page = page;
child->doc_rect = *doc_rect;
+ g_object_set_data_full (child_widget, "ev-child",
+ child, ev_child_free);
+
gtk_widget_set_parent (child_widget, GTK_WIDGET (view));
- view->children = g_list_append (view->children, child);
}
static void
@@ -4387,7 +4392,6 @@ ev_view_size_allocate (GtkWidget *widget,
int baseline)
{
EvView *view = EV_VIEW (widget);
- GList *l;
gint root_x, root_y;
if (!view->document)
@@ -4414,21 +4418,23 @@ ev_view_size_allocate (GtkWidget *widget,
view->pending_point.x = 0;
view->pending_point.y = 0;
- for (l = view->children; l && l->data; l = g_list_next (l)) {
+ for (GtkWidget *child = gtk_widget_get_first_child (widget);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child)) {
+ EvViewChild *data = g_object_get_data (child, "ev-child");
GdkRectangle view_area;
- EvViewChild *child = (EvViewChild *)l->data;
- if (!gtk_widget_get_visible (child->widget))
+ if (!data || !gtk_widget_get_visible (child))
continue;
- _ev_view_transform_doc_rect_to_view_rect (view, child->page, &child->doc_rect, &view_area);
+ _ev_view_transform_doc_rect_to_view_rect (view, data->page, &data->doc_rect, &view_area);
view_area.x -= view->scroll_x;
view_area.y -= view->scroll_y;
- gtk_widget_set_size_request (child->widget, view_area.width, view_area.height);
+ gtk_widget_set_size_request (child, view_area.width, view_area.height);
// TODO: this is a temporary solution to eliminate the warning
- gtk_widget_measure (child->widget, GTK_ORIENTATION_HORIZONTAL, view_area.width, NULL, NULL,
NULL, NULL);
- gtk_widget_size_allocate (child->widget, &view_area, baseline);
+ gtk_widget_measure (child, GTK_ORIENTATION_HORIZONTAL, view_area.width, NULL, NULL, NULL,
NULL);
+ gtk_widget_size_allocate (child, &view_area, baseline);
}
if (view->link_preview.popover)
@@ -4913,17 +4919,16 @@ static void ev_view_snapshot(GtkWidget *widget, GtkSnapshot *snapshot)
#endif
}
- for (GList *l = view->children; l && l->data; l = g_list_next (l)) {
- EvViewChild *child = (EvViewChild *)l->data;
-
- if (!gtk_widget_get_visible (child->widget))
+ for (GtkWidget *child = gtk_widget_get_first_child (widget);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child)) {
+ if (!gtk_widget_get_visible (child))
continue;
- gtk_widget_snapshot_child (GTK_WIDGET (view), child->widget, snapshot);
+ gtk_widget_snapshot_child (GTK_WIDGET (view), child, snapshot);
}
gtk_snapshot_pop (snapshot);
-
}
static void
@@ -8259,7 +8264,6 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
int dx = 0, dy = 0;
gdouble x, y;
gint value;
- GList *l;
GdkEvent *event;
gboolean cursor_updated;
@@ -8289,12 +8293,17 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
view->scroll_y = 0;
}
- for (l = view->children; l && l->data; l = g_list_next (l)) {
- EvViewChild *child = (EvViewChild *)l->data;
+ for (GtkWidget *child = gtk_widget_get_first_child (widget);
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child)) {
+ EvViewChild *data = g_object_get_data (child, "ev-child");
+
+ if (!data)
+ continue;
- child->x += dx;
- child->y += dy;
- if (gtk_widget_get_visible (child->widget) && gtk_widget_get_visible (widget))
+ data->x += dx;
+ data->y += dy;
+ if (gtk_widget_get_visible (child) && gtk_widget_get_visible (widget))
gtk_widget_queue_resize (widget);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]