summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2023-03-04 16:04:04 +0000
committerEmmanuele Bassi <ebassi@gmail.com>2023-03-04 16:04:04 +0000
commit32f0723bf02ba53cd523f2a252a5442eb188daba (patch)
treeb9fbc50056e6e906e129d9078c5e9e06f97f5b81
parent90a3584c1d5ee007b85f34bc02531f40741e893e (diff)
parent891b6dc4a916a76704e9f3f7248be02f2bbcb294 (diff)
downloadgtk+-32f0723bf02ba53cd523f2a252a5442eb188daba.tar.gz
Merge branch 'ebassi/file-info-attributes' into 'main'
Check for attributes being available before querying them See merge request GNOME/gtk!5592
-rw-r--r--gtk/gtkfilechooserwidget.c7
-rw-r--r--gtk/gtkfilesystemmodel.c13
-rw-r--r--gtk/gtkpathbar.c14
3 files changed, 23 insertions, 11 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 70276967e5..0c29b31076 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -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;
diff --git a/gtk/gtkfilesystemmodel.c b/gtk/gtkfilesystemmodel.c
index 9f4a5fafa9..d37237f1c7 100644
--- a/gtk/gtkfilesystemmodel.c
+++ b/gtk/gtkfilesystemmodel.c
@@ -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.
**/
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 1e3f1c669a..a19985732e 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -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.
**/