[gtk+/wip/matthiasc/local-search: 5/8] Add a helper function for remote locations
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/local-search: 5/8] Add a helper function for remote locations
- Date: Fri, 24 Jul 2015 20:29:02 +0000 (UTC)
commit 59fc57bdc3d289fc4253e05ea4df09ba0217a218
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 24 16:01:25 2015 -0400
Add a helper function for remote locations
Add a helper function that says whether a location should be
considered remote. To determine this, we look at the filesystem
type reported by gvfs, and say 'remote' for sftp, webdav, ftp,
nfs and cifs.
gtk/gtkfilesystem.c | 31 +++++++++++++++++++++++++++++++
gtk/gtkfilesystem.h | 2 ++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index 772618f..baae742 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -921,3 +921,34 @@ _gtk_file_has_native_path (GFile *file)
return has_native_path;
}
+
+static const gchar * const remote_types[] = {
+ "sftp",
+ "webdav",
+ "ftp",
+ "nfs",
+ "cifs",
+ NULL
+};
+
+gboolean
+_gtk_file_consider_as_remote (GFile *file)
+{
+ GFileInfo *info;
+ gboolean is_remote;
+
+ info = g_file_query_filesystem_info (file, "filesystem::type", NULL, NULL);
+ if (info)
+ {
+ const gchar *type;
+
+ type = g_file_info_get_attribute_string (info, "filesystem::type");
+ is_remote = g_strv_contains (remote_types, type);
+
+ g_object_unref (info);
+ }
+ else
+ is_remote = FALSE;
+
+ return is_remote;
+}
diff --git a/gtk/gtkfilesystem.h b/gtk/gtkfilesystem.h
index ebc796e..70bd3ea 100644
--- a/gtk/gtkfilesystem.h
+++ b/gtk/gtkfilesystem.h
@@ -118,6 +118,8 @@ gboolean _gtk_file_info_consider_as_directory (GFileInfo *info);
/* GFile helper functions */
gboolean _gtk_file_has_native_path (GFile *file);
+gboolean _gtk_file_consider_as_remote (GFile *file);
+
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]