remove tab by swiping it in overview
This commit is contained in:
parent
ae9ec33b96
commit
43967b674b
@ -136,6 +136,20 @@ progress, trough {
|
|||||||
img (doto (Gtk.Image) (: :set_from_surface scaled))]
|
img (doto (Gtk.Image) (: :set_from_surface scaled))]
|
||||||
(button:set_image img)))))
|
(button:set_image img)))))
|
||||||
|
|
||||||
|
(fn connect-swipe-gesture [widget bus index]
|
||||||
|
(Gtk.GestureSwipe {
|
||||||
|
:widget widget
|
||||||
|
:on_update
|
||||||
|
(fn [self]
|
||||||
|
(self:set_state Gtk.EventSequenceState.CLAIMED))
|
||||||
|
:on_swipe
|
||||||
|
(fn [self x y]
|
||||||
|
(if (and (< 700 x) (< y 700))
|
||||||
|
(bus:publish :close-tab index)
|
||||||
|
(self:set_state Gtk.EventSequenceState.DENIED))
|
||||||
|
true)
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
(fn update-tab-overview [bus tabs scrolledwindow]
|
(fn update-tab-overview [bus tabs scrolledwindow]
|
||||||
(let [box (Gtk.Box {
|
(let [box (Gtk.Box {
|
||||||
@ -149,14 +163,14 @@ progress, trough {
|
|||||||
(when (> i 0)
|
(when (> i 0)
|
||||||
(box:pack_start
|
(box:pack_start
|
||||||
(doto (Gtk.Button {
|
(doto (Gtk.Button {
|
||||||
:label w.title
|
|
||||||
:image-position Gtk.PositionType.TOP
|
:image-position Gtk.PositionType.TOP
|
||||||
:relief Gtk.ReliefStyle.NONE
|
|
||||||
:on_clicked
|
:on_clicked
|
||||||
#(bus:publish :switch-tab i)
|
#(bus:publish :switch-tab i)
|
||||||
})
|
})
|
||||||
|
(connect-swipe-gesture bus i)
|
||||||
(load-webview-thumbnail w))
|
(load-webview-thumbnail w))
|
||||||
false false 5)))
|
false false 5)))
|
||||||
|
|
||||||
(scrolledwindow:add box)
|
(scrolledwindow:add box)
|
||||||
(scrolledwindow:show_all)
|
(scrolledwindow:show_all)
|
||||||
))
|
))
|
||||||
@ -168,7 +182,7 @@ progress, trough {
|
|||||||
:show_tabs false
|
:show_tabs false
|
||||||
:on_switch_page
|
:on_switch_page
|
||||||
(fn [self page num]
|
(fn [self page num]
|
||||||
(when (= num 0)
|
(when (= num 0)
|
||||||
(update-tab-overview bus tabs page)))
|
(update-tab-overview bus tabs page)))
|
||||||
})
|
})
|
||||||
new-tab (fn [self child]
|
new-tab (fn [self child]
|
||||||
@ -178,6 +192,7 @@ progress, trough {
|
|||||||
(v:show)
|
(v:show)
|
||||||
(set widget.page i)
|
(set widget.page i)
|
||||||
v))
|
v))
|
||||||
|
tab-overview (Gtk.ScrolledWindow)
|
||||||
current #(. tabs widget.page)]
|
current #(. tabs widget.page)]
|
||||||
(bus:subscribe :fetch #(match (current) c (c:load_uri $1)))
|
(bus:subscribe :fetch #(match (current) c (c:load_uri $1)))
|
||||||
(bus:subscribe :stop-loading
|
(bus:subscribe :stop-loading
|
||||||
@ -187,9 +202,14 @@ progress, trough {
|
|||||||
(bus:subscribe :go-back
|
(bus:subscribe :go-back
|
||||||
#(match (current) c (and (c:can_go_back) (c:go_back))))
|
#(match (current) c (and (c:can_go_back) (c:go_back))))
|
||||||
(bus:subscribe :new-tab new-tab)
|
(bus:subscribe :new-tab new-tab)
|
||||||
(bus:subscribe :switch-tab (fn [i] (widget:set_current_page i)))
|
(bus:subscribe :switch-tab #(widget:set_current_page $1))
|
||||||
|
(bus:subscribe :close-tab
|
||||||
|
(fn [i]
|
||||||
|
(tset tabs i nil)
|
||||||
|
(update-tab-overview bus tabs tab-overview)
|
||||||
|
(widget:set_current_page 0)))
|
||||||
|
(new-tab nil tab-overview)
|
||||||
|
|
||||||
(new-tab nil (Gtk.ScrolledWindow))
|
|
||||||
{
|
{
|
||||||
:new-tab new-tab
|
:new-tab new-tab
|
||||||
:current-tab current
|
:current-tab current
|
||||||
|
Loading…
Reference in New Issue
Block a user