summaryrefslogtreecommitdiff
path: root/examples/md5sum-property-page.py
diff options
context:
space:
mode:
authorYaakov Selkowitz <[email protected]>2012-12-20 00:41:24 -0600
committerStefano Karapetsas <[email protected]>2013-01-22 14:10:00 +0100
commit825c1dd01981c159368a1a7a99931146fbbe60f1 (patch)
tree13a781b2b2023d06a1d8fb52d600e71ff40f911a /examples/md5sum-property-page.py
parent29149f504a4e5e28a19b92d9ebb831bb53100a01 (diff)
downloadpython-caja-825c1dd01981c159368a1a7a99931146fbbe60f1.tar.bz2
python-caja-825c1dd01981c159368a1a7a99931146fbbe60f1.tar.xz
Port examples to g-i and gsettings
Diffstat (limited to 'examples/md5sum-property-page.py')
-rw-r--r--examples/md5sum-property-page.py31
1 files changed, 18 insertions, 13 deletions
diff --git a/examples/md5sum-property-page.py b/examples/md5sum-property-page.py
index 13c59e7..dd2a7ee 100644
--- a/examples/md5sum-property-page.py
+++ b/examples/md5sum-property-page.py
@@ -1,10 +1,9 @@
import hashlib
import urllib
-import gtk
-import caja
+from gi.repository import Caja, Gtk, GObject
-class MD5SumPropertyPage(caja.PropertyPageProvider):
+class MD5SumPropertyPage(GObject.GObject, Caja.PropertyPageProvider):
def __init__(self):
pass
@@ -21,22 +20,28 @@ class MD5SumPropertyPage(caja.PropertyPageProvider):
filename = urllib.unquote(file.get_uri()[7:])
- self.property_label = gtk.Label('MD5Sum')
+ self.property_label = Gtk.Label('MD5Sum')
self.property_label.show()
- self.hbox = gtk.HBox(0, False)
+ self.hbox = Gtk.HBox(homogeneous=False, spacing=0)
self.hbox.show()
- label = gtk.Label('MD5Sum:')
+ label = Gtk.Label('MD5Sum:')
label.show()
- self.hbox.pack_start(label)
+ self.hbox.pack_start(label, False, False, 0)
- self.value_label = gtk.Label()
- self.hbox.pack_start(self.value_label)
+ self.value_label = Gtk.Label()
+ self.hbox.pack_start(self.value_label, False, False, 0)
- md5sum = hashlib.md5(filename).hexdigest()
- self.value_label.set_text(md5sum)
+ md5sum = hashlib.md5()
+ with open(filename,'rb') as f:
+ for chunk in iter(lambda: f.read(8192), ''):
+ md5sum.update(chunk)
+ f.close()
+
+ self.value_label.set_text(md5sum.hexdigest())
self.value_label.show()
- return caja.PropertyPage("CajaPython::md5_sum",
- self.property_label, self.hbox),
+ return Caja.PropertyPage(name="CajaPython::md5_sum",
+ label=self.property_label,
+ page=self.hbox),