Own Page similar to about:* pages

Asked by sylwke3100 on 2013-08-19

I have idea for extension but i don't know how define own page/pages similar to all about pages. How create this page in code ?

Question information

Language:
English Edit question
Status:
Answered
For:
Midori Web Browser Edit question
Assignee:
No assignee Edit question
Last query:
2013-08-19
Last reply:
2013-08-20
André Stösel (ivaldi) said : #1

The "api" for about pages isn't merged yet, but you could use this branch: lp:~ivaldi/midori/about-content-signal

Example:

private class Test : Midori.Extension {
    private bool handle_about_content (Midori.View view, string uri) {
        if (uri == "about:foo") {
            view.web_view.load_html_string ("<h1>Foo :D</h1>", "about:foo");
            return true;
        }
        return false;
    }

    private void tab_added (Midori.Browser browser, Midori.View view) {
        view.about_content.connect (this.handle_about_content);
    }

    private void tab_removed (Midori.Browser browser, Midori.View view) {
        view.about_content.disconnect (this.handle_about_content);
    }

    private void browser_added (Midori.Browser browser) {
        foreach (Midori.View tab in browser.get_tabs ())
            this.tab_added (browser, tab);
        browser.add_tab.connect (this.tab_added);
        browser.remove_tab.connect (this.tab_removed);
    }

    private void browser_removed (Midori.Browser browser) {
        foreach (Midori.View tab in browser.get_tabs ())
            this.tab_removed (browser, tab);
        browser.add_tab.disconnect (this.tab_added);
        browser.remove_tab.disconnect (this.tab_removed);
    }

    private void activated (Midori.App app) {
        foreach (Midori.Browser browser in app.get_browsers ())
            this.browser_added (browser);
        app.add_browser.connect (this.browser_added);
        app.remove_browser.connect (this.browser_removed);
    }

    private void deactivated () {
        Midori.App app = this.get_app ();
        foreach (Midori.Browser browser in app.get_browsers ())
            this.browser_removed (browser);
        app.add_browser.disconnect (this.browser_added);
        app.remove_browser.disconnect (this.browser_removed);
    }

    internal Test () {
        GLib.Object (name: _("Test Extension"),
                     description: _("...."),
                     version: "0.1",
                     authors: "...");

        this.activate.connect (this.activated);
        this.deactivate.connect (this.deactivated);
    }
}

public Midori.Extension extension_init () {
    return new Test ();
}

Can you help with this problem?

Provide an answer of your own, or ask sylwke3100 for more information if necessary.

To post a message you must log in.