[pitivi/ges] If available, show thumbnails for missing files to help the user



commit 5b9f1e67c921977193edde617fbc1b25d4007ba9
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Wed Apr 4 00:05:29 2012 -0400

    If available, show thumbnails for missing files to help the user
    
    This depends on the availability of orphan thumbnail files.
    Partially fixes bug #583243.

 pitivi/mainwindow.py |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 86dfb57..f8eb471 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -34,7 +34,7 @@ from time import time
 from urllib import unquote
 from gettext import gettext as _
 from gtk import RecentManager
-
+from hashlib import md5
 
 from pitivi.utils.loggable import Loggable
 from pitivi.settings import GlobalSettings
@@ -896,6 +896,23 @@ class PitiviMainWindow(gtk.Window, Loggable):
         dialog.get_content_area().set_spacing(SPACING)
         dialog.set_transient_for(self)
 
+        # This box will contain the label and optionally a thumbnail
+        hbox = gtk.HBox()
+        hbox.set_spacing(SPACING)
+
+        # Check if we have a thumbnail available.
+        # This can happen if the file was moved or deleted by an application
+        # that does not manage Freedesktop thumbnails. The user is in luck!
+        # This is based on medialibrary's addDiscovererInfo method.
+        thumbnail_hash = md5(tfs.get_uri()).hexdigest()
+        thumb_dir = os.path.expanduser("~/.thumbnails/normal/")
+        thumb_path_normal = thumb_dir + thumbnail_hash + ".png"
+        if os.path.exists(thumb_path_normal):
+            self.debug("A thumbnail file was found for %s" % tfs.get_uri())
+            thumbnail = gtk.image_new_from_file(thumb_path_normal)
+            thumbnail.set_padding(0, SPACING)
+            hbox.pack_start(thumbnail, False, False)
+
         # FIXME GES port, help user identify files with more information
         # need work to be done in GES directly
         # TODO: display the filesize to help the user identify the file
@@ -916,8 +933,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         label = gtk.Label()
         label.set_markup(text)
-        dialog.get_content_area().pack_start(label, False, False)
-        label.show()
+        hbox.pack_start(label, False, False)
+        dialog.get_content_area().pack_start(hbox, False, False)
+        hbox.show_all()
 
         chooser = gtk.FileChooserWidget(action=gtk.FILE_CHOOSER_ACTION_OPEN)
         chooser.set_select_multiple(False)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]