зеркало из https://github.com/mono/webkit-sharp.git
2008-05-16 Everaldo Canuto <ecanuto@novell.com>
* sources/Makefile.am: Add carriage return to .h fix routine. * sources/webkit-sharp.metadata: Add WebView signals. * samples/FunnyBrowser.cs: Improved sample browse: - Add toolbar buttons back, forward, stop and refresh. - Add URI entry to type addresses. - Show links on status bar using mouse over events. svn path=/trunk/webkit-sharp/; revision=103351
This commit is contained in:
Родитель
fbe102471c
Коммит
5c356ce638
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2008-05-16 Everaldo Canuto <ecanuto@novell.com>
|
||||
|
||||
* sources/Makefile.am: Add carriage return to .h fix routine.
|
||||
|
||||
* sources/webkit-sharp.metadata: Add WebView signals.
|
||||
|
||||
* samples/FunnyBrowser.cs: Improved sample browse:
|
||||
- Add toolbar buttons back, forward, stop and refresh.
|
||||
- Add URI entry to type addresses.
|
||||
- Show links on status bar using mouse over events.
|
||||
|
||||
2008-05-12 Everaldo Canuto <ecanuto@novell.com>
|
||||
|
||||
* sources/webkit-sharp.dll.config.in: Dll map added to webkit.
|
||||
|
|
|
@ -52,61 +52,191 @@ namespace FunnyBrowser
|
|||
const string APP_NAME = "FunnyBrowser";
|
||||
|
||||
private string url = "http://www.google.com/";
|
||||
private Toolbar toolbar = null;
|
||||
|
||||
private Gtk.VBox vbox = null;
|
||||
private Gtk.Toolbar toolbar = null;
|
||||
private Gtk.Toolbar findbar = null;
|
||||
private Gtk.Entry uri_entry = null;
|
||||
private Gtk.Entry find_entry = null;
|
||||
private WebKit.WebView webview = null;
|
||||
private Gtk.Statusbar statusbar = null;
|
||||
|
||||
private Gtk.Action action_back;
|
||||
private Gtk.Action action_forward;
|
||||
private Gtk.Action action_reload;
|
||||
private Gtk.Action action_stop;
|
||||
private Gtk.Action action_jump;
|
||||
|
||||
public MainWindow (string url): base (Gtk.WindowType.Toplevel)
|
||||
{
|
||||
if (url != "")
|
||||
this.url = url;
|
||||
|
||||
InitializeWidgets ();
|
||||
CreateWidgets ();
|
||||
webview.Open (this.url);
|
||||
}
|
||||
|
||||
private void InitializeWidgets ()
|
||||
private void CreateWidgets ()
|
||||
{
|
||||
this.Title = "";
|
||||
this.Title = APP_NAME;
|
||||
this.SetDefaultSize (700, 500);
|
||||
this.DeleteEvent += new DeleteEventHandler (OnDeleteEvent);
|
||||
|
||||
Gtk.VBox vbox = new VBox (false, 1);
|
||||
|
||||
toolbar = new Toolbar ();
|
||||
toolbar.ToolbarStyle = ToolbarStyle.Both;
|
||||
toolbar.Orientation = Orientation.Horizontal;
|
||||
toolbar.ShowArrow = true;
|
||||
vbox.PackStart (toolbar, false, false, 0);
|
||||
|
||||
webview = new WebView ();
|
||||
|
||||
CreateActions ();
|
||||
CreateToolbar ();
|
||||
CreateWebView ();
|
||||
CreateFindbar ();
|
||||
CreateStatusBar ();
|
||||
|
||||
Gtk.ScrolledWindow scroll = new Gtk.ScrolledWindow ();
|
||||
scroll.Add (webview);
|
||||
scroll.SetPolicy (PolicyType.Automatic, PolicyType.Automatic);
|
||||
|
||||
vbox = new Gtk.VBox (false, 1);
|
||||
vbox.PackStart (toolbar, false, false, 0);
|
||||
vbox.PackStart (scroll);
|
||||
|
||||
statusbar = new Gtk.Statusbar ();
|
||||
//vbox.PackStart (findbar, false, false, 0);
|
||||
vbox.PackEnd (statusbar, false, true, 0);
|
||||
|
||||
this.Add (vbox);
|
||||
this.ShowAll ();
|
||||
}
|
||||
|
||||
/*public string Caption
|
||||
|
||||
private void CreateActions ()
|
||||
{
|
||||
get { return base.Title; }
|
||||
set {
|
||||
string fmt_str = (value != "") ? "{1} - {0}" : "{0}";
|
||||
|
||||
base.Title = String.Format (fmt_str, APP_NAME, value);
|
||||
}
|
||||
}*/
|
||||
|
||||
protected void OnDeleteEvent (object sender, DeleteEventArgs a)
|
||||
action_back = new Gtk.Action("go-back", "Go Back", null, "gtk-go-back");
|
||||
action_forward = new Gtk.Action("go-forward", "Go Forward", null, "gtk-go-forward");
|
||||
action_reload = new Gtk.Action("reload", "Reload", null, "gtk-refresh");
|
||||
action_stop = new Gtk.Action("stop", "Stop", null, "gtk-stop");
|
||||
action_jump = new Gtk.Action("jump", "Jump", null, "gtk-jump-to");
|
||||
|
||||
action_back.Activated += new EventHandler(on_back_activate);
|
||||
action_forward.Activated += new EventHandler(on_forward_activate);
|
||||
action_reload.Activated += new EventHandler(on_reload_activate);
|
||||
action_stop.Activated += new EventHandler(on_stop_activate);
|
||||
action_jump.Activated += new EventHandler(on_uri_activate);
|
||||
}
|
||||
|
||||
private void CreateToolbar ()
|
||||
{
|
||||
// UrlEntry
|
||||
uri_entry = new Gtk.Entry ();
|
||||
uri_entry.Activated += new EventHandler(on_uri_activate);
|
||||
|
||||
Gtk.ToolItem uri_item = new Gtk.ToolItem ();
|
||||
uri_item.Expand = true;
|
||||
uri_item.Add (uri_entry);
|
||||
|
||||
// Toolbar
|
||||
toolbar = new Toolbar ();
|
||||
toolbar.ToolbarStyle = ToolbarStyle.Icons;
|
||||
toolbar.Orientation = Orientation.Horizontal;
|
||||
toolbar.ShowArrow = true;
|
||||
|
||||
// Toolbar Itens
|
||||
toolbar.Add (action_back.CreateToolItem());
|
||||
toolbar.Add (action_forward.CreateToolItem());
|
||||
toolbar.Add (action_reload.CreateToolItem());
|
||||
toolbar.Add (action_stop.CreateToolItem());
|
||||
toolbar.Add (uri_item);
|
||||
toolbar.Add (action_jump.CreateToolItem());
|
||||
}
|
||||
|
||||
private void CreateWebView ()
|
||||
{
|
||||
webview = new WebView ();
|
||||
webview.Editable = false;
|
||||
webview.TitleChanged += new TitleChangedHandler (OnTitleChanged);
|
||||
webview.HoveringOverLink += new HoveringOverLinkHandler (OnHoveringOverLink);
|
||||
webview.LoadCommitted += new LoadCommittedHandler (OnLoadCommitted);
|
||||
webview.LoadFinished += new LoadFinishedHandler (OnLoadFinished);
|
||||
}
|
||||
|
||||
private void CreateStatusBar ()
|
||||
{
|
||||
statusbar = new Gtk.Statusbar ();
|
||||
}
|
||||
|
||||
private void CreateFindbar ()
|
||||
{
|
||||
// FindEntry
|
||||
find_entry = new Gtk.Entry ();
|
||||
//find_entry.Activated += new EventHandler(on_uri_activate);
|
||||
|
||||
Gtk.ToolItem find_item = new Gtk.ToolItem ();
|
||||
//find_item.Expand = true;
|
||||
find_item.Add (find_entry);
|
||||
|
||||
// Toolbar
|
||||
findbar = new Toolbar ();
|
||||
findbar.ToolbarStyle = ToolbarStyle.Icons;
|
||||
findbar.Orientation = Orientation.Horizontal;
|
||||
findbar.ShowArrow = true;
|
||||
|
||||
// Toolbar Itens
|
||||
findbar.Add (action_stop.CreateToolItem());
|
||||
findbar.Add (find_item);
|
||||
findbar.Add (action_back.CreateToolItem());
|
||||
findbar.Add (action_forward.CreateToolItem());
|
||||
}
|
||||
|
||||
protected void OnDeleteEvent (object sender, DeleteEventArgs args)
|
||||
{
|
||||
Application.Quit ();
|
||||
a.RetVal = true;
|
||||
args.RetVal = true;
|
||||
}
|
||||
|
||||
private void OnTitleChanged (object o, TitleChangedArgs args)
|
||||
{
|
||||
if (args.Title == String.Empty)
|
||||
this.Title = APP_NAME;
|
||||
else
|
||||
this.Title = String.Format ("{0} - {1}", args.Title, APP_NAME);
|
||||
}
|
||||
|
||||
private void OnHoveringOverLink (object o, HoveringOverLinkArgs args)
|
||||
{
|
||||
statusbar.Pop (1);
|
||||
if (args.Link != null) {
|
||||
statusbar.Push (1, args.Link);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoadCommitted (object o, LoadCommittedArgs args)
|
||||
{
|
||||
action_back.Sensitive = webview.CanGoBack ();
|
||||
action_forward.Sensitive = webview.CanGoForward ();
|
||||
|
||||
uri_entry.Text = args.Frame.Uri;
|
||||
}
|
||||
|
||||
private void OnLoadFinished (object o, LoadFinishedArgs args)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
private void on_back_activate (object o, EventArgs args)
|
||||
{
|
||||
webview.GoBack ();
|
||||
}
|
||||
|
||||
private void on_forward_activate (object o, EventArgs args)
|
||||
{
|
||||
webview.GoForward ();
|
||||
}
|
||||
|
||||
private void on_reload_activate (object o, EventArgs args)
|
||||
{
|
||||
webview.Reload ();
|
||||
}
|
||||
|
||||
private void on_stop_activate (object o, EventArgs args)
|
||||
{
|
||||
webview.StopLoading ();
|
||||
}
|
||||
|
||||
private void on_uri_activate (object o, EventArgs args)
|
||||
{
|
||||
webview.Open (uri_entry.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ all: generated-stamp $(ASSEMBLY)
|
|||
get-sources:
|
||||
cp -rf /usr/include/webkit-1.0 .
|
||||
@for file in webkit-1.0/webkit/*.h; do \
|
||||
sed -i -e 's,WEBKIT_API ,/*WEBKIT_API*/ ,' $$file; \
|
||||
sed -i -e 's,^WEBKIT_API ,/*WEBKIT_API*/\r,' $$file; \
|
||||
done
|
||||
@for file in webkit-1.0/JavaScriptCore/*.h; do \
|
||||
sed -i -e 's,JS_EXPORT ,/*JS_EXPORT*/ ,' $$file; \
|
||||
sed -i -e 's,^JS_EXPORT ,/*JS_EXPORT*/\r,' $$file; \
|
||||
done
|
||||
|
||||
api: get-sources
|
||||
|
|
|
@ -1,14 +1,183 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- TODO: navigation-requested -->
|
||||
<metadata>
|
||||
|
||||
<!-- Add missing events in WebView -->
|
||||
<add-node path="/api/namespace/object[@cname='WebKitWebFrame']">
|
||||
|
||||
<method name="GetName" cname="webkit_web_frame_get_name">
|
||||
<return-type type="const-gchar*" />
|
||||
</method>
|
||||
<method name="GetTitle" cname="webkit_web_frame_get_title">
|
||||
<return-type type="const-gchar*" />
|
||||
</method>
|
||||
<method name="GetUri" cname="webkit_web_frame_get_uri">
|
||||
<return-type type="const-gchar*" />
|
||||
</method>
|
||||
|
||||
</add-node>
|
||||
|
||||
|
||||
<!-- Add missing signal in WebView -->
|
||||
<add-node path="/api/namespace/object[@cname='WebKitWebView']">
|
||||
<signal name="TitleChanged" cname="title-changed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="WindowObjectCleared" cname="window-object-cleared" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
<parameter type="gpointer" name="context" /> <!-- TODO: check the right type -->
|
||||
<parameter type="gpointer" name="window_object" /> <!-- TODO: check the right type -->
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="LoadStarted" cname="load-started" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="LoadCommitted" cname="load-committed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="LoadProgressChanged" cname="load-progress-changed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="gint" name="progress" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="LoadFinished" cname="load-finished" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="TitleChanged" cname="title-changed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
<parameter type="const-gchar*" name="title" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="HoveringOverLink" cname="hovering-over-link" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="const-gchar*" name="title" />
|
||||
<parameter type="const-gchar*" name="link" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="PopulatePopup" cname="populate-popup" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="GtkMenu" name="menu" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="StatusBarTextChanged" cname="status-bar-text-changed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="const-gchar*" name="value" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="IconLoaded" cname="icon-loaded" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="SelectionChanged" cname="selection-changed" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="ConsoleMessage" cname="console-message" when="LAST">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="const-gchar*" name="message" />
|
||||
<parameter type="gint" name="line" />
|
||||
<parameter type="const-gchar*" name="source_id" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="ScriptAlert" cname="script-alert" when="LAST">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
<parameter type="const-gchar*" name="message" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="ScriptConfirm" cname="script-confirm" when="LAST">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
<parameter type="const-gchar*" name="message" />
|
||||
<parameter type="gboolean" name="confirmed" />
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<signal name="ScriptPrompt" cname="script-prompt" when="LAST">
|
||||
<return-type type="gboolean" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
<parameter type="WebKitWebFrame*" name="frame" />
|
||||
<parameter type="const-gchar*" name="message" />
|
||||
<parameter type="const-gchar*" name="default_value" />
|
||||
<parameter type="gpointer" name="text" /> <!-- TODO: check the right type -->
|
||||
</parameters>
|
||||
</signal>
|
||||
|
||||
<!-- TODO: We really need this signals ?
|
||||
|
||||
<signal name="SelectedAll" cname="select-all" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
<signal name="ClipboardCut" cname="cut-clipboard" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
<signal name="ClipboardCopy" cname="copy-clipboard" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>
|
||||
<signal name="PastedClipboard" cname="paste-clipboard" when="LAST">
|
||||
<return-type type="void" />
|
||||
<parameters>
|
||||
<parameter type="WebKitWebView*" name="webview" />
|
||||
</parameters>
|
||||
</signal>-->
|
||||
|
||||
</add-node>
|
||||
|
||||
</metadata>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче