mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-11-05 16:04:31 +00:00
file: add note to the list of excluded metadata emblems
This also slightly changes the behavior for emblems added by an extension: before the patch they were subject to the same exclusion list of metadata keywords. Now they are added unconditionally, since we assume an extension knows better and will always want the emblem list it sets properly displayed.
This commit is contained in:
parent
151a96add6
commit
bff5894f3f
1 changed files with 49 additions and 21 deletions
|
@ -6407,6 +6407,50 @@ sort_keyword_list_and_remove_duplicates (GList *keywords)
|
||||||
return keywords;
|
return keywords;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clean_up_metadata_keywords (NautilusFile *file,
|
||||||
|
GList **metadata_keywords)
|
||||||
|
{
|
||||||
|
NautilusFile *parent_file;
|
||||||
|
GList *l, *res = NULL;
|
||||||
|
char *exclude[4];
|
||||||
|
char *keyword;
|
||||||
|
gboolean found;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
exclude[i++] = NAUTILUS_FILE_EMBLEM_NAME_TRASH;
|
||||||
|
exclude[i++] = NAUTILUS_FILE_EMBLEM_NAME_NOTE;
|
||||||
|
|
||||||
|
parent_file = nautilus_file_get_parent (file);
|
||||||
|
if (parent_file) {
|
||||||
|
if (!nautilus_file_can_write (parent_file)) {
|
||||||
|
exclude[i++] = NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE;
|
||||||
|
}
|
||||||
|
nautilus_file_unref (parent_file);
|
||||||
|
}
|
||||||
|
exclude[i++] = NULL;
|
||||||
|
|
||||||
|
for (l = *metadata_keywords; l != NULL; l = l->next) {
|
||||||
|
keyword = l->data;
|
||||||
|
found = FALSE;
|
||||||
|
|
||||||
|
for (i = 0; exclude[i] != NULL; i++) {
|
||||||
|
if (strcmp (exclude[i], keyword) == 0) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
res = g_list_prepend (res, keyword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_list_free (*metadata_keywords);
|
||||||
|
*metadata_keywords = res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nautilus_file_get_keywords
|
* nautilus_file_get_keywords
|
||||||
*
|
*
|
||||||
|
@ -6419,7 +6463,7 @@ sort_keyword_list_and_remove_duplicates (GList *keywords)
|
||||||
static GList *
|
static GList *
|
||||||
nautilus_file_get_keywords (NautilusFile *file)
|
nautilus_file_get_keywords (NautilusFile *file)
|
||||||
{
|
{
|
||||||
GList *keywords;
|
GList *keywords, *metadata_keywords;
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -6429,7 +6473,10 @@ nautilus_file_get_keywords (NautilusFile *file)
|
||||||
|
|
||||||
keywords = eel_g_str_list_copy (file->details->extension_emblems);
|
keywords = eel_g_str_list_copy (file->details->extension_emblems);
|
||||||
keywords = g_list_concat (keywords, eel_g_str_list_copy (file->details->pending_extension_emblems));
|
keywords = g_list_concat (keywords, eel_g_str_list_copy (file->details->pending_extension_emblems));
|
||||||
keywords = g_list_concat (keywords, nautilus_file_get_metadata_list (file, NAUTILUS_METADATA_KEY_EMBLEMS));
|
|
||||||
|
metadata_keywords = nautilus_file_get_metadata_list (file, NAUTILUS_METADATA_KEY_EMBLEMS);
|
||||||
|
clean_up_metadata_keywords (file, &metadata_keywords);
|
||||||
|
keywords = g_list_concat (keywords, metadata_keywords);
|
||||||
|
|
||||||
return sort_keyword_list_and_remove_duplicates (keywords);
|
return sort_keyword_list_and_remove_duplicates (keywords);
|
||||||
}
|
}
|
||||||
|
@ -6447,14 +6494,11 @@ nautilus_file_get_keywords (NautilusFile *file)
|
||||||
GList *
|
GList *
|
||||||
nautilus_file_get_emblem_icons (NautilusFile *file)
|
nautilus_file_get_emblem_icons (NautilusFile *file)
|
||||||
{
|
{
|
||||||
NautilusFile *parent_file;
|
|
||||||
GList *keywords, *l;
|
GList *keywords, *l;
|
||||||
GList *icons;
|
GList *icons;
|
||||||
char *icon_names[2];
|
char *icon_names[2];
|
||||||
char *exclude[3];
|
|
||||||
char *keyword;
|
char *keyword;
|
||||||
GIcon *icon;
|
GIcon *icon;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -6462,28 +6506,12 @@ nautilus_file_get_emblem_icons (NautilusFile *file)
|
||||||
|
|
||||||
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
|
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
|
||||||
|
|
||||||
i = 0;
|
|
||||||
parent_file = nautilus_file_get_parent (file);
|
|
||||||
exclude[i++] = NAUTILUS_FILE_EMBLEM_NAME_TRASH;
|
|
||||||
if (parent_file) {
|
|
||||||
if (!nautilus_file_can_write (parent_file)) {
|
|
||||||
exclude[i++] = NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE;
|
|
||||||
}
|
|
||||||
nautilus_file_unref (parent_file);
|
|
||||||
}
|
|
||||||
exclude[i++] = NULL;
|
|
||||||
|
|
||||||
keywords = nautilus_file_get_keywords (file);
|
keywords = nautilus_file_get_keywords (file);
|
||||||
keywords = prepend_automatic_keywords (file, keywords);
|
keywords = prepend_automatic_keywords (file, keywords);
|
||||||
|
|
||||||
icons = NULL;
|
icons = NULL;
|
||||||
for (l = keywords; l != NULL; l = l->next) {
|
for (l = keywords; l != NULL; l = l->next) {
|
||||||
keyword = l->data;
|
keyword = l->data;
|
||||||
for (i = 0; exclude[i] != NULL; i++) {
|
|
||||||
if (strcmp (exclude[i], keyword) == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
icon_names[0] = g_strconcat ("emblem-", keyword, NULL);
|
icon_names[0] = g_strconcat ("emblem-", keyword, NULL);
|
||||||
icon_names[1] = keyword;
|
icon_names[1] = keyword;
|
||||||
|
|
Loading…
Reference in a new issue