[gnome-screenshot] screenshot: only emit an error sound on failure if not interactive



commit c3767e9202976a853270dd2f9a65bee6f67c947f
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jan 25 21:21:56 2012 -0500

    screenshot: only emit an error sound on failure if not interactive
    
    If we're not in interactive mode (i.e. we're launched from a
    keybinding), we don't want to spawn dialogs.

 src/screenshot-application.c |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/src/screenshot-application.c b/src/screenshot-application.c
index e946d8a..508cc9a 100644
--- a/src/screenshot-application.c
+++ b/src/screenshot-application.c
@@ -290,17 +290,24 @@ build_filename_ready_cb (GObject *source,
 
   save_uri = screenshot_build_filename_finish (res, &error);
 
+  /* now release the application */
+  g_application_release (G_APPLICATION (self));
+
   if (error != NULL)
     {
       g_critical ("Impossible to find a valid location to save the screenshot: %s",
                   error->message);
       g_error_free (error);
 
-      exit(1);
-    }
+      if (screenshot_config->interactive)
+        screenshot_show_error_dialog (NULL,
+                                      _("Unable to capture a screenshot"),
+                                      _("Error creating file"));
+      else
+        screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot"));
 
-  /* now release the application */
-  g_application_release (G_APPLICATION (self));
+      return;
+    }
 
   self->priv->dialog = screenshot_dialog_new (self->priv->screenshot, save_uri);
   toplevel = screenshot_dialog_get_toplevel (self->priv->dialog);
@@ -326,10 +333,18 @@ finish_prepare_screenshot (ScreenshotApplication *self,
 
   if (screenshot == NULL)
     {
-      screenshot_show_error_dialog (NULL,
-                                    _("Unable to take a screenshot of the current window"),
-                                    NULL);
-      exit (1);
+      g_critical ("Unable to capture a screenshot of any window");
+
+      if (screenshot_config->interactive)
+        screenshot_show_error_dialog (NULL,
+                                      _("Unable to capture a screenshot"),
+                                      _("All possible methods failed"));
+      else
+        screenshot_play_sound_effect ("dialog-error", _("Unable to capture a screenshot"));
+
+      g_application_release (G_APPLICATION (self));
+
+      return;
     }
 
   if (screenshot_config->take_window_shot)



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