[gedit/wip/loader-saver: 49/54] File loading: set 'create' flag on GeditDocument
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 49/54] File loading: set 'create' flag on GeditDocument
- Date: Mon, 30 Jun 2014 22:39:20 +0000 (UTC)
commit 347514d47cc0b7fc165bc69c99ae254c2263b7dd
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Jun 28 22:59:12 2014 +0200
File loading: set 'create' flag on GeditDocument
gedit/gedit-document.c | 27 ++++++++++++++++++++++-----
gedit/gedit-document.h | 5 +++++
gedit/gedit-tab.c | 10 ++++------
3 files changed, 31 insertions(+), 11 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index a432a35..b5872ff 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -68,14 +68,11 @@ struct _GeditDocumentPrivate
*/
GtkSourceSearchContext *search_context;
- /* Temp data while loading */
- gboolean create; /* Create file if uri points
- * to a non existing file */
-
guint readonly : 1;
guint externally_modified : 1;
guint deleted : 1;
guint language_set_by_user : 1;
+ guint mtime_set : 1;
/* The search is empty if there is no search context, or if the
* search text is empty. It is used for the sensitivity of some menu
@@ -83,7 +80,10 @@ struct _GeditDocumentPrivate
*/
guint empty_search : 1;
- guint mtime_set : 1;
+ /* Create file if location points to a non existing file (for example
+ * when opened from the command line).
+ */
+ guint create : 1;
};
enum
@@ -1816,4 +1816,21 @@ gedit_document_get_file (GeditDocument *doc)
return doc->priv->file;
}
+void
+_gedit_document_set_create (GeditDocument *doc,
+ gboolean create)
+{
+ g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
+
+ doc->priv->create = create != FALSE;
+}
+
+gboolean
+_gedit_document_get_create (GeditDocument *doc)
+{
+ g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), FALSE);
+
+ return doc->priv->create;
+}
+
/* ex:set ts=8 noet: */
diff --git a/gedit/gedit-document.h b/gedit/gedit-document.h
index 8e6d72b..9fd196d 100644
--- a/gedit/gedit-document.h
+++ b/gedit/gedit-document.h
@@ -167,6 +167,11 @@ gboolean _gedit_document_needs_saving (GeditDocument *doc);
gboolean _gedit_document_get_empty_search
(GeditDocument *doc);
+void _gedit_document_set_create (GeditDocument *doc,
+ gboolean create);
+
+gboolean _gedit_document_get_create (GeditDocument *doc);
+
G_END_DECLS
#endif /* __GEDIT_DOCUMENT_H__ */
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index a062188..cf1359f 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -75,7 +75,6 @@ struct _GeditTabPrivate
gint ask_if_externally_modified : 1;
/* tmp data for loading */
- guint load_create : 1;
guint user_requested_encoding : 1;
};
@@ -224,7 +223,6 @@ clear_loading (GeditTab *tab)
{
g_clear_object (&tab->priv->loader);
g_clear_object (&tab->priv->cancellable);
- tab->priv->load_create = FALSE;
}
static void
@@ -611,8 +609,6 @@ io_loading_error_info_bar_response (GtkWidget *info_bar,
set_info_bar (tab, NULL, GTK_RESPONSE_NONE);
gedit_tab_set_state (tab, GEDIT_TAB_STATE_LOADING);
- tab->priv->load_create = FALSE;
-
load (tab,
encoding,
tab->priv->tmp_line_pos,
@@ -1694,7 +1690,7 @@ load_cb (GtkSourceFileLoader *loader,
}
/* Special case creating a named new doc. */
- else if (tab->priv->load_create &&
+ else if (_gedit_document_get_create (doc) &&
error->domain == G_IO_ERROR &&
error->code == G_IO_ERROR_NOT_FOUND &&
g_file_has_uri_scheme (location, "file"))
@@ -1990,7 +1986,7 @@ _gedit_tab_load (GeditTab *tab,
tab->priv->loader = gtk_source_file_loader_new (file, location);
- tab->priv->load_create = create != FALSE;
+ _gedit_document_set_create (doc, create);
load (tab, encoding, line_pos, column_pos);
}
@@ -2022,6 +2018,8 @@ _gedit_tab_load_stream (GeditTab *tab,
tab->priv->loader = gtk_source_file_loader_new_from_stream (file, stream);
+ _gedit_document_set_create (doc, FALSE);
+
load (tab, encoding, line_pos, column_pos);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]