From 360a89e080197f6ea68ee7156dbac72db252f344 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Jadi?= Date: Tue, 16 Jul 2013 19:39:19 +0200 Subject: [PATCH] * src/xwidget.c (Fxwidget_view_lookup): Bring `xwidget-view-lookup' to the Lisp side. (xwidget_view_lookup): `xwidget_view_lookup' is just a wrapper around `xwidget-view-lookup' to convert from `struct *' to `Lisp_Object'. --- src/xwidget.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/xwidget.c b/src/xwidget.c index e716308e27f..fcebc85bba1 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -1545,6 +1545,28 @@ DEFUN("xwidget-delete-zombies", Fxwidget_delete_zombies , Sxwidget_delete_zombie } } +DEFUN ("xwidget-view-lookup", Fxwidget_view_lookup, Sxwidget_view_lookup, + 1, 2, 0, + doc: /* Return the xwidget-view associated to XWIDGET in +WINDOW if specified, otherwise it uses the selected window. */) + (Lisp_Object xwidget, Lisp_Object window) +{ + CHECK_XWIDGET (xwidget); + + if (NILP (window)) + window = Fselected_window(); + CHECK_WINDOW (window); + + for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail); tail = XCDR (tail)) + { + Lisp_Object xwidget_view = XCAR (tail); + if (EQ (Fxwidget_view_model (xwidget_view), xwidget) + && EQ (Fxwidget_view_window (xwidget_view), window)) + return xwidget_view; + } + + return Qnil; +} DEFUN ("xwidget-plist", Fxwidget_plist, Sxwidget_plist, 1, 1, 0, @@ -1592,6 +1614,7 @@ syms_of_xwidget (void) defsubr (&Sget_buffer_xwidgets); defsubr (&Sxwidget_view_model); defsubr (&Sxwidget_view_window); + defsubr (&Sxwidget_view_lookup); #ifdef HAVE_WEBKIT_OSR defsubr (&Sxwidget_webkit_goto_uri); @@ -1721,21 +1744,16 @@ xwidget_view_delete_all_in_window (struct window *w) } } - - struct xwidget_view* xwidget_view_lookup (struct xwidget* xw, struct window *w) { - struct xwidget_view* xv = NULL; - for (Lisp_Object tail = Vxwidget_view_list; CONSP (tail); tail = XCDR (tail)) - { - if (XWIDGET_VIEW_P (XCAR (tail))) { - xv = XXWIDGET_VIEW (XCAR (tail)); - if (XXWIDGET (xv->model) == xw && XWINDOW (xv->w) == w) - return xv; - } - } - return NULL; /* we didnt find a matching view */ + Lisp_Object xwidget, window, ret; + XSETXWIDGET (xwidget, xw); + XSETWINDOW (window, w); + + ret = Fxwidget_view_lookup (xwidget, window); + + return EQ (ret, Qnil) ? NULL : XXWIDGET_VIEW (ret); } struct xwidget* -- 2.39.2