thunarx.PropertyPageProvider

thunarx.PropertyPageProvider — thunarx.PropertyPageProvider Reference

Synopsis

class thunarx.PropertyPageProvider:
    def get_pages(files)

Description

To add a property page to the file properties dialog, extensions must implement the ThunarxPropertyPageProvider interface. This interface has only one virtual method, get_pages, that is passed a list of thunarx.FileInfo objects and returns a list of thunarx.PropertyPage objects.

Example 4. A thunarx.PropertyPageProvider plugin

import hashlib
import urllib

import thunarx
import gtk

class ThunarxPropertyPagePlugin(thunarx.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 = urllib.unquote(file.get_uri()[7:])

        self.hbox = gtk.HBox(0, False)
        self.hbox.show()

        label = gtk.Label('MD5Sum:')
        label.show()
        self.hbox.pack_start(label)

        self.value_label = gtk.Label()
        self.hbox.pack_start(self.value_label)

        md5sum = hashlib.md5(filename).hexdigest()
        self.value_label.set_text(md5sum)
        self.value_label.show()

        page = thunarx.PropertyPage("MD5")

        page.add(self.hbox)

        return [page]
    

Passive Methods

thunarx.PropertyPageProvider.get_pages

    def get_pages(files)

files :

a list of thunarx.FileInfo objects.

Returns :

a list of thunarx.PropertyPage objects

This function is called by Thunar 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.