File: update-file-info-async.py

package info (click to toggle)
nautilus-python 4.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: xml: 1,713; ansic: 619; python: 250; makefile: 10
file content (30 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (3)
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
from gi.repository import Nautilus, GObject


class UpdateFileInfoAsync(GObject.GObject, Nautilus.InfoProvider):
    def __init__(self):
        super().__init__()
        self.timers = []
        pass

    def update_file_info_full(self, provider, handle, closure, file):
        print("update_file_info_full")
        self.timers.append(
            GObject.timeout_add_seconds(3, self.update_cb, provider, handle, closure)
        )
        return Nautilus.OperationResult.IN_PROGRESS

    def update_cb(self, provider, handle, closure):
        print("update_cb")
        Nautilus.info_provider_update_complete_invoke(
            closure,
            provider,
            handle,
            Nautilus.OperationResult.FAILED,
        )

    def cancel_update(self, provider, handle):
        print("cancel_update")
        for t in self.timers:
            GObject.source_remove(t)
        self.timers = []