Skip to content

Commit

Permalink
Defer extension-provided file attributes until the file is made visible
Browse files Browse the repository at this point in the history
in a view.

This expands on the changes introduced in bb049a4.
  • Loading branch information
mtwebster committed May 23, 2020
1 parent c798336 commit 4386080
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 28 deletions.
5 changes: 3 additions & 2 deletions libnemo-private/nemo-directory-async.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,13 +1686,14 @@ lacks_link_info (NemoFile *file)
static gboolean
lacks_extension_info (NemoFile *file)
{
return file->details->pending_info_providers != NULL;
return file->details->load_deferred_attrs &&
file->details->pending_info_providers != NULL;
}

static gboolean
lacks_thumbnail (NemoFile *file)
{
return file->details->load_thumb &&
return file->details->load_deferred_attrs &&
nemo_file_should_show_thumbnail (file) &&
file->details->thumbnail_path != NULL &&
!file->details->thumbnail_is_up_to_date;
Expand Down
2 changes: 1 addition & 1 deletion libnemo-private/nemo-file-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ struct NemoFileDetails
eel_boolean_bit filesystem_readonly : 1;
eel_boolean_bit filesystem_use_preview : 2; /* GFilesystemPreviewType */
eel_boolean_bit filesystem_info_is_up_to_date : 1;
eel_boolean_bit load_thumb : 1;
eel_boolean_bit load_deferred_attrs : 1;

NemoFilePinning pinning;

Expand Down
8 changes: 4 additions & 4 deletions libnemo-private/nemo-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ nemo_file_clear_info (NemoFile *file)
file->details->ctime = 0;
file->details->btime = 0;
file->details->trash_time = 0;
file->details->load_thumb = FALSE;
file->details->load_deferred_attrs = FALSE;
g_free (file->details->symlink_name);
file->details->symlink_name = NULL;
eel_ref_str_unref (file->details->mime_type);
Expand Down Expand Up @@ -8041,10 +8041,10 @@ nemo_file_invalidate_extension_info_internal (NemoFile *file)
}

void
nemo_file_set_load_thumb (NemoFile *file,
gboolean load_thumb)
nemo_file_set_load_deferred_attrs (NemoFile *file,
gboolean load_deferred_attrs)
{
file->details->load_thumb = load_thumb;
file->details->load_deferred_attrs = load_deferred_attrs;
}

void
Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ typedef char * (*NemoTruncateCallback) (const char *string,
int width,
void *context);


#define NEMO_FILE_ATTRIBUTES_FOR_ICON (NEMO_FILE_ATTRIBUTE_INFO | NEMO_FILE_ATTRIBUTE_LINK_INFO | NEMO_FILE_ATTRIBUTE_THUMBNAIL)
#define NEMO_FILE_DEFERRED_ATTRIBUTES (NEMO_FILE_ATTRIBUTE_THUMBNAIL | NEMO_FILE_ATTRIBUTE_EXTENSION_INFO)

typedef void NemoFileListHandle;

Expand Down Expand Up @@ -523,7 +523,7 @@ void nemo_file_set_is_desktop_orphan (NemoFile *file, gboolean is_d

gboolean nemo_file_get_pinning (NemoFile *file);
void nemo_file_set_pinning (NemoFile *file, gboolean pin);
void nemo_file_set_load_thumb (NemoFile *file, gboolean load_thumb);
void nemo_file_set_load_deferred_attrs (NemoFile *file, gboolean load_deferred_attrs);
/* Debugging */
void nemo_file_dump (NemoFile *file);

Expand Down
12 changes: 6 additions & 6 deletions libnemo-private/nemo-icon-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -4967,7 +4967,7 @@ nemo_icon_container_init (NemoIconContainer *container)
details->renaming_allocation_count = 0;

details->update_visible_icons_id = 0;
details->ok_to_load_thumbs = FALSE;
details->ok_to_load_deferred_attrs = FALSE;

details->h_adjust = 100;
details->v_adjust = 100;
Expand Down Expand Up @@ -5220,7 +5220,7 @@ nemo_icon_container_clear (NemoIconContainer *container)
details->stretch_icon = NULL;
details->drop_target = NULL;

details->ok_to_load_thumbs = FALSE;
details->ok_to_load_deferred_attrs = FALSE;

for (p = details->icons; p != NULL; p = p->next) {
icon_free (p->data);
Expand Down Expand Up @@ -5652,12 +5652,12 @@ update_visible_icons_cb (NemoIconContainer *container)
NemoFile *file = NEMO_FILE (icon->data);

icon->ok_to_show_thumb = TRUE;
nemo_file_set_load_thumb (file, TRUE);
nemo_file_set_load_deferred_attrs (file, TRUE);

if (nemo_file_is_thumbnailing (file)) {
nemo_icon_container_prioritize_thumbnailing (container, icon);
} else {
nemo_file_invalidate_attributes (file, NEMO_FILE_ATTRIBUTES_FOR_ICON);
nemo_file_invalidate_attributes (file, NEMO_FILE_DEFERRED_ATTRIBUTES);
}
}

Expand Down Expand Up @@ -8129,10 +8129,10 @@ nemo_icon_container_get_additional_text_line_count (NemoIconContainer *container
}

void
nemo_icon_container_set_ok_to_load_thumbs (NemoIconContainer *container,
nemo_icon_container_set_ok_to_load_deferred_attrs (NemoIconContainer *container,
gboolean ok)
{
container->details->ok_to_load_thumbs = ok;
container->details->ok_to_load_deferred_attrs = ok;

if (ok) {
queue_update_visible_icons (container, INITIAL_UPDATE_VISIBLE_DELAY);
Expand Down
4 changes: 2 additions & 2 deletions libnemo-private/nemo-icon-container.h
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,6 @@ void nemo_icon_container_setup_tooltip_preference_callback (NemoIconCont
void nemo_icon_container_update_tooltip_text (NemoIconContainer *container,
NemoIconCanvasItem *item);
gint nemo_icon_container_get_additional_text_line_count (NemoIconContainer *container);
void nemo_icon_container_set_ok_to_load_thumbs (NemoIconContainer *container,
gboolean ok);
void nemo_icon_container_set_ok_to_load_deferred_attrs (NemoIconContainer *container,
gboolean ok);
#endif /* NEMO_ICON_CONTAINER_H */
2 changes: 1 addition & 1 deletion libnemo-private/nemo-icon-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ struct NemoIconContainerDetails {
eel_boolean_bit store_layout_timestamps : 1;
eel_boolean_bit store_layout_timestamps_when_finishing_new_icons : 1;

gint ok_to_load_thumbs;
gint ok_to_load_deferred_attrs;
guint update_visible_icons_id;

GQueue *lazy_icon_load_queue;
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-icon-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ nemo_icon_view_begin_loading (NemoView *view)
uri = nemo_file_get_uri (file);
icon_container = GTK_WIDGET (get_icon_container (icon_view));

nemo_icon_container_set_ok_to_load_thumbs (NEMO_ICON_CONTAINER (icon_container), FALSE);
nemo_icon_container_set_ok_to_load_deferred_attrs (NEMO_ICON_CONTAINER (icon_container), FALSE);

nemo_icon_container_begin_loading (NEMO_ICON_CONTAINER (icon_container));

Expand Down Expand Up @@ -1092,7 +1092,7 @@ nemo_icon_view_end_loading (NemoView *view,

monitor = nemo_clipboard_monitor_get ();
info = nemo_clipboard_monitor_get_clipboard_info (monitor);
nemo_icon_container_set_ok_to_load_thumbs (NEMO_ICON_CONTAINER (icon_container), TRUE);
nemo_icon_container_set_ok_to_load_deferred_attrs (NEMO_ICON_CONTAINER (icon_container), TRUE);
icon_view_notify_clipboard_info (monitor, info, icon_view);
}

Expand Down
16 changes: 8 additions & 8 deletions src/nemo-list-view.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct NemoListViewDetails {
int drag_x;
int drag_y;

gint ok_to_load_thumbs;
gint ok_to_load_deferred_attrs;
guint update_visible_icons_id;

gboolean rename_on_release;
Expand Down Expand Up @@ -1484,10 +1484,10 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat
}

static void
set_ok_to_load_thumbs (NemoListView *list_view,
set_ok_to_load_deferred_attrs (NemoListView *list_view,
gboolean ok)
{
list_view->details->ok_to_load_thumbs = ok;
list_view->details->ok_to_load_deferred_attrs = ok;

if (ok) {
queue_update_visible_icons (list_view, INITIAL_UPDATE_VISIBLE_DELAY);
Expand Down Expand Up @@ -2238,12 +2238,12 @@ prioritize_visible_files (NemoListView *view)
if (file != NULL && file != last_file) {
last_file = file;

nemo_file_set_load_thumb (file, TRUE);
nemo_file_set_load_deferred_attrs (file, TRUE);

if (nemo_file_is_thumbnailing (file)) {
nemo_thumbnail_prioritize (nemo_file_peek_uri (file));
} else {
nemo_file_invalidate_attributes (file, NEMO_FILE_ATTRIBUTES_FOR_ICON);
nemo_file_invalidate_attributes (file, NEMO_FILE_DEFERRED_ATTRIBUTES);
}
}
}
Expand Down Expand Up @@ -2801,7 +2801,7 @@ nemo_list_view_begin_loading (NemoView *view)
set_zoom_level_from_metadata_and_preferences (list_view);
set_columns_settings_from_metadata_and_preferences (list_view);

set_ok_to_load_thumbs (list_view, FALSE);
set_ok_to_load_deferred_attrs (list_view, FALSE);

AtkObject *atk = gtk_widget_get_accessible (GTK_WIDGET (NEMO_LIST_VIEW (view)->details->tree_view));

Expand Down Expand Up @@ -2833,7 +2833,7 @@ nemo_list_view_clear (NemoView *view)

list_view = NEMO_LIST_VIEW (view);

list_view->details->ok_to_load_thumbs = FALSE;
list_view->details->ok_to_load_deferred_attrs = FALSE;

tree_selection = gtk_tree_view_get_selection (list_view->details->tree_view);

Expand Down Expand Up @@ -4000,7 +4000,7 @@ nemo_list_view_end_loading (NemoView *view,

nemo_list_view_update_selection (view);

set_ok_to_load_thumbs (NEMO_LIST_VIEW (view), TRUE);
set_ok_to_load_deferred_attrs (NEMO_LIST_VIEW (view), TRUE);

monitor = nemo_clipboard_monitor_get ();
info = nemo_clipboard_monitor_get_clipboard_info (monitor);
Expand Down

0 comments on commit 4386080

Please sign in to comment.