Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

How to add context menu actions? #42

Open
Ambrevar opened this issue May 5, 2020 · 0 comments
Open

How to add context menu actions? #42

Ambrevar opened this issue May 5, 2020 · 0 comments

Comments

@Ambrevar
Copy link

Ambrevar commented May 5, 2020

This might be more of a GTK question than a Common Lisp question, but allow me to post here, just in case.
I'm trying to create a custom context menu in WebKitGTK (using cl-webkit).

A simple attempt:

; Helper to populate the browser "context-menu-entries" slot:
(defun make-context-menu-entries ()
	(let ((foo-action (gio:g-simple-action-new
										 "foo"
										 (glib:g-variant-type-new glib:+g-variant-type-maybe+))))

		(gobject:g-signal-connect
		 foo-action "activate"
		 (lambda (action parameter)
			 (declare (ignore action parameter))
			 (log:info "foo action")))

		(gio:g-simple-action-set-enabled foo-action t)

		(list :foo
					(webkit:webkit-context-menu-item-new-from-gaction
					 foo-action
					 "Do foo"
					 (cffi:null-pointer)))))

; Initialize the web view:
; ...
(gobject:g-signal-connect (gtk-object buffer) "context-menu"

	 (lambda (web-view context-menu event hit-test-result)
		 (declare (ignore web-view event hit-test-result))

		 (webkit:webkit-context-menu-append
			context-menu
			(getf (context-menu-entries *browser*) :foo))
		 ;; Return nil to show the context menu.
		 nil))

It works and shows "Do foo" in the context menu; sadly, it's greyed out.
It seems that g-simple-action-set-enabled does not do what I
think it does.

Any clue what I'm missing?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant