pzurek (owner)
Private Gist
All pages are served over SSL and all pushing and pulling is done over SSH. No one may fork, clone, or view it unless they are given this private URL.
Every gist with this icon (
) is private.
Public Gist
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
(*
to compile use:
fsc FebKit.fs -r "/usr/lib/cli/webkit-sharp-1.0/webkit-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/gtk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/gdk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/atk-sharp.dll" -r "/usr/lib/mono/gtk-sharp-2.0/glib-sharp.dll"
*)
#light
open System
open WebKit
open Gtk
Gtk.Application.Init()
let url = "http://piotrzurek.net"
let window = new Window("FebKit")
let webViewContainer = new ScrolledWindow()
let webView = new WebView()
let toolbar = new Toolbar()
let urlToolItem = new ToolItem();
let urlEntry = new Entry(url)
let addressHBox = new HBox()
let statusbar = new Statusbar()
let vBox = new VBox()
let backAction = new Action("back", "Go Back", null, "gtk-go-back")
let forwardAction = new Action("forward", "Go Forward", null, "gtk-go-forward")
let stopAction = new Action("stop", "Stop", null, "gtk-stop")
let refreshAction = new Action("refresh", "Refresh", null, "gtk-refresh")
let openUrl address =
webView.Open(address)
urlEntry.Text <- address
let setWindowTitle title =
if String.IsNullOrEmpty(title) then window.Title <- "FebKit"
else window.Title <- title
let commitLoad uri =
urlEntry.Text <- uri
stopAction.Sensitive <- true
refreshAction.Sensitive <- false
//updateBackForwardButtons
(*
let disableButtons =
backAction.Sensitive <- false
forwardAction.Sensitive <- false
stopAction.Sensitive <- false
refreshAction.Sensitive <- false
let updateBackForwardButtons =
backAction.Sensitive <- webView.CanGoBack()
forwardAction.Sensitive <- webView.CanGoForward()
*)
let finishLoad wView =
stopAction.Sensitive <- false
refreshAction.Sensitive <- true
//updateBackForwardButtons
webView.Editable <- false
webView.MaintainsBackForwardList <- true
webView.TitleChanged.Add(fun e -> setWindowTitle e.Title)
webView.LoadCommitted.Add(fun e -> commitLoad(e.Frame.Uri))
webView.LoadFinished.Add(fun _ -> finishLoad(webView))
webView.HoveringOverLink.Add(fun args -> if args.Link = null then ignore()
else statusbar.Push((uint32)1, args.Link) |> ignore)
urlToolItem.Expand <- true
urlEntry.Activated.Add(fun _ -> webView.Open(urlEntry.Text))
backAction.Activated.Add(fun _ -> webView.GoBack())
forwardAction.Activated.Add(fun _ -> webView.GoForward())
stopAction.Activated.Add(fun _ -> webView.StopLoading())
refreshAction.Activated.Add(fun _ -> webView.Reload())
urlToolItem.Add(urlEntry)
toolbar.BorderWidth <- (uint32)6
toolbar.ToolbarStyle <- ToolbarStyle.Icons
toolbar.Add(backAction.CreateToolItem())
toolbar.Add(forwardAction.CreateToolItem())
toolbar.Add(stopAction.CreateToolItem())
toolbar.Add(refreshAction.CreateToolItem())
toolbar.Add(urlToolItem)
webViewContainer.ShadowType <- ShadowType.EtchedIn
webViewContainer.Add(webView)
vBox.PackStart(toolbar, false, false, (uint32)0)
vBox.PackStart(webViewContainer)
vBox.PackEnd(statusbar, false, false, (uint32)0)
window.Add(vBox)
window.WindowPosition <- Gtk.WindowPosition.Center
window.SetDefaultSize(1200, 800)
window.Destroyed.Add(fun _ -> Application.Quit())
webView.Open(url)
window.ShowAll()
Gtk.Application.Run()
Please log in to comment.







