[Cream-browser-devel] Cream-Browser isn't dead
Status: Beta
Brought to you by:
linkdd
|
From: linkdd <li...@yd...> - 2011-01-20 11:36:14
|
Hi,
It's just to share you the news of Cream-Browser.
Recently I started working on a new version of Cream-Browser and I have
some new ideas.
First, the website will be updated. rhaamo is designing a new one in
Ruby-on-Rails. It
will available soon, but we have time :)
Secondly, in Cream-Browser. I had 3 ideas :
----------------------------------------------------------------------------------------------------------------------------------------------
* The configuration file in Lua : Do you know awesome ? You define the
interface into the
rc.lua file, you set keybindings (associated to lua functions) etc... Lua
is lightweight,
and simple to implement. I made a sample exemple for example :
rc.lua:
> 000 -- Cream-Browser lua API
> 001 require ("cbapi")
> 002
> 003 useragents = {
> 004 { "google\.(fr|com)", "Mozilla/5.0 (X11; U; Linux i686;
en-US; rv:1.9.2.1) Gecko/20100122 firefox/3.6.1" }
> 005 }
> 006
> 007 -- Load theme
> 008 cbapi.theme.init
("~/.config/cream-browser/themes/default/theme.lua")
> 009
> 010 -- Load wanted modules
> 011 cbapi.module.enable ("webkit")
> 012 cbapi.module.enable ("about")
> 013 cbapi.module.enable ("ftp")
> 014
> 015 -- Misc
> 016 cbapi.proxy.url = "192.168.1.172:8123"
> 017 cbapi.proxy.enable = true
> 018 cbapi.javascript.enable = true
> 019 cbapi.cookies.enable = true
> 020 cbapi.session.enable = true
> 021
> 023 cbapi.encodage = "UTF-8"
> 024 cbapi.homepage = "http://cream-browser.net"
> 025
> 026 -- Build GUI
> 027 cbapi.widgets.box ({
> 028 cbapi.widgets.notebook,
> 029 cbapi.widgets.webview,
> 030 cbapi.widgets.statusbar,
> 031 cbapi.widgets.promptbox
> 032 })
> 034
> 035 -- Mouse bindings
> 036
> 037 cbapi.widgets.notebook.buttons (cbapi.util.table.join (
> 038 cbapi.button ({ }, 1, function (t) cbapi.tab.focus =
t; t:raise () end),
> 039 cbapi.button ({ "Mod1" }, 3, function (t) t:close () end),
> 040 cbapi.button ({ }, 4, cbapi.tab.viewnext),
> 041 cbapi.button ({ }, 5, cbapi.tab.viewprev)
> 042 ))
> 043
> 044 -- Key bindings
> 045 globalkeys = cbapi.util.table.join (
> 056 -- Misc
> 047 cbapi.key ({ "Mod1", "Control" }, "q", cbapi.quit),
> 048 cbapi.key ({ "Control" }, "p", function ()
cbapi.proxy.enable = not cbapi.proxy.enable end),
> 049 cbapi.key ({ "Control" }, "j", function ()
cbapi.javascript.enable = not cbapi.javascript.enable end),
> 050 cbapi.key ({ "Control" }, "c", function ()
cbapi.cookies.enable = not cbapi.cookies.enable end),
> 051 cbapi.key ({ "Control" }, "s", function ()
cbapi.session.enable = not cbapi.session.enable end),
> 052 -- Cream-Browser modes
> 053 cbapi.key ({ }, "Insert", function ()
cbapi.mode.current = cbapi.mode.insert end),
> 054 cbapi.key ({ }, "i", function ()
cbapi.mode.current = cbapi.mode.insert end),
> 055 cbapi.key ({ }, ":", function ()
cbapi.mode.current = cbapi.mode.prompt end),
> 056 cbapi.key ({ }, "Escape", function ()
cbapi.mode.current = cbapi.mode.command end),
> 057 cbapi.key ({ }, "f", function ()
cbapi.mode.current = cbapi.mode.hint end),
> 058 -- Notebook controls
> 059 cbapi.key ({ "Mod1" }, "Left",
cbapi.tab.viewprev),
> 060 cbapi.key ({ "Mod1" }, "Right",
cbapi.tab.viewnext),
> 061 cbapi.key ({ "Control" }, "w", function ()
cbapi.tab.focus:close () end),
> 062 cbapi.key ({ "Control" }, "t", cbapi.tab.new),
> 063 -- Basic commands
> 064 cbapi.key ({ }, "o", function ()
cbapi.mode.current = cbapi.mode.prompt; cb_promptbox.text = ":open " end),
> 065 cbapi.key ({ "Shift" }, "o", function ()
cbapi.mode.current = cbapi.mode.prompt; cb_promptbox.text = ":open " ..
> 066 cbapi.tab.focus:url () end),
> 067 cbapi.key ({ }, "t", function ()
cbapi.mode.current = cbapi.mode.prompt; cb_promptbox.text = ":tabopen "
end),
> 068 cbapi.key ({ "Shift" }, "t", function ()
cbapi.mode.current = cbapi.mode.prompt; cb_promptbox.text = ":tabopen " ..
> 069 cbapi.tab.focus:url () end),
> 070 cbapi.key ({ }, "y",
cbapi.url.yank),
> 071 cbapi.key ({ }, "p",
cbapi.url.paste),
> 072 cbapi.key ({ "Shift" }, "p", function ()
cbapi.tab.new (cbapi.url.yanked) end),
> 073 cbapi.key ({ }, "h", function ()
cbapi.tab.focus:url (cbapi.homepage) end),
> 074 cbapi.key ({ "Shift" }, "h", function ()
cbapi.tab.new (cbapi.homepage) end),
> 075 -- History
> 076 cbapi.key ({ "Control" }, "Left",
cbapi.history.backward),
> 077 cbapi.key ({ "Control" }, "Right",
cbapi.history.forward)
> 078 )
> 079
> 080 -- Bind all key numbers to notebook
> 081 for i = 0, 9 do
> 082 globalkeys = cbapi.util.table.join (globalkeys,
> 083 cbapi.key ({ "Mod1" }, i, function ()
cbapi.tab.goto (i) end),
> 084 cbapi.key ({ "Control" }, i, function ()
cbapi.tab.close (i) end)
> 085 )
> 086 end
> 087
> 088 cbapi.keys (globalkeys)
> 089
> 090 -- Add signals handler to webview
> 091 cbapi.widgets.webview.add_signal ("download-requested", function
(w, d)
> 092 cbapi.util.spawn ("urxvt -e wget \"" .. d:url () .. "\"
-O \"" .. d:filename () .. "\"")
> 093 end)
> 094
> 095 cbapi.widgets.webview.add_signal ("load-committed", function (w)
> 096 for i = 1, #useragents do
> 097 if cbapi.util.regex.match (useragents[i][1], w:url
()) then
> 098 w:useragent (useragents[i][2])
> 099 end
> 100 end
> 101
> 102 cbapi.util.spawn ("echo \"" .. w:url () .. " " ..
w:title () .. "\" >> ~/.cache/cream-browser/history")
> 103 end)
> 104
theme.lua:
> 00 theme.global.font = "droidsans normal 8"
> 01
> 02 theme.statsubar.bg_normal = "#000000"
> 03 theme.statusbar.bg_secure = "#B0FF00"
> 04 theme.statusbar.fg_normal = "#FFFFFF"
> 05 theme.statusbar.fg_secure = "#000000"
> 06 theme.statusbar.font = "droidsans normal 8"
> 07
> 08 theme.tab.border = "1px solid black"
> 09 theme.tab.bg_normal = "#505050"
> 10 theme.tab.bg_focus = "#000000"
> 11 theme.tab.fg_normal = "#CCCCCC"
> 12 theme.tab.fg_focus = "#FFFFFF"
> 13 theme.tab.font = "droidsans normal 8"
> 14
> 15 theme.prompt.font = "droidsans normal 8"
> 16 theme.prompt.bg_normal = "#151515"
> 17 theme.prompt.bg_error = "#FF0000"
> 18 theme.prompt.fg_normal = "#CCCCCC"
> 19 theme.prompt.fg_error = "#000000"
> 20
> 21 -- Module VTE (Virtual Terminal Emulator)
> 22 theme.module.vte.font = "droidsans normal 8"
> 23 theme.module.vte.shell = "/bin/sh"
> 24 theme.module.vte.bg = "#000000"
> 25 theme.module.vte.fg = "#CCCCCC"
----------------------------------------------------------------------------------------------------------------------------------------------
* modules ar shared libraries : This concept is pretty simple. The module
webkit (which allows
protocols HTTP and HTTPS) is compiled separatly of Cream-Browser, as a
dynamic library. Then, I
use GModule, from glib to load the module after Cream-Browser is started.
This need an API common
to every module.
GModule:
http://library.gnome.org/devel/glib/unstable/glib-Dynamic-Loading-of-Modules.html
----------------------------------------------------------------------------------------------------------------------------------------------
* a new error system : When Cream-Browser has a bug, you have to tell
every modules to stop its
activity. And when a module has a bug, you have to tell Cream-Browser to
stop using the module
(of course it depends of the error's type). So you need a system to report
and receive errors.
This one is in 2 parts.
1) Report an error
* The module have to "register an error domain", it's a name to
identify the
module. Then we attributes to this domain an integer identifier (the
hash of the name) and create
a FIFO (using sys/queue.h). Each domain, its identifier and the
pointer to the simple queue are
stored in a list.
* The module send an error using a simple function which needs 3
arguments : the domain identifier,
the type of error (fatal: the module can't continue to run,
critical: the module can continue to
run, warning: we can ignore it), and the error message
2) Receive the error
* Cream-Browser have to register a callback to the error system, a
callback which will be called every
times an error is reported. We can set more than one callback
3) Cream-Browser can send errors and modules can receive them.
----------------------------------------------------------------------------------------------------------------------------------------------
Send your comments about it ;)
Regards, David Delassus
|