[webkit-gtk] Implement runOpenPanel in WebKit2GTK+

Mario Sanchez Prada msanchez at igalia.com
Fri Feb 10 15:10:22 PST 2012


Hi all,

I started yesterday working on an implementation for WebKitUIClient's
runOpenPanel() in WebKit2GTK+, and would like to share here the ideas
behind it and the current status of it (aka the patch I have so far).

What I did so far is basically the following:

- Implement runOpenPanel() in WebKitUIClient.cpp, where I create 
  an object of a new class wrapping WKOpenPanelResultListenerRef and
  WKOpenPanelParametersRef, which I named WebKitOpenPanelDecision atm.

- The API for that new WebKitOpenPanelDecision is simple: it provides a 
  allows_multiple_files(), choose_files() and cancel() methods, 
  implemented in terms of the wrapped WKOpenPanelResultListenerRef and
  WKOpenPanelParametersRef attributes.

- Once that object is created, pass it to the webView to emit a new 
  signal from there, including that new object as parameter. At the
  moment, I named that new signal 'decide-open-panel', inspired in the
  'decide-policy' signal. It uses g_signal_accumulator_true_handled.

- Provide a default handler in the webview for this new signal so, if 
  not intercepted from the app, a GtkFileChooserDialog will be run and
  a handler for that dialog's 'response' signal will be installed, to 
  asynchronously handle the result after selecting files/cancelling: it 
  will call webkit_open_panel_decision_cancel() if the dialog was
  cancelled it and webkit_open_panel_decision_choose_files() otherwise.

I'm not quite sure about some parts of this at the moment (e.g. the
names for signals and the new class), but I think this is a good point
to start discussing about it, and see if we can agree on something
before keeping working along this line.

So, I'm attaching the patch I've at the moment for reference and in
order to help with the discussion. Please notice it's not a final patch,
but more kind of a draft :-)

Mario
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Implement-runOpenPanel-in-WebKit2GTK.patch
Type: text/x-patch
Size: 21976 bytes
Desc: not available
URL: <http://lists.webkit.org/pipermail/webkit-gtk/attachments/20120211/a2da391d/attachment.bin>


More information about the webkit-gtk mailing list