<?xml version="1.0"?>
<typesystem package="PyFalkon">
    <load-typesystem name="typesystem_webenginecore.xml" generate="no"/>
    <load-typesystem name="typesystem_webenginewidgets.xml" generate="no"/>
    <load-typesystem name="typesystem_sql.xml" generate="no"/>

    <inject-code class="native" position="beginning">
      #include &lt;pythonplugin.h&gt;
    </inject-code>

    <namespace-type name="Qz">
      <enum-type name="BrowserWindowType"/>
      <enum-type name="CommandLineAction"/>
      <enum-type name="ObjectName"/>
      <enum-type name="NewTabPositionFlag" flags="NewTabPositionFlags"/>
      <rejection class="*" field-name="sessionVersion"/>
    </namespace-type>

    <object-type name="LineEdit">
      <enum-type name="WidgetPosition"/>
      <enum-type name="EditAction"/>
    </object-type>
    <object-type name="SideWidget"/>
    <object-type name="SqueezeLabelV1"/>
    <object-type name="SqueezeLabelV2"/>
    <object-type name="QtSingleApplication">
      <include file-name="qtsingleapplication/qtsingleapplication.h" location="global"/>
      <modify-function signature="QtSingleApplication(int&amp;,char**,bool)" remove="all"/>
      <modify-function signature="QtSingleApplication(QString,int&amp;,char**)" remove="all"/>
    </object-type>
    <value-type name="LoadRequest">
      <enum-type name="Operation"/>
    </value-type>
    <object-type name="WebPage">
      <enum-type name="JsWorld"/>
      <modify-function signature="execJavaScript(QString,quint32,int)">
        <modify-argument index="2">
          <replace-default-expression with="WebPage::UnsafeJsWorld"/>
        </modify-argument>
      </modify-function>
      <modify-function signature="javaScriptPrompt(const QUrl&amp;, const QString&amp;, const QString&amp;, QString*)" remove="all"/>
    </object-type>
    <object-type name="WebView"/>
    <object-type name="WebInspector"/>
    <value-type name="WebHitTestResult"/>
    <object-type name="PluginInterface">
      <enum-type name="InitState"/>
    </object-type>
    <object-type name="ExternalJsObject">
      <include file-name="javascript/externaljsobject.h" location="global"/>
    </object-type>
    <object-type name="Plugins">
      <value-type name="Plugin">
        <enum-type name="Type"/>
      </value-type>
    </object-type>
    <value-type name="PluginSpec"/>
    <object-type name="PluginProxy">
      <enum-type name="EventHandlerType"/>
    </object-type>
    <object-type name="DesktopNotificationsFactory">
      <enum-type name="Type"/>
    </object-type>

    <object-type name="AutoSaver"/>
    <object-type name="BrowserWindow"/>
    <object-type name="DataPaths">
      <enum-type name="Path"/>
    </object-type>
    <object-type name="MainApplication">
      <enum-type name="AfterLaunch"/>
      <modify-function signature="MainApplication(int&amp;,char**)" remove="all"/>
    </object-type>
    <object-type name="Settings"/>

    <object-type name="AutoFill"/>
    <value-type name="PageFormData"/>
    <object-type name="PasswordManager"/>
    <value-type name="PasswordEntry"/>
    <object-type name="PasswordBackend">
      <include file-name="passwordbackends/passwordbackend.h" location="global"/>
    </object-type>

    <object-type name="BookmarkItem">
      <enum-type name="Type"/>
    </object-type>
    <object-type name="Bookmarks">
      <modify-function signature="addBookmark(BookmarkItem*, BookmarkItem*)">
        <modify-argument index="1">
          <define-ownership class="target" owner="c++"/>
        </modify-argument>
        <modify-argument index="2">
          <define-ownership class="target" owner="c++"/>
        </modify-argument>
      </modify-function>
    </object-type>
    <object-type name="BookmarksModel">
      <enum-type name="Roles"/>
    </object-type>
    <object-type name="BookmarksFoldersMenu"/>
    <object-type name="BookmarksFoldersButton"/>
    <object-type name="BookmarksTools"/>

    <object-type name="CookieJar"/>
    <object-type name="CookieManager"/>

    <object-type name="DownloadItem"/>
    <object-type name="DownloadManager">
      <enum-type name="DownloadOption"/>
      <value-type name="DownloadInfo"/>
    </object-type>

    <object-type name="History">
      <value-type name="HistoryEntry"/>
    </object-type>
    <object-type name="HistoryItem"/>
    <object-type name="HistoryModel">
      <enum-type name="Roles"/>
    </object-type>

    <object-type name="LocationBar">
      <value-type name="LoadAction">
        <enum-type name="Type"/>
      </value-type>
    </object-type>
    <object-type name="NavigationBar"/>

    <object-type name="NetworkManager">
      <modify-function signature="certificateError(QWebEngineCertificateError&amp;, QWidget*)" remove="all"/>
    </object-type>
    <object-type name="UrlInterceptor"/>
    <object-type name="ExtensionSchemeHandler">
      <include file-name="schemehandlers/extensionschemehandler.h" location="global"/>
    </object-type>

    <object-type name="SearchEnginesDialog"/>
    <object-type name="SearchEnginesManager">
      <value-type name="Engine"/>
    </object-type>

    <object-type name="CheckBoxDialog"/>
    <object-type name="QzSettings"/>
    <object-type name="StatusBar"/>

    <object-type name="SideBarManager">
      <modify-function signature="addSidebar(QString,SideBarInterface*)">
        <modify-argument index="2">
          <define-ownership owner="c++"/>
        </modify-argument>
      </modify-function>
    </object-type>
    <object-type name="SideBarInterface">
      <modify-function signature="createMenuAction()">
        <modify-argument index="return">
          <define-ownership class="target" owner="c++"/>
        </modify-argument>
      </modify-function>
      <modify-function signature="createSideBarWidget(BrowserWindow*)">
        <modify-argument index="return">
          <define-ownership class="target" owner="c++"/>
        </modify-argument>
      </modify-function>
    </object-type>

    <object-type name="SiteSettingsManager">
      <enum-type name="Permission"/>
      <enum-type name="PageOptions"/>
      <value-type name="SiteSettings"/>
    </object-type>

    <object-type name="ComboTabBar">
      <enum-type name="SizeType"/>
      <enum-type name="DropIndicatorPosition"/>
    </object-type>
    <object-type name="TabBar"/>
    <object-type name="TabContextMenu">
      <enum-type name="Option" flags="Options"/>
    </object-type>
    <object-type name="TabIcon">
      <value-type name="Data"/>
    </object-type>
    <object-type name="TabModel">
      <enum-type name="Roles"/>
    </object-type>
    <object-type name="TabMruModel"/>
    <object-type name="TabStackedWidget"/>
    <object-type name="TabTreeModel"/>
    <object-type name="TabWidget">
      <modify-function signature="addView(LoadRequest,QString,QFlags&lt;Qz::NewTabPositionFlag&gt;,bool,int,bool)">
        <modify-argument index="2">
          <replace-default-expression with="TabWidget::tr(&quot;New tab&quot;)"/>
        </modify-argument>
      </modify-function>
    </object-type>

    <object-type name="AbstractButtonInterface">
      <object-type name="ClickController"/>
    </object-type>
    <object-type name="ClickableLabel"/>
    <object-type name="DelayedFileWatcher"/>
    <value-type name="DesktopFile"/>
    <object-type name="Menu"/>
    <object-type name="Action"/>
    <object-type name="IconProvider"/>
    <object-type name="QzTools">
      <modify-function signature="getOpenFileName(const QString&amp;, QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)">
        <modify-argument index="return">
          <replace-type modified-type="(fileName, selectedFilter)"/>
        </modify-argument>
        <modify-argument index="6">
          <replace-type modified-type="QString"/>
          <replace-default-expression with="QString()"/>
        </modify-argument>
        <inject-code class="target" position="end">
          <insert-template name="return_for_QFileDialog"/>
        </inject-code>
      </modify-function>
      <modify-function signature="getOpenFileNames(const QString&amp;, QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)">
        <modify-argument index="return">
          <replace-type modified-type="(fileNames, selectedFilter)"/>
        </modify-argument>
        <modify-argument index="6">
          <replace-type modified-type="QString"/>
          <replace-default-expression with="QString()"/>
        </modify-argument>
        <inject-code class="target" position="end">
          <insert-template name="return_for_QFileDialog"/>
        </inject-code>
      </modify-function>
      <modify-function signature="getSaveFileName(const QString&amp;, QWidget*, const QString&amp;, const QString&amp;, const QString&amp;, QString*, QFlags&lt;QFileDialog::Option&gt;)">
        <modify-argument index="return">
          <replace-type modified-type="(fileName, selectedFilter)"/>
        </modify-argument>
        <modify-argument index="6">
          <replace-type modified-type="QString"/>
          <replace-default-expression with="QString()"/>
        </modify-argument>
        <inject-code class="target" position="end">
          <insert-template name="return_for_QFileDialog"/>
        </inject-code>
      </modify-function>
    </object-type>
    <object-type name="SqlQueryJob"/>
    <object-type name="SqlDatabase"/>
    <object-type name="ToolButton"/>
    <value-type name="WheelHelper">
      <enum-type name="Direction"/>
    </value-type>

    <object-type name="SearchToolBar"/>
    <object-type name="TabbedWebView"/>
    <object-type name="WebTab">
      <enum-type name="AddChildBehavior"/>
    </object-type>

    <add-function signature="registerPlugin(PluginInterface*)">
      <inject-code class="target" position="beginning">
        Py_INCREF(%PYARG_1);
        pyfalkon_register_plugin(%1);
      </inject-code>
    </add-function>

    <inject-code class="target" position="end">
    QList&lt;QByteArray&gt; version = QByteArray(Qz::VERSION).split('.');
    PyObject *pyFalkonVersion = PyTuple_New(3);
    for (int i = 0; i &lt; 3; ++i)
        PyTuple_SET_ITEM(pyFalkonVersion, i, PyLong_FromLong(version[i].toInt()));
    PyModule_AddObject(module, "__version_info__", pyFalkonVersion);
    PyModule_AddStringConstant(module, "__version__", Qz::VERSION);
    </inject-code>

    <template name="return_for_QFileDialog">
    %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5, &amp;%6, %7);
    %PYARG_0 = PyTuple_New(2);
    PyTuple_SET_ITEM(%PYARG_0, 0, %CONVERTTOPYTHON[%RETURN_TYPE](retval_));
    auto ARG6_PTR = &amp;%6;
    PyTuple_SET_ITEM(%PYARG_0, 1, %CONVERTTOPYTHON[%ARG6_TYPE](ARG6_PTR));
    </template>

    <suppress-warning text="Unable to translate type &quot;std::function&lt;QPoint (QSize)&gt;&quot;:*"/>
    <suppress-warning text="Unable to translate type &quot;std::function&lt;void ()&gt;&quot;:*"/>
    <suppress-warning text="skipping field 'ClickController::popupClosed'*"/>
    <suppress-warning text="skipping field 'ClickController::popupPosition'*"/>

</typesystem>
