Giter Club home page Giter Club logo

Comments (2)

bohonghuang avatar bohonghuang commented on July 19, 2024

It could be implemented with CFFI. I added the CFFI definition for Rectangle and an example for it:

(define-application (:name popover-test
:id "org.bohonghuang.gdk4-example.popover-test")
(define-main-window (window (make-application-window :application *application*))
(setf (window-title window) "Popover Test")
(let ((box (make-box :orientation +orientation-vertical+ :spacing 0)))
(setf (widget-size-request box) '(200 200))
(let ((controller (make-gesture-click)))
(connect controller 'pressed (lambda (self n-press x y)
(declare (ignore self n-press))
(let ((popover (make-popover)))
(box-append box popover)
(cffi:with-foreign-object (rect '(:struct gdk4:rectangle))
(cffi:with-foreign-slots ((gdk::x gdk::y gdk::width gdk::height) rect (:struct gdk4:rectangle))
(setf gdk::x (round x)
gdk::y (round y)
gdk::width (round 0)
gdk::height (round 0)))
(setf (popover-child popover) (make-label :str "Popover")
(popover-pointing-to popover) (gobj:pointer-object rect 'gdk:rectangle))
(popover-popup popover)))))
;; The `add_controller' method takes ownership of the `controller',
;; but `cl-gobject-introspection' doesn't remove the finalizer for the `controller' automatically,
;; so we need to remove it here to avoid memory safety issues at present.
(assert (tg:cancel-finalization (gobj:object-pointer controller)))
(widget-add-controller box controller))
(let ((label (make-label :str "Click to pop up a Popover")))
(setf (widget-vexpand-p label) t)
(box-append box label))
(setf (window-child window) box))
(unless (widget-visible-p window)
(window-present window))))

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

Thank you!

from cl-gtk4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.