[Goodies-commits] r6246 - in xfce4-screenshooter-plugin/trunk: . lib

Jerome Guelfucci jeromeg at xfce.org
Mon Dec 1 18:57:30 CET 2008


Author: jeromeg
Date: 2008-12-01 17:57:30 +0000 (Mon, 01 Dec 2008)
New Revision: 6246

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/NEWS
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
Log:
  * lib/screenshooter-dialogs.c:
    - indent the code correctly.
    - add some more detailed comments.
    - show an error dialog when saving the screenshot failed.
  * NEWS: updated.


Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-12-01 17:32:37 UTC (rev 6245)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-12-01 17:57:30 UTC (rev 6246)
@@ -1,5 +1,13 @@
 2008-12-01 jeromeg
 
+  * lib/screenshooter-dialogs.c:
+    - indent the code correctly.
+    - add some more detailed comments.
+    - show an error dialog when saving the screenshot failed.
+  * NEWS: updated.
+
+2008-12-01 jeromeg
+
   * lib/screenshooter-dialogs.c: use a custom button instead of the 
     stock ok button to be more precise on the action of this button.
 

Modified: xfce4-screenshooter-plugin/trunk/NEWS
===================================================================
--- xfce4-screenshooter-plugin/trunk/NEWS	2008-12-01 17:32:37 UTC (rev 6245)
+++ xfce4-screenshooter-plugin/trunk/NEWS	2008-12-01 17:57:30 UTC (rev 6246)
@@ -1,15 +1,21 @@
 === Version 1.x.x ===
 
-  * BUGFIX: correctly grab active windows. In particular, menus are
-    grabbed now.
-  * BUGFIX: correctly save the preferences, even if ~/.config/xfce4 does
-    not exist. Thanks to Nick Schermer for the explanations.
-  * Use -V for the version CLI option.
-  * Add possibility to copy the screenshot to the clipboard, thanks to
-    David Collins.
-  * The dialog for the plugin preferences and the application has been
-    totally rewritten to improve the user interface: it should look 
-    cleaner and tooltips have been added. Work started by David Collins.
+  * Bugfixes: 
+    - correctly grab active windows. In particular, menus are grabbed 
+      now (bug #4611).
+    - correctly save the preferences, even if ~/.config/xfce4 does
+      not exist. Thanks to Nick Schermer for the explanations.
+    - when saving the screenshot fails, show an error dialog 
+      explaning why it failed.
+  
+  * Enhancements:
+    - Use -V for the version CLI option.
+    - Add possibility to copy the screenshot to the clipboard, thanks to
+      David Collins.
+    - The dialog for the plugin preferences and the application has been
+      totally rewritten to improve the user interface: it should look 
+      cleaner and tooltips have been added. Work started by David 
+      Collins.
 
 === Version 1.4.0 ===
 

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-12-01 17:32:37 UTC (rev 6245)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-dialogs.c	2008-12-01 17:57:30 UTC (rev 6246)
@@ -889,17 +889,23 @@
 {
   GdkPixbuf *thumbnail;
   gchar *filename = NULL, *savename = NULL;;
+  
   GtkWidget *preview;
   GtkWidget *chooser;
   gint dialog_response;
-
+  
+  GError *error = NULL;
+  
+  /* Generate the filename for the default save location */
+  
   filename = generate_filename_for_uri (default_dir);
     
   if (show_save_dialog)
 	  {
-	    /* If the user wants a save dialog, we run it, and grab the filename 
-	    the user has chosen. */
-	  
+	    /* If the user wants a save dialog, we run it, and grab the 
+       * filename the user has chosen. */
+	    
+      /* Create the dialog and set its default properties */
       chooser = 
         gtk_file_chooser_dialog_new (_("Save screenshot as..."),
                                      NULL,
@@ -909,19 +915,26 @@
                                      GTK_STOCK_SAVE, 
                                      GTK_RESPONSE_ACCEPT,
                                      NULL);
+                                     
       gtk_window_set_icon_name (GTK_WINDOW (chooser), 
                                 "applets-screenshooter");
-      gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (chooser), 
-                                                      TRUE);
+                                
+      gtk_file_chooser_set_do_overwrite_confirmation (
+      GTK_FILE_CHOOSER (chooser), TRUE);
+      
       gtk_dialog_set_default_response (GTK_DIALOG (chooser), 
-                                     GTK_RESPONSE_ACCEPT);
+                                       GTK_RESPONSE_ACCEPT);
+
       gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (chooser), 
                                           default_dir);
 
-      preview = gtk_image_new ();
-  
       gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), 
                                          filename);
+
+      /* Create the preview and the thumbnail */
+      
+      preview = gtk_image_new ();
+                                          
       gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER (chooser), 
                                            preview);
   
@@ -932,6 +945,7 @@
                                  GDK_INTERP_BILINEAR);
       
       gtk_image_set_from_pixbuf (GTK_IMAGE (preview), thumbnail);
+      
       g_object_unref (thumbnail);
       
       /* We the user opens a folder in the fine_chooser, we set a valid
@@ -940,15 +954,27 @@
                         G_CALLBACK(cb_current_folder_changed), NULL);
     
       dialog_response = gtk_dialog_run (GTK_DIALOG (chooser));
-	  
+	    
+      /* The user pressed the save button */
 	    if (dialog_response == GTK_RESPONSE_ACCEPT)
 	      {
-	        savename = 
-	          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser) );
-          gdk_pixbuf_save (screenshot, savename, "png", NULL, NULL);
+	        /* Get the save location */
+          savename = 
+	          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
+          
+          /* Try to save the screenshot. If it fails, we show an error
+           * dialog */
+          
+          if (!gdk_pixbuf_save (screenshot, savename, 
+                                "png", &error, NULL))
+            {
+              xfce_err ("%s", error->message);
+              
+              g_error_free (error);
+            }
 	      }
 	  
-	    gtk_widget_destroy ( GTK_WIDGET ( chooser ) );
+	    gtk_widget_destroy (GTK_WIDGET (chooser));
 	  }  
 	else
 	  {    
@@ -956,8 +982,16 @@
 	    /* Else, we just save the file in the default folder */
       
       savename = g_build_filename (default_dir, filename, NULL);
-	    gdk_pixbuf_save (screenshot, savename, "png", NULL, NULL);
 	    
+      /* Try to save the screenshot. If it fails, we show an error
+      * dialog */
+      if (!gdk_pixbuf_save (screenshot, savename, "png", &error, NULL))
+            {
+              xfce_err ("%s", error->message);
+              
+              g_error_free (error);
+            }
+	    
 	  }
 
   g_free (filename);




More information about the Goodies-commits mailing list