xed-io-error-message-area: Clean up code styling

This commit is contained in:
JosephMcc 2016-12-12 03:43:54 -08:00
parent e9834c0883
commit a5c62d2380
1 changed files with 837 additions and 936 deletions

View File

@ -57,7 +57,8 @@ is_recoverable_error (const GError *error)
if (error->domain == G_IO_ERROR)
{
switch (error->code) {
switch (error->code)
{
case G_IO_ERROR_PERMISSION_DENIED:
case G_IO_ERROR_NOT_FOUND:
case G_IO_ERROR_HOST_NOT_FOUND:
@ -139,8 +140,7 @@ set_message_area_text_and_icon (GtkWidget *message_area,
if (secondary_text != NULL)
{
secondary_markup = g_strdup_printf ("<small>%s</small>",
secondary_text);
secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text);
secondary_label = gtk_label_new (secondary_markup);
g_free (secondary_markup);
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
@ -162,23 +162,15 @@ create_io_loading_error_message_area (const gchar *primary_text,
{
GtkWidget *message_area;
message_area = gtk_info_bar_new_with_buttons (
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR);
message_area = gtk_info_bar_new_with_buttons (GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_ERROR);
set_message_area_text_and_icon (message_area,
"gtk-dialog-error",
primary_text,
secondary_text);
set_message_area_text_and_icon (message_area, "gtk-dialog-error", primary_text, secondary_text);
if (recoverable_error)
{
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Retry"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("_Retry"),
GTK_STOCK_REFRESH, GTK_RESPONSE_OK);
}
return message_area;
@ -197,8 +189,7 @@ parse_gio_error (gint code,
{
case G_IO_ERROR_NOT_FOUND:
case G_IO_ERROR_NOT_DIRECTORY:
*error_message = g_strdup_printf (_("Could not find the file %s."),
uri_for_display);
*error_message = g_strdup_printf (_("Could not find the file %s."), uri_for_display);
*message_details = g_strdup (_("Please check that you typed the "
"location correctly and try again."));
break;
@ -214,8 +205,7 @@ parse_gio_error (gint code,
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 (_("xed cannot handle %s locations."),
scheme_markup);
*message_details = g_strdup_printf (_("xed cannot handle %s locations."), scheme_markup);
g_free (scheme_markup);
}
else
@ -226,29 +216,22 @@ parse_gio_error (gint code,
g_free (scheme_string);
}
break;
case G_IO_ERROR_NOT_MOUNTABLE_FILE:
*message_details = g_strdup (_("The location of the file cannot be mounted."));
break;
case G_IO_ERROR_NOT_MOUNTED:
*message_details = g_strdup( _("The location of the file cannot be accessed because it is not mounted."));
break;
case G_IO_ERROR_IS_DIRECTORY:
*error_message = g_strdup_printf (_("%s is a directory."),
uri_for_display);
*error_message = g_strdup_printf (_("%s is a directory."), uri_for_display);
*message_details = g_strdup (_("Please check that you typed the "
"location correctly and try again."));
break;
case G_IO_ERROR_INVALID_FILENAME:
*error_message = g_strdup_printf (_("%s is not a valid location."),
uri_for_display);
*error_message = g_strdup_printf (_("%s is not a valid location."), uri_for_display);
*message_details = g_strdup (_("Please check that you typed the "
"location correctly and try again."));
break;
case G_IO_ERROR_HOST_NOT_FOUND:
/* This case can be hit for user-typed strings like "foo" due to
* the code that guesses web addresses when there's no initial "/".
@ -272,8 +255,7 @@ parse_gio_error (gint code,
g_free (host_name);
/* Translators: %s is a host name */
*message_details = g_strdup_printf (
_("Host %s could not be found. "
*message_details = g_strdup_printf (_("Host %s could not be found. "
"Please check that your proxy settings "
"are correct and try again."),
host_markup);
@ -285,23 +267,18 @@ parse_gio_error (gint code,
if (!*message_details)
{
/* use the same string as INVALID_HOST */
*message_details = g_strdup_printf (
_("Hostname was invalid. "
*message_details = g_strdup_printf (_("Hostname was invalid. "
"Please check that you typed the location "
"correctly and try again."));
}
}
break;
case G_IO_ERROR_NOT_REGULAR_FILE:
*message_details = g_strdup_printf (_("%s is not a regular file."),
uri_for_display);
*message_details = g_strdup_printf (_("%s is not a regular file."), uri_for_display);
break;
case G_IO_ERROR_TIMED_OUT:
*message_details = g_strdup (_("Connection timed out. Please try again."));
break;
default:
ret = FALSE;
break;
@ -324,7 +301,6 @@ parse_xed_error (gint code,
case XED_DOCUMENT_ERROR_TOO_BIG:
*message_details = g_strdup (_("The file is too big."));
break;
default:
ret = FALSE;
break;
@ -344,27 +320,17 @@ parse_error (const GError *error,
if (error->domain == G_IO_ERROR)
{
ret = parse_gio_error (error->code,
error_message,
message_details,
uri,
uri_for_display);
ret = parse_gio_error (error->code, error_message, message_details, uri, uri_for_display);
}
else if (error->domain == XED_DOCUMENT_ERROR)
{
ret = parse_xed_error (error->code,
error_message,
message_details,
uri,
uri_for_display);
ret = parse_xed_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);
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);
}
}
@ -381,8 +347,7 @@ xed_unrecoverable_reverting_error_message_area_new (const gchar *uri,
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail ((error->domain == XED_DOCUMENT_ERROR) ||
(error->domain == G_IO_ERROR), NULL);
g_return_val_if_fail ((error->domain == XED_DOCUMENT_ERROR) || (error->domain == G_IO_ERROR), NULL);
full_formatted_uri = xed_utils_uri_for_display (uri);
@ -390,8 +355,7 @@ xed_unrecoverable_reverting_error_message_area_new (const gchar *uri,
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -409,13 +373,10 @@ xed_unrecoverable_reverting_error_message_area_new (const gchar *uri,
if (error_message == NULL)
{
error_message = g_strdup_printf (_("Could not revert the file %s."),
uri_for_display);
error_message = g_strdup_printf (_("Could not revert the file %s."), uri_for_display);
}
message_area = create_io_loading_error_message_area (error_message,
message_details,
FALSE);
message_area = create_io_loading_error_message_area (error_message, message_details, FALSE);
g_free (uri_for_display);
g_free (error_message);
@ -425,7 +386,8 @@ xed_unrecoverable_reverting_error_message_area_new (const gchar *uri,
}
static void
create_combo_box (GtkWidget *message_area, GtkWidget *vbox)
create_combo_box (GtkWidget *message_area,
GtkWidget *vbox)
{
GtkWidget *hbox;
GtkWidget *label;
@ -434,28 +396,16 @@ create_combo_box (GtkWidget *message_area, GtkWidget *vbox)
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
label_markup = g_strdup_printf ("<small>%s</small>",
_("Ch_aracter Encoding:"));
label_markup = g_strdup_printf ("<small>%s</small>", _("Ch_aracter Encoding:"));
label = gtk_label_new_with_mnemonic (label_markup);
g_free (label_markup);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
menu = xed_encodings_combo_box_new (TRUE);
g_object_set_data (G_OBJECT (message_area),
"xed-message-area-encoding-menu",
menu);
g_object_set_data (G_OBJECT (message_area), "xed-message-area-encoding-menu", menu);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), menu);
gtk_box_pack_start (GTK_BOX (hbox),
label,
FALSE,
FALSE,
0);
gtk_box_pack_start (GTK_BOX (hbox),
menu,
FALSE,
FALSE,
0);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
gtk_widget_show_all (hbox);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
@ -477,10 +427,8 @@ create_conversion_error_message_area (const gchar *primary_text,
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Retry"),
GTK_STOCK_REDO,
GTK_RESPONSE_OK);
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("_Retry"),
GTK_STOCK_REDO, GTK_RESPONSE_OK);
if (edit_anyway)
{
@ -494,16 +442,12 @@ create_conversion_error_message_area (const gchar *primary_text,
different from other main menu access keys (Open, Edit, View...) */
_("D_on't Edit"),
GTK_RESPONSE_NO);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING);
}
else
{
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_ERROR);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_ERROR);
}
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
@ -528,8 +472,7 @@ create_conversion_error_message_area (const gchar *primary_text,
if (secondary_text != NULL)
{
secondary_markup = g_strdup_printf ("<small>%s</small>",
secondary_text);
secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text);
secondary_label = gtk_label_new (secondary_markup);
g_free (secondary_markup);
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
@ -574,17 +517,20 @@ xed_io_loading_error_message_area_new (const gchar *uri,
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
g_free (temp_uri_for_display);
if (encoding != NULL)
{
encoding_name = xed_encoding_to_string (encoding);
}
else
{
encoding_name = g_strdup ("UTF-8");
}
if (is_gio_error (error, G_IO_ERROR_TOO_MANY_LINKS))
{
@ -604,11 +550,9 @@ xed_io_loading_error_message_area_new (const gchar *uri,
_("Select a character encoding from the menu and try again."), NULL);
convert_error = TRUE;
}
else if (error->domain == XED_DOCUMENT_ERROR &&
error->code == XED_DOCUMENT_ERROR_CONVERSION_FALLBACK)
else if (error->domain == XED_DOCUMENT_ERROR && error->code == XED_DOCUMENT_ERROR_CONVERSION_FALLBACK)
{
error_message = g_strdup_printf (_("There was a problem opening the file %s."),
uri_for_display);
error_message = g_strdup_printf (_("There was a problem opening the file %s."), uri_for_display);
message_details = g_strconcat (_("The file you opened has some invalid characters. "
"If you continue editing this file you could make this "
"document useless."), "\n",
@ -633,15 +577,12 @@ xed_io_loading_error_message_area_new (const gchar *uri,
if (error_message == NULL)
{
error_message = g_strdup_printf (_("Could not open the file %s."),
uri_for_display);
error_message = g_strdup_printf (_("Could not open the file %s."), uri_for_display);
}
if (convert_error)
{
message_area = create_conversion_error_message_area (error_message,
message_details,
edit_anyway);
message_area = create_conversion_error_message_area (error_message, message_details, edit_anyway);
}
else
{
@ -659,8 +600,7 @@ xed_io_loading_error_message_area_new (const gchar *uri,
}
GtkWidget *
xed_conversion_error_while_saving_message_area_new (
const gchar *uri,
xed_conversion_error_while_saving_message_area_new (const gchar *uri,
const XedEncoding *encoding,
const GError *error)
{
@ -684,8 +624,7 @@ xed_conversion_error_while_saving_message_area_new (
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -700,10 +639,7 @@ xed_conversion_error_while_saving_message_area_new (
"using the specified character encoding."), "\n",
_("Select a different character encoding from the menu and try again."), NULL);
message_area = create_conversion_error_message_area (
error_message,
message_details,
FALSE);
message_area = create_conversion_error_message_area (error_message, message_details, FALSE);
g_free (uri_for_display);
g_free (encoding_name);
@ -720,12 +656,10 @@ xed_conversion_error_message_area_get_encoding (GtkWidget *message_area)
g_return_val_if_fail (GTK_IS_INFO_BAR (message_area), NULL);
menu = g_object_get_data (G_OBJECT (message_area),
"xed-message-area-encoding-menu");
menu = g_object_get_data (G_OBJECT (message_area), "xed-message-area-encoding-menu");
g_return_val_if_fail (menu, NULL);
return xed_encodings_combo_box_get_selected_encoding
(XED_ENCODINGS_COMBO_BOX (menu));
return xed_encodings_combo_box_get_selected_encoding (XED_ENCODINGS_COMBO_BOX (menu));
}
GtkWidget *
@ -751,8 +685,7 @@ xed_file_already_open_warning_message_area_new (const gchar *uri)
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -769,8 +702,7 @@ xed_file_already_open_warning_message_area_new (const gchar *uri)
different from other main menu access keys (Open, Edit, View...) */
_("D_on't Edit"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING);
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
@ -798,8 +730,7 @@ xed_file_already_open_warning_message_area_new (const gchar *uri)
secondary_text = _("xed opened this instance of the file in a non-editable way. "
"Do you want to edit it anyway?");
secondary_markup = g_strdup_printf ("<small>%s</small>",
secondary_text);
secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text);
secondary_label = gtk_label_new (secondary_markup);
g_free (secondary_markup);
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
@ -816,8 +747,7 @@ xed_file_already_open_warning_message_area_new (const gchar *uri)
}
GtkWidget *
xed_externally_modified_saving_error_message_area_new (
const gchar *uri,
xed_externally_modified_saving_error_message_area_new (const gchar *uri,
const GError *error)
{
GtkWidget *message_area;
@ -845,8 +775,7 @@ xed_externally_modified_saving_error_message_area_new (
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -854,15 +783,10 @@ xed_externally_modified_saving_error_message_area_new (
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("S_ave Anyway"),
GTK_STOCK_SAVE, GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING);
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
@ -877,8 +801,7 @@ xed_externally_modified_saving_error_message_area_new (
// FIXME: review this message, it's not clear since for the user the "modification"
// could be interpreted as the changes he made in the document. beside "reading" is
// not accurate (since last load/save)
primary_text = g_strdup_printf (_("The file %s has been modified since reading it."),
uri_for_display);
primary_text = g_strdup_printf (_("The file %s has been modified since reading it."), uri_for_display);
g_free (uri_for_display);
primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
@ -893,8 +816,7 @@ xed_externally_modified_saving_error_message_area_new (
gtk_label_set_selectable (GTK_LABEL (primary_label), TRUE);
secondary_text = _("If you save it, all the external changes could be lost. Save it anyway?");
secondary_markup = g_strdup_printf ("<small>%s</small>",
secondary_text);
secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text);
secondary_label = gtk_label_new (secondary_markup);
g_free (secondary_markup);
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
@ -941,8 +863,7 @@ xed_no_backup_saving_error_message_area_new (const gchar *uri,
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -950,15 +871,10 @@ xed_no_backup_saving_error_message_area_new (const gchar *uri,
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("S_ave Anyway"),
GTK_STOCK_SAVE,
GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
_("D_on't Save"),
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("S_ave Anyway"),
GTK_STOCK_SAVE, GTK_RESPONSE_YES);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area), _("D_on't Save"), GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING);
hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
@ -973,11 +889,13 @@ xed_no_backup_saving_error_message_area_new (const gchar *uri,
// FIXME: review this messages
if (xed_prefs_manager_get_create_backup_copy ())
primary_text = g_strdup_printf (_("Could not create a backup file while saving %s"),
uri_for_display);
{
primary_text = g_strdup_printf (_("Could not create a backup file while saving %s"), uri_for_display);
}
else
primary_text = g_strdup_printf (_("Could not create a temporary backup file while saving %s"),
uri_for_display);
{
primary_text = g_strdup_printf (_("Could not create a temporary backup file while saving %s"), uri_for_display);
}
g_free (uri_for_display);
@ -995,8 +913,7 @@ xed_no_backup_saving_error_message_area_new (const gchar *uri,
secondary_text = _("xed could not back up the old copy of the file before saving the new one. "
"You can ignore this warning and save the file anyway, but if an error "
"occurs while saving, you could lose the old copy of the file. Save anyway?");
secondary_markup = g_strdup_printf ("<small>%s</small>",
secondary_text);
secondary_markup = g_strdup_printf ("<small>%s</small>", secondary_text);
secondary_label = gtk_label_new (secondary_markup);
g_free (secondary_markup);
gtk_box_pack_start (GTK_BOX (vbox), secondary_label, TRUE, TRUE, 0);
@ -1027,8 +944,7 @@ xed_unrecoverable_saving_error_message_area_new (const gchar *uri,
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail ((error->domain == XED_DOCUMENT_ERROR) ||
(error->domain == G_IO_ERROR), NULL);
g_return_val_if_fail ((error->domain == XED_DOCUMENT_ERROR) || (error->domain == G_IO_ERROR), NULL);
full_formatted_uri = xed_utils_uri_for_display (uri);
@ -1036,8 +952,7 @@ xed_unrecoverable_saving_error_message_area_new (const gchar *uri,
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -1101,8 +1016,7 @@ xed_unrecoverable_saving_error_message_area_new (const gchar *uri,
"a limitation on length of the file names. "
"Please use a shorter name."));
}
else if (error->domain == XED_DOCUMENT_ERROR &&
error->code == XED_DOCUMENT_ERROR_TOO_BIG)
else if (error->domain == XED_DOCUMENT_ERROR && error->code == XED_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 "
@ -1111,22 +1025,15 @@ xed_unrecoverable_saving_error_message_area_new (const gchar *uri,
}
else
{
parse_error (error,
&error_message,
&message_details,
uri,
uri_for_display);
parse_error (error, &error_message, &message_details, uri, uri_for_display);
}
if (error_message == NULL)
{
error_message = g_strdup_printf (_("Could not save the file %s."),
uri_for_display);
error_message = g_strdup_printf (_("Could not save the file %s."), uri_for_display);
}
message_area = create_io_loading_error_message_area (error_message,
message_details,
FALSE);
message_area = create_io_loading_error_message_area (error_message, message_details, FALSE);
g_free (uri_for_display);
g_free (error_message);
@ -1154,8 +1061,7 @@ xed_externally_modified_message_area_new (const gchar *uri,
* though the dialog uses wrapped text, if the URI doesn't contain
* white space then the text-wrapping code is too stupid to wrap it.
*/
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri,
MAX_URI_IN_DIALOG_LENGTH);
temp_uri_for_display = xed_utils_str_middle_truncate (full_formatted_uri, MAX_URI_IN_DIALOG_LENGTH);
g_free (full_formatted_uri);
uri_for_display = g_markup_printf_escaped ("<i>%s</i>", temp_uri_for_display);
@ -1164,31 +1070,26 @@ xed_externally_modified_message_area_new (const gchar *uri,
// FIXME: review this message, it's not clear since for the user the "modification"
// could be interpreted as the changes he made in the document. beside "reading" is
// not accurate (since last load/save)
primary_text = g_strdup_printf (_("The file %s changed on disk."),
uri_for_display);
primary_text = g_strdup_printf (_("The file %s changed on disk."), uri_for_display);
g_free (uri_for_display);
if (document_modified)
{
secondary_text = _("Do you want to drop your changes and reload the file?");
}
else
{
secondary_text = _("Do you want to reload the file?");
}
message_area = gtk_info_bar_new ();
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area),
_("_Reload"),
GTK_STOCK_REFRESH,
GTK_RESPONSE_OK);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area),
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area),
GTK_MESSAGE_WARNING);
info_bar_add_stock_button_with_text (GTK_INFO_BAR (message_area), _("_Reload"),
GTK_STOCK_REFRESH, GTK_RESPONSE_OK);
gtk_info_bar_add_button (GTK_INFO_BAR (message_area), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
gtk_info_bar_set_message_type (GTK_INFO_BAR (message_area), GTK_MESSAGE_WARNING);
set_message_area_text_and_icon (message_area,
"gtk-dialog-warning",
primary_text,
secondary_text);
set_message_area_text_and_icon (message_area, "gtk-dialog-warning", primary_text, secondary_text);
return message_area;
}