{% extends "base.html" %}

{% block title %}{{ namespace.name }}.{{ interface.name }}{% endblock %}

{% block meta_other %}
  <meta property="og:title" content="{{ namespace.name }}.{{ interface.name }}"/>
  <meta property="og:description" content="Reference for {{ namespace.name }}.{{ interface.name }}"/>
  <meta name="twitter:title" content="{{ namespace.name }}.{{ interface.name }}"/>
  <meta name="twitter:description" content="Reference for {{ namespace.name }}.{{ interface.name }}"/>
{% endblock %}

{% macro sidebar_block(elements, iface_name, section_title, section_class, section_fragment) -%}
{% if elements|length > 0 %}
<div class="section">
  <h5>{{ section_title }}</h5>
  <div class="links">
  {% for m in elements %}
    <a class="{{ section_class }}" href="{{ section_fragment }}.{{ iface_name }}.{{ m.name }}.html">{{ m.name }}</a>
  {% endfor %}
  </div>
</div>
{% endif %}
{% endmacro %}

{% block sidebar %}
<div class="section">
  <h5>Type</h5>
  <div class="links">
    <a class="current" href="iface.{{ interface.name }}.html#description">{{ interface.name }}</a>
  </div>
</div>

{% for section in sections %}
  {{ sidebar_block(section.index, interface.name, section.title, section.section_class, section.section_fragment) }}
{% endfor %}
{% endblock %}

{% macro navbar_block(elements, section_title, section_link) -%}
{% if elements|length > 0 %}
<li class="toc-list-item"><a href="{{ section_link }}"><span class="link-text">{{ section_title }}</span></a></li>
{% endif %}
{% endmacro %}

{% block navbar %}
<div id="toc" class="toc">
  <nav aria-labelledby="toc-title">
    <p id="toc-title">Content</p>
    <ul class="toc-list">
      <li class="toc-list-item"><a href="#description"><span class="link-text">Description</span></a></li>
      {% if interface.description_toc %}
      <ul class="toc-list">
      {% if interface.description_toc|length == 1 %}
      {% for header in interface.description_toc[0].children %}
        <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name }}</span></a></li>
      {% endfor %}
      {% else %}
      {% for header in interface.description_toc %}
        <li class="toc-list-item"><a href="#{{ header.id }}"><span class="link-text">{{ header.name }}</span></a></li>
      {% endfor %}
      {% endif %}
      </ul>
      {% endif %}
      {{ navbar_block(interface.type_funcs, "Functions", "#type-functions") }}
      {{ navbar_block(interface.methods, "Methods", "#methods") }}
      {{ navbar_block(interface.properties, "Properties", "#properties") }}
      {{ navbar_block(interface.signals, "Signals", "#signals") }}
      {{ navbar_block(interface.class_methods, "Class methods", "#class-methods") }}
      {{ navbar_block(interface.virtual_methods, "Virtual methods", "#virtual-methods") }}
    </ul>
  </nav>
</div>
{% endblock %}

