Commit 5772bba6 authored by namanyadav12's avatar namanyadav12 Committed by Alexandru Băluț

mainwindow: Use AssetThumbnail to get the thumbnails from cache

Had to make __get_thumbnails_from_xdg_cache a public static method so it
can be used in a different module.
Reviewed-by: Alexandru Băluț's avatarAlex Băluț <>
Differential Revision:
parent 6ba114be
......@@ -18,7 +18,6 @@
# Boston, MA 02110-1301, USA.
import os
from gettext import gettext as _
from hashlib import md5
from time import time
from urllib.parse import unquote
......@@ -40,6 +39,7 @@ from pitivi.configure import VERSION
from pitivi.dialogs.prefs import PreferencesDialog
from pitivi.effects import EffectListWidget
from pitivi.mediafilespreviewer import PreviewWidget
from pitivi.medialibrary import AssetThumbnail
from pitivi.medialibrary import MediaLibraryWidget
from pitivi.project import ProjectSettingsDialog
from pitivi.settings import GlobalSettings
......@@ -934,16 +934,10 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
# 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(uri.encode()).hexdigest()
thumb_dir = os.path.expanduser("~/.thumbnails/normal/")
thumb_path_normal = thumb_dir + thumbnail_hash + ".png"
if os.path.exists(thumb_path_normal):
small_thumb, large_thumb = AssetThumbnail.get_thumbnails_from_xdg_cache(uri)
if large_thumb:
self.debug("A thumbnail file was found for %s", uri)
thumbnail = Gtk.Image.new_from_file(thumb_path_normal)
thumbnail = Gtk.Image.new_from_pixbuf(large_thumb)
thumbnail.set_padding(0, SPACING)
hbox.pack_start(thumbnail, False, False, 0)
......@@ -210,7 +210,7 @@ class AssetThumbnail(Loggable):
if video_streams:
# Check if the files have thumbnails in the user's cache directory.
real_uri = get_proxy_target(self.__asset)
small_thumb, large_thumb = self.__get_thumbnails_from_xdg_cache(real_uri)
small_thumb, large_thumb = self.get_thumbnails_from_xdg_cache(real_uri)
if not small_thumb:
if self.__asset.is_image():
path = Gst.uri_get_location(real_uri)
......@@ -251,7 +251,8 @@ class AssetThumbnail(Loggable):
small_thumb, large_thumb = self.__get_icons("audio-x-generic")
return small_thumb, large_thumb
def __get_thumbnails_from_xdg_cache(self, real_uri):
def get_thumbnails_from_xdg_cache(real_uri):
"""Gets pixbufs for the specified thumbnail from the user's cache dir.
Looks for thumbnails according to the [Thumbnail Managing Standard](
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment