From 5c356ce63880643e201ac6663508325d3581d52b Mon Sep 17 00:00:00 2001 From: Everaldo Canuto Date: Fri, 16 May 2008 16:31:05 +0000 Subject: [PATCH] 2008-05-16 Everaldo Canuto * 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 --- ChangeLog | 11 ++ samples/FunnyBrowser.cs | 188 ++++++++++++++++++++++++++++------ sources/Makefile.am | 4 +- sources/webkit-sharp.metadata | 183 +++++++++++++++++++++++++++++++-- 4 files changed, 348 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5d7861b..43ac2cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-05-16 Everaldo Canuto + + * 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 * sources/webkit-sharp.dll.config.in: Dll map added to webkit. diff --git a/samples/FunnyBrowser.cs b/samples/FunnyBrowser.cs index de32311..37d8075 100644 --- a/samples/FunnyBrowser.cs +++ b/samples/FunnyBrowser.cs @@ -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); } } } diff --git a/sources/Makefile.am b/sources/Makefile.am index 7aee645..31b7875 100644 --- a/sources/Makefile.am +++ b/sources/Makefile.am @@ -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 diff --git a/sources/webkit-sharp.metadata b/sources/webkit-sharp.metadata index 3c22f4d..a829480 100644 --- a/sources/webkit-sharp.metadata +++ b/sources/webkit-sharp.metadata @@ -1,14 +1,183 @@ + - + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +