[gnome-screenshot] screenshot: simplify fallback code path



commit f6d3c160d9e1f90105af1c6281b31a72c877a98a
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jan 25 13:52:40 2012 -0500

    screenshot: simplify fallback code path
    
    Make it so that we can enter the fallback code path from only one point.

 src/screenshot-utils.c |   26 +++++++++-----------------
 1 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/src/screenshot-utils.c b/src/screenshot-utils.c
index 24a31dc..771f841 100644
--- a/src/screenshot-utils.c
+++ b/src/screenshot-utils.c
@@ -573,7 +573,7 @@ GdkPixbuf *
 screenshot_get_pixbuf (GdkWindow    *window,
                        GdkRectangle *rectangle)
 {
-  GdkPixbuf *screenshot;
+  GdkPixbuf *screenshot = NULL;
   gchar *path, *filename, *tmpname;
   const gchar *method_name;
   GVariant *method_params;
@@ -618,29 +618,21 @@ screenshot_get_pixbuf (GdkWindow    *window,
                                NULL,
                                &error);
 
-  if (error != NULL)
-    {
-      g_warning ("Unable to use GNOME Shell's builtin screenshot interface, "
-                 "resorting to fallback X11. Error: %s", error->message);
-      g_error_free (error);
-
-      screenshot = screenshot_get_pixbuf_fallback (window, rectangle);
-    }
-  else
+  if (error == NULL)
     {
       screenshot = gdk_pixbuf_new_from_file (filename, &error);
 
       /* remove the temporary file created by the shell */
       g_unlink (filename);
+    }
 
-      if (error != NULL)
-        {
-          g_warning ("Unable to load GNOME Shell's builtin screenshot result, "
-                     "resorting to fallback X11. Error: %s", error->message);
-          g_error_free (error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to use GNOME Shell's builtin screenshot interface, "
+                 "resorting to fallback X11. Error: %s", error->message);
+      g_error_free (error);
 
-          screenshot = screenshot_get_pixbuf_fallback (window, rectangle);
-        }
+      screenshot = screenshot_get_pixbuf_fallback (window, rectangle);
     }
 
   g_free (path);



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