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

Jerome Guelfucci jeromeg at xfce.org
Sat Sep 20 14:54:10 CEST 2008


Author: jeromeg
Date: 2008-09-20 12:54:10 +0000 (Sat, 20 Sep 2008)
New Revision: 5426

Modified:
   xfce4-screenshooter-plugin/trunk/ChangeLog
   xfce4-screenshooter-plugin/trunk/NEWS
   xfce4-screenshooter-plugin/trunk/src/main.c
Log:
Plug some remaining leaks and remove some useless code in main.

Modified: xfce4-screenshooter-plugin/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter-plugin/trunk/ChangeLog	2008-09-20 03:32:09 UTC (rev 5425)
+++ xfce4-screenshooter-plugin/trunk/ChangeLog	2008-09-20 12:54:10 UTC (rev 5426)
@@ -1,3 +1,11 @@
+2008-19-20 jeromeg
+
+  * src/main.c:
+    - (main) plug some leaks with the dir and screenshot_dir.
+    - (main) don't use screenshot_dir to store the dirname, it should be done
+      with sd->screenshot_dir.
+  * NEWS: updated.
+
 2008-09-19 jeromeg
 
   * icons/*: add some default icons for the applet taken from the Rodent icon

Modified: xfce4-screenshooter-plugin/trunk/NEWS
===================================================================
--- xfce4-screenshooter-plugin/trunk/NEWS	2008-09-20 03:32:09 UTC (rev 5425)
+++ xfce4-screenshooter-plugin/trunk/NEWS	2008-09-20 12:54:10 UTC (rev 5426)
@@ -3,7 +3,8 @@
   * Use applets-screenshooter icon for preferences dialog and save dialog.
   * Add some default icons taken from the Rodent icon theme to make sure the
   applet has an icon.
-
+  * Plug some remaining leaks and remove some useless code in main.
+  
 === Version 1.3.2 ===
   * BUGFIX: plug some stupid leaks.
   * BUGFIX: when the active window is the desktop, instead of returning a

Modified: xfce4-screenshooter-plugin/trunk/src/main.c
===================================================================
--- xfce4-screenshooter-plugin/trunk/src/main.c	2008-09-20 03:32:09 UTC (rev 5425)
+++ xfce4-screenshooter-plugin/trunk/src/main.c	2008-09-20 12:54:10 UTC (rev 5426)
@@ -88,17 +88,15 @@
   if (g_file_test (rc_file, G_FILE_TEST_EXISTS))
     {
       rc = xfce_rc_simple_open (rc_file, TRUE);
-      screenshot_dir = g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", 
-                               DEFAULT_SAVE_DIRECTORY));
-      sd->screenshot_dir = screenshot_dir;
+      sd->screenshot_dir = g_strdup (xfce_rc_read_entry (rc, "screenshot_dir", 
+                                     DEFAULT_SAVE_DIRECTORY));
       xfce_rc_close (rc);
     }
   else
     {
-      screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
-      sd->screenshot_dir = screenshot_dir;
+      sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
     }
-
+  
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
   
   /* Print a message to advise to use help when a non existing cli option is
@@ -145,26 +143,30 @@
 
   sd->screenshot_delay = delay;
   
-  /* Verify that the user gave a valid directory name */
-  if (g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR))
+  /* If the user gave a directory name, verify that it is valid */
+  if (screenshot_dir != NULL)  
     {
-    /* Check if the path is absolute, if not make it absolute */
-      if (g_path_is_absolute (screenshot_dir))
-        { 
-          sd->screenshot_dir = screenshot_dir;
+      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))
+            { 
+              sd->screenshot_dir = screenshot_dir;
+            }
+          else
+            {
+              sd->screenshot_dir = 
+              g_build_filename (g_get_current_dir (), screenshot_dir, NULL);
+              g_free (screenshot_dir);
+            }
         }
-    else
-      {
-        screenshot_dir = 
-          g_build_filename (g_get_current_dir (), screenshot_dir, NULL);
-        sd->screenshot_dir = screenshot_dir;
-      }
+      else
+        {
+          g_warning ("%s is not a valid directory, the default directory will be used.", 
+                     screenshot_dir);
+          g_free (screenshot_dir);
+        }
     }
-  else
-    {
-      g_warning ("%s is not a valid directory, the default directory will be used.", 
-                 screenshot_dir);
-    }
   
   /* If -p is given, show the preferences dialog, else just take the screenshots
   with the given options */
@@ -183,8 +185,7 @@
       
       /* The preferences dialog is a plain gtk_file_chooser, we just get the
       folder the user selected and write it in the conf file*/
-      dir = screenshot_dir;
-
+      
       chooser = 
         gtk_file_chooser_dialog_new (_("Default save folder"),
                                      NULL,
@@ -194,14 +195,15 @@
                                      NULL);
       gtk_window_set_icon_name (GTK_WINDOW (chooser), "applets-screenshooter");
       gtk_dialog_set_default_response (GTK_DIALOG (chooser), GTK_RESPONSE_ACCEPT);
-      gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), dir);
-
+      gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), 
+                                           sd->screenshot_dir);
+      
       dialog_response = gtk_dialog_run(GTK_DIALOG (chooser));
 
       if (dialog_response == GTK_RESPONSE_ACCEPT)
 	      {
 	        dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser));
-      
+          
           rc = xfce_rc_simple_open (rc_file, FALSE);
           xfce_rc_write_entry (rc, "screenshot_dir", dir);
           xfce_rc_close (rc);
@@ -214,6 +216,6 @@
   g_free (sd->screenshot_dir);
   g_free (sd);
   g_free (rc_file);
-  
+    
   return 0;
 }




More information about the Goodies-commits mailing list