Giter Club home page Giter Club logo

Comments (3)

bohonghuang avatar bohonghuang commented on July 19, 2024 1

I wrote an example of the GTK menu with the newly added macro define-application used for interactive programming, but I can't guarantee its stability in terms of API yet. Just for your reference:

cl-gtk4/examples/gtk4.lisp

Lines 95 to 152 in ad8fae4

(define-application (:name menu-test
:id "org.bohonghuang.gtk4-example.menu-test")
(defun menu-test-menu ()
(let ((menu (gio:make-menu)))
(let ((submenu (gio:make-menu)))
(gio:menu-append-item submenu (gio:make-menu-item :model menu :label "Open" :detailed-action "app.open"))
(gio:menu-append-item submenu (gio:make-menu-item :model menu :label "Exit" :detailed-action "app.exit"))
(gio:menu-append-submenu menu "File" submenu))
(let ((submenu (gio:make-menu)))
(gio:menu-append-item submenu (gio:make-menu-item :model menu :label "About" :detailed-action "app.about"))
(gio:menu-append-submenu menu "Help" submenu))
(values menu)))
(defun menu-test-about-dialog ()
(let ((dialog (make-about-dialog))
(system (asdf:find-system :cl-gtk4)))
(setf (about-dialog-authors dialog) (list (asdf:system-author system))
(about-dialog-website dialog) (asdf:system-homepage system)
(about-dialog-version dialog) (asdf:component-version system)
(about-dialog-program-name dialog) (asdf:component-name system)
(about-dialog-comments dialog) (asdf:system-description system)
(about-dialog-logo-icon-name dialog) "application-x-addon")
(values dialog)))
(define-main-window (window (make-application-window :application *application*))
(setf (window-title window) "Menu Test")
(let ((header-bar (make-header-bar)))
(let ((menu-button (make-menu-button)))
(setf (menu-button-menu-model menu-button) (menu-test-menu)
(button-icon-name menu-button) "open-menu-symbolic")
(header-bar-pack-end header-bar menu-button))
(setf (window-titlebar window) header-bar))
(let ((action (gio:make-simple-action :name "exit"
:parameter-type nil)))
(gio:action-map-add-action *application* action)
(connect action "activate"
(lambda (action param)
(declare (ignore action param))
(gtk::destroy-all-windows-and-quit))))
(let ((action (gio:make-simple-action :name "about"
:parameter-type nil)))
(gio:action-map-add-action *application* action)
(connect action "activate"
(lambda (action param)
(declare (ignore action param))
(let ((dialog (menu-test-about-dialog)))
(setf (window-modal-p dialog) t
(window-transient-for dialog) window)
(window-present dialog)))))
(let ((window-box (make-box :orientation +orientation-vertical+
:spacing 0)))
(let ((menu-bar (make-popover-menu-bar :model (menu-test-menu))))
(box-append window-box menu-bar))
(let ((empty-box (make-box :orientation +orientation-vertical+
:spacing 0)))
(setf (widget-size-request empty-box) '(400 200))
(box-append window-box empty-box))
(setf (window-child window) window-box))
(unless (widget-visible-p window)
(window-present window))))

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

Thank you, that should be enough to point me in the right direction.

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

(gtk::destroy-all-windows-and-quit))))

is the temporary answer

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.