[nautilus] Change show_error_dialog() to show_dialog()



commit 2ab5c897e4a52dc7d02e72740a84808e2a317734
Author: George Mocanu <mocanu geo98 gmail com>
Date:   Mon Apr 2 14:25:06 2018 +0300

    Change show_error_dialog() to show_dialog()
    
    Changed show_error_dialog() to show_dialog() so that multiple dialog
    types can be used.

 src/nautilus-application.c              |  2 +-
 src/nautilus-error-reporting.c          | 16 +++++++++++-----
 src/nautilus-file-operations.c          | 14 ++++++++------
 src/nautilus-files-view.c               | 31 ++++++++++++++++++++-----------
 src/nautilus-mime-actions.c             | 23 ++++++++++++++++-------
 src/nautilus-mime-application-chooser.c | 21 ++++++++++++---------
 src/nautilus-program-choosing.c         | 29 ++++++++++++++++-------------
 src/nautilus-properties-window.c        | 28 ++++++++++++++++------------
 src/nautilus-ui-utilities.c             |  9 +++++----
 src/nautilus-ui-utilities.h             |  5 +++--
 src/nautilus-window-slot.c              |  2 +-
 src/nautilus-window.c                   |  2 +-
 12 files changed, 110 insertions(+), 72 deletions(-)
---
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 21c3ac697..f38340e24 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -192,7 +192,7 @@ check_required_directories (NautilusApplication *self)
                                              directories_as_string->str);
         }
 
-        dialog = show_error_dialog (error_string, detail_string, NULL);
+        dialog = show_dialog (error_string, detail_string, NULL, GTK_MESSAGE_ERROR);
         /* We need the main event loop so the user has a chance to see the dialog. */
         gtk_application_add_window (GTK_APPLICATION (self),
                                     GTK_WINDOW (dialog));
diff --git a/src/nautilus-error-reporting.c b/src/nautilus-error-reporting.c
index 547edb904..5ef9e6cb2 100644
--- a/src/nautilus-error-reporting.c
+++ b/src/nautilus-error-reporting.c
@@ -112,7 +112,10 @@ nautilus_report_error_loading_directory (NautilusFile *file,
         message = g_strdup (error->message);
     }
 
-    show_error_dialog (_("This location could not be displayed."), message, parent_window);
+    show_dialog (_("This location could not be displayed."),
+                 message,
+                 parent_window,
+                 GTK_MESSAGE_ERROR);
 }
 
 void
@@ -164,7 +167,7 @@ nautilus_report_error_setting_group (NautilusFile *file,
     }
 
 
-    show_error_dialog (_("The group could not be changed."), message, parent_window);
+    show_dialog (_("The group could not be changed."), message, parent_window, GTK_MESSAGE_ERROR);
 }
 
 void
@@ -188,7 +191,7 @@ nautilus_report_error_setting_owner (NautilusFile *file,
     message = g_strdup_printf (_("Sorry, could not change the owner of “%s”: %s"),
                                truncated_name, truncated_error_message);
 
-    show_error_dialog (_("The owner could not be changed."), message, parent_window);
+    show_dialog (_("The owner could not be changed."), message, parent_window, GTK_MESSAGE_ERROR);
 }
 
 void
@@ -212,7 +215,10 @@ nautilus_report_error_setting_permissions (NautilusFile *file,
     message = g_strdup_printf (_("Sorry, could not change the permissions of “%s”: %s"),
                                truncated_name, truncated_error_message);
 
-    show_error_dialog (_("The permissions could not be changed."), message, parent_window);
+    show_dialog (_("The permissions could not be changed."),
+                 message,
+                 parent_window,
+                 GTK_MESSAGE_ERROR);
 }
 
 typedef struct _NautilusRenameData
@@ -313,7 +319,7 @@ nautilus_report_error_renaming_file (NautilusFile *file,
                                    truncated_error_message);
     }
 
-    show_error_dialog (_("The item could not be renamed."), message, parent_window);
+    show_dialog (_("The item could not be renamed."), message, parent_window, GTK_MESSAGE_ERROR);
 }
 
 static void
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index eb620f051..55bc3abae 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -2604,9 +2604,10 @@ unmount_mount_callback (GObject      *source_object,
                 primary = g_strdup_printf (_("Unable to unmount %s"),
                                            mount_name);
             }
-            show_error_dialog (primary,
-                               error->message,
-                               data->parent_window);
+            show_dialog (primary,
+                         error->message,
+                         data->parent_window,
+                         GTK_MESSAGE_ERROR);
             g_free (primary);
         }
     }
