File: Uzbl.hs

package info (click to toggle)
haskell-gtk 0.15.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,964 kB
  • sloc: haskell: 3,346; ansic: 826; makefile: 161
file content (48 lines) | stat: -rw-r--r-- 1,279 bytes parent folder | download | duplicates (11)
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