Baul.InfoProvider
Prev | Provider Interfaces | Next

## Baul.InfoProvider

Baul.InfoProvider — Baul.InfoProvider Reference

## Synopsis

    class Baul.InfoProvider:
        def update_file_info(file)
        def update_file_info_full(provider, handle, closure, file)
        def cancel_update(provider, handle)
        def Baul.info_provider_update_complete_invoke(provider, handle, closure, result=Baul.OperationResult.COMPLETE)

## Description

If subclassed, Baul will call update_file_info(_full) to notify extensions of which files are being viewed by the user. This gives extensions an opportunity to invoke actions on the files, or to add emblems or attributes.

Example 3. Baul.InfoProvider Example

    from gi.repository import Baul, GObject

    class ColumnExtension(GObject.GObject, Baul.InfoProvider):
        def __init__(self):
            pass

        def update_file_info_full(self, provider, handle, closure, file):
            gobject.timeout_add_seconds(3, self.update_cb, provider, handle, closure)
            return Baul.OperationResult.IN_PROGRESS

        def update_cb(self, provider, handle, closure):
            Baul.info_provider_update_complete_invoke(closure, provider, handle, Baul.OperationResult.FAILED)

## Passive Methods

### Baul.InfoProvider.update_file_info

        def update_file_info(file)

`file` : | a `Baul.FileInfo` object

This method is called by Baul for each file or folder that exists under the current directory listing. There is no return value.

### Baul.InfoProvider.update_file_info_full

        def update_file_info_full(provider, handle, closure, file)

`provider` : | the current `Baul.InfoProvider` instance
`handle` : | a `Baul.OperationHandle` generated solely to track this call
`closure` : | a C Closure that must be passed to Baul.info_provider_update_complete_invoke if that method is called
`file` : | a `Baul.FileInfo` object
Returns : | None or a `Baul.OperationResult` enum

This method is called by Baul for each file or folder that exists under the current directory listing. Originally, `Baul.InfoProvider` only provided the update_file_info method, which blocked Baul when the method required a lot of computation time. This method was created to allow an extension to tell Baul that it will be spending time on an operation and that Baul should not block itself during that time.

In order to notify Baul of your extension's intentions, you must return a `Baul.OperationResult` enum. Then, when the operation has completed, call the Baul.info_provider_update_complete_invoke method, passing the provider, handle and closure variables as parameters.

This method was created for backwards compatibility reasons. If your extension used the `update_file_info` method and you want non-blocking usage, you should switch to this method.

### Note

This method was introduced in baul-python 0.7.0.

### Baul.InfoProvider.cancel_update

        def cancel_update(provider, handle)

`provider` : | the current `Baul.InfoProvider` instance
`handle` : | a `Baul.OperationHandle` generated for a specific update_file_info_full call

This method is called by Baul when an update_file_info_full call is in progress but is no longer required. This may happen because the user is moving directories or a file has been deleted, etc. You may use the handle parameter here to match the handle parameter passed in `update_file_info_full`.

### Note

This method was introduced in baul-python 0.7.0.

## Active Methods

### Baul.info_provider_update_complete_invoke

        def info_provider_update_complete_invoke(provider, handle, closure, result=Baul.OperationResult.COMPLETE)

`provider` : | the current `Baul.InfoProvider` instance
`handle` : | a `Baul.OperationHandle` generated for a specific update_file_info_full call
`closure` : | a C Closure that must be passed to Baul.info_provider_update_complete_invoke if that method is called
`result` : | an optional parameter. If left out, `Baul.OperationResult.COMPLETE` is assumed. Otherwise, you may pass any any of the `Baul.OperationResult` enums.

An extension must call this method for each update_file_info_full method that returns the `Baul.OperationResult.IN_PROGRESS` enum. The method must be called with the provider, handle, and closure parameters which were passed to the earlier `update_file_info_full` method.

### Note

This method was introduced in baul-python 0.7.0.

Prev | Up | Next
Baul.ColumnProvider | Home | Baul.LocationWidgetProvider