From 7ca4d22bc30a48b7b22f60fc0fc4174a2b3d33b7 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Mon, 4 Apr 2016 14:32:56 +0200 Subject: [PATCH] file-chooser-widget: Fix "format not a string literal" error https://bugzilla.gnome.org/show_bug.cgi?id=764585 --- gtk/gtkfilechooserwidget.c | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 653c11d58b..90e0addfc7 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -750,20 +750,11 @@ error_message (GtkFileChooserWidget *impl, static void error_dialog (GtkFileChooserWidget *impl, const char *msg, - GFile *file, GError *error) { if (error) { - char *uri = NULL; - char *text; - - if (file) - uri = g_file_get_uri (file); - text = g_strdup_printf (msg, uri); - error_message (impl, text, error->message); - g_free (text); - g_free (uri); + error_message (impl, msg, error->message); g_error_free (error); } } @@ -776,7 +767,7 @@ error_creating_folder_dialog (GtkFileChooserWidget *impl, { error_dialog (impl, _("The folder could not be created"), - file, error); + error); } /* Shows an error about not being able to create a folder because a file with @@ -791,7 +782,7 @@ error_creating_folder_over_existing_file_dialog (GtkFileChooserWidget *impl, _("The folder could not be created, as a file with the same " "name already exists. Try using a different name for the " "folder, or rename the file first."), - file, error); + error); } static void @@ -799,14 +790,17 @@ error_with_file_under_nonfolder (GtkFileChooserWidget *impl, GFile *parent_file) { GError *error; + char *uri, *msg; error = NULL; g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_NOT_DIRECTORY, _("You need to choose a valid filename.")); - error_dialog (impl, - _("Cannot create a file under %s as it is not a folder"), - parent_file, error); + uri = g_file_get_uri (parent_file); + msg = g_strdup_printf (_("Cannot create a file under %s as it is not a folder"), uri); + g_free (uri); + error_dialog (impl, msg, error); + g_free (msg); } static void @@ -833,8 +827,7 @@ static void error_building_filename_dialog (GtkFileChooserWidget *impl, GError *error) { - error_dialog (impl, _("Invalid file name"), - NULL, error); + error_dialog (impl, _("Invalid file name"), error); } /* Shows an error dialog when we cannot switch to a folder */ @@ -843,8 +836,7 @@ error_changing_folder_dialog (GtkFileChooserWidget *impl, GFile *file, GError *error) { - error_dialog (impl, _("The folder contents could not be displayed"), - file, error); + error_dialog (impl, _("The folder contents could not be displayed"), error); } static void @@ -852,7 +844,7 @@ error_deleting_file (GtkFileChooserWidget *impl, GFile *file, GError *error) { - error_dialog (impl, _("The file could not be deleted"), file, error); + error_dialog (impl, _("The file could not be deleted"), error); } static void @@ -860,7 +852,7 @@ error_trashing_file (GtkFileChooserWidget *impl, GFile *file, GError *error) { - error_dialog (impl, _("The file could not be moved to the Trash"), file, error); + error_dialog (impl, _("The file could not be moved to the Trash"), error); } /* Changes folders, displaying an error dialog if this fails */ @@ -1594,7 +1586,7 @@ rename_file_rename_clicked (GtkButton *button, { if (!g_file_move (priv->rename_file_source_file, child, G_FILE_COPY_NONE, NULL, NULL, NULL, &error)) - error_dialog (impl, _("The file could not be renamed"), child, error); + error_dialog (impl, _("The file could not be renamed"), error); g_object_unref (child); } @@ -1907,7 +1899,7 @@ error_selecting_dragged_file_dialog (GtkFileChooserWidget *impl, { error_dialog (impl, _("Could not select file"), - file, error); + error); } static void