[gtksourceview] file: add is_local() function



commit 2163ae5713958686ee3e35b973c330b744cc4caa
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sun Jun 14 14:58:51 2015 +0200

    file: add is_local() function
    
    And add a recommendation for check_file_on_disk().

 docs/reference/gtksourceview-3.0-sections.txt |    1 +
 gtksourceview/gtksourcefile.c                 |   26 +++++++++++++++++++++++++
 gtksourceview/gtksourcefile.h                 |    2 +
 3 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gtksourceview-3.0-sections.txt b/docs/reference/gtksourceview-3.0-sections.txt
index 5a1f093..7e18b88 100644
--- a/docs/reference/gtksourceview-3.0-sections.txt
+++ b/docs/reference/gtksourceview-3.0-sections.txt
@@ -251,6 +251,7 @@ gtk_source_file_get_encoding
 gtk_source_file_get_newline_type
 gtk_source_file_get_compression_type
 gtk_source_file_check_file_on_disk
+gtk_source_file_is_local
 gtk_source_file_is_externally_modified
 gtk_source_file_is_deleted
 gtk_source_file_is_readonly
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index cdd22d8..59021f8 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -480,6 +480,29 @@ _gtk_source_file_set_modification_time (GtkSourceFile *file,
 }
 
 /**
+ * gtk_source_file_is_local:
+ * @file: a #GtkSourceFile.
+ *
+ * Returns whether the file is local. If the #GtkSourceFile:location is %NULL,
+ * returns %FALSE.
+ *
+ * Returns: whether the file is local.
+ * Since: 3.18
+ */
+gboolean
+gtk_source_file_is_local (GtkSourceFile *file)
+{
+       g_return_val_if_fail (GTK_SOURCE_IS_FILE (file), FALSE);
+
+       if (file->priv->location == NULL)
+       {
+               return FALSE;
+       }
+
+       return g_file_has_uri_scheme (file->priv->location, "file");
+}
+
+/**
  * gtk_source_file_check_file_on_disk:
  * @file: a #GtkSourceFile.
  *
@@ -490,6 +513,9 @@ _gtk_source_file_set_modification_time (GtkSourceFile *file,
  * this function needs to be called instead. Creating lots of #GFileMonitor's
  * would take lots of resources.
  *
+ * Since this function is synchronous, it is advised to call it only on local
+ * files. See gtk_source_file_is_local().
+ *
  * Since: 3.18
  */
 void
diff --git a/gtksourceview/gtksourcefile.h b/gtksourceview/gtksourcefile.h
index 3ddc8df..82dc889 100644
--- a/gtksourceview/gtksourcefile.h
+++ b/gtksourceview/gtksourcefile.h
@@ -89,6 +89,8 @@ void           gtk_source_file_set_mount_operation_factory    (GtkSourceFile
 
 void            gtk_source_file_check_file_on_disk             (GtkSourceFile *file);
 
+gboolean        gtk_source_file_is_local                       (GtkSourceFile *file);
+
 gboolean        gtk_source_file_is_externally_modified         (GtkSourceFile *file);
 
 gboolean        gtk_source_file_is_deleted                     (GtkSourceFile *file);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]