From: Grégoire Jadi Date: Tue, 11 Jun 2013 13:14:43 +0000 (+0200) Subject: * src/xwidget.c (Fmake_xwidget): Add a docstring and add BUFFER as an optional parameter. X-Git-Tag: emacs-25.0.90~2903^2~7 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7a00481ac3501d071446618c6308ecd7d7f1f18c;p=emacs.git * src/xwidget.c (Fmake_xwidget): Add a docstring and add BUFFER as an optional parameter. The docstring now lists the types accepted. The GCPROtection has also been removed because it wasn't necessary (no call to Feval/eval_sub either directly or indirectly). (syms_of_xwidget): Add a comment to remind us to update the docstring of `Fmake_xwidget' if new types are added. --- diff --git a/lisp/xwidget.el b/lisp/xwidget.el index 00f1ca9b87e..3ba84c53d74 100644 --- a/lisp/xwidget.el +++ b/lisp/xwidget.el @@ -12,10 +12,12 @@ ;;; Code: (defun xwidget-insert (pos type title width height) - "Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and HEIGHT. + "Insert an xwidget at POS, given ID, TYPE, TITLE WIDTH and +HEIGHT in the current buffer. + Return ID -see xwidget.c for types suitable for TYPE." +see `make-xwidget' for types suitable for TYPE." (goto-char pos) (let ((id (make-xwidget (point) (point) type title width height nil))) diff --git a/src/xwidget.c b/src/xwidget.c index 9c9e8169790..d7c219f6cfd 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -188,14 +188,27 @@ xwgir_event_callback (GtkWidget *widget, GtkWidget* xwgir_create(char* class, char* namespace); static void send_xembed_ready_event (struct xwidget* xw, int xembedid); -DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, - doc: /* xw */ +DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 8, 0, + doc: /* Make an xwidget from BEG to END of TYPE. + +If BUFFER is nil it uses the current buffer. If BUFFER is a string and +no such buffer exists, it is created. + +TYPE is a symbol which can take one of the following values: +- Button +- ToggleButton +- slider +- socket +- socket-osr +- cairo +*/ ) (Lisp_Object beg, Lisp_Object end, - Lisp_Object type, - Lisp_Object title, - Lisp_Object width, Lisp_Object height, - Lisp_Object data) + Lisp_Object type, + Lisp_Object title, + Lisp_Object width, Lisp_Object height, + Lisp_Object data, + Lisp_Object buffer) { //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) // arg "type" and fwd should be keyword args eventually @@ -203,12 +216,14 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, //(xwidget-info (car xwidget-alist)) struct xwidget* xw = allocate_xwidget(); Lisp_Object val; - struct gcpro gcpro1; - GCPRO1(xw); XSETSYMBOL(xw->type, type); XSETSTRING(xw->title, title); - //TODO buffer should be an optional argument not just assumed to be the current buffer - XSETBUFFER(xw->buffer, Fcurrent_buffer()); // conservatively gcpro xw since we call lisp + if (NILP (buffer)) + buffer = Fcurrent_buffer(); // no need to gcpro because Fcurrent_buffer doesn't call Feval/eval_sub. + else + buffer = Fget_buffer_create (buffer); + XSETBUFFER(xw->buffer, buffer); + xw->height = XFASTINT(height); xw->width = XFASTINT(width); XSETPSEUDOVECTOR (val, xw, PVEC_XWIDGET); // set the vectorlike_header of VAL with the correct value @@ -295,7 +310,6 @@ DEFUN ("make-xwidget", Fmake_xwidget, Smake_xwidget, 7, 7, 0, } #endif /* HAVE_WEBKIT_OSR */ - UNGCPRO; return val; } @@ -1617,6 +1631,8 @@ syms_of_xwidget (void) DEFSYM (Qcxwgir_class ,":xwgir-class"); DEFSYM (Qtitle ,":title"); + /* Do not forget to update the docstring of make-xwidget if you add + new types. */ DEFSYM (Qbutton, "Button"); //changed to match the gtk class because xwgir(experimental and not really needed) DEFSYM (Qtoggle, "ToggleButton"); DEFSYM (Qslider, "slider");