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

Jerome Guelfucci jeromeg at xfce.org
Sun Dec 28 11:40:09 CET 2008


Author: jeromeg
Date: 2008-12-28 10:40:09 +0000 (Sun, 28 Dec 2008)
New Revision: 6370

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c
   xfce4-screenshooter-plugin/trunk/src/main.c
Log:
  * src/main.c:
    - only read the preferences file once when using the application.
    - check if the directory name stored in the preferences still exists
      before trying to use it.
  * lib/screenshooter-actions.c: set home as the default folder for the
    file chooser, only use sd->screenshot_dir when we don't show the
    save dialog. This should be more transparent for the user.


Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-12-27 12:18:35 UTC (rev 6369)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-12-28 10:40:09 UTC (rev 6370)
@@ -1,3 +1,13 @@
+2008-12-28 jeromeg
+
+  * src/main.c:
+    - only read the preferences file once when using the application.
+    - check if the directory name stored in the preferences still exists
+      before trying to use it.
+  * lib/screenshooter-actions.c: set home as the default folder for the
+    file chooser, only use sd->screenshot_dir when we don't show the
+    save dialog. This should be more transparent for the user.
+
 2008-12-20 jeromeg
 
   * NEWS: updated.

Modified: xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c	2008-12-27 12:18:35 UTC (rev 6369)
+++ xfce4-screenshooter-plugin/trunk/lib/screenshooter-actions.c	2008-12-28 10:40:09 UTC (rev 6370)
@@ -26,9 +26,18 @@
   
   if (sd->action == SAVE)
     {
-      screenshooter_save_screenshot (screenshot, 
-                                     sd->show_save_dialog, 
-                                     sd->screenshot_dir);
+      if (sd->show_save_dialog == 1)
+        {
+          screenshooter_save_screenshot (screenshot, 
+                                         1, 
+                                         g_strdup (DEFAULT_SAVE_DIRECTORY));
+        }
+      else
+        {
+          screenshooter_save_screenshot (screenshot, 
+                                         0, 
+                                         sd->screenshot_dir);
+        }
     }
   else if (sd->action == CLIPBOARD)
     {

Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c	2008-12-27 12:18:35 UTC (rev 6369)
+++ xfce4-screenshooter-plugin/trunk/src/main.c	2008-12-28 10:40:09 UTC (rev 6370)
@@ -170,13 +170,20 @@
   if (rc_file != NULL)
     g_free (rc_file);
     
+  /* Check if the directory read from the preferences is valid */
+  if (!g_file_test (sd->screenshot_dir, G_FILE_TEST_IS_DIR))
+    {
+      sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
+    }
+    
   /* Print a message to advise to use help when a non existing cli option is
   passed to the executable. */  
   if (!gtk_init_with_args(&argc, &argv, _(""), entries, PACKAGE, &cli_error))
     {
       if (cli_error != NULL)
         {
-          g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), 
+          g_print (_("%s: %s\nTry %s --help to see a full list of"
+                     " available command line options.\n"), 
                    PACKAGE, cli_error->message, PACKAGE_NAME);
           g_error_free (cli_error);
           return 1;
@@ -189,99 +196,90 @@
       g_print ("%s\n", PACKAGE_STRING);
       return 0;
     }
-  
-  /* If -w is given to the executable, grab the active window, else just 
-   * grab the desktop.*/
-  if (window)
+    
+  /* If a mode cli option is given, take the screenshot accordingly. */
+  if (fullscreen || window || region)
     {
-      sd->mode = ACTIVE_WINDOW;    
-    }
-  else if (fullscreen)
-    {
-      sd->mode = FULLSCREEN;
-    }
-  else if (region)
-    {
-      sd->mode = RECTANGLE;
-    }
-  
-  /* Wether to show the save dialog allowing to choose a filename and a save 
-  location */
-  if (no_save_dialog)
-    {
-      sd->show_save_dialog = 0;
-    }
-  else
-    {
-      sd->show_save_dialog = 1;
-    }
+      /* Set the region to be captured */
+      if (window)
+        {
+          sd->mode = ACTIVE_WINDOW;    
+        }
+      else if (fullscreen)
+        {
+          sd->mode = FULLSCREEN;
+        }
+      else if (region)
+        {
+          sd->mode = RECTANGLE;
+        }
+      
+      /* Wether to show the save dialog allowing to choose a filename 
+       * and a save location */
+      if (no_save_dialog)
+        {
+          sd->show_save_dialog = 0;
+        }
+      else
+        {
+          sd->show_save_dialog = 1;
+        }
 
-  sd->delay = delay;
-  
-  if (application != NULL)
-    {
-      sd->app = application;
-      sd->action = OPEN;
-    }
-  else
-    {
-      sd->app = g_strdup ("none");
-      sd->action = SAVE;
-    }
-  
-  /* If the user gave a directory name, verify that it is valid */
-  if (screenshot_dir != NULL)  
-    {
-      if (g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR))
+      sd->delay = delay;
+      
+      if (application != NULL)
         {
-          /* Check if the path is absolute, if not make it absolute */
-          if (g_path_is_absolute (screenshot_dir))
-            { 
-              g_free (sd->screenshot_dir);
-              
-              sd->screenshot_dir = screenshot_dir;              
+          sd->app = application;
+          sd->action = OPEN;
+        }
+      else
+        {
+          sd->app = g_strdup ("none");
+          sd->action = SAVE;
+        }
+      
+      /* If the user gave a directory name, verify that it is valid */
+      if (screenshot_dir != NULL)  
+        {
+          if (g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR))
+            {
+              /* Check if the path is absolute, if not make it 
+               * absolute */
+              if (g_path_is_absolute (screenshot_dir))
+                { 
+                  g_free (sd->screenshot_dir);
+                  
+                  sd->screenshot_dir = screenshot_dir;              
+                }
+              else
+                {
+                  g_free (sd->screenshot_dir);
+                  
+                  sd->screenshot_dir = 
+                    g_build_filename (g_get_current_dir (), 
+                                      screenshot_dir, 
+                                      NULL);
+                  
+                  g_free (screenshot_dir);
+                }
             }
           else
             {
-              g_free (sd->screenshot_dir);
+              g_warning (_("%s is not a valid directory, the default"
+                           " directory will be used."), 
+                         screenshot_dir);
               
-              sd->screenshot_dir = 
-                g_build_filename (g_get_current_dir (), 
-                                  screenshot_dir, 
-                                  NULL);
-              
               g_free (screenshot_dir);
             }
         }
-      else
-        {
-          g_warning (_("%s is not a valid directory, the default directory"
-                       " will be used."), 
-                     screenshot_dir);
-          
-          g_free (screenshot_dir);
-        }
-    }
-  
-  /* If a mode cli option is given, take the screenshot accordingly. */
-  if (fullscreen || window || region)
-    {
+      
       screenshooter_take_and_output_screenshot (sd);
     }
   /* Else we just show up the main application */
   else
     {
       GtkWidget *dialog;
-                  
-      rc_file = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, 
-                                      "xfce4/xfce4-screenshooter");
-      
-      /* Read the preferences */
-      screenshooter_read_rc_file (rc_file, sd);
-      
-      if (rc_file != NULL)
-        g_free (rc_file);
-      
+                 
       /* Set the dialog up */
       
       dialog = screenshooter_dialog_new (sd, FALSE);




More information about the Goodies-commits mailing list