{% block content %}
<section id="main" class="content">
  <header>
    <h3>Interface</h3>
    <h1><a href="index.html">{{ namespace.name }}</a><span class="sep"></span>{{ interface.name }}</h1>
  </header>

  <section>
    <summary>
      <div class="docblock">
        <p>
        {%- if CONFIG.is_unstable(interface.available_since) -%}
        <span class="emblem available-next" title="This type will be available in the next stable release">unstable</span>&nbsp;
        {%- endif %}
        {%- if interface.deprecated_since -%}
        <span class="emblem deprecated">deprecated: {{ interface.deprecated_since.version }}</span>&nbsp;
        {%- endif -%}
        {%- if interface.available_since -%}
        <span class="emblem available">since: {{ interface.available_since }}</span>
        {%- endif -%}
        </p>
      </div>
      <div class="toggle-wrapper">
        <h4 id="description" style="display:flex;">
          Description
          <a href="#description" class="anchor"></a>
          {% if CONFIG.source_location_url and interface.docs_location %}
          <a class="srclink" title="go to source location" href="{{ CONFIG.source_link(interface.docs_location) }}">[src]</a>
          {% endif %}
        </h4>

        <pre><code>{{ interface.c_decl }}</code></pre>

        <div class="docblock">
          {{ interface.description }}
        </div>

        <div class="docblock">
          {% if interface.stability %}
          <p>Stability: {{ interface.stability }}</p>
          {% endif %}
          {% if interface.available_since %}
          <p>Available since: {{ interface.available_since }}</p>
          {% endif %}
          {% if interface.deprecated_since %}
          <div class="admonition deprecation">
            <p class="admonition-title">Deprecated since: {{ interface.deprecated_since.version }}</p>
            {%- if interface.deprecated_since.message -%}
            {{ interface.deprecated_since.message }}
            {%- else -%}
            <p>Do not use in newly written code.</p>
            {%- endif -%}
          </div>
          {% endif %}
        </div>

        {% if interface.attributes %}
        <div class="docblock">
          <table class="attributes">
          {% for (key, value) in interface.attributes.items()|sort %}
            <tr><td>{{ key|escape }}</td><td>{{ value|escape }}</td></tr>
          {% endfor %}
          </table>
        </div>
        {% endif %}
      </div>
    </summary>

    <div class="toggle-wrapper prerequisite">
      <h4 id="prerequisite">
        Prerequisite
        <a href="#prerequisite" class="anchor"></a>
      </h4>

      <div class="docblock">
        <p>In order to implement {{ interface.name }}, your type must inherit from
        {%- if interface.requires_namespace == namespace.name -%}
        <a href="{{ interface.requires_link_fragment }}.{{ interface.requires_name }}.html">
        {%- else -%}
        <a data-namespace="{{ interface.requires_namespace }}" data-link="{{ interface.requires_link_fragment }}.{{ interface.requires_name }}.html" href="javascript:void(0)" class="external">
        {%- endif -%}
        <code>{{ interface.requires_ctype }}</code></a>.</p>
      </div>
    </div>

    {% if interface.implementations %}
    <div class="implementations toggle-wrapper default-hide">
      <h4 id="implementations">Implementations<a href="#implementations" class="anchor"></a></h4>
      <div class="docblock">
        <ul>
        {%- for impl in interface.implementations %}
          <li><a href="class.{{ impl.name }}.html">{{ impl.ctype }}</a></li>
        {% endfor -%}
        </ul>
      </div>
    </div>
    {% endif %}

    {% if interface.type_funcs %}
    <div class="methods toggle-wrapper">
      <h4 id="type-functions">
        Functions
        <a href="#type-functions" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for func in interface.type_funcs %}
      <div class="{% if func.deprecated_since %}deprecated{% endif %}">
        <h6><a href="type_func.{{ interface.name }}.{{ func.name }}.html">{{ func.identifier }}</a></h6>
        <div class="docblock">
          {{ func.summary }}
        </div>
        <div class="docblock">
          <p>
          {%- if CONFIG.is_unstable(func.available_since) -%}
          <span class="emblem available-next" title="This function will be available in the next stable release">unstable</span>&nbsp;
          {%- endif %}
          {%- if func.deprecated_since -%}
          <span class="emblem deprecated">deprecated: {{ func.deprecated_since }}</span>&nbsp;
          {%- endif -%}
          {%- if func.available_since -%}
          <span class="emblem available">since: {{ func.available_since }}</span>
          {%- endif -%}
          </p>
        </div>
      </div>
      {% endfor %}
      </div>
    </div>
    {% endif %}

    {% if interface.methods %}
    <div class="methods toggle-wrapper">
      <h4 id="methods">
        Instance methods
        <a href="#methods" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for method in interface.methods %}
        <div class="{% if method.deprecated_since %}deprecated{% endif %}">
          <h6><a href="method.{{ interface.name}}.{{ method.name }}.html">{{ method.identifier }}</a></h6>
          <div class="docblock">
            {{ method.summary }}
          </div>
          <div class="docblock">
            <p>
            {%- if CONFIG.is_unstable(method.available_since) -%}
            <span class="emblem available-next" title="This method will be available in the next stable release">unstable</span>&nbsp;
            {%- endif %}
            {%- if method.deprecated_since -%}
            <span class="emblem deprecated">deprecated: {{ method.deprecated_since }}</span>&nbsp;
            {%- endif -%}
            {%- if method.available_since -%}
            <span class="emblem available">since: {{ method.available_since }}</span>
            {%- endif -%}
            </p>
          </div>
        </div>
      {% endfor %}
      </div>

    </div>
    {% endif %}

    {% if interface.properties %}
    <div class="properties toggle-wrapper">
      <h4 id="properties">
        Properties
        <a href="#properties" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for property in interface.properties %}
        <div class="{% if property.deprecated_since %}deprecated{% endif %}">
          <h6><a href="property.{{ interface.name }}.{{ property.name }}.html">{{ interface.fqtn }}:{{ property.name }}</a></h6>
          <div class="docblock">
            {{ property.summary }}
          </div>
          <div class="docblock">
            <p>
            {%- if CONFIG.is_unstable(property.available_since) -%}
            <span class="emblem available-next" title="This property will be available in the next stable release">unstable</span>&nbsp;
            {%- endif %}
            {%- if property.deprecated_since -%}
            <span class="emblem deprecated">deprecated: {{ property.deprecated_since }}</span>&nbsp;
            {%- endif -%}
            {%- if property.available_since -%}
            <span class="emblem available">since: {{ property.available_since }}</span>
            {%- endif -%}
            </p>
          </div>
        </div>
      {% endfor %}
      </div>

    </div>
    {% endif %}

    {% if interface.signals %}
    <div class="signals toggle-wrapper">
      <h4 id="signals">
        Signals
        <a href="#signals" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for signal in interface.signals %}
        <div class="{% if signal.deprecated_since %}deprecated{% endif %}">
          <h6><a href="signal.{{ interface.name }}.{{ signal.name }}.html">{{ interface.fqtn }}::{{ signal.name }}</a></h6>
          <div class="docblock">
            {{ signal.summary }}
          </div>
          <div class="docblock">
            <p>
            {%- if CONFIG.is_unstable(signal.available_since) -%}
            <span class="emblem available-next" title="This signal will be available in the next stable release">unstable</span>&nbsp;
            {%- endif %}
            {%- if signal.deprecated_since -%}
            <span class="emblem deprecated">deprecated: {{ signal.deprecated_since }}</span>&nbsp;
            {%- endif -%}
            {%- if signal.available_since -%}
            <span class="emblem available">since: {{ signal.available_since }}</span>
            {%- endif -%}
            </p>
          </div>
        </div>
      {% endfor %}
      </div>
    </div>
    {% endif %}

    {% if interface.class_name %}
    <div class="interface toggle-wrapper default-hide">
      <h4 style="display:flex;" id="interface-struct">
        Interface structure
        <a href="#interface-struct" class="anchor"></a>
        {% if CONFIG.source_location_url and interface.source_location %}
        <a class="srclink" title="go to source location" href="{{ CONFIG.source_link(interface.source_location) }}">[src]</a>
        {% endif %}
      </h4>

      <div class="docblock">
        <pre><code>struct {{ namespace.name}}{{ interface.class_name }} {
  {% for field in interface.class_fields %}
  {%- if field.is_callback -%}
  {{ field.type_cname }};
  {%- else -%}
  {{ field.type_cname }} {{ field.name }};
  {%- endif %}
  {% else %}/* no available fields */{% endfor %}
}</code></pre>
      </div>

      <div class="docblock">
        {{ interface.class_description }}
      </div>

      {% if interface.class_fields %}
      <div class="docblock">
        <h6>Interface members</h6>

        <table>
        {% for field in interface.class_fields %}
        <tr>
          <td style="vertical-align:top"><code>{{ field.name }}</code></td>
          <td style="vertical-align:top"><pre><code>{{ field.type_cname }}</code></pre></td>
        </tr>
        <tr>
          <td>&nbsp;</td><td style="vertical-align:top">{{ field.description }}</td>
        </tr>
        {% endfor %}
        </table>
      </div>
      {% endif %}
    </div>
    {% endif %}

    {% if interface.class_methods %}
    <div class="toggle-wrapper methods">
      <h4 id="interface-methods">
        Interface methods
        <a href="#interface-methods" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for method in interface.class_methods %}
      <div class="{% if method.deprecated_since %}deprecated{% endif %}">
        <h6><a href="class_method.{{ interface.name }}.{{ method.name }}.html">{{ method.identifier }}</a></h6>
        <div class="docblock">
          {{ method.summary }}
        </div>
        <div class="docblock">
          <p>
          {%- if CONFIG.is_unstable(method.available_since) -%}
          <span class="emblem available-next" title="This interface method will be available in the next stable release">unstable</span>&nbsp;
          {%- endif %}
          {%- if method.deprecated_since -%}
          <span class="emblem deprecated">deprecated: {{ method.deprecated_since }}</span>&nbsp;
          {%- endif -%}
          {%- if method.available_since -%}
          <span class="emblem available">since: {{ method.available_since }}</span>
          {%- endif -%}
          </p>
        </div>
      </div>
      {% endfor %}
      </div>
    </div>
    {% endif %}

    {% if interface.virtual_methods %}
    <div class="toggle-wrapper methods">
      <h4 id="virtual-methods">
        Virtual methods
        <a href="#virtual-methods" class="anchor"></a>
      </h4>

      <div class="docblock">
      {% for method in interface.virtual_methods %}
        <div class="{% if method.deprecated_since %}deprecated{% endif %}">
          <h6 id="vfunc-{{ method.name }}"><a href="vfunc.{{ interface.name }}.{{ method.name }}.html">{{ namespace.name }}.{{ interface.name }}.{{ method.name }}</a></h6>
          <div class="docblock">
            {{ method.summary }}
          </div>
          <div class="docblock">
            <p>
            {%- if CONFIG.is_unstable(method.available_since) -%}
            <span class="emblem available-next" title="This virtual method will be available in the next stable release">unstable</span>&nbsp;
            {%- endif %}
            {%- if method.deprecated_since -%}
            <span class="emblem deprecated">deprecated: {{ method.deprecated_since }}</span>&nbsp;
            {%- endif -%}
            {%- if method.available_since -%}
            <span class="emblem available">since: {{ method.available_since }}</span>
            {%- endif -%}
            </p>
          </div>
        </div>
      {% endfor %}
      </div>
    </div>
    {% endif %}

  </section>
</section>
{% endblock %}
