diff options
| author | Grégoire Jadi | 2013-06-24 10:22:45 +0200 |
|---|---|---|
| committer | Grégoire Jadi | 2013-06-24 10:22:45 +0200 |
| commit | da95bc007d161d6d901b7600120a97fd2f54ce4b (patch) | |
| tree | 1a1ac334d23acedd4dd97cea4066537c67a36cdc /src | |
| parent | d65ea7dd1d4aa93a44c39a44d0e79fca6e912690 (diff) | |
| download | emacs-da95bc007d161d6d901b7600120a97fd2f54ce4b.tar.gz emacs-da95bc007d161d6d901b7600120a97fd2f54ce4b.zip | |
Handle xwidgets like processes and delete them when their buffer is killed.
* lisp/xwidget.el (xwidget-kill-buffer-query-function): New function to
query a user before killing a buffer with xwidgets in it.
This function is stored in `kill-buffer-query-functions' and called from
`kill-buffer'.
* src/buffer.c (Fkill_buffer): Call `kill_buffer_xwidgets'.
* src/xwidget.c (kill_buffer_xwidgets): Delete xwidgets attached to the
specified buffer.
* src/xwidget.h (kill_buffer_xwidgets): Add definition.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 9 | ||||
| -rw-r--r-- | src/xwidget.c | 18 | ||||
| -rw-r--r-- | src/xwidget.h | 2 |
3 files changed, 27 insertions, 2 deletions
diff --git a/src/buffer.c b/src/buffer.c index abebdf21135..4e0dbe778ef 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -44,6 +44,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 44 | #include "keymap.h" | 44 | #include "keymap.h" |
| 45 | #include "frame.h" | 45 | #include "frame.h" |
| 46 | 46 | ||
| 47 | #ifdef HAVE_XWIDGETS | ||
| 48 | #include "xwidget.h" | ||
| 49 | #endif /* HAVE_XWIDGETS */ | ||
| 50 | |||
| 47 | struct buffer *current_buffer; /* The current buffer. */ | 51 | struct buffer *current_buffer; /* The current buffer. */ |
| 48 | 52 | ||
| 49 | /* First buffer in chain of all buffers (in reverse order of creation). | 53 | /* First buffer in chain of all buffers (in reverse order of creation). |
| @@ -1835,6 +1839,11 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1835 | kill_buffer_processes (buffer); | 1839 | kill_buffer_processes (buffer); |
| 1836 | UNGCPRO; | 1840 | UNGCPRO; |
| 1837 | 1841 | ||
| 1842 | #ifdef HAVE_XWIDGETS | ||
| 1843 | GCPRO1 (buffer); | ||
| 1844 | kill_buffer_xwidgets (buffer); | ||
| 1845 | UNGCPRO; | ||
| 1846 | #endif /* HAVE_XWIDGETS */ | ||
| 1838 | /* Killing buffer processes may run sentinels which may have killed | 1847 | /* Killing buffer processes may run sentinels which may have killed |
| 1839 | our buffer. */ | 1848 | our buffer. */ |
| 1840 | if (!BUFFER_LIVE_P (b)) | 1849 | if (!BUFFER_LIVE_P (b)) |
diff --git a/src/xwidget.c b/src/xwidget.c index ed7ea98fb42..57d27a2b3c7 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -202,7 +202,7 @@ TYPE is a symbol which can take one of the following values: | |||
| 202 | //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) | 202 | //should work a bit like "make-button"(make-button BEG END &rest PROPERTIES) |
| 203 | // arg "type" and fwd should be keyword args eventually | 203 | // arg "type" and fwd should be keyword args eventually |
| 204 | //(make-xwidget 3 3 'button "oei" 31 31 nil) | 204 | //(make-xwidget 3 3 'button "oei" 31 31 nil) |
| 205 | //(xwidget-info (car xwidget-alist)) | 205 | //(xwidget-info (car xwidget-list)) |
| 206 | struct xwidget* xw = allocate_xwidget(); | 206 | struct xwidget* xw = allocate_xwidget(); |
| 207 | Lisp_Object val; | 207 | Lisp_Object val; |
| 208 | xw->type = type; | 208 | xw->type = type; |
| @@ -1619,7 +1619,7 @@ syms_of_xwidget (void) | |||
| 1619 | 1619 | ||
| 1620 | DEFSYM (QCplist, ":plist"); | 1620 | DEFSYM (QCplist, ":plist"); |
| 1621 | 1621 | ||
| 1622 | DEFVAR_LISP ("xwidget-alist", Vxwidget_list, doc: /*xwidgets list*/); | 1622 | DEFVAR_LISP ("xwidget-list", Vxwidget_list, doc: /*xwidgets list*/); |
| 1623 | Vxwidget_list = Qnil; | 1623 | Vxwidget_list = Qnil; |
| 1624 | 1624 | ||
| 1625 | DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/); | 1625 | DEFVAR_LISP ("xwidget-view-alist", Vxwidget_view_alist, doc: /*xwidget views list*/); |
| @@ -1845,4 +1845,18 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) | |||
| 1845 | } | 1845 | } |
| 1846 | } | 1846 | } |
| 1847 | 1847 | ||
| 1848 | /* Kill all xwidget in BUFFER. */ | ||
| 1849 | void | ||
| 1850 | kill_buffer_xwidgets (Lisp_Object buffer) | ||
| 1851 | { | ||
| 1852 | Lisp_Object tail, xw; | ||
| 1853 | |||
| 1854 | for (tail = Fget_buffer_xwidgets (buffer); CONSP (tail); tail = XCDR (tail)) | ||
| 1855 | { | ||
| 1856 | xw = XCAR (tail); | ||
| 1857 | Vxwidget_list = Fdelq (xw, Vxwidget_list); | ||
| 1858 | /* TODO free the GTK things in xw */ | ||
| 1859 | } | ||
| 1860 | } | ||
| 1861 | |||
| 1848 | #endif /* HAVE_XWIDGETS */ | 1862 | #endif /* HAVE_XWIDGETS */ |
diff --git a/src/xwidget.h b/src/xwidget.h index 3ca9dbe0e1a..530b087796c 100644 --- a/src/xwidget.h +++ b/src/xwidget.h | |||
| @@ -107,4 +107,6 @@ struct xwidget* lookup_xwidget (Lisp_Object spec); | |||
| 107 | #define XG_XWIDGET "emacs_xwidget" | 107 | #define XG_XWIDGET "emacs_xwidget" |
| 108 | #define XG_XWIDGET_VIEW "emacs_xwidget_view" | 108 | #define XG_XWIDGET_VIEW "emacs_xwidget_view" |
| 109 | void xwidget_view_delete_all_in_window( struct window *w ); | 109 | void xwidget_view_delete_all_in_window( struct window *w ); |
| 110 | |||
| 111 | void kill_buffer_xwidgets (Lisp_Object buffer); | ||
| 110 | #endif /* XWIDGET_H_INCLUDED */ | 112 | #endif /* XWIDGET_H_INCLUDED */ |