@@ -2929,9 +2930,10 @@ volume_mount_cb (GObject      *source_object,
             primary = g_strdup_printf (_("Unable to access “%s”"), name);
             g_free (name);
             success = FALSE;
-            show_error_dialog (primary,
-                               error->message,
-                               parent);
+            show_dialog (primary,
+                         error->message,
+                         parent,
+                         GTK_MESSAGE_ERROR);
             g_free (primary);
         }
         g_error_free (error);
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index a1cd2c9cd..d798b348d 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -6551,8 +6551,10 @@ file_mount_callback (NautilusFile *file,
         name = nautilus_file_get_display_name (file);
         /* Translators: %s is a file name formatted for display */
         text = g_strdup_printf (_("Unable to access “%s”"), name);
-        show_error_dialog (text, error->message,
-                           GTK_WINDOW (nautilus_files_view_get_window (view)));
+        show_dialog (text,
+                     error->message,
+                     GTK_WINDOW (nautilus_files_view_get_window (view)),
+                     GTK_MESSAGE_ERROR);
         g_free (text);
         g_free (name);
     }
@@ -6579,8 +6581,10 @@ file_unmount_callback (NautilusFile *file,
         name = nautilus_file_get_display_name (file);
         /* Translators: %s is a file name formatted for display */
         text = g_strdup_printf (_("Unable to remove “%s”"), name);
-        show_error_dialog (text, error->message,
-                           GTK_WINDOW (nautilus_files_view_get_window (view)));
+        show_dialog (text,
+                     error->message,
+                     GTK_WINDOW (nautilus_files_view_get_window (view)),
+                     GTK_MESSAGE_ERROR);
         g_free (text);
         g_free (name);
     }
@@ -6607,8 +6611,10 @@ file_eject_callback (NautilusFile *file,
         name = nautilus_file_get_display_name (file);
         /* Translators: %s is a file name formatted for display */
         text = g_strdup_printf (_("Unable to eject “%s”"), name);
-        show_error_dialog (text, error->message,
-                           GTK_WINDOW (nautilus_files_view_get_window (view)));
+        show_dialog (text,
+                     error->message,
+                     GTK_WINDOW (nautilus_files_view_get_window (view)),
+                     GTK_MESSAGE_ERROR);
         g_free (text);
         g_free (name);
     }
@@ -6629,9 +6635,10 @@ file_stop_callback (NautilusFile *file,
          (error->code != G_IO_ERROR_CANCELLED &&
           error->code != G_IO_ERROR_FAILED_HANDLED)))
     {
-        show_error_dialog (_("Unable to stop drive"),
-                           error->message,
-                           GTK_WINDOW (nautilus_files_view_get_window (view)));
+        show_dialog (_("Unable to stop drive"),
+                     error->message,
+                     GTK_WINDOW (nautilus_files_view_get_window (view)),
+                     GTK_MESSAGE_ERROR);
     }
 }
 
@@ -6742,8 +6749,10 @@ file_start_callback (NautilusFile *file,
         name = nautilus_file_get_display_name (file);
         /* Translators: %s is a file name formatted for display */
         text = g_strdup_printf (_("Unable to start “%s”"), name);
-        show_error_dialog (text, error->message,
-                           GTK_WINDOW (nautilus_files_view_get_window (view)));
+        show_dialog (text,
+                     error->message,
+                     GTK_WINDOW (nautilus_files_view_get_window (view)),
+                     GTK_MESSAGE_ERROR);
         g_free (text);
         g_free (name);
     }
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index c59a4f7af..4386921ee 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -1184,8 +1184,10 @@ search_for_application_dbus_call_notify_cb (GDBusProxy   *proxy,
             message = g_strdup_printf ("%s\n%s",
                                        _("There was an internal error trying to search for applications:"),
                                        error->message);
-            show_error_dialog (_("Unable to search for application"), message,
-                               parameters_install->parent_window);
+            show_dialog (_("Unable to search for application"),
+                         message,
+                         parameters_install->parent_window,
+                         GTK_MESSAGE_ERROR);
             g_free (message);
         }
         else
@@ -1901,7 +1903,10 @@ activation_mount_not_mounted_callback (GObject      *source_object,
              error->code != G_IO_ERROR_FAILED_HANDLED &&
              error->code != G_IO_ERROR_ALREADY_MOUNTED))
         {
-            show_error_dialog (_("Unable to access location"), error->message, parameters->parent_window);
+            show_dialog (_("Unable to access location"),
+                         error->message,
+                         parameters->parent_window,
+                         GTK_MESSAGE_ERROR);
         }
 
         if (error->domain != G_IO_ERROR ||
@@ -2196,8 +2201,10 @@ activation_mountable_mounted (NautilusFile *file,
              error->code != G_IO_ERROR_FAILED_HANDLED &&
              error->code != G_IO_ERROR_ALREADY_MOUNTED))
         {
-            show_error_dialog (_("Unable to access location"),
-                               error->message, parameters->parent_window);
+            show_dialog (_("Unable to access location"),
+                         error->message,
+                         parameters->parent_window,
+                         GTK_MESSAGE_ERROR);
         }
 
         if (error->code == G_IO_ERROR_CANCELLED)
