WIP tabbed browsing
- need to update title and url on tab change - need to stop background tabs from changing the url and title - better ui for choosing which tab
This commit is contained in:
parent
d44ed56d44
commit
e07e04f28f
@ -99,16 +99,40 @@ progress, trough {
|
|||||||
(let [webview (WebKit2.WebView {
|
(let [webview (WebKit2.WebView {
|
||||||
:on_notify
|
:on_notify
|
||||||
#(handle-webview-properties $1 $2 bus)
|
#(handle-webview-properties $1 $2 bus)
|
||||||
})]
|
|
||||||
(bus:subscribe :fetch #(webview:load_uri $1))
|
|
||||||
(bus:subscribe :stop-loading #(webview:stop_loading))
|
|
||||||
(bus:subscribe :reload #(webview:reload))
|
|
||||||
(bus:subscribe :go-back #(if (webview:can_go_back)
|
|
||||||
(webview:go_back)))
|
|
||||||
|
|
||||||
|
})]
|
||||||
(load-adblocks webview.user_content_manager content-filter-store)
|
(load-adblocks webview.user_content_manager content-filter-store)
|
||||||
webview))
|
webview))
|
||||||
|
|
||||||
|
(fn pane-cave [bus]
|
||||||
|
(let [widget (Gtk.Notebook { :show_tabs false })
|
||||||
|
tabs {}
|
||||||
|
new-tab (fn []
|
||||||
|
(print "new tab")
|
||||||
|
(let [v (new-webview bus)
|
||||||
|
i (widget:append_page v)]
|
||||||
|
(tset tabs i v)
|
||||||
|
(v:show)
|
||||||
|
v))
|
||||||
|
current #(. tabs widget.page)]
|
||||||
|
(bus:subscribe :fetch #(match (current) c (c:load_uri $1)))
|
||||||
|
(bus:subscribe :stop-loading
|
||||||
|
#(match (current) c (c:stop_loading)))
|
||||||
|
(bus:subscribe :reload
|
||||||
|
#(match (current) c (c:reload)))
|
||||||
|
(bus:subscribe :go-back
|
||||||
|
#(match (current) c (and (c:can_go_back) (c:go_back))))
|
||||||
|
(bus:subscribe :new-tab new-tab)
|
||||||
|
{
|
||||||
|
:new-tab new-tab
|
||||||
|
:current-tab current
|
||||||
|
:widget widget
|
||||||
|
:next-tab (fn [self]
|
||||||
|
(let [n (+ 1 widget.page)]
|
||||||
|
(widget:set_current_page (if (. tabs n) n 0)))
|
||||||
|
(widget:get_current_page))
|
||||||
|
}))
|
||||||
|
|
||||||
(let [current-url "https://terse.telent.net"
|
(let [current-url "https://terse.telent.net"
|
||||||
bus (event-bus)
|
bus (event-bus)
|
||||||
window (Gtk.Window {
|
window (Gtk.Window {
|
||||||
@ -136,14 +160,20 @@ progress, trough {
|
|||||||
:on_clicked #(bus:publish :stop-loading)
|
:on_clicked #(bus:publish :stop-loading)
|
||||||
})
|
})
|
||||||
(: :set_image (named-image "process-stop")))
|
(: :set_image (named-image "process-stop")))
|
||||||
|
new-tab (Gtk.Button {
|
||||||
|
:on_clicked #(bus:publish :new-tab)
|
||||||
|
:label "➕"
|
||||||
|
})
|
||||||
refresh (doto (Gtk.Button {
|
refresh (doto (Gtk.Button {
|
||||||
:on_clicked #(bus:publish :reload)
|
:on_clicked #(bus:publish :reload)
|
||||||
})
|
})
|
||||||
(: :set_image (named-image "view-refresh")))
|
(: :set_image (named-image "view-refresh")))
|
||||||
;; views (Gtk.Notebook {
|
views (pane-cave bus)
|
||||||
;; :show_tabs false
|
next-tab (Gtk.Button {
|
||||||
;; })
|
:label ">>"
|
||||||
webview (new-webview bus)
|
:on_clicked #(views:next-tab)
|
||||||
|
})
|
||||||
|
|
||||||
back (doto
|
back (doto
|
||||||
(Gtk.Button {
|
(Gtk.Button {
|
||||||
:on_clicked #(bus:publish :go-back)
|
:on_clicked #(bus:publish :go-back)
|
||||||
@ -161,24 +191,23 @@ progress, trough {
|
|||||||
(bus:subscribe :stop-loading
|
(bus:subscribe :stop-loading
|
||||||
(fn [] (stop:hide) (refresh:show)))
|
(fn [] (stop:hide) (refresh:show)))
|
||||||
|
|
||||||
|
(views:new-tab)
|
||||||
|
|
||||||
(nav-bar:pack_start back false false 2)
|
(nav-bar:pack_start back false false 2)
|
||||||
(nav-bar:pack_start refresh false false 2)
|
(nav-bar:pack_start refresh false false 2)
|
||||||
(nav-bar:pack_start stop false false 2)
|
(nav-bar:pack_start stop false false 2)
|
||||||
(nav-bar:pack_start url true true 2)
|
(nav-bar:pack_start url true true 2)
|
||||||
|
(nav-bar:pack_end next-tab false false 2)
|
||||||
|
(nav-bar:pack_end new-tab false false 2)
|
||||||
|
|
||||||
(container:pack_start nav-bar false false 5)
|
(container:pack_start nav-bar false false 5)
|
||||||
(container:pack_start progress-bar false false 0)
|
(container:pack_start progress-bar false false 0)
|
||||||
(container:pack_start webview true true 5)
|
(container:pack_start views.widget true true 5)
|
||||||
|
|
||||||
(bus:publish :fetch current-url)
|
|
||||||
|
|
||||||
(window:add container)
|
(window:add container)
|
||||||
|
|
||||||
(window:show_all))
|
(window:show_all)
|
||||||
|
(bus:publish :fetch current-url))
|
||||||
(: (WebKit2.WebContext:get_default) :get_website_data_manager)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(Gtk.main)
|
(Gtk.main)
|
||||||
|
Loading…
Reference in New Issue
Block a user