Debian Codegraph @

demo/embedded/Uzbl.hs

raw
1 -- | This is program use uzbl embedded in window to render webpage.
2 -- Just simple model demo for view, haven't handle event or else.
3 --
4 -- You need install uzbl (git clone git://github.com/Dieterbe/uzbl.git) first.
5 --
6 -- How to use:
7 -- ./Uzbl default open Google page.
8 -- ./Uzbl url will open url you input
9 --
10 module Main where
11
12 import Graphics.UI.Gtk
13 import System.Process
14 import System.Environment
15
16 main :: IO ()
17 main = do
18 -- Init.
19 initGUI
20
21 -- Get program arguments.
22 args <- getArgs
23 let url = case args of
24 [arg] -> arg -- get user input url
25 _ -> "http://www.google.com" -- set default url
26
27 -- Create window.
28 window <- windowNew
29 windowSetDefaultSize window 900 600
30 windowSetPosition window WinPosCenter
31 windowSetOpacity window 0.8 -- this function need window-manager support Alpha channel in X11
32
33 -- Create socket.
34 socket <- socketNew
35 widgetShow socket -- must show before add to parent
36 window `containerAdd` socket
37
38 -- Get socket id.
39 socketId <- fmap (show . fromNativeWindowId) $ socketGetId socket
40
41 -- Start uzbl-core process.
42 runCommand $ "uzbl-core -s " ++ socketId ++ " -u " ++ url
43
44 -- Show.
45 window `onDestroy` mainQuit
46 widgetShowAll window
47
48 mainGUI