@@ -2285,8 +2292,10 @@ activation_mountable_started (NautilusFile *file,
             (error->code != G_IO_ERROR_CANCELLED &&
              error->code != G_IO_ERROR_FAILED_HANDLED))
         {
-            show_error_dialog (_("Unable to start location"),
-                               error->message, NULL);
+            show_dialog (_("Unable to start location"),
+                         error->message,
+                         NULL,
+                         GTK_MESSAGE_ERROR);
         }
 
         if (error->code == G_IO_ERROR_CANCELLED)
diff --git a/src/nautilus-mime-application-chooser.c b/src/nautilus-mime-application-chooser.c
index 43399e0c3..a09bf322e 100644
--- a/src/nautilus-mime-application-chooser.c
+++ b/src/nautilus-mime-application-chooser.c
@@ -84,9 +84,10 @@ add_clicked_cb (GtkButton *button,
     {
         message = g_strdup_printf (_("Error while adding “%s”: %s"),
                                    g_app_info_get_display_name (info), error->message);
-        show_error_dialog (_("Could not add application"),
-                           message,
-                           GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
+        show_dialog (_("Could not add application"),
+                     message,
+                     GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))),
+                     GTK_MESSAGE_ERROR);
         g_error_free (error);
         g_free (message);
     }
@@ -116,9 +117,10 @@ remove_clicked_cb (GtkMenuItem *item,
                                               chooser->content_type,
                                               &error))
         {
-            show_error_dialog (_("Could not forget association"),
-                               error->message,
-                               GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
+            show_dialog (_("Could not forget association"),
+                         error->message,
+                         GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))),
+                         GTK_MESSAGE_ERROR);
             g_error_free (error);
         }
 
@@ -181,9 +183,10 @@ set_as_default_clicked_cb (GtkButton *button,
     {
         message = g_strdup_printf (_("Error while setting “%s” as default application: %s"),
                                    g_app_info_get_display_name (info), error->message);
-        show_error_dialog (_("Could not set as default"),
-                           message,
-                           GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))));
+        show_dialog (_("Could not set as default"),
+                     message,
+                     GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (chooser))),
+                     GTK_MESSAGE_ERROR);
     }
 
     g_object_unref (info);
