Hi, Axel
Thanks for your help.
I am working on it, it seems works very well. after I finish it, I
will upload a new patch.
And I still had another problem when implementing a signal of webkitgtk.
In webkitgtk, there is a signal "create-web-view", when link pressed
and requires to open a new window, it will be emitted,
And require developer to prepare a new webview instance and return it
in callback.
Webkitgtk will internally pass the url to the new webview instance and
setup settings for it.
after it is ready, "web-view-ready" signal will be emitted and inform
developer the widget can be shown now.
please look at below c codes for reference.
My question is how can I implemented it in Haskell.
I tried like this.
connect_OBJECT__OBJECT ::
(GObjectClass a', GObjectClass obj) => SignalName ->
ConnectAfter -> obj ->
(a' -> IO WebView) ->
IO (ConnectId obj)
connect_OBJECT__OBJECT signal after obj user =
connectGeneric signal after obj action
where action :: Ptr GObject -> Ptr GObject -> IO WebView
action _ obj1 =
failOnGError $
makeNewGObject mkGObject (return obj1) >>= \obj1' ->
user (unsafeCastGObject obj1')
onCreateWebView :: (WebViewClass self) => self -> (WebFrame -> IO
WebView) -> IO (ConnectId self)
onCreateWebView =
connect_OBJECT__OBJECT "create-web-view" True
onCreateWebView2 :: (WebViewClass self) => self -> (WebFrame -> IO())
-> IO (ConnectId self)
onCreateWebView2 =
connect_OBJECT__NONE "create-web-view" True
And onCreateWebView2 works, I can catch the signal but it is not full
functionality.
if I use,
-- I tried to return the current webview instance.
onCreateWebView webview $ \_ -> return webview.
It will cause a segfault.
With ltrace, I got:
g_object_ref(0x81182c8, 0xad9145e0, 0, 0xad60be20, 0xbfa77248)
= 0x81182c8
g_type_fundamental(0x8138dc8, 0x80ea960, 0x80ea960, 0xb689ed44,
0x81a9a60) = 80
g_value_set_object(0xbfa78c60, 0xb4b81305, 0x80ea960, 0xb689ed44,
0x81a9a60 <unfinished ...>
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++
Any help on this?
Thanks.
========================
the example c code, return the current webview instance, so it will
open url always on the same window.
WebKitWebView * webview = webview = WEBKIT_WEB_VIEW(webkit_web_view_new();
g_signal_connect(G_OBJECT(webview),"create-web-view",
G_CALLBACK(create_cb),webview);
WebKitWebView * create_cb(WebKitWebView *w, WebKitWebFrame *f,gpointer data)
{
fprintf(stderr,"creatre!!! %s\n",webkit_web_frame_get_uri(f));
return data;
}
On Sun, Sep 13, 2009 at 3:48 PM, Axel Simon <[email protected]> wrote:
> Hi,
>
> On Sep 12, 2009, at 15:26, Cjacker wrote:
>
>> Hello, everybuddy,
>>
>> Here is webkit binding patch for gtk2hs
>> and tested with gtk2hs.darcs/gtk2hs-0.10.1 and webkit-1.1.13.
>>
>> To see how to use, check demo/webkit.
>>
>> Hope it can be merged:-)
>
> It certainly can. That's quite an amazing patch!
>
> Before I apply this patch, I'd like to check if you used the right functions
> to construct objects. I see you use makeNewObject throughout. This is
> correct if all the objects you're creating are GtkObjects or GtkWidgets
> (more likely). Many object that do not represent widgets are mere GObjects.
> In this case you need to use constructGObject or makeGObject. This might
> explain why you had to use castPtr in many places. Note that there is only
> one constructor function for GtkObject/GtkWidget but two for GObject. The
> constructGObject function is used when a new object is created, the
> makeGObject function is when you extract a GObject from an existing data
> structure in Webkit. The difference between the two lies in the way
> reference counting is done.
>
> Could you review you patch with respect to this? You could start to change
>
> webSettingsNew = do
> makeNewObject mkWebSettings $ liftM castPtr ${#call web_settings_new#}
>
> webSettingsNew = do
> constructNewGObject mkWebSettings {#call web_settings_new#}
>
> and see if this works.
>
> Thanks a lot in advance,
>
> Axel.
>
>
>
>> <add-webkit-binding.dpatch>
>
>
>
------------------------------------------------------------------------------
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