gtkfilechooser: queue visible image files for thumbnails
This commit is contained in:
parent
67820cc624
commit
fd799a203b
1 changed files with 71 additions and 0 deletions
|
|
@ -945,6 +945,75 @@ thumbnail_file_list_clear_pixbuf_caches (GtkFileChooserDefault *impl)
|
|||
gtk_widget_queue_draw (impl->browse_files_current_view);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
thumbnail_queue_should_enqueue (GtkFileChooserDefault *impl,
|
||||
GFile *file,
|
||||
GFileInfo *info)
|
||||
{
|
||||
const gchar *content_type;
|
||||
|
||||
if (!impl->show_thumbnails)
|
||||
return FALSE;
|
||||
|
||||
if (!VIEW_MODE_USES_ICON_VIEW (impl->view_mode))
|
||||
return FALSE;
|
||||
|
||||
if (file == NULL || info == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_THUMBNAIL_PATH))
|
||||
return FALSE;
|
||||
|
||||
if (g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_THUMBNAILING_FAILED))
|
||||
return FALSE;
|
||||
|
||||
content_type = g_file_info_get_content_type (info);
|
||||
if (content_type == NULL || !g_str_has_prefix (content_type, "image/"))
|
||||
return FALSE;
|
||||
|
||||
/* Keep the first implementation conservative: only local files can be
|
||||
* thumbnailed without surprising network or VFS latency.
|
||||
*/
|
||||
if (!g_file_is_native (file))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
thumbnail_queue_ensure (GtkFileChooserDefault *impl)
|
||||
{
|
||||
if (!impl->thumbnail_cancellable)
|
||||
impl->thumbnail_cancellable = g_cancellable_new ();
|
||||
|
||||
if (!impl->thumbnail_queued_files)
|
||||
impl->thumbnail_queued_files =
|
||||
g_hash_table_new_full ((GHashFunc) g_file_hash,
|
||||
(GEqualFunc) g_file_equal,
|
||||
g_object_unref,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
thumbnail_queue_enqueue (GtkFileChooserDefault *impl,
|
||||
GFile *file,
|
||||
GFileInfo *info)
|
||||
{
|
||||
if (!thumbnail_queue_should_enqueue (impl, file, info))
|
||||
return;
|
||||
|
||||
thumbnail_queue_ensure (impl);
|
||||
|
||||
if (g_hash_table_lookup (impl->thumbnail_queued_files, file))
|
||||
return;
|
||||
|
||||
g_hash_table_insert (impl->thumbnail_queued_files,
|
||||
g_object_ref (file),
|
||||
GUINT_TO_POINTER (1));
|
||||
impl->thumbnail_queue = g_slist_prepend (impl->thumbnail_queue,
|
||||
g_object_ref (file));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_default_finalize (GObject *object)
|
||||
{
|
||||
|
|
@ -9807,6 +9876,8 @@ file_system_model_set (GtkFileSystemModel *model,
|
|||
|
||||
if (file_visible)
|
||||
{
|
||||
thumbnail_queue_enqueue (impl, file, info);
|
||||
|
||||
/* #2 start loading standard icon (callback will be handled by #1) */
|
||||
if (!g_file_info_has_attribute (info, "filechooser::icon_queried"))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue