From d65ea7dd1d4aa93a44c39a44d0e79fca6e912690 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Jadi?= Date: Mon, 24 Jun 2013 10:22:45 +0200 Subject: [PATCH] * src/xwidget.c (Fmake_xwidget): Store xwidget in Vxwidget_list. (syms_of_xwidget): Rename Vxwidget_alist to Vxwidget_list and register `get-buffer-xwidgets' as a new subr. (Fget_buffer_xwidgets): New function to return a list of xwidgets attached to the specified buffer. --- src/xwidget.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/xwidget.c b/src/xwidget.c index a73710479d7..ed7ea98fb42 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -216,7 +216,7 @@ TYPE is a symbol which can take one of the following values: xw->height = XFASTINT(height); xw->width = XFASTINT(width); XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); // set the vectorlike_header of VAL with the correct value - Vxwidget_alist = Fcons (val, Vxwidget_alist); + Vxwidget_list = Fcons (val, Vxwidget_list); xw->widgetwindow_osr = NULL; xw->widget_osr = NULL; xw->plist = Qnil; @@ -302,6 +302,30 @@ TYPE is a symbol which can take one of the following values: return val; } +DEFUN ("get-buffer-xwidgets", Fget_buffer_xwidgets, Sget_buffer_xwidgets, 1, 1, 0, + doc: /* Return the xwidgets associated with BUFFER. +BUFFER may be a buffer or the name of one. + */ + ) + (Lisp_Object buffer) +{ + Lisp_Object xw, tail, xw_list; + + if (NILP (buffer)) return Qnil; + buffer = Fget_buffer (buffer); + if (NILP (buffer)) return Qnil; + + xw_list = Qnil; + + for (tail = Vxwidget_list; CONSP (tail); tail = XCDR (tail)) + { + xw = XCAR (tail); + if (XXWIDGETP (xw) && EQ (Fxwidget_buffer (xw), buffer)) + xw_list = Fcons (xw, xw_list); + } + return xw_list; +} + int xwidget_hidden(struct xwidget_view *xv) { @@ -1557,6 +1581,7 @@ syms_of_xwidget (void) defsubr (&Sxwidget_info); defsubr (&Sxwidget_view_info); defsubr (&Sxwidget_resize); + defsubr (&Sget_buffer_xwidgets); #ifdef HAVE_WEBKIT_OSR defsubr (&Sxwidget_webkit_goto_uri); @@ -1594,8 +1619,8 @@ syms_of_xwidget (void) DEFSYM (QCplist, ":plist"); - DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); - Vxwidget_alist = Qnil; + DEFVAR_LISP ("xwidget-alist", Vxwidget_list, doc: /*xwidgets list*/); + Vxwidget_list = Qnil; DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/); Vxwidget_view_alist = Qnil; @@ -1820,5 +1845,4 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) } } - #endif /* HAVE_XWIDGETS */ -- 2.39.2