summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2018-02-08 20:54:44 +0100
committerCarlos Soriano <csoriano1618@gmail.com>2018-02-12 13:20:38 +0000
commitc6657af3420fb17b96ceeffa65da52d3b8b22dfc (patch)
treef681385e05a52e50e2ac2d4c4546b5c34d681b87 /eel
parent1a38f2edb6fe2f2a39dbc773918b9501b47db174 (diff)
downloadnautilus-c6657af3420fb17b96ceeffa65da52d3b8b22dfc.tar.gz
files-view: Show starring only for indexed (by default) files
Currently the star menu item is shown for every file in the system, however when a file is not indexed by tracker this operation fails. We cannot set Tracker to index the file and wait for Tracker to index it, since that happens in an idle and Tracker doesn't queue the operation of starring. There is no easy solution for this, so for now we will show the star menu item for indexed (by default) locations, which are the XDG folders, otherwise we will hide the item. A better solution needs to be researched for 3.30, but this will do for now. Related https://gitlab.gnome.org/GNOME/nautilus/issues/243
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-vfs-extensions.c32
-rw-r--r--eel/eel-vfs-extensions.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/eel/eel-vfs-extensions.c b/eel/eel-vfs-extensions.c
index 54ccd7f98..94160f8fb 100644
--- a/eel/eel-vfs-extensions.c
+++ b/eel/eel-vfs-extensions.c
@@ -67,6 +67,38 @@ eel_uri_is_other_locations (const char *uri)
return g_str_has_prefix (uri, "other-locations:");
}
+gboolean
+eel_uri_is_in_xdg_dirs (const gchar *uri)
+{
+ GUserDirectory dir;
+ g_autoptr (GFile) location = NULL;
+ gboolean has_prefix = FALSE;
+
+ location = g_file_new_for_uri (uri);
+ for (dir = 0; dir < G_USER_N_DIRECTORIES; dir++)
+ {
+ g_autoptr (GFile) xdg_dir_location = NULL;
+ const gchar *path;
+
+ path = g_get_user_special_dir (dir);
+ if (path == NULL)
+ {
+ continue;
+ }
+
+ xdg_dir_location = g_file_new_for_path (path);
+ has_prefix = g_file_has_prefix (location, xdg_dir_location) ||
+ g_file_equal (location, xdg_dir_location);
+
+ if (has_prefix)
+ {
+ break;
+ }
+ }
+
+ return has_prefix;
+}
+
char *
eel_filename_get_extension_offset (const char *filename)
{
diff --git a/eel/eel-vfs-extensions.h b/eel/eel-vfs-extensions.h
index 69aa51088..1881edc31 100644
--- a/eel/eel-vfs-extensions.h
+++ b/eel/eel-vfs-extensions.h
@@ -39,6 +39,7 @@ gboolean eel_uri_is_trash (const char *
gboolean eel_uri_is_search (const char *uri);
gboolean eel_uri_is_other_locations (const char *uri);
gboolean eel_uri_is_recent (const char *uri);
+gboolean eel_uri_is_in_xdg_dirs (const char *uri);
char * eel_filename_strip_extension (const char *filename);
void eel_filename_get_rename_region (const char *filename,