File: thunarx-property-page-plugin.py

package info (click to toggle)
thunarx-python 0.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: xml: 1,500; ansic: 678; python: 136; makefile: 106; sh: 11
file content (46 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
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 GObject, Gtk, Thunarx

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

        hbox = Gtk.HBox(0, False)
        hbox.show()

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

        value_label = Gtk.Label()
        hbox.pack_start(value_label, True, True, 0)

        md5sum = hashlib.md5(filename.encode("utf-8")).hexdigest()
        value_label.set_text(md5sum)
        value_label.show()

        page = Thunarx.PropertyPage()
        page.set_label("MD5")
        page.add(hbox)

        return [page]