[gedit] Use gtk_source_file_is_local()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Use gtk_source_file_is_local()
- Date: Sun, 14 Jun 2015 13:22:14 +0000 (UTC)
commit 8e9c4dbc9c55e8c188c34ee9522019d6d598b207
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jun 14 15:13:01 2015 +0200
Use gtk_source_file_is_local()
And deprecate gedit_document_is_local().
gedit/gedit-document.c | 19 +++++++++----------
gedit/gedit-document.h | 1 +
gedit/gedit-open-document-selector-store.c | 20 +++++++++++++++-----
gedit/gedit-tab.c | 10 ++++------
4 files changed, 29 insertions(+), 21 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index c01d2ab..e6c6273 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1381,24 +1381,23 @@ gedit_document_is_untitled (GeditDocument *doc)
return gtk_source_file_get_location (priv->file) == NULL;
}
+/**
+ * gedit_document_is_local:
+ * @doc: a #GeditDocument.
+ *
+ * Returns: whether the document is local.
+ * Deprecated: 3.18: Use gtk_source_file_is_local() instead.
+ */
gboolean
gedit_document_is_local (GeditDocument *doc)
{
GeditDocumentPrivate *priv;
- GFile *location;
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
priv = gedit_document_get_instance_private (doc);
- location = gtk_source_file_get_location (priv->file);
-
- if (location == NULL)
- {
- return FALSE;
- }
-
- return g_file_has_uri_scheme (location, "file");
+ return gtk_source_file_is_local (priv->file);
}
/**
@@ -1440,7 +1439,7 @@ _gedit_document_needs_saving (GeditDocument *doc)
return TRUE;
}
- if (gedit_document_is_local (doc))
+ if (gtk_source_file_is_local (priv->file))
{
gtk_source_file_check_file_on_disk (priv->file);
externally_modified = gtk_source_file_is_externally_modified (priv->file);
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index 6a129d3..b169642 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -82,6 +82,7 @@ gboolean gedit_document_is_untouched (GeditDocument *doc);
gboolean gedit_document_is_untitled (GeditDocument *doc);
+G_DEPRECATED_FOR (gtk_source_file_is_local)
gboolean gedit_document_is_local (GeditDocument *doc);
G_DEPRECATED
diff --git a/gedit/gedit-open-document-selector-store.c b/gedit/gedit-open-document-selector-store.c
index 5adad6b..2260c38 100644
--- a/gedit/gedit-open-document-selector-store.c
+++ b/gedit/gedit-open-document-selector-store.c
@@ -236,17 +236,27 @@ get_active_doc_dir_list (GeditOpenDocumentSelectorStore *selector_store,
{
GeditWindow *window;
GeditDocument *active_doc;
+ GtkSourceFile *source_file;
GList *file_items_list = NULL;
- GFile *file;
- GFile *parent_dir;
window = gedit_open_document_selector_get_window (selector);
active_doc = gedit_window_get_active_document (window);
- if (active_doc != NULL && gedit_document_is_local (active_doc))
+
+ if (active_doc == NULL)
+ {
+ return NULL;
+ }
+
+ source_file = gedit_document_get_file (active_doc);
+ if (gtk_source_file_is_local (source_file))
{
- file = gtk_source_file_get_location (gedit_document_get_file (active_doc));
- parent_dir = g_file_get_parent (file);
+ GFile *location;
+ GFile *parent_dir;
+
+ location = gtk_source_file_get_location (source_file);
+ parent_dir = g_file_get_parent (location);
+
if (parent_dir != NULL)
{
file_items_list = get_children_from_dir (selector_store, parent_dir);
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index 0b0216f..58fb855 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1241,6 +1241,7 @@ view_focused_in (GtkWidget *widget,
GeditTab *tab)
{
GeditDocument *doc;
+ GtkSourceFile *file;
g_return_val_if_fail (GEDIT_IS_TAB (tab), GDK_EVENT_PROPAGATE);
@@ -1257,14 +1258,11 @@ view_focused_in (GtkWidget *widget,
}
doc = gedit_tab_get_document (tab);
+ file = gedit_document_get_file (doc);
/* If file was never saved or is remote we do not check */
- if (gedit_document_is_local (doc))
+ if (gtk_source_file_is_local (file))
{
- GtkSourceFile *file;
-
- file = gedit_document_get_file (doc);
-
gtk_source_file_check_file_on_disk (file);
if (gtk_source_file_is_externally_modified (file))
@@ -1311,7 +1309,7 @@ _gedit_tab_set_network_available (GeditTab *tab,
file = gedit_document_get_file (doc);
location = gtk_source_file_get_location (file);
- if (gedit_document_is_local (doc) || location == NULL)
+ if (gtk_source_file_is_local (file) || location == NULL)
{
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]