[evince/wip/gpoo/gtk4-rebase-port: 50/65] ev-view: reuse the GtkWidget child API
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/wip/gpoo/gtk4-rebase-port: 50/65] ev-view: reuse the GtkWidget child API
- Date: Mon, 21 Mar 2022 02:57:03 +0000 (UTC)
commit 171e3d08aae68bae8586fdf19b357cfb50fc6f3d
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date: Fri Aug 27 11:17:30 2021 +0800
ev-view: reuse the GtkWidget child API
Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>
libview/ev-view.c | 47 +++++++++++++++++++++++++----------------------
1 file changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 575a4afad..0278d8b2c 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -3095,16 +3095,15 @@ static gboolean
ev_view_find_player_for_media (EvView *view,
EvMedia *media)
{
- GList *l;
-
- for (l = view->children; l; l = g_list_next (l)) {
- EvViewChild *child = (EvViewChild *)l->data;
-
- //if (!EV_IS_MEDIA_PLAYER (child->widget))
- // continue;
+ for (GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (view));
+ child != NULL;
+ child = gtk_widget_get_next_sibling (child))
+ {
+ if (!GTK_IS_VIDEO (child))
+ continue;
- //if (ev_media_player_get_media (EV_MEDIA_PLAYER (child->widget)) == media)
- // return TRUE;
+ if (g_object_get_data (child, "media") == media)
+ return TRUE;
}
return FALSE;
@@ -3134,13 +3133,16 @@ ev_view_handle_media (EvView *view,
gtk_video_set_autoplay (player, TRUE);
g_object_unref (uri);
+ g_object_set_data_full (player, "media",
+ g_object_ref (media),
+ (GDestroyNotify)g_object_unref);
+
mapping = ev_mapping_list_find (media_mapping, media);
_ev_view_transform_doc_rect_to_view_rect (view, page, &mapping->area, &render_area);
render_area.x -= view->scroll_x;
render_area.y -= view->scroll_y;
ev_view_put (view, player, render_area.x, render_area.y, page, &mapping->area);
- gtk_widget_show (player);
}
/* Annotations */
@@ -5767,18 +5769,19 @@ on_middle_clicked_drag_update (GtkGestureDrag *self,
view->drag_info.buffer[0].y = y;
}
-static void remove_ev_view_child (EvViewChild *child)
-{
- gtk_widget_unparent (child->widget);
- g_slice_free (EvViewChild, child);
-}
-
static void
ev_view_remove_all_form_fields (EvView *view)
{
- g_list_free_full (view->children, remove_ev_view_child);
- view->children = NULL;
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ GtkWidget *child = gtk_widget_get_first_child (GTK_WIDGET (view));
+
+ while (child != NULL) {
+ GtkWidget *next = gtk_widget_get_next_sibling (child);
+
+ if (g_object_get_data (child, "form-field"))
+ gtk_widget_unparent (child);
+
+ child = next;
+ }
}
#if 0
@@ -7808,13 +7811,13 @@ ev_view_focus_next (EvView *view,
g_list_free (elements);
if (focus_element) {
- //ev_view_remove_all_form_fields (view);
- //_ev_view_focus_form_field (view, EV_FORM_FIELD (focus_element->data));
+ ev_view_remove_all_form_fields (view);
+ _ev_view_focus_form_field (view, EV_FORM_FIELD (focus_element->data));
return TRUE;
}
- //ev_view_remove_all_form_fields (view);
+ ev_view_remove_all_form_fields (view);
_ev_view_set_focused_element (view, NULL, -1);
/* Only try to move the focus to next/previous pages when the current page had
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]