[gedit/wip/loader-saver: 47/48] GeditDocument: bug fix for reading stdin
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/loader-saver: 47/48] GeditDocument: bug fix for reading stdin
- Date: Wed, 9 Jul 2014 11:11:58 +0000 (UTC)
commit 3901cb97f496ec847ba08a1b9ea67e0d52abbfa6
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Jul 8 21:47:30 2014 +0200
GeditDocument: bug fix for reading stdin
The location is NULL when reading stdin.
gedit/gedit-document.c | 80 +++++++++++++++++++++++++----------------------
1 files changed, 43 insertions(+), 37 deletions(-)
---
diff --git a/gedit/gedit-document.c b/gedit/gedit-document.c
index 7547cb7..58f3536 100644
--- a/gedit/gedit-document.c
+++ b/gedit/gedit-document.c
@@ -1059,8 +1059,6 @@ loaded_query_info_cb (GFile *location,
GeditDocument *doc)
{
GFileInfo *info;
- const gchar *content_type = NULL;
- gboolean read_only = FALSE;
GError *error = NULL;
info = g_file_query_info_finish (location, result, &error);
@@ -1080,18 +1078,24 @@ loaded_query_info_cb (GFile *location,
error = NULL;
}
- doc->priv->mtime_set = FALSE;
-
if (info != NULL)
{
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE))
{
+ const gchar *content_type;
+
content_type = g_file_info_get_attribute_string (info,
G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE);
+
+ gedit_document_set_content_type (doc, content_type);
}
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE))
{
+ gboolean read_only;
+
read_only = !g_file_info_get_attribute_boolean (info,
G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+
+ set_readonly (doc, read_only);
}
if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED))
@@ -1099,23 +1103,19 @@ loaded_query_info_cb (GFile *location,
g_file_info_get_modification_time (info, &doc->priv->mtime);
doc->priv->mtime_set = TRUE;
}
- }
-
- set_readonly (doc, read_only);
-
- g_get_current_time (&doc->priv->time_of_last_save_or_load);
-
- doc->priv->externally_modified = FALSE;
- doc->priv->deleted = FALSE;
-
- gedit_document_set_content_type (doc, content_type);
- if (info != NULL)
- {
- /* content_type (owned by info) is no longer needed. */
g_object_unref (info);
}
+ /* Async operation finished. */
+ g_object_unref (doc);
+}
+
+static void
+gedit_document_loaded_real (GeditDocument *doc)
+{
+ GFile *location;
+
if (!doc->priv->language_set_by_user)
{
GtkSourceLanguage *language = guess_language (doc);
@@ -1126,27 +1126,33 @@ loaded_query_info_cb (GFile *location,
set_language (doc, language, FALSE);
}
- /* Async operation finished. */
- g_object_unref (doc);
-}
+ doc->priv->mtime_set = FALSE;
+ doc->priv->externally_modified = FALSE;
+ doc->priv->deleted = FALSE;
-static void
-gedit_document_loaded_real (GeditDocument *doc)
-{
- GFile *location = gtk_source_file_get_location (doc->priv->file);
+ g_get_current_time (&doc->priv->time_of_last_save_or_load);
- /* Keep the doc alive during the async operation. */
- g_object_ref (doc);
+ set_readonly (doc, FALSE);
- g_file_query_info_async (location,
- G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
- G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ","
- G_FILE_ATTRIBUTE_TIME_MODIFIED,
- G_FILE_QUERY_INFO_NONE,
- G_PRIORITY_DEFAULT,
- NULL,
- (GAsyncReadyCallback) loaded_query_info_cb,
- doc);
+ gedit_document_set_content_type (doc, NULL);
+
+ location = gtk_source_file_get_location (doc->priv->file);
+
+ if (location != NULL)
+ {
+ /* Keep the doc alive during the async operation. */
+ g_object_ref (doc);
+
+ g_file_query_info_async (location,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE ","
+ G_FILE_ATTRIBUTE_TIME_MODIFIED,
+ G_FILE_QUERY_INFO_NONE,
+ G_PRIORITY_DEFAULT,
+ NULL,
+ (GAsyncReadyCallback) loaded_query_info_cb,
+ doc);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]