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
|
-- | This is program use uzbl embedded in window to render webpage.
-- Just simple model demo for view, haven't handle event or else.
--
-- You need install uzbl (git clone git://github.com/Dieterbe/uzbl.git) first.
--
-- How to use:
-- ./Uzbl default open Google page.
-- ./Uzbl url will open url you input
--
module Main where
import Graphics.UI.Gtk
import System.Process
import System.Environment
main :: IO ()
main = do
-- Init.
initGUI
-- Get program arguments.
args <- getArgs
let url = case args of
[arg] -> arg -- get user input url
_ -> "http://www.google.com" -- set default url
-- Create window.
window <- windowNew
windowSetDefaultSize window 900 600
windowSetPosition window WinPosCenter
windowSetOpacity window 0.8 -- this function need window-manager support Alpha channel in X11
-- Create socket.
socket <- socketNew
widgetShow socket -- must show before add to parent
window `containerAdd` socket
-- Get socket id.
socketId <- fmap (show . fromNativeWindowId) $ socketGetId socket
-- Start uzbl-core process.
runCommand $ "uzbl-core -s " ++ socketId ++ " -u " ++ url
-- Show.
window `onDestroy` mainQuit
widgetShowAll window
mainGUI
|