diff --git a/src/nautilus-program-choosing.c b/src/nautilus-program-choosing.c
index 9954ec65e..e283b947a 100644
--- a/src/nautilus-program-choosing.c
+++ b/src/nautilus-program-choosing.c
@@ -336,9 +336,10 @@ nautilus_launch_desktop_file (GdkScreen   *screen,
     {
         g_free (desktop_file_path);
         g_object_unref (desktop_file);
-        show_error_dialog(_("Sorry, but you cannot execute commands from a remote site."),
-                          _("This is disabled due to security considerations."),
-                          parent_window);
+        show_dialog (_("Sorry, but you cannot execute commands from a remote site."),
+                     _("This is disabled due to security considerations."),
+                     parent_window,
+                     GTK_MESSAGE_ERROR);
 
         return;
     }
@@ -348,9 +349,10 @@ nautilus_launch_desktop_file (GdkScreen   *screen,
     g_free (desktop_file_path);
     if (app_info == NULL)
     {
-        show_error_dialog(_("There was an error launching the application."),
-                          NULL,
-                          parent_window);
+        show_dialog (_("There was an error launching the application."),
+                     NULL,
+                     parent_window,
+                     GTK_MESSAGE_ERROR);
         return;
     }
 
@@ -376,10 +378,10 @@ nautilus_launch_desktop_file (GdkScreen   *screen,
         if (count == 0)
         {
             /* all files are non-local */
-            show_error_dialog(_("This drop target only supports local files."),
-                              _("To open non-local files copy them to a local folder and then"
-                              " drop them again."),
-                              parent_window);
+            show_dialog (_("This drop target only supports local files."),
+                         _("To open non-local files copy them to a local folder and then drop them again."),
+                         parent_window,
+                         GTK_MESSAGE_ERROR);
 
             g_list_free_full (files, g_object_unref);
             g_object_unref (app_info);
@@ -423,9 +425,10 @@ nautilus_launch_desktop_file (GdkScreen   *screen,
     if (error != NULL)
     {
         message = g_strconcat (_("Details: "), error->message, NULL);
-        show_error_dialog(_("There was an error launching the application."),
-                          message,
-                          parent_window);
+        show_dialog (_("There was an error launching the application."),
+                     message,
+                     parent_window,
+                     GTK_MESSAGE_ERROR);
 
         g_error_free (error);
         g_free (message);
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 10b315c37..477812ef9 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -487,9 +487,10 @@ nautilus_properties_window_drag_data_received (GtkWidget        *widget,
 
     if (!exactly_one)
     {
-        show_error_dialog(_("You cannot assign more than one custom icon at a time!"),
-                          _("Please drop just one image to set a custom icon."),
-                          window);
+        show_dialog (_("You cannot assign more than one custom icon at a time!"),
+                     _("Please drop just one image to set a custom icon."),
+                     window,
+                     GTK_MESSAGE_ERROR);
     }
     else
     {
@@ -504,15 +505,17 @@ nautilus_properties_window_drag_data_received (GtkWidget        *widget,
             f = g_file_new_for_uri (uris[0]);
             if (!g_file_is_native (f))
             {
-                show_error_dialog(_("The file that you dropped is not local."),
-                                  _("You can only use local images as custom icons."),
-                                  window);
+                show_dialog (_("The file that you dropped is not local."),
+                             _("You can only use local images as custom icons."),
+                             window,
+                             GTK_MESSAGE_ERROR);
             }
             else
             {
-                show_error_dialog(_("The file that you dropped is not an image."),
-                                  _("You can only use local images as custom icons."),
-                                  window);
+                show_dialog (_("The file that you dropped is not an image."),
+                             _("You can only use local images as custom icons."),
+                             window,
+                             GTK_MESSAGE_ERROR);
             }
             g_object_unref (f);
         }
@@ -3112,9 +3115,10 @@ open_in_disks (GtkButton                *button,
     if (error != NULL)
     {
         message = g_strdup_printf (_("Details: %s"), error->message);
-        show_error_dialog (_("There was an error launching the application."),
-                           message,
-                           GTK_WINDOW (self));
+        show_dialog (_("There was an error launching the application."),
+                     message,
+                     GTK_WINDOW (self),
+                     GTK_MESSAGE_ERROR);
     }
 }
 
diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c
index 765097f9e..ac2c423da 100644
--- a/src/nautilus-ui-utilities.c
+++ b/src/nautilus-ui-utilities.c
@@ -393,9 +393,10 @@ get_text_for_date_range (GPtrArray *date_range,
 }
 
 GtkDialog *
-show_error_dialog (const gchar *primary_text,
-                   const gchar *secondary_text,
-                   GtkWindow   *parent)
+show_dialog (const gchar *primary_text,
+             const gchar *secondary_text,
+             GtkWindow   *parent,
+             GtkMessageType type)
 {
     GtkWidget *dialog;
 
@@ -403,7 +404,7 @@ show_error_dialog (const gchar *primary_text,
 
     dialog = gtk_message_dialog_new (parent,
                                      GTK_DIALOG_MODAL,
-                                     GTK_MESSAGE_ERROR,
+                                     type,
                                      GTK_BUTTONS_OK,
                                      "%s", primary_text);
 
diff --git a/src/nautilus-ui-utilities.h b/src/nautilus-ui-utilities.h
index a35aaec6e..74139e3f4 100644
--- a/src/nautilus-ui-utilities.h
+++ b/src/nautilus-ui-utilities.h
@@ -46,6 +46,7 @@ gboolean   nautilus_file_date_in_between           (guint64           file_unix_
 gchar*     get_text_for_date_range                 (GPtrArray         *date_range,
                                                     gboolean           prefix_with_since);
 
-GtkDialog *    show_error_dialog                   (const gchar *primary_text,
+GtkDialog *    show_dialog                         (const gchar *primary_text,
                                                     const gchar *secondary_text,
-                                                    GtkWindow   *parent);
\ No newline at end of file
+                                                    GtkWindow   *parent,
+                                                    GtkMessageType type);
\ No newline at end of file
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 541dd24a8..895bbc209 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -1526,7 +1526,7 @@ nautilus_window_slot_display_view_selection_failure (NautilusWindow *window,
         detail_message = g_strdup_printf (_("Unhandled error message: %s"), error->message);
     }
 
-    show_error_dialog (error_message, detail_message, GTK_WINDOW (window));
+    show_dialog (error_message, detail_message, GTK_WINDOW (window), GTK_MESSAGE_ERROR);
 
 done:
     g_free (error_message);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 05fb98572..4dba58a37 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1110,7 +1110,7 @@ places_sidebar_show_error_message_cb (GtkPlacesSidebar *sidebar,
 {
     NautilusWindow *window = NAUTILUS_WINDOW (user_data);
 
-    show_error_dialog (primary, secondary, GTK_WINDOW (window));
+    show_dialog (primary, secondary, GTK_WINDOW (window), GTK_MESSAGE_ERROR);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]