Last active
February 18, 2025 04:46
-
-
Save yogthos/81d560da28da7dd5b86dcda3003b35e7 to your computer and use it in GitHub Desktop.
Gjs ClojureScript example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns gjs-example.core) | |
(defn main [] | |
(set! (-> js/imports .-gi .-versions .-Gtk) "3.0") | |
(let [Gtk (doto (-> js/imports .-gi .-Gtk) (.init nil)) | |
window (Gtk.Window. | |
(clj->js | |
{:type (-> Gtk .-WindowType .-TOPLEVEL) | |
:title "A default title" | |
:default_width 300 | |
:default_height 250 | |
:window_position (-> Gtk .-WindowPosition .-CENTER)})) | |
button (Gtk.Button. | |
(clj->js | |
{:label "close" | |
:visible true | |
:valign (-> Gtk .-Align .-CENTER) | |
:halign (-> Gtk .-Align .-CENTER)}))] | |
(set! (.-title window) "Hello World") | |
(.connect window "delete-event" #(boolean (js/log "delete event"))) | |
(.connect window "destroy" #(.main_quit Gtk)) | |
(.connect button "clicked" #(.destroy window)) | |
(.add window button) | |
(.show window) | |
(.main Gtk))) | |
(main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject gjs-test "0.1.0" | |
:dependencies [[org.clojure/clojure "1.10.1"] | |
[org.clojure/clojurescript "1.10.520"]] | |
:plugins [[lein-cljsbuild "1.1.7"]] | |
:cljsbuild {:builds [{:source-paths ["src"] | |
:compiler {:output-to "target/app.js" | |
:optimizations :simple | |
:target :nodejs | |
:pretty-print true}}]}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!