Skip to content

Commit 32f88a3

Browse files
committed
Use Adw.ViewSwitcher
1 parent 1718726 commit 32f88a3

3 files changed

Lines changed: 24 additions & 20 deletions

File tree

src/main/lobjur/main.cljs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +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]
78
[clojure.string :as str]
89
[lobjur.state :as state]
910
[lobjur.widgets.comments :as comments]
@@ -42,7 +43,8 @@
4243
(-> state
4344
(push-view (home-stories))
4445
(assoc :title-widget
45-
[Gtk/StackSwitcher
46+
[Adw/ViewSwitcher
47+
:policy Adw/ViewSwitcherPolicy.WIDE
4648
:stack (:home-stories @state/global-widgets)]))
4749
:push-user
4850
(push-titled-view state (user/user-view payload) payload)
@@ -108,22 +110,21 @@
108110
")
109111

110112
(defn activate [app]
111-
(doto (Adw/ApplicationWindow.
112-
#js
113-
{:application app
114-
:default_width 720
115-
:default_height 720
116-
:content
117-
(build-ui (window-content))})
118-
(.present))
113+
(let [win (Adw/ApplicationWindow.
114+
#js
115+
{:application app
116+
:default_width 720
117+
:default_height 720
118+
:content
119+
(build-ui (window-content))})]
120+
(.present win))
119121
(Gtk/StyleContext.add_provider_for_display
120122
(Gdk/Display.get_default)
121123
(doto (new Gtk/CssProvider) (.load_from_data (ByteArray/fromString app-css)))
122124
600)
123125
(state/send [:init]))
124126

125-
(defn ^:export main [& args]
126-
(println "Command line arguments are: " (str/join ", " args))
127+
(defn ^:export main [& _args]
127128
(doto (Adw/Application. #js {:application_id "com.ranfdev.Lobjur"})
128129
(.connect "activate" activate)
129130
(.run #js [])))

src/main/lobjur/widgets/stories_list_view.cljs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,16 @@
128128
:$clicked #(swap! page inc)]]]]]))
129129

130130
(defn home-stories []
131-
(let [stack (doto (Gtk/Stack.)
132-
(.add_titled
133-
(build-ui (stories-list-view lobster/hottest))
134-
"hottest" "Hottest")
135-
(.add_titled
136-
(build-ui (stories-list-view lobster/active))
137-
"active" "Active"))]
131+
(let [stack (Adw/ViewStack.)]
132+
(doto (.add_titled stack
133+
(build-ui (stories-list-view lobster/hottest))
134+
"hottest"
135+
"Hottest")
136+
(.set_icon_name "power-profile-performance-symbolic"))
137+
(doto (.add_titled stack
138+
(build-ui (stories-list-view lobster/active))
139+
"active" "Active")
140+
(.set_icon_name "audio-speakers-symbolic"))
138141
(swap! state/global-widgets assoc :home-stories stack)
139142
[Gtk/Box
140143
::rollui/ref-in [global-widgets :home]

src/main/lobjur/widgets/window.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
(derived-atom [state/state]
1414
:header-start #(get % :header-start nil))]
1515
:.pack_end [Adw/Bin :child
16-
(derived-atom [state/state]
17-
:header-end #(get % :header-end nil))]
16+
(derived-atom [state/state]
17+
:header-end #(get % :header-end nil))]
1818
:title_widget (derived-atom
1919
[state/state] :title-widget #(get % :title-widget nil))])
2020

0 commit comments

Comments
 (0)