1

現在、webkit gtk ビューで html ファイルを実行しています。これらの設定を設定しました:

    let new_settings = new WebKit.WebSettings ();
    new_settings.enable_universal_access_from_file_uris = true;
    this._web_view.set_settings(new_settings);

私のコンピューターにファイルをダウンロードさせてくれると思っていました(これは私がやろうとしていることではありませんが、テストしたかったのです)。これはうまくいきませんでした:/

担当のhtmlは以下です。

<a href="resume/resume1.doc"><img class="shadow" src="images/design/1.jpg" alt="img01"></a>

私がやろうとしているのは、ユーザーが画像をクリックしたときに、リブレオフィス内でresume1.docを自動的に開くことです。GTK/HTMLでそれを行う方法がよくわかりません

ありがとう!:)

4

2 に答える 2

0

あなたはそれを正しく始めています。MIME タイプを処理し、Libre Office を開く方法を決定するだけです。ローカル ファイルの例を次に示します (uri は、ローカルで開きたいサーバー上の特定のドキュメントへのパスです)。

this._web_view.connect('mime-type-policy-decision-requested',
        (function (webview, frame, request, mimetype, decision) {
            if (mimetype === 'application/msword' ||
                mimetype === 'application/vnd.oasis.opendocument.spreadsheet') {
                // Spawn a libreoffice process with this uri. Necessary because
                // we want to open the files as templates - the `-n` option
                // requires the user to save-as.
                GLib.spawn_async(null, /* cwd */
                                 ['libreoffice', '-n', request.get_uri()],
                                 null, /* inherit environment */
                                 GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.SEARCH_PATH,
                                 null /* setup function */ );
                decision.ignore();
                return true;

            } else if (mimetype === 'application/pdf') {
                // if PDF, use the build in viewer (usually evince)
                Gtk.show_uri(null, request.get_uri(), 0);
                decision.ignore();
                return true;
            }
            // default handler
            return false;
    }).bind(this));
于 2016-07-14T23:21:04.233 に答える