Commit 04a6e01c authored by Bruno Boaventura's avatar Bruno Boaventura Committed by Paolo Borelli

create is_recoverable_error, rename unrecoverable_error to

2006-12-12  Bruno Boaventura <brunoboaventura@gmail.com>

	* gedit/gedit-io-error-message-area.[ch]: create
	is_recoverable_error, rename unrecoverable_error to
	io_loading_error.
	* gedit/gedit-tab.c: rename recoverable_loading_error to
	conversion_loading_error. Add a "Retry" button to the message
	area when the error is recoverable. Fixes #372653.
parent 76e4ad71
2006-12-12 Bruno Boaventura <brunoboaventura@gmail.com>
* gedit/gedit-io-error-message-area.[ch]: create
is_recoverable_error, rename unrecoverable_error to
io_loading_error.
* gedit/gedit-tab.c: rename recoverable_loading_error to
conversion_loading_error. Add a "Retry" button to the message
area when the error is recoverable. Fixes #372653.
2006-12-10 Paolo Borelli <pborelli@katamail.com> 2006-12-10 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-module.c: fail gradefully if * gedit/gedit-module.c: fail gradefully if
......
...@@ -52,9 +52,31 @@ ...@@ -52,9 +52,31 @@
#define MAX_URI_IN_DIALOG_LENGTH 50 #define MAX_URI_IN_DIALOG_LENGTH 50
static gboolean
is_recoverable_error (const GError *error)
{
gboolean is_recoverable = FALSE;
if (error->domain == GEDIT_DOCUMENT_ERROR)
{
switch (error->code) {
case GNOME_VFS_ERROR_ACCESS_DENIED:
case GNOME_VFS_ERROR_TOO_MANY_OPEN_FILES:
case GNOME_VFS_ERROR_NO_MEMORY:
case GNOME_VFS_ERROR_HOST_NOT_FOUND:
case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS:
case GNOME_VFS_ERROR_LOGIN_FAILED:
is_recoverable = TRUE;
}
}
return is_recoverable;
}
static GtkWidget * static GtkWidget *
create_unrecoverable_error_message_area (const gchar *primary_text, create_io_loading_error_message_area (const gchar *primary_text,
const gchar *secondary_text) const gchar *secondary_text)
{ {
GtkWidget *message_area; GtkWidget *message_area;
GtkWidget *hbox_content; GtkWidget *hbox_content;
...@@ -113,8 +135,8 @@ create_unrecoverable_error_message_area (const gchar *primary_text, ...@@ -113,8 +135,8 @@ create_unrecoverable_error_message_area (const gchar *primary_text,
} }
GtkWidget * GtkWidget *
gedit_unrecoverable_loading_error_message_area_new (const gchar *uri, gedit_io_loading_error_message_area_new (const gchar *uri,
const GError *error) const GError *error)
{ {
gchar *error_message = NULL; gchar *error_message = NULL;
gchar *message_details = NULL; gchar *message_details = NULL;
...@@ -331,8 +353,16 @@ gedit_unrecoverable_loading_error_message_area_new (const gchar *uri, ...@@ -331,8 +353,16 @@ gedit_unrecoverable_loading_error_message_area_new (const gchar *uri,
error_message = g_strdup_printf (_("Could not open the file %s."), error_message = g_strdup_printf (_("Could not open the file %s."),
uri_for_display); uri_for_display);
message_area = create_unrecoverable_error_message_area (error_message, message_area = create_io_loading_error_message_area (error_message,
message_details); message_details);
if (is_recoverable_error (error))
{
gedit_message_area_add_stock_button_with_text (GEDIT_MESSAGE_AREA (message_area),
_("_Retry"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
}
g_free (uri_for_display); g_free (uri_for_display);
g_free (error_message); g_free (error_message);
...@@ -552,8 +582,8 @@ gedit_unrecoverable_reverting_error_message_area_new (const gchar *uri, ...@@ -552,8 +582,8 @@ gedit_unrecoverable_reverting_error_message_area_new (const gchar *uri,
error_message = g_strdup_printf (_("Could not revert the file %s."), error_message = g_strdup_printf (_("Could not revert the file %s."),
uri_for_display); uri_for_display);
message_area = create_unrecoverable_error_message_area (error_message, message_area = create_io_loading_error_message_area (error_message,
message_details); message_details);
g_free (uri_for_display); g_free (uri_for_display);
g_free (error_message); g_free (error_message);
...@@ -1318,8 +1348,8 @@ gedit_unrecoverable_saving_error_message_area_new (const gchar *uri, ...@@ -1318,8 +1348,8 @@ gedit_unrecoverable_saving_error_message_area_new (const gchar *uri,
error_message = g_strdup_printf (_("Could not save the file %s."), error_message = g_strdup_printf (_("Could not save the file %s."),
uri_for_display); uri_for_display);
message_area = create_unrecoverable_error_message_area (error_message, message_area = create_io_loading_error_message_area (error_message,
message_details); message_details);
g_free (uri_for_display); g_free (uri_for_display);
g_free (error_message); g_free (error_message);
......
...@@ -35,42 +35,33 @@ ...@@ -35,42 +35,33 @@
G_BEGIN_DECLS G_BEGIN_DECLS
GtkWidget *gedit_unrecoverable_loading_error_message_area_new ( GtkWidget *gedit_io_loading_error_message_area_new (const gchar *uri,
const gchar *uri, const GError *error);
const GError *error);
GtkWidget *gedit_unrecoverable_reverting_error_message_area_new ( GtkWidget *gedit_unrecoverable_reverting_error_message_area_new (const gchar *uri,
const gchar *uri, const GError *error);
const GError *error);
GtkWidget *gedit_conversion_error_while_loading_message_area_new ( GtkWidget *gedit_conversion_error_while_loading_message_area_new (const gchar *uri,
const gchar *uri, const GeditEncoding *encoding,
const GeditEncoding *encoding, const GError *error);
const GError *error);
GtkWidget *gedit_conversion_error_while_saving_message_area_new ( GtkWidget *gedit_conversion_error_while_saving_message_area_new (const gchar *uri,
const gchar *uri, const GeditEncoding *encoding,
const GeditEncoding *encoding, const GError *error);
const GError *error);
const GeditEncoding const GeditEncoding
*gedit_conversion_error_message_area_get_encoding ( *gedit_conversion_error_message_area_get_encoding (GtkWidget *message_area);
GtkWidget *message_area);
GtkWidget *gedit_file_already_open_warning_message_area_new ( GtkWidget *gedit_file_already_open_warning_message_area_new (const gchar *uri);
const gchar *uri);
GtkWidget *gedit_externally_modified_saving_error_message_area_new ( GtkWidget *gedit_externally_modified_saving_error_message_area_new (const gchar *uri,
const gchar *uri, const GError *error);
const GError *error);
GtkWidget *gedit_no_backup_saving_error_message_area_new ( GtkWidget *gedit_no_backup_saving_error_message_area_new (const gchar *uri,
const gchar *uri, const GError *error);
const GError *error);
GtkWidget *gedit_unrecoverable_saving_error_message_area_new ( GtkWidget *gedit_unrecoverable_saving_error_message_area_new (const gchar *uri,
const gchar *uri, const GError *error);
const GError *error);
G_END_DECLS G_END_DECLS
......
...@@ -461,17 +461,42 @@ remove_tab (GeditTab *tab) ...@@ -461,17 +461,42 @@ remove_tab (GeditTab *tab)
} }
static void static void
unrecoverable_loading_error_message_area_response (GeditMessageArea *message_area, io_loading_error_message_area_response (GeditMessageArea *message_area,
gint response_id, gint response_id,
GeditTab *tab) GeditTab *tab)
{ {
remove_tab (tab); if (response_id == GTK_RESPONSE_OK)
{
GeditDocument *doc;
gchar *uri;
doc = gedit_tab_get_document (tab);
g_return_if_fail (GEDIT_IS_DOCUMENT (doc));
uri = gedit_document_get_uri (doc);
g_return_if_fail (uri != NULL);
set_message_area (tab, NULL);
gedit_tab_set_state (tab, GEDIT_TAB_STATE_LOADING);
g_return_if_fail (tab->priv->auto_save_timeout <= 0);
gedit_document_load (doc,
uri,
tab->priv->tmp_encoding,
tab->priv->tmp_line_pos,
FALSE);
}
else
{
remove_tab (tab);
}
} }
static void static void
recoverable_loading_error_message_area_response (GeditMessageArea *message_area, conversion_loading_error_message_area_response (GeditMessageArea *message_area,
gint response_id, gint response_id,
GeditTab *tab) GeditTab *tab)
{ {
GeditDocument *doc; GeditDocument *doc;
gchar *uri; gchar *uri;
...@@ -485,17 +510,17 @@ recoverable_loading_error_message_area_response (GeditMessageArea *message_area, ...@@ -485,17 +510,17 @@ recoverable_loading_error_message_area_response (GeditMessageArea *message_area,
if (response_id == GTK_RESPONSE_OK) if (response_id == GTK_RESPONSE_OK)
{ {
const GeditEncoding *encoding; const GeditEncoding *encoding;
encoding = gedit_conversion_error_message_area_get_encoding ( encoding = gedit_conversion_error_message_area_get_encoding (
GTK_WIDGET (message_area)); GTK_WIDGET (message_area));
g_return_if_fail (encoding != NULL); g_return_if_fail (encoding != NULL);
set_message_area (tab, NULL); set_message_area (tab, NULL);
gedit_tab_set_state (tab, GEDIT_TAB_STATE_LOADING); gedit_tab_set_state (tab, GEDIT_TAB_STATE_LOADING);
tab->priv->tmp_encoding = encoding; tab->priv->tmp_encoding = encoding;
g_return_if_fail (tab->priv->auto_save_timeout <= 0); g_return_if_fail (tab->priv->auto_save_timeout <= 0);
gedit_document_load (doc, gedit_document_load (doc,
...@@ -508,9 +533,7 @@ recoverable_loading_error_message_area_response (GeditMessageArea *message_area, ...@@ -508,9 +533,7 @@ recoverable_loading_error_message_area_response (GeditMessageArea *message_area,
{ {
_gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), uri); _gedit_recent_remove (GEDIT_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tab))), uri);
unrecoverable_loading_error_message_area_response (message_area, remove_tab (tab);
response_id,
tab);
} }
g_free (uri); g_free (uri);
...@@ -924,11 +947,11 @@ document_loaded (GeditDocument *document, ...@@ -924,11 +947,11 @@ document_loaded (GeditDocument *document,
if (tab->priv->state == GEDIT_TAB_STATE_LOADING_ERROR) if (tab->priv->state == GEDIT_TAB_STATE_LOADING_ERROR)
{ {
emsg = gedit_unrecoverable_loading_error_message_area_new (uri, emsg = gedit_io_loading_error_message_area_new (uri,
error); error);
g_signal_connect (emsg, g_signal_connect (emsg,
"response", "response",
G_CALLBACK (unrecoverable_loading_error_message_area_response), G_CALLBACK (io_loading_error_message_area_response),
tab); tab);
} }
else else
...@@ -963,7 +986,7 @@ document_loaded (GeditDocument *document, ...@@ -963,7 +986,7 @@ document_loaded (GeditDocument *document,
g_signal_connect (emsg, g_signal_connect (emsg,
"response", "response",
G_CALLBACK (recoverable_loading_error_message_area_response), G_CALLBACK (conversion_loading_error_message_area_response),
tab); tab);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment