Merge branch 'ebassi/file-info-attributes' into 'main'

Check for attributes being available before querying them

See merge request GNOME/gtk!5592
This commit is contained in:
Emmanuele Bassi 2023-03-04 16:04:04 +00:00
commit 32f0723bf0
3 changed files with 23 additions and 11 deletions

View File

@ -3549,9 +3549,12 @@ show_and_select_files (GtkFileChooserWidget *impl,
if (!g_file_info_get_attribute_boolean (info, "filechooser::visible"))
{
gboolean has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
gboolean has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
if (!enabled_hidden &&
(g_file_info_get_is_hidden (info) ||
g_file_info_get_is_backup (info)))
((has_is_hidden && g_file_info_get_is_hidden (info)) ||
(has_is_backup && g_file_info_get_is_backup (info))))
{
set_show_hidden (impl, TRUE);
enabled_hidden = TRUE;

View File

@ -209,13 +209,18 @@ node_should_be_visible (GtkFileSystemModel *model,
gboolean filtered_out)
{
FileModelNode *node = get_node (model, id);
gboolean has_is_hidden;
gboolean has_is_backup;
gboolean result;
if (node->info == NULL)
return FALSE;
has_is_hidden = g_file_info_has_attribute (node->info, "standard::is-hidden");
has_is_backup = g_file_info_has_attribute (node->info, "standard::is-backup");
if (!model->show_hidden &&
(g_file_info_get_is_hidden (node->info) || g_file_info_get_is_backup (node->info)))
((has_is_hidden && g_file_info_get_is_hidden (node->info)) ||
(has_is_backup && g_file_info_get_is_backup (node->info))))
return FALSE;
if (_gtk_file_info_consider_as_directory (node->info))
@ -941,7 +946,7 @@ _gtk_file_system_model_set_filter_folders (GtkFileSystemModel *model,
* @model: the model
*
* Gets the cancellable used by the @model. This is the cancellable used
* internally by the @model that will be cancelled when @model is
* internally by the @model that will be cancelled when @model is
* disposed. So you can use it for operations that should be cancelled
* when the model goes away.
*
@ -1005,7 +1010,7 @@ _gtk_file_system_model_update_files (GtkFileSystemModel *model,
* _gtk_file_system_model_set_filter:
* @mode: a `GtkFileSystemModel`
* @filter: (nullable): %NULL or filter to use
*
*
* Sets a filter to be used for deciding if a row should be visible or not.
* Whether this filter applies to directories can be toggled with
* _gtk_file_system_model_set_filter_folders().
@ -1028,7 +1033,7 @@ _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
* @file: the file to add
* @attributes: attributes to query before adding the file
*
* This is a convenience function that calls g_file_query_info_async() on
* This is a convenience function that calls g_file_query_info_async() on
* the given file, and when successful, adds it to the model.
* Upon failure, the @file is discarded.
**/

View File

@ -218,7 +218,7 @@ gtk_path_bar_init (GtkPathBar *path_bar)
desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
if (desktop != NULL)
path_bar->desktop_file = g_file_new_for_path (desktop);
else
else
path_bar->desktop_file = NULL;
}
else
@ -306,7 +306,7 @@ update_visibility_up_to_next_root (GtkPathBar *path_bar,
{
gboolean fake_root_found = FALSE;
GList *l;
for (l = start_from_button; l; l = l->next)
{
GtkWidget *button = BUTTON_DATA (l->data)->button;
@ -776,6 +776,7 @@ gtk_path_bar_get_info_callback (GObject *source,
GFileInfo *info;
ButtonData *button_data;
const char *display_name;
gboolean has_is_hidden, has_is_backup;
gboolean is_hidden;
info = g_file_query_info_finish (file, result, NULL);
@ -794,7 +795,10 @@ gtk_path_bar_get_info_callback (GObject *source,
file_info->cancellable = NULL;
display_name = g_file_info_get_display_name (info);
is_hidden = g_file_info_get_is_hidden (info) || g_file_info_get_is_backup (info);
has_is_hidden = g_file_info_has_attribute (info, "standard::is-hidden");
has_is_backup = g_file_info_has_attribute (info, "standard::is-backup");
is_hidden = (has_is_hidden && g_file_info_get_is_hidden (info)) ||
(has_is_backup && g_file_info_get_is_backup (info));
button_data = make_directory_button (file_info->path_bar, display_name,
file_info->file,
@ -879,7 +883,7 @@ _gtk_path_bar_set_file (GtkPathBar *path_bar,
/**
* _gtk_path_bar_up:
* @path_bar: a `GtkPathBar`
*
*
* If the selected button in the pathbar is not the furthest button up (in the
* root direction), act as if the user clicked on the next button up.
**/
@ -906,7 +910,7 @@ _gtk_path_bar_up (GtkPathBar *path_bar)
/**
* _gtk_path_bar_down:
* @path_bar: a `GtkPathBar`
*
*
* If the selected button in the pathbar is not the furthest button down (in the
* leaf direction), act as if the user clicked on the next button down.
**/