I finally made it.

*In Browser.hs
-- Just return the current instance when request a new webview
-- That is to say It will open the page always in the same window.

onCreateWebView webview $
    \_ ->  webViewToWebViewPtr webview


*The implementation is:

webViewToWebViewPtr :: WebView -> IO (Ptr WebView)
webViewToWebViewPtr webview =
    withForeignPtr ((unWebView.toWebView) webview) $ \webViewPtr ->
return webViewPtr

webViewFromWebViewPtr :: (Ptr WebView) -> IO WebView
webViewFromWebViewPtr  =
    makeNewObject mkWebView . return


-- |create-web-view signal will emitted when user clicked a link and
the page request a new window
-- !!!NOTE!!!
-- Your callback functions should setup a new webview instance
-- and connect a callback function to this instance's signal "web-view-ready"
-- and finally return a (Ptr WebView)
-- You should not manipulate this instance now util it emit
"web-view-ready" signal!

onCreateWebView :: (WebViewClass self) => self -> (WebFrame -> IO (Ptr
WebView)) -> IO (ConnectId self)
onCreateWebView =
    connect_OBJECT__OBJECTPTR "create-web-view" True
    where connect_OBJECT__OBJECTPTR ::
              (GObjectClass a', GObjectClass obj) => SignalName ->
              ConnectAfter -> obj ->
              (a' -> IO (Ptr WebView)) ->
              IO (ConnectId obj)
          connect_OBJECT__OBJECTPTR signal after obj user =
            connectGeneric signal after obj action
              where action :: Ptr GObject -> Ptr GObject -> IO (Ptr WebView)
                    action _ obj1  =
                        failOnGError $
                        makeNewGObject mkGObject (return obj1) >>= \obj1' ->
                        user (unsafeCastGObject obj1')

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtk2hs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk2hs-devel

Reply via email to