Merge branch 'file_chooser_stuff' into 'main'

filechooser: two small changes

See merge request GNOME/gtk!5619
This commit is contained in:
Matthias Clasen 2023-03-08 21:57:13 +00:00
commit 9ca3a52bf0

View File

@ -637,28 +637,36 @@ _gtk_file_chooser_extract_recent_folders (GList *infos)
for (l = infos; l; l = l->next) for (l = infos; l; l = l->next)
{ {
GtkRecentInfo *info = l->data; GtkRecentInfo *info = l->data;
const char *uri; const char *uri, *mime_type;
GFile *parent; GFile *dir;
GFile *file; GFile *file;
uri = gtk_recent_info_get_uri (info); if (!gtk_recent_info_is_local (info))
if (!g_str_has_prefix (uri, "file://"))
continue; continue;
uri = gtk_recent_info_get_uri (info);
file = g_file_new_for_uri (uri); file = g_file_new_for_uri (uri);
parent = g_file_get_parent (file);
g_object_unref (file);
if (parent) mime_type = gtk_recent_info_get_mime_type (info);
if (strcmp (mime_type, "inode/directory") != 0)
{ {
if (!g_hash_table_lookup (folders, parent)) dir = g_file_get_parent (file);
g_object_unref (file);
}
else
{ {
g_hash_table_insert (folders, parent, (gpointer) 1); dir = file;
result = g_list_prepend (result, g_object_ref (parent));
} }
g_object_unref (parent); if (dir)
{
if (!g_hash_table_lookup (folders, dir))
{
g_hash_table_insert (folders, dir, (gpointer) 1);
result = g_list_prepend (result, g_object_ref (dir));
}
g_object_unref (dir);
} }
} }
@ -5996,8 +6004,7 @@ recent_start_loading (GtkFileChooserWidget *impl)
GtkRecentInfo *info = l->data; GtkRecentInfo *info = l->data;
GFile *file; GFile *file;
const char *uri = gtk_recent_info_get_uri (info); if (!gtk_recent_info_is_local (info))
if (!g_str_has_prefix (uri, "file://"))
continue; continue;
if (gtk_recent_info_get_private_hint (info) && if (gtk_recent_info_get_private_hint (info) &&