[gnome-builder/wip/chergert/perspective] libide: add ide_uri_new_from_file().



commit 9af1fb3c159aec969eb8d7135c07ec6c12e38748
Author: Christian Hergert <christian hergert me>
Date:   Sun Nov 15 15:37:26 2015 -0800

    libide: add ide_uri_new_from_file().

 libide/ide-uri.c |   23 +++++++++++++++++++++++
 libide/ide-uri.h |   17 +++++++++--------
 2 files changed, 32 insertions(+), 8 deletions(-)
---
diff --git a/libide/ide-uri.c b/libide/ide-uri.c
index 85f4cb8..fe99126 100644
--- a/libide/ide-uri.c
+++ b/libide/ide-uri.c
@@ -1494,3 +1494,26 @@ ide_uri_error_quark (void)
 {
   return g_quark_from_static_string ("ide-uri-error-quark");
 }
+
+/**
+ * ide_uri_new_from_file:
+ * @file: A #GFile.
+ *
+ * Creates a new #IdeUri from the uri provided by @file.
+ *
+ * Returns: (transfer full): A newly allcoated #IdeUri.
+ */
+IdeUri *
+ide_uri_new_from_file (GFile *file)
+{
+  IdeUri *uri;
+  gchar *uristr;
+
+  g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+  uristr = g_file_get_uri (file);
+  uri = ide_uri_new (uristr, 0, NULL);
+  g_free (uristr);
+
+  return uri;
+}
diff --git a/libide/ide-uri.h b/libide/ide-uri.h
index 6438f6e..f3508e7 100644
--- a/libide/ide-uri.h
+++ b/libide/ide-uri.h
@@ -21,7 +21,7 @@
 #ifndef __IDE_URI_H__
 #define __IDE_URI_H__
 
-#include <glib-object.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -39,13 +39,14 @@ typedef enum
   IDE_URI_PARSE_UTF8_ONLY   = 1 << 7
 } IdeUriParseFlags;
 
-IdeUri *       ide_uri_new          (const gchar        *uri_string,
-                                     IdeUriParseFlags    flags,
-                                     GError            **error);
-IdeUri *       ide_uri_new_relative (IdeUri             *base_uri,
-                                     const gchar        *uri_string,
-                                     IdeUriParseFlags    flags,
-                                     GError            **error);
+IdeUri *       ide_uri_new           (const gchar        *uri_string,
+                                      IdeUriParseFlags    flags,
+                                      GError            **error);
+IdeUri *       ide_uri_new_relative  (IdeUri             *base_uri,
+                                      const gchar        *uri_string,
+                                      IdeUriParseFlags    flags,
+                                      GError            **error);
+IdeUri *       ide_uri_new_from_file (GFile              *file);
 
 typedef enum
 {


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