add buffer
This commit is contained in:
parent
e638b2c330
commit
a34e63877d
35
buffer.fnl
Normal file
35
buffer.fnl
Normal file
@ -0,0 +1,35 @@
|
||||
(local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi))
|
||||
|
||||
(fn new-buffer [name]
|
||||
(let [props {}
|
||||
widget (WebKit2.WebView {
|
||||
;; :on_decide_policy
|
||||
;; (fn [self decision dtype]
|
||||
;; (if (and
|
||||
;; (WebKit2.ResponsePolicyDecision:is_type_of decision)
|
||||
;; (not (decision:is_mime_type_supported)))
|
||||
;; (do
|
||||
;; (download decision.request.uri decision.response.http_headers)
|
||||
;; (decision:ignore)
|
||||
;; true)
|
||||
;; false))
|
||||
:on_notify
|
||||
(fn [self pspec]
|
||||
(when (not (= pspec.name :parent))
|
||||
(let [val (. self pspec.name)]
|
||||
(tset props pspec.name val)
|
||||
;(listeners:notify pspec.name val)
|
||||
)))
|
||||
})]
|
||||
{:webview widget
|
||||
:visit (fn [self u] (print "visit " u) (widget:load_uri u))
|
||||
:properties props}))
|
||||
|
||||
(let [buffers {}]
|
||||
{
|
||||
:new (fn [name]
|
||||
(let [b (new-buffer name)]
|
||||
(tset buffers name b)
|
||||
b))
|
||||
:find (fn [self term] (. buffers term))
|
||||
})
|
@ -2,9 +2,11 @@
|
||||
(local { : Gtk : Gdk : WebKit2 : cairo } lgi)
|
||||
|
||||
(local frame (require :frame))
|
||||
(local buffer (require :buffer))
|
||||
|
||||
(let [f (frame.new)
|
||||
b (buffer.new "main")]
|
||||
(f:show-buffer b)
|
||||
(b:visit "file:///home/dan/src/dunlin/doc/index.html"))
|
||||
|
||||
|
||||
|
||||
(frame.new)
|
||||
(Gtk.main)
|
||||
|
30
frame.fnl
30
frame.fnl
@ -1,7 +1,9 @@
|
||||
(local { : Gtk : Gdk : WebKit2 : cairo } (require :lgi))
|
||||
|
||||
(local { : view } (require :fennel))
|
||||
(local command (require :command))
|
||||
|
||||
(var frames [])
|
||||
|
||||
(fn new-frame []
|
||||
(let [hpad 2
|
||||
vpad 2
|
||||
@ -24,9 +26,9 @@
|
||||
:fraction 1.0
|
||||
:margin 0
|
||||
})
|
||||
contentwidget (Gtk.Button {
|
||||
:label "paceholder"
|
||||
})
|
||||
contentwidget (Gtk.Box {
|
||||
:orientation Gtk.Orientation.VERTICAL
|
||||
})
|
||||
]
|
||||
(doto container
|
||||
(: :pack_start commander false false vpad)
|
||||
@ -34,6 +36,22 @@
|
||||
(: :pack_start contentwidget true true vpad))
|
||||
(window:add container)
|
||||
(window:show_all)
|
||||
window))
|
||||
(let [f
|
||||
{
|
||||
:window window
|
||||
:buffer nil
|
||||
:commander commander
|
||||
:content contentwidget
|
||||
:show-buffer (fn [self b]
|
||||
(each [_ w (pairs (contentwidget:get_children))]
|
||||
(print "hide " w)
|
||||
(w:hide))
|
||||
(print "show " (view b))
|
||||
(contentwidget:pack_start b.webview true true 0)
|
||||
(b.webview:show))
|
||||
}]
|
||||
(table.insert frames f)
|
||||
f)))
|
||||
|
||||
{ :new new-frame }
|
||||
|
||||
{ :new new-frame :frames frames }
|
||||
|
Loading…
Reference in New Issue
Block a user