Hi Martin,

thanks for getting back on this!

On 02/06/2012 06:17 PM, Martin Robinson wrote:
On Mon, Feb 6, 2012 at 7:44 AM, Simon Schampijer<[email protected]>  wrote:

- is the approach above with a 'upload-requested' signal a good one that you
would consider of adding as public API or are there other better approaches
to solve the issue of having a custom file-chooser?

I think it makes a lot of sense. There's some kind of generic "run an
open panel" signal that the WebKit layer gets. We could pipe that out
to a WebKitWebView signal.

Ok, I did an initial patch (attached) to pipe an "upload-requested" signal out, the return value is a boolean to indicate whether the application handles the upload or not.

We have to get back the information from the application which file(s) should be uploaded as well. I wonder how the API would best look like for this. We could handle that in the return value, if we get a filename back it was handled, if NULL is returned we display the default upload dialog. This would be similar signal handling as in 'create-plugin-widget' where we return a widget from the signal callback. Looks like we would have to write a custom GSignalAccumulator for this. Other ideas suggestions?

- is this an easy addition for someone familiar with the codebase? Is there
someone willing to do it or do I have to try and rip my hair out and write
an ugly patch first? :)

It's a little hairy to get and build WebKit, but you can always drop
by the channel and ask for help. :) There's also a lot of good
documentation:

http://trac.webkit.org/wiki/BuildingGtk
http://www.webkit.org/coding/contributing.html

Yeah, it uses a lot of disk resources actually :) I am patching the Fedora rpm for the moment.

- API additions for webkit vs webkit2?

It'd make sense to have it in both ports actually.

Agreed,
   Simon

diff -ru webkit-1.6.1/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp webkit-1.6.1-upload/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
--- webkit-1.6.1/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp.old	2011-09-26 22:55:01.000000000 +0200
+++ webkit-1.6.1/Source/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp	2012-02-09 22:24:05.930973589 +0100
@@ -606,6 +606,12 @@
 {
     RefPtr<FileChooser> chooser = prpFileChooser;
 
+    gboolean handled;
+    g_signal_emit_by_name(m_webView, "upload-requested", &handled);
+    if (handled) {
+        return;
+    }
+
     GtkWidget* dialog = gtk_file_chooser_dialog_new(_("Upload File"),
                                                     GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(m_webView))),
                                                     GTK_FILE_CHOOSER_ACTION_OPEN,
diff -ru webkit-1.6.1/Source/WebKit/gtk/webkit/webkitwebview.cpp webkit-1.6.1-upload/Source/WebKit/gtk/webkit/webkitwebview.cpp
--- webkit-1.6.1/Source/WebKit/gtk/webkit/webkitwebview.cpp.old	2011-09-26 22:55:01.000000000 +0200
+++ webkit-1.6.1/Source/WebKit/gtk/webkit/webkitwebview.cpp	2012-02-09 23:24:06.085892079 +0100
@@ -178,6 +178,7 @@
     PASTE_CLIPBOARD,
     CUT_CLIPBOARD,
     DOWNLOAD_REQUESTED,
+    UPLOAD_REQUESTED,
     MOVE_CURSOR,
     PRINT_REQUESTED,
     PLUGIN_WIDGET,
@@ -2000,6 +2001,21 @@
             G_TYPE_OBJECT);
 
     /**
+     * WebKitWebView::upload-requested:
+     * @webView: the object on which the signal is emitted
+     *
+     * A new Upload is being requested.
+     */
+    webkit_web_view_signals[UPLOAD_REQUESTED] = g_signal_new("upload-requested",
+        G_TYPE_FROM_CLASS(webViewClass),
+        (GSignalFlags)G_SIGNAL_RUN_LAST,
+        0,
+        g_signal_accumulator_true_handled,
+        NULL,
+        webkit_marshal_BOOLEAN__OBJECT,
+        G_TYPE_BOOLEAN, 0);
+
+    /**
      * WebKitWebView::load-started:
      * @webView: the object on which the signal is emitted
      * @frame: the frame going to do the load

_______________________________________________
webkit-gtk mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-gtk

Reply via email to