Skip to content

Commit 85363bc

Browse files
committed
Add about dialog
1 parent 32f88a3 commit 85363bc

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/main/lobjur/main.cljs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
["gjs.gi.Adw" :as Adw]
55
["gjs.gi.Gdk" :as Gdk]
66
["gjs.gi.Gtk" :as Gtk]
7-
["gjs.gi.GLib" :as GLib]
8-
[clojure.string :as str]
7+
["gjs.gi.Gio" :as Gio]
98
[lobjur.state :as state]
109
[lobjur.widgets.comments :as comments]
1110
[lobjur.widgets.stories-list-view :refer [home-stories stories-list-view]]
@@ -42,6 +41,11 @@
4241
:init
4342
(-> state
4443
(push-view (home-stories))
44+
(assoc :header-end [Gtk/MenuButton
45+
:icon-name "open-menu-symbolic"
46+
:menu-model (doto (Gio/Menu.)
47+
(.append "About" "win.about")
48+
(.append "Donate" "win.donate"))])
4549
(assoc :title-widget
4650
[Adw/ViewSwitcher
4751
:policy Adw/ViewSwitcherPolicy.WIDE
@@ -109,6 +113,21 @@
109113
}
110114
")
111115

116+
(defn about []
117+
(.present (build-ui
118+
[Gtk/AboutDialog.
119+
:license "
120+
This program comes with absolutely no warranty.
121+
See the <a href=\"https://www.gnu.org/licenses/gpl-3.0.html\">GNU General Public License, version 3 or later</a> for details."
122+
:license-type Gtk/License.GPL_3_0
123+
:program-name "Lobjur"
124+
:authors #js ["ranfdev https://ranfdev.com/about"]
125+
:version "1.1.0"
126+
:comments "A simple https://lobste.rs client"
127+
:logo-icon-name "com.ranfdev.Lobjur"
128+
:website-label "Source"
129+
:website "https://github.com/ranfdev/Lobjur"])))
130+
112131
(defn activate [app]
113132
(let [win (Adw/ApplicationWindow.
114133
#js
@@ -117,6 +136,12 @@
117136
:default_height 720
118137
:content
119138
(build-ui (window-content))})]
139+
(doto win
140+
(.present)
141+
(.add_action (doto (Gio/SimpleAction. #js {:name "about"})
142+
(.connect "activate" #(about))))
143+
(.add_action (doto (Gio/SimpleAction. #js {:name "donate"})
144+
(.connect "activate" #(Gtk/show_uri nil "https://github.com/sponsors/ranfdev" 0)))))
120145
(.present win))
121146
(Gtk/StyleContext.add_provider_for_display
122147
(Gdk/Display.get_default)

src/main/lobjur/widgets/window.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:.pack_end [Adw/Bin :child
1616
(derived-atom [state/state]
1717
:header-end #(get % :header-end nil))]
18+
1819
:title_widget (derived-atom
1920
[state/state] :title-widget #(get % :title-widget nil))])
2021

0 commit comments

Comments
 (0)