<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-nautilus-python-property-page-provider">
  <refnamediv>
    <refname>Nautilus.PropertyPageProvider</refname>
    <refpurpose>Nautilus.PropertyPageProvider Reference</refpurpose>
  </refnamediv>

<!-- ******************************* -->
<!-- BEGIN OF SYNOPSIS -->
<!-- ******************************* -->

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>Nautilus.PropertyPageProvider</classname></ooclass>

      <methodsynopsis language="python">
        <methodname><link linkend="method-nautilus-property-page-provider--get-pages">get_pages</link></methodname>
        <methodparam><parameter role="keyword">files</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>
  </refsect1>

<!-- ********************************** -->
<!-- BEGIN OF DESCRIPTION -->
<!-- ********************************** -->

  <refsect1 id="description-property-page-provider">
    <title>Description</title>

      <para>
      If subclassed, Nautilus will request a list of custom property pages that should
      appear when a user opens the Properties dialog for a file or folder.
      </para>

<example>
    <title>Nautilus.PropertyPageProvider Example</title>
    <programlisting>
import hashlib

# A way to get unquote working with python 2 and 3
try:
    from urllib import unquote
except ImportError:
    from urllib.parse import unquote

from gi.repository import Nautilus, Gtk, GObject

class MD5SumPropertyPage(GObject.GObject, Nautilus.PropertyPageProvider):
    def __init__(self):
        pass
    
    def get_property_pages(self, files):
        if len(files) != 1:
            return
        
        file = files[0]
        if file.get_uri_scheme() != 'file':
            return

        if file.is_directory():
            return

        filename = unquote(file.get_uri()[7:])

        self.property_label = Gtk.Label('MD5Sum')
        self.property_label.show()

        self.hbox = Gtk.HBox(homogeneous=False, spacing=0)
        self.hbox.show()

        label = Gtk.Label('MD5Sum:')
        label.show()
        self.hbox.pack_start(label, False, False, 0)

        self.value_label = Gtk.Label()
        self.hbox.pack_start(self.value_label, False, False, 0)

        md5sum = hashlib.md5(filename.encode("utf-8")).hexdigest()
        self.value_label.set_text(md5sum)
        self.value_label.show()
        
        return Nautilus.PropertyPage(name="NautilusPython::md5_sum",
                                     label=self.property_label, 
                                     page=self.hbox),
    </programlisting>
</example>
        
  </refsect1>

<!-- ****************************** -->
<!-- BEGIN OF METHODS -->
<!-- ****************************** -->

  <refsect1>
        <title>Passive Methods</title>

        <refsect2 id="method-nautilus-property-page-provider--get-pages">
          <title>Nautilus.PropertyPageProvider.get_pages</title>

          <programlisting><methodsynopsis language="python">
            <methodname>get_pages</methodname>
              <methodparam></methodparam>
          </methodsynopsis></programlisting>

          <variablelist>
            <varlistentry>
	            <term><parameter role="keyword">files</parameter>&nbsp;:</term>
	            <listitem><simpara>a list of <link linkend="class-nautilus-python-file-info"><classname>Nautilus.FileInfo</classname></link> objects.</simpara></listitem>
            </varlistentry>
            <varlistentry>
              <term><emphasis>Returns</emphasis>&nbsp;:</term>
              <listitem><simpara>a list of <link linkend="class-nautilus-python-property-page"><classname>Nautilus.PropertyPage</classname></link> objects</simpara></listitem>
            </varlistentry>
          </variablelist>

          <para>
                This function is called by Nautilus when it wants property page items from the extension.  
                It is called in the main thread before a property page is shown, so it should return quickly.
          </para>
        </refsect2>
    </refsect1>

</refentry>

