## Nautilus.PropertiesModelProvider

Nautilus.PropertiesModelProvider — Nautilus.PropertiesModelProvider Reference

## Synopsis

     Nautilus.PropertiesModelProvider {
      get_models(files);
    }

## Description

If subclassed, Nautilus will request a list of custom properties models that should appear when a user opens the Properties dialog for a file or folder.

Example 5. Nautilus.PropertiesModelProvider Example

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39

    import hashlib

    from urllib.parse import unquote
    from gi.repository import Nautilus, Gio, GObject
    from typing import List

    class MD5SumPropertiesModel(GObject.GObject, Nautilus.PropertiesModelProvider):
        def get_models(
            self,
            files: List[Nautilus.FileInfo],
        ) -> List[Nautilus.PropertiesModel]:
            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:]).encode("utf-8")

            section_model = Gio.ListStore.new(item_type=Nautilus.PropertiesItem)

            section_model.append(
                Nautilus.PropertiesItem(
                    name="MD5 sum of the filename",
                    value=hashlib.md5(filename).hexdigest(),
                )
            )

            return [
                Nautilus.PropertiesModel(
                    title="MD5Sum",
                    model=section_model,
                ),
            ]

## Passive Methods

### Nautilus.PropertiesModelProvider.get_models

    get_models(files);

`files` : | a list of `Nautilus.FileInfo` objects.
Returns : | a list of `Nautilus.PropertiesModel` objects

This function is called by Nautilus when it wants properties model items from the extension. It is called in the main thread before a properties model is shown, so it should return quickly.