unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#24019: 25.1.50; Allow using a custom callback with xwidget
@ 2016-07-18 12:30 Puneeth Chaganti
  2020-01-20 20:23 ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Puneeth Chaganti @ 2016-07-18 12:30 UTC (permalink / raw)
  To: 24019

[-- Attachment #1: Type: text/plain, Size: 328 bytes --]


Hello,

`xwidgets.el' seems to have some commented code that used to allow using
a different callback on each xwidget.  This functionality is useful to
have and this is a patch that uncomments this code.  I've tested the
code, and it seems to work, and I'm not really sure, why this was
commented in the first place.

Thanks!


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Use-the-callback-set-as-widget-s-property.patch --]
[-- Type: text/x-diff, Size: 1295 bytes --]

From 63d1b53583263065edea3ee53d708693415a6057 Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@muse-amuse.in>
Date: Mon, 18 Jul 2016 16:34:24 +0530
Subject: [PATCH 1/2] Use the callback set as widget's property

Revert a commented piece of code, that allows using a different callback
for each xwidget on an event, instead of a single global one.
* lisp/xwidget.el (xwidget-event-handler): Use callback widget property
---
 lisp/xwidget.el | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index 7a0ca8b..3434e24 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -172,12 +172,8 @@ xwidget-event-handler
   (let*
       ((xwidget-event-type (nth 1 last-input-event))
        (xwidget (nth 2 last-input-event))
-       ;;(xwidget-callback (xwidget-get xwidget 'callback))
-       ;;TODO stopped working for some reason
-       )
-    ;;(funcall  xwidget-callback xwidget xwidget-event-type)
-    (message "xw callback %s" xwidget)
-    (funcall  'xwidget-webkit-callback xwidget xwidget-event-type)))
+       (xwidget-callback (xwidget-get xwidget 'callback)))
+    (funcall xwidget-callback xwidget xwidget-event-type)))
 
 (defun xwidget-webkit-callback (xwidget xwidget-event-type)
   "Callback for xwidgets.
-- 
2.7.4


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Allow-specifying-the-callback-if-new-session.patch --]
[-- Type: text/x-diff, Size: 1508 bytes --]

From 095f02a5581c2c5c157ec312a64288b0c675da74 Mon Sep 17 00:00:00 2001
From: Puneeth Chaganti <punchagan@muse-amuse.in>
Date: Mon, 18 Jul 2016 17:46:19 +0530
Subject: [PATCH 2/2] Allow specifying the callback if new session

This change makes it easier to create xwidgets with their callbacks that
are invoked by the event handler
* lisp/xwidget.el (xwidget-webkit-new-session): Optional callback arg
---
 lisp/xwidget.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index 3434e24..0f6751e 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -416,16 +416,17 @@ xwidget-webkit-fit-width
                                  (car (window-inside-pixel-edges)))
                               1000))
 
-(defun xwidget-webkit-new-session (url)
+(defun xwidget-webkit-new-session (url &optional callback)
   "Create a new webkit session buffer with URL."
   (let*
       ((bufname (generate-new-buffer-name "*xwidget-webkit*"))
+       (callback (or callback #'xwidget-webkit-callback))
        xw)
     (setq xwidget-webkit-last-session-buffer (switch-to-buffer
                                               (get-buffer-create bufname)))
     (insert " 'a' adjusts the xwidget size.")
     (setq xw (xwidget-insert 1 'webkit  bufname 1000 1000))
-    (xwidget-put xw 'callback 'xwidget-webkit-callback)
+    (xwidget-put xw 'callback callback)
     (xwidget-webkit-mode)
     (xwidget-webkit-goto-uri (xwidget-webkit-last-session) url)))
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-11 14:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-18 12:30 bug#24019: 25.1.50; Allow using a custom callback with xwidget Puneeth Chaganti
2020-01-20 20:23 ` Stefan Kangas
2020-08-11 14:21   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).