gedit r6419 - in trunk: . gedit
- From: jessevdk svn gnome org
- To: svn-commits-list gnome org
- Subject: gedit r6419 - in trunk: . gedit
- Date: Sat, 16 Aug 2008 16:53:47 +0000 (UTC)
Author: jessevdk
Date: Sat Aug 16 16:53:47 2008
New Revision: 6419
URL: http://svn.gnome.org/viewvc/gedit?rev=6419&view=rev
Log:
* gedit-tab.c:
* gedit-local-document-saver.c:
* gedit-gio-document-saver.c:
* gedit-io-error-message-area.c:
* gedit-gio-document-loader.c:
* gedit-mmap-document-loader.c:
* gedit-document.c:
* gedit-document.h:
* gedit-document-saver.c:
Fixed proper use of gio errors
Modified:
trunk/ChangeLog
trunk/gedit/gedit-document-saver.c
trunk/gedit/gedit-document.c
trunk/gedit/gedit-document.h
trunk/gedit/gedit-gio-document-loader.c
trunk/gedit/gedit-gio-document-saver.c
trunk/gedit/gedit-io-error-message-area.c
trunk/gedit/gedit-local-document-saver.c
trunk/gedit/gedit-mmap-document-loader.c
trunk/gedit/gedit-tab.c
Modified: trunk/gedit/gedit-document-saver.c
==============================================================================
--- trunk/gedit/gedit-document-saver.c (original)
+++ trunk/gedit/gedit-document-saver.c Sat Aug 16 16:53:47 2008
@@ -386,7 +386,7 @@
if (!res)
{
g_set_error (error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
}
Modified: trunk/gedit/gedit-document.c
==============================================================================
--- trunk/gedit/gedit-document.c (original)
+++ trunk/gedit/gedit-document.c Sat Aug 16 16:53:47 2008
@@ -1064,7 +1064,7 @@
/* special case creating a named new doc */
else if (doc->priv->create &&
- (error->code == G_IO_ERROR_NOT_FOUND) &&
+ (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND) &&
(gedit_utils_uri_has_file_scheme (doc->priv->uri)))
{
reset_temp_loading_data (doc);
Modified: trunk/gedit/gedit-document.h
==============================================================================
--- trunk/gedit/gedit-document.h (original)
+++ trunk/gedit/gedit-document.h Sat Aug 16 16:53:47 2008
@@ -139,8 +139,7 @@
enum
{
- /* we use GIO error codes, so start at some high number? */
- GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED = 1 << 10,
+ GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED,
GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP,
GEDIT_DOCUMENT_ERROR_TOO_BIG,
GEDIT_DOCUMENT_NUM_ERRORS
Modified: trunk/gedit/gedit-gio-document-loader.c
==============================================================================
--- trunk/gedit/gedit-gio-document-loader.c (original)
+++ trunk/gedit/gedit-gio-document-loader.c Sat Aug 16 16:53:47 2008
@@ -189,6 +189,15 @@
static void read_file_chunk (AsyncData *async);
static void
+async_failed (AsyncData *async, GError *error)
+{
+ g_propagate_error (&async->loader->priv->error, error);
+ g_error_free (error);
+
+ remote_load_completed_or_failed (async->loader, async);
+}
+
+static void
async_read_cb (GInputStream *stream,
GAsyncResult *res,
AsyncData *async)
@@ -212,13 +221,7 @@
/* error occurred */
if (bytes_read == -1)
{
- g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- remote_load_completed_or_failed (gvloader, async);
-
+ async_failed (async, error);
return;
}
@@ -228,7 +231,7 @@
g_set_error (&gvloader->priv->error,
GEDIT_DOCUMENT_ERROR,
GEDIT_DOCUMENT_ERROR_TOO_BIG,
- _("File too big"));
+ "File too big");
remote_load_completed_or_failed (gvloader, async);
@@ -294,9 +297,9 @@
g_file_info_get_file_type (gvloader->priv->info) != G_FILE_TYPE_REGULAR)
{
g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_NOT_REGULAR_FILE,
- _("Not a regular file"));
+ "Not a regular file");
remote_load_completed_or_failed (gvloader, async);
@@ -334,15 +337,7 @@
if (!gvloader->priv->info)
{
/* propagate the error and clean up */
- g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- g_error_free (error);
-
- remote_load_completed_or_failed (gvloader, async);
-
+ async_failed (async, error);
return;
}
@@ -391,15 +386,7 @@
}
/* propagate the error and clean up */
- g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- g_error_free (error);
-
- remote_load_completed_or_failed (gvloader, async);
-
+ async_failed (async, error);
return;
}
@@ -425,13 +412,7 @@
if (!mounted)
{
- g_set_error (&async->loader->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- g_error_free (error);
- remote_load_completed_or_failed (async->loader, async);
+ async_failed (async, error);
}
else
{
@@ -491,12 +472,8 @@
return;
}
- /* Propagate error using GEDIT_DOCUMENT_ERROR for the domain */
- g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
+ /* Propagate error */
+ g_propagate_error (&gvloader->priv->error, error);
gedit_document_loader_loading (GEDIT_DOCUMENT_LOADER (gvloader),
TRUE,
gvloader->priv->error);
@@ -617,7 +594,7 @@
g_cancellable_cancel (gvloader->priv->cancellable);
g_set_error (&gvloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_CANCELLED,
"Operation cancelled");
Modified: trunk/gedit/gedit-gio-document-saver.c
==============================================================================
--- trunk/gedit/gedit-gio-document-saver.c (original)
+++ trunk/gedit/gedit-gio-document-saver.c Sat Aug 16 16:53:47 2008
@@ -158,7 +158,8 @@
}
static void
-remote_save_completed_or_failed (GeditGioDocumentSaver *gvsaver, AsyncData *async)
+remote_save_completed_or_failed (GeditGioDocumentSaver *gvsaver,
+ AsyncData *async)
{
if (async)
async_data_free (async);
@@ -168,6 +169,16 @@
gvsaver->priv->error);
}
+static void
+async_failed (AsyncData *async,
+ GError *error)
+{
+ g_propagate_error (&async->saver->priv->error, error);
+ g_error_free (error);
+
+ remote_save_completed_or_failed (async->saver, async);
+}
+
/* prototype, because they call each other... isn't C lovely */
static void write_file_chunk (AsyncData *async);
@@ -225,11 +236,7 @@
else
{
gedit_debug_message (DEBUG_SAVER, "Query info failed: %s", error->message);
-
- g_set_error (&saver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
+ g_propagate_error (&saver->priv->error, error);
g_error_free (error);
}
@@ -256,13 +263,7 @@
{
gedit_debug_message (DEBUG_SAVER, "Closing stream error: %s", error->message);
- g_set_error (&async->saver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
- g_error_free (error);
-
- remote_save_completed_or_failed (async->saver, async);
+ async_failed (async, error);
return;
}
@@ -292,10 +293,7 @@
if (!g_output_stream_close_finish (stream, res, &error))
{
- g_set_error (&async->saver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
+ g_propagate_error (&async->saver->priv->error, error);
g_error_free (error);
}
@@ -341,10 +339,7 @@
else
{
gedit_debug_message (DEBUG_SAVER, "Query info failed: %s", error->message);
- g_set_error (&saver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
+ g_propagate_error (&saver->priv->error, error);
g_error_free (error);
next_callback = (GAsyncReadyCallback) close_async_ready_cb;
@@ -409,13 +404,7 @@
if (bytes_written == -1)
{
gedit_debug_message (DEBUG_SAVER, "Write error: %s", error->message);
-
- g_set_error (&gvsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- remote_save_completed_or_failed (gvsaver, async);
+ async_failed (async, error);
return;
}
@@ -481,12 +470,7 @@
if (!gvsaver->priv->stream)
{
gedit_debug_message (DEBUG_SAVER, "Opening file failed: %s", error->message);
- g_set_error (&gvsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- remote_save_completed_or_failed (gvsaver, async);
+ async_failed (async, error);
return;
}
@@ -561,12 +545,7 @@
if (!buffer)
{
- g_set_error (&gvsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- remote_save_completed_or_failed (gvsaver, async);
+ async_failed (async, error);
return;
}
@@ -605,13 +584,7 @@
if (!mounted)
{
- g_set_error (&async->saver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- g_error_free (error);
- remote_save_completed_or_failed (async->saver, async);
+ async_failed (async, error);
}
else
{
@@ -670,13 +643,8 @@
}
gedit_debug_message (DEBUG_SAVER, "Error getting modification: %s", error->message);
- g_set_error (&gvsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
- error->code,
- error->message);
-
- remote_save_completed_or_failed (gvsaver, async);
+ async_failed (async, error);
return;
}
Modified: trunk/gedit/gedit-io-error-message-area.c
==============================================================================
--- trunk/gedit/gedit-io-error-message-area.c (original)
+++ trunk/gedit/gedit-io-error-message-area.c Sat Aug 16 16:53:47 2008
@@ -57,7 +57,7 @@
{
gboolean is_recoverable = FALSE;
- if (error->domain == GEDIT_DOCUMENT_ERROR)
+ if (error->domain == G_IO_ERROR)
{
switch (error->code) {
case G_IO_ERROR_PERMISSION_DENIED:
@@ -74,6 +74,13 @@
return is_recoverable;
}
+static gboolean
+is_gio_error (const GError *error,
+ gint code)
+{
+ return error->domain == G_IO_ERROR && error->code == code;
+}
+
static void
set_message_area_text_and_icon (GeditMessageArea *message_area,
const gchar *icon_stock_id,
@@ -148,14 +155,16 @@
return message_area;
}
-static void
-parse_error (const GError *error,
- gchar **error_message,
- gchar **message_details,
- const gchar *uri,
- const gchar *uri_for_display)
+static gboolean
+parse_gio_error (gint code,
+ gchar **error_message,
+ gchar **message_details,
+ const gchar *uri,
+ const gchar *uri_for_display)
{
- switch (error->code)
+ gboolean ret = TRUE;
+
+ switch (code)
{
case G_IO_ERROR_NOT_FOUND:
*error_message = g_strdup_printf (_("Could not find the file %s."),
@@ -188,10 +197,6 @@
}
break;
- case GEDIT_DOCUMENT_ERROR_TOO_BIG:
- *message_details = g_strdup (_("The file is too big."));
- break;
-
case G_IO_ERROR_NOT_MOUNTABLE_FILE:
*message_details = g_strdup (_("The location of the file cannot be mounted."));
break;
@@ -264,15 +269,69 @@
*message_details = g_strdup (_("Connection timed out. Please try again."));
break;
- case G_IO_ERROR_FAILED:
+ default:
+ ret = FALSE;
break;
+ }
+ return ret;
+}
+
+static gboolean
+parse_gedit_error (gint code,
+ gchar **error_message,
+ gchar **message_details,
+ const gchar *uri,
+ const gchar *uri_for_display)
+{
+ gboolean ret = TRUE;
+
+ switch (code)
+ {
+ case GEDIT_DOCUMENT_ERROR_TOO_BIG:
+ *message_details = g_strdup (_("The file is too big."));
+ break;
+
default:
+ ret = FALSE;
+ break;
+ }
+
+ return ret;
+}
+
+static void
+parse_error (const GError *error,
+ gchar **error_message,
+ gchar **message_details,
+ const gchar *uri,
+ const gchar *uri_for_display)
+{
+ gboolean ret = FALSE;
+
+ if (error->domain == G_IO_ERROR)
+ {
+ ret = parse_gio_error (error->code,
+ error_message,
+ message_details,
+ uri,
+ uri_for_display);
+ }
+ else if (error->domain == GEDIT_DOCUMENT_ERROR)
+ {
+ ret = parse_gedit_error (error->code,
+ error_message,
+ message_details,
+ uri,
+ uri_for_display);
+ }
+
+ if (!ret)
+ {
g_warning ("Hit unhandled case %d (%s) in %s.",
error->code, error->message, G_STRFUNC);
*message_details = g_strdup_printf (_("Unexpected error: %s"),
error->message);
- break;
}
}
@@ -304,19 +363,17 @@
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
- switch (error->code)
+ if (is_gio_error (error, G_IO_ERROR_TOO_MANY_LINKS))
{
- case G_IO_ERROR_TOO_MANY_LINKS:
message_details = g_strdup (_("The number of followed links is limited and the actual file could not be found within this limit."));
- break;
-
- case G_IO_ERROR_PERMISSION_DENIED:
+ }
+ else if (is_gio_error (error, G_IO_ERROR_PERMISSION_DENIED))
+ {
message_details = g_strdup (_("You do not have the permissions necessary to open the file."));
- break;
-
- default:
+ }
+ else
+ {
parse_error (error, &error_message, &message_details, uri, uri_for_display);
- break;
}
if (error_message == NULL)
@@ -369,16 +426,14 @@
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
- switch (error->code)
+ if (is_gio_error (error, G_IO_ERROR_NOT_FOUND))
{
- case G_IO_ERROR_NOT_FOUND:
message_details = g_strdup (_("gedit cannot find the file. "
"Perhaps it has recently been deleted."));
- break;
-
- default:
+ }
+ else
+ {
parse_error (error, &error_message, &message_details, uri, uri_for_display);
- break;
}
if (error_message == NULL)
@@ -948,81 +1003,79 @@
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
- switch (error->code)
+ if (is_gio_error (error, G_IO_ERROR_NOT_SUPPORTED))
{
- case G_IO_ERROR_NOT_SUPPORTED:
- scheme_string = g_uri_parse_scheme (uri);
+ scheme_string = g_uri_parse_scheme (uri);
- if ((scheme_string != NULL) && g_utf8_validate (scheme_string, -1, NULL))
- {
- scheme_markup = g_markup_printf_escaped ("<i>%s:</i>", scheme_string);
-
- /* Translators: %s is a URI scheme (like for example http:, ftp:, etc.) */
- message_details = g_strdup_printf (_("gedit cannot handle %s locations in write mode. "
- "Please check that you typed the "
- "location correctly and try again."),
- scheme_markup);
- g_free (scheme_markup);
- }
- else
- {
- message_details = g_strdup (_("gedit cannot handle this location in write mode. "
- "Please check that you typed the "
- "location correctly and try again."));
- }
-
- g_free (scheme_string);
- break;
-
- case GEDIT_DOCUMENT_ERROR_TOO_BIG:
- message_details = g_strdup (_("The disk where you are trying to save the file has "
- "a limitation on file sizes. Please try saving "
- "a smaller file or saving it to a disk that does not "
- "have this limitation."));
- break;
-
- case G_IO_ERROR_INVALID_FILENAME:
- message_details = g_strdup (_("%s is not a valid location. "
- "Please check that you typed the "
- "location correctly and try again."));
- break;
+ if ((scheme_string != NULL) && g_utf8_validate (scheme_string, -1, NULL))
+ {
+ scheme_markup = g_markup_printf_escaped ("<i>%s:</i>", scheme_string);
- case G_IO_ERROR_PERMISSION_DENIED:
- message_details = g_strdup (_("You do not have the permissions necessary to save the file. "
+ /* Translators: %s is a URI scheme (like for example http:, ftp:, etc.) */
+ message_details = g_strdup_printf (_("gedit cannot handle %s locations in write mode. "
+ "Please check that you typed the "
+ "location correctly and try again."),
+ scheme_markup);
+ g_free (scheme_markup);
+ }
+ else
+ {
+ message_details = g_strdup (_("gedit cannot handle this location in write mode. "
"Please check that you typed the "
"location correctly and try again."));
+ }
- break;
-
- case G_IO_ERROR_NO_SPACE:
- message_details = g_strdup (_("There is not enough disk space to save the file. "
- "Please free some disk space and try again."));
- break;
-
- case G_IO_ERROR_READ_ONLY:
- message_details = g_strdup (_("You are trying to save the file on a read-only disk. "
- "Please check that you typed the location "
- "correctly and try again."));
- break;
-
- case G_IO_ERROR_EXISTS:
- message_details = g_strdup (_("A file with the same name already exists. "
- "Please use a different name."));
- break;
-
- case G_IO_ERROR_FILENAME_TOO_LONG:
- message_details = g_strdup (_("The disk where you are trying to save the file has "
- "a limitation on length of the file names. "
- "Please use a shorter name."));
- break;
-
- default:
- parse_error (error,
- &error_message,
- &message_details,
- uri,
- uri_for_display);
- break;
+ g_free (scheme_string);
+ }
+ else if (is_gio_error (error, G_IO_ERROR_INVALID_FILENAME))
+ {
+ message_details = g_strdup (_("%s is not a valid location. "
+ "Please check that you typed the "
+ "location correctly and try again."));
+ }
+ else if (is_gio_error (error, G_IO_ERROR_PERMISSION_DENIED))
+ {
+ message_details = g_strdup (_("You do not have the permissions necessary to save the file. "
+ "Please check that you typed the "
+ "location correctly and try again."));
+ }
+ else if (is_gio_error (error, G_IO_ERROR_NO_SPACE))
+ {
+ message_details = g_strdup (_("There is not enough disk space to save the file. "
+ "Please free some disk space and try again."));
+ }
+ else if (is_gio_error (error, G_IO_ERROR_READ_ONLY))
+ {
+ message_details = g_strdup (_("You are trying to save the file on a read-only disk. "
+ "Please check that you typed the location "
+ "correctly and try again."));
+ }
+ else if (is_gio_error (error, G_IO_ERROR_EXISTS))
+ {
+ message_details = g_strdup (_("A file with the same name already exists. "
+ "Please use a different name."));
+ }
+ else if (is_gio_error (error, G_IO_ERROR_FILENAME_TOO_LONG))
+ {
+ message_details = g_strdup (_("The disk where you are trying to save the file has "
+ "a limitation on length of the file names. "
+ "Please use a shorter name."));
+ }
+ else if (error->domain == GEDIT_DOCUMENT_ERROR &&
+ error->code == GEDIT_DOCUMENT_ERROR_TOO_BIG)
+ {
+ message_details = g_strdup (_("The disk where you are trying to save the file has "
+ "a limitation on file sizes. Please try saving "
+ "a smaller file or saving it to a disk that does not "
+ "have this limitation."));
+ }
+ else
+ {
+ parse_error (error,
+ &error_message,
+ &message_details,
+ uri,
+ uri_for_display);
}
if (error_message == NULL)
Modified: trunk/gedit/gedit-local-document-saver.c
==============================================================================
--- trunk/gedit/gedit-local-document-saver.c (original)
+++ trunk/gedit/gedit-local-document-saver.c Sat Aug 16 16:53:47 2008
@@ -197,7 +197,7 @@
if (bytes_read == -1)
{
g_set_error (error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -218,7 +218,7 @@
continue;
g_set_error (error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -297,7 +297,7 @@
if (fstat (lsaver->priv->fd, &statbuf) != 0)
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -310,14 +310,14 @@
if (S_ISDIR (statbuf.st_mode))
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_IS_DIRECTORY,
"Is a directory");
}
else
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_NOT_REGULAR_FILE,
"Not a regular file");
}
@@ -329,7 +329,7 @@
if ((statbuf.st_mode & 0222) == 0) //FIXME... check better what else vim does
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_READ_ONLY,
"File is read only");
@@ -360,7 +360,7 @@
g_warning (_("Could not obtain backup filename"));
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_FAILED,
"Failure");
@@ -468,7 +468,7 @@
gedit_debug_message (DEBUG_SAVER, "could not rename original -> backup");
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -485,7 +485,7 @@
gedit_debug_message (DEBUG_SAVER, "could not rename tmp -> original");
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -505,7 +505,7 @@
if (fstat (tmpfd, &new_statbuf) != 0)
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -691,7 +691,7 @@
if (fstat (lsaver->priv->fd, &new_statbuf) != 0)
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -707,7 +707,7 @@
if (close (lsaver->priv->fd))
g_warning ("File '%s' has not been correctly closed: %s",
saver->uri,
- strerror (errno));
+ g_strerror (errno));
lsaver->priv->fd = -1;
g_free (backup_filename);
@@ -737,7 +737,7 @@
if (fstat (lsaver->priv->fd, &statbuf) != 0)
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -753,7 +753,7 @@
if (close (lsaver->priv->fd))
g_warning ("File '%s' has not been correctly closed: %s",
GEDIT_DOCUMENT_SAVER (lsaver)->uri,
- strerror (errno));
+ g_strerror (errno));
lsaver->priv->fd = -1;
@@ -810,7 +810,7 @@
/* else error */
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -845,7 +845,7 @@
else
{
g_set_error (&lsaver->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"Operation is not supported");
}
Modified: trunk/gedit/gedit-mmap-document-loader.c
==============================================================================
--- trunk/gedit/gedit-mmap-document-loader.c (original)
+++ trunk/gedit/gedit-mmap-document-loader.c Sat Aug 16 16:53:47 2008
@@ -156,7 +156,7 @@
if (fstat (mloader->priv->fd, &mloader->priv->statbuf) != 0)
{
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -169,14 +169,14 @@
if (S_ISDIR (mloader->priv->statbuf.st_mode))
{
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_IS_DIRECTORY,
"Is a directory");
}
else
{
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_NOT_REGULAR_FILE,
"Not a regular file");
}
@@ -215,7 +215,7 @@
gedit_debug_message (DEBUG_LOADER, "mmap failed");
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -237,7 +237,7 @@
gedit_debug_message (DEBUG_LOADER, "SIGBUS during mmap");
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_FAILED,
"I/O error");
@@ -245,7 +245,7 @@
if (ret != 0)
g_warning ("File '%s' has not been correctly unmapped: %s",
GEDIT_DOCUMENT_LOADER (mloader)->uri,
- strerror (errno));
+ g_strerror (errno));
goto done;
}
@@ -262,7 +262,7 @@
if (ret != 0)
g_warning ("File '%s' has not been correctly unmapped: %s",
GEDIT_DOCUMENT_LOADER (mloader)->uri,
- strerror (errno));
+ g_strerror (errno));
goto done;
}
@@ -286,7 +286,7 @@
if (ret != 0)
g_warning ("File '%s' has not been correctly unmapped: %s",
GEDIT_DOCUMENT_LOADER (mloader)->uri,
- strerror (errno));
+ g_strerror (errno));
}
done:
@@ -295,7 +295,7 @@
if (ret != 0)
g_warning ("File '%s' has not been correctly closed: %s",
GEDIT_DOCUMENT_LOADER (mloader)->uri,
- strerror (errno));
+ g_strerror (errno));
mloader->priv->fd = -1;
@@ -331,7 +331,7 @@
if (mloader->priv->fd == -1)
{
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
g_io_error_from_errno (errno),
g_strerror (errno));
@@ -373,7 +373,7 @@
else
{
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_NOT_SUPPORTED,
"Not supported");
}
@@ -417,7 +417,7 @@
GeditMmapDocumentLoader *mloader = GEDIT_MMAP_DOCUMENT_LOADER (loader);
g_set_error (&mloader->priv->error,
- GEDIT_DOCUMENT_ERROR,
+ G_IO_ERROR,
G_IO_ERROR_CANCELLED,
"Cancelled");
Modified: trunk/gedit/gedit-tab.c
==============================================================================
--- trunk/gedit/gedit-tab.c (original)
+++ trunk/gedit/gedit-tab.c Sat Aug 16 16:53:47 2008
@@ -924,46 +924,45 @@
encoding = gedit_document_get_encoding (document);
- if (error->domain == GEDIT_DOCUMENT_ERROR)
+ if (error->domain == G_IO_ERROR &&
+ error->code == G_IO_ERROR_CANCELLED)
{
- if (error->code == G_IO_ERROR_CANCELLED)
- {
- /* remove the tab, but in an idle handler, since
- * we are in the handler of doc loaded and we
- * don't want doc and tab to be finalized now.
- */
- g_idle_add ((GSourceFunc) remove_tab_idle, tab);
+ /* remove the tab, but in an idle handler, since
+ * we are in the handler of doc loaded and we
+ * don't want doc and tab to be finalized now.
+ */
+ g_idle_add ((GSourceFunc) remove_tab_idle, tab);
+
+ goto end;
+ }
+ else if (error->domain == G_IO_ERROR ||
+ error->domain == GEDIT_DOCUMENT_ERROR)
+ {
+ _gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), uri);
- goto end;
+ if (tab->priv->state == GEDIT_TAB_STATE_LOADING_ERROR)
+ {
+ emsg = gedit_io_loading_error_message_area_new (uri,
+ error);
+ g_signal_connect (emsg,
+ "response",
+ G_CALLBACK (io_loading_error_message_area_response),
+ tab);
}
else
{
- _gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), uri);
-
- if (tab->priv->state == GEDIT_TAB_STATE_LOADING_ERROR)
- {
- emsg = gedit_io_loading_error_message_area_new (uri,
- error);
- g_signal_connect (emsg,
- "response",
- G_CALLBACK (io_loading_error_message_area_response),
- tab);
- }
- else
- {
- g_return_if_fail (tab->priv->state == GEDIT_TAB_STATE_REVERTING_ERROR);
-
- emsg = gedit_unrecoverable_reverting_error_message_area_new (uri,
- error);
-
- g_signal_connect (emsg,
- "response",
- G_CALLBACK (unrecoverable_reverting_error_message_area_response),
- tab);
- }
+ g_return_if_fail (tab->priv->state == GEDIT_TAB_STATE_REVERTING_ERROR);
+
+ emsg = gedit_unrecoverable_reverting_error_message_area_new (uri,
+ error);
- set_message_area (tab, emsg);
+ g_signal_connect (emsg,
+ "response",
+ G_CALLBACK (unrecoverable_reverting_error_message_area_response),
+ tab);
}
+
+ set_message_area (tab, emsg);
}
else
{
@@ -1293,55 +1292,55 @@
{
gedit_tab_set_state (tab, GEDIT_TAB_STATE_SAVING_ERROR);
- if (error->domain == GEDIT_DOCUMENT_ERROR)
+ if (error->domain == GEDIT_DOCUMENT_ERROR &&
+ error->code == GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED)
{
- if (error->code == GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED)
- {
- /* This error is recoverable */
- emsg = gedit_externally_modified_saving_error_message_area_new (
- tab->priv->tmp_save_uri,
- error);
- g_return_if_fail (emsg != NULL);
+ /* This error is recoverable */
+ emsg = gedit_externally_modified_saving_error_message_area_new (
+ tab->priv->tmp_save_uri,
+ error);
+ g_return_if_fail (emsg != NULL);
- set_message_area (tab, emsg);
+ set_message_area (tab, emsg);
- g_signal_connect (emsg,
- "response",
- G_CALLBACK (externally_modified_error_message_area_response),
- tab);
- }
- else if (error->code == GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP)
- {
- /* This error is recoverable */
- emsg = gedit_no_backup_saving_error_message_area_new (
- tab->priv->tmp_save_uri,
- error);
- g_return_if_fail (emsg != NULL);
+ g_signal_connect (emsg,
+ "response",
+ G_CALLBACK (externally_modified_error_message_area_response),
+ tab);
+ }
+ else if (error->domain == GEDIT_DOCUMENT_ERROR &&
+ error->code == GEDIT_DOCUMENT_ERROR_CANT_CREATE_BACKUP)
+ {
+ /* This error is recoverable */
+ emsg = gedit_no_backup_saving_error_message_area_new (
+ tab->priv->tmp_save_uri,
+ error);
+ g_return_if_fail (emsg != NULL);
- set_message_area (tab, emsg);
+ set_message_area (tab, emsg);
- g_signal_connect (emsg,
- "response",
- G_CALLBACK (no_backup_error_message_area_response),
- tab);
- }
- else
- {
- /* These errors are _NOT_ recoverable */
- _gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))),
- tab->priv->tmp_save_uri);
-
- emsg = gedit_unrecoverable_saving_error_message_area_new (tab->priv->tmp_save_uri,
- error);
- g_return_if_fail (emsg != NULL);
-
- set_message_area (tab, emsg);
+ g_signal_connect (emsg,
+ "response",
+ G_CALLBACK (no_backup_error_message_area_response),
+ tab);
+ }
+ else if (error->domain == GEDIT_DOCUMENT_ERROR ||
+ error->domain == G_IO_ERROR)
+ {
+ /* These errors are _NOT_ recoverable */
+ _gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))),
+ tab->priv->tmp_save_uri);
+
+ emsg = gedit_unrecoverable_saving_error_message_area_new (tab->priv->tmp_save_uri,
+ error);
+ g_return_if_fail (emsg != NULL);
+
+ set_message_area (tab, emsg);
- g_signal_connect (emsg,
- "response",
- G_CALLBACK (unrecoverable_saving_error_message_area_response),
- tab);
- }
+ g_signal_connect (emsg,
+ "response",
+ G_CALLBACK (unrecoverable_saving_error_message_area_response),
+ tab);
}
else
{
@@ -1365,7 +1364,6 @@
GTK_RESPONSE_CANCEL);
gtk_widget_show (emsg);
